Regarding enable paging code and swapper_pg_dir.

mindentropy mindentropy at
Mon Apr 4 17:07:03 EDT 2011

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.
> So, this "swapper_pg_dir" is a symbol in a section of code. That section of
> code has an associated segment and this symbol lives at a particular
> location in that section and thus in that segment, and that particular
> location, relative to the beginning of the section is it's offset. Combine
> those two and
> you have the logical address of swapper_pg_dir.
Ok I think I got where the addresses are assigned. Its in the linker script I got the precise answer here
I had completely forgotten about linker scripts. I was getting confused as the 
ENTRY(swapper_pg_dir) has ORG 0x10000 as the offset. Was struggling to find 
where the .text address was.

More information about the Kernelnewbies mailing list