understanding of PTD symbol

Mark Tinguely tinguely at casselton.net
Wed Feb 11 10:32:02 PST 2009


>  Hello all,
>                 I am having doubts in understanding the usage of the
>  symbol PTD. Could anyone pls explain the usage of PTD in the FreeBSD
>  kernel??
>
>  In pmap_growkernel when we execute the following instruction wht is
>  returned by pdir_pde ? Is it the physical address of a page table for
>  KVA addressing??
>
>                     while (pdir_pde(PTD, kernel_vm_end))
>
>  When I used objdump on the kernel executable i found the address of
>  PTD symbol to be 0xBFEFF000 , I could not understand this , as in a
>  virtual memory with 1G/3G split the kernel addressing must be between
>  the addresses 0xC0000000 and 0xFFFFFFFF.
>
>  Regards,
>  Mehul

On the i386/amd64, the page table sits just below the kernel virtual memory. 
The recursive virtual address reference to the page table is inside this address.

Assume i386 with 4 byte pointers and 4GB virtual address space with the 3GB
user vm and 1GB kernel vm:

the PTmap will start at 0xbfc00000 (which is one 4MB entry below the KVA).

the PTD page directory descripters for the page table descripter will be
0xdeff000 which is 767 4K entries into the page table. Note: 768 is the
3G mark, so 767 is one less than 3/4 into the page table.

PTDpde is the page table descriptor the the page table. It is PTD + 767 * 4

I found it easier to draw the various layouts and the page table itself.
The i386 in 32 bit mode is 10 bits for the page directory, 10 bits for the
page table and 12 bits for the physical page. The ARM processor is funner
with 12/8/12 bits.

--Mark Tinguely.


More information about the freebsd-hackers mailing list