아무것도 몰라요

실험실 (커널 오류) 11

[kernel panic] not syncing: Real mode trampoline was not allocated

1. 발생 배경 새로운 서버에 NOVA를 Mount 하기 위한 사전 작업을 하던 도중 발생한 오류이다. 위의 그림처럼 "memmap=64G!0G"라는 GRUB command line 명령어를 추가하였다. 이는 memory의 0G부터 64G를 이후 pmem을 emulate 하기 위해 reserve 하라는 명령어이다. 여기서 0G부터 시작하는 게 오류의 원인이 되었던 것 같다. "Real mode trampoline was not allocate" 이 오류를 이해하기 위해서는 "real mode"와 "trampoline" 두가지를 이해해야 된다. 우선 real mode(real address mode)란 x86 compatible CPU에서 사용하는 운영 모드이다. 주소가 실제 메모리 위치에 대응한다는 점에..

[kernel] Opening files inside the Kernelspace

커널 안에서 파일을 여는 경우가 있을까? 다음 코드는 fs/open.c의 한 부분이다. /** * file_open_name - open file and return file pointer * * @name: struct filename containing path to open * @flags: open flags as per the open(2) second argument * @mode: mode for the new file if O_CREAT is set, else ignored * * This is the helper to open a file from kernelspace if you really * have to. But in generally you should not do this, s..

[kernel panic] unable to handle kernel paging request at ~~

1. 도입 오늘 밀워키 벅스가 NBA 우승을 했다. 매년 이 순간에 내가 뭘 했는지를 돌아보곤 하는데, 올해는 AS관에 앉아서 디버깅을 하고 있다. 기존에는 항상 NULL을 참조해서 panic이 발생했지만, 이번에는 kernel paging request를 다룰 수 없다는 bug이다. write path에서 dedup queue에 write entry를 push 하는 함수를 호출하였고, dedup system call에서 이 queue안의 write entry를 꺼내는 방식을 구현해보았다. // fs/nova/dedup.c // Get next Dedup queue entry int nova_dedup_queue_get_next_entry(struct nova_file_write_entry *next_e..

[NOVA] write path - offset, pos 추적 (7/20)

... offset = pos & (sb->s_blocksize - 1); printk("%lld %lld\n",pos, offset); ... while (num_blocks > 0) { offset = pos & (nova_inode_blk_size(sih) - 1); start_blk = pos >> sb->s_blocksize_bits; printk("start block address: %lu\n",start_blk); printk("start block address: %llu\n",cpu_to_le64(start_blk)); .... } Nova file system에서 이론상 write path시에 'offset'은 하나의 block에서 시작 위치를 나타내고, pos는 파일 내에서 file..

[kernel build error] VFS: Unable to mount root fs on unknown-block(0,0)

학교 컴퓨터에 Ubuntu 20.04를 다운 받고, NOVA를 실험하기 위해 kernel code를 받고 빌드하여 load해보았다. 하지만 grub에서 해당 kernel image를 선택하면 위와 같은 오류가 떳다. Enter를 누르니 다음 화면으로 넘어갔다. out of memory, unable to mount root fs... 다 아는 용어이지만 어떤 부분에서 오류가 발생했는지 가늠할 수 없었다. 어떤 블로그에서는 grub의 설정을 바꿔서 initramfs를 설정해야된다고 했고, 어떤 곳에서는 /mnt에 모든 것들을 mount하는 해결법을 제공했다. 하지만 어느것도 나에게 해당되지 않았다. 결국 나의 결론은(연구실 선배의 조언 99%)... nova가 사용하고 있는 linux-5.1.0은 ubun..

[NOVA] system call argument 추가 오류(2)

지난 7/17에 마지막 시도를 해보다가 서버가 죽어버렸다. 월요일이 돼서야 학교에 와서 서버를 복구할 수 있었다. 오늘 약 6시간의 시도 끝에 드디어 해결을 하였다. File Descriptor는 File Pointer가 아니다!!! // Test.c #include #include #include #include int main() { FILE *fp; fp = fopen("/mnt/nova/file.txt","w"); long int temp =0; unsigned int fd = fileno(fp); temp = syscall(335,fd); if(!temp){ printf("System Call well Implemented! Returned: % ld\n", temp); } else { prin..

[NOVA] system call argument 추가 오류(1)

이제 실제 어디에 어떤 구현을 할 것인지 대충 정해야 될 때가 왔다. 하지만 그 전에 file operation을 설정해줘야되는데, 이를 시험하기 위해서 system call을 약간 수정하였다. 하지만 약간 수정한 system call에서 오류가 바로 발생하였고, system call에서 오류가 발생한 것을 고치기 위해서 끊임없이 build를 하고 있다. 우선 바꾼 system call을 살펴보면 다음과 같다. #include #include #include #include SYSCALL_DEFINE1(dedup, unsigned int, fd){ printk("0\n"); struct fd f = fdget_pos(fd); printk("1\n"); struct file *file = f.file; p..

[kernel build] NOVA vanilla code build 오류

문제: vanilla code를 가지고 와서 config를 한 뒤, 다른 것 수정 없이 Make를 했지만 위와 같은 오류가 발생하였다. 해결: gcc version을 9 --> 8로 변경하였다. sudo apt-get install gcc-8 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 50 구글에 아무리 검색해도 아래의 사이트 외에는, '-mindirect-branc' and '-fcf-protection' are not compatible, 와 같은 오류는 찾을 수 없었다. 따라서 어떤 문제인지 정확하게는 모르겠다. https://badsimplicity.com/2019/07/10/gcc-9-and-ubuntu-kernel-e..

[kernel build] System Call 추가하기 오류기록(02/19)

1차 시도 include/linux/syscalls.h --> +unsigned long how_many_syscall; arch/x86/kernel/cpu/common.c --> +how_many_syscall=0; arch/x86/entry/common.c --> +how_many_syscall++; hello/hello.c --> +printk("The total amount of system calls called is %lu\n",how_many_syscall); 이유: system call이 몇번 불렸는지 count하는 변수를 선언,초기화,증가 시키며 hello라는 syscall에서 값을 출력한다. 실패: 'syscall_init'에서 how_many_syscall 인지를 못 함 2차 시도 a..