On Sunday 03 Apr 2011 2:22:19 am James Light wrote:
On Sat, Apr 02, 2011 at 11:18:19PM +0530, mindentropy wrote:
On Saturday 02 Apr 2011 9:55:35 pm James Light wrote:
To put the physical address into cr3 later. $swapper_pg_dir is not the PHYSICAL address of the PGD.
Correct me if I am wrong but a mov $foo,%eax would move the address of foo variable to eax right? Or is there a macro somewhere where they are adding PAGE_OFFSET to the address so that the $swapper_pg_dir - __PAGE_OFFSET justifies?
Right, but it uses the logical address of foo which n the case of swapper_pg_dir must be converted to a physical address. When paging is not enabled, linear addresses are interpreted as physical addressess. So it has to get this logical address only one step farther into a linear address.
Can you please elaborate on what one step farther is? So why not use the swapper_pg_dir directly i.e. mov $swapper_pg_dir,cr0? In the absence of paging the segment:offset is the physical address isn't it? i.e. the $swapper_pg_dir should be equal to 0x10100 as per the code fragment below? I am having difficulty in understanding the addressing calculations here and not the code,
In linux2.1.66, the physical address is used directly. Just for comparison: ------------------------------------------------------------------------------ 58/* 59 * Setup paging (the tables are already set up, just switch them on) 60 */ 611: 62 movl $0x101000,%eax 63 movl %eax,%cr3 /* set the page table pointer.. */ 64 movl %cr0,%eax 65 orl $0x80000000,%eax 66 movl %eax,%cr0 /* ..and set paging (PG) bit */ 67 jmp 1f /* flush the prefetch-queue */ -----------------------------------------------------------------------------