sys_get_phyloc
을 98번째 system call로 설정함.sys_get_phyloc(main)
syscall을 호출하기 위해 week14.c 파일을 위와 같이 수정함.step0: print the value of PGDIR_SHIFT, PTRS_PER_PGD, PAGE_SHIFT, PTRS_PER_PTE
PGDIR_SHIFT=22: number of shifting to extract directory number from a logical address. Logical address 0x080484a4 = (dir 20h, page 48h, offset 4a4h)cd
pgd_index=20h, pte_index=48h
PAGE_SHIFT=12: number of shifting to extract page number from a logical address.
PTRS_PER_PGD=1024: number of directory entries in a directory table
PTRS_PER_PTE=1024: number of frame pointer entries in a directory
step1: extract directory number (dir), page number(pg), and offset(off) from addr, and display them.
step2: print the location of directory table of the current process: x
step3: print the location of directory table entry for main(): y
y= &x[dir];
step4: print the physical location of the directory (partial page table) for main():pdir
pdir= *y & 0xfffff000; // the physical address should be at frame boundary
step5: print the virtual address of this directory: vdir
vdir = pdir + 0xc0000000; // physical to virtual mapping for kernel address
// read about kernel address space in Section 7.4.
step6: print the location of the frame entry for main(): k
k = &vdir[pg];
step7: print the physical location of frame for main(): pfr
pfr = *k & 0xfffff000; // the physical address should be at frame boundary
step8: print the physical address of main(): pmain
step9: print the virtual address for the physical address of main(): vmain
step10: display the first 4 bytes in vmain and compare them with the first 4 bytes of main in the original executable file(use "objdump -d program-name" to see the first 4 bytes of main in the original program). If they are same, you have the correct physical address of main.
cd linux-2.6.25.10/mm
vi mmap.c
→ 문제에서 주어진 step 대로 코드 작성