HW - Lecture 8

12191789 유호현


7.

Make a system call, sys_get_phyloc(), which will display the physical address of main().

1) Write a simple program that prints the address of main().

Untitled

2) Call sys_get_phyloc(main) in this program which passes the address of main.

Untitled

Untitled

3) sys_get_phyloc(addr) is a system call that performs following steps in order:

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.

Untitled

Untitled

→ 문제에서 주어진 step 대로 코드 작성

Untitled