Page 1 of 1

gdt problem

Posted: Sat May 29, 2004 7:04 am
by ocean390
when I read some book about linux kernel , it says before linux
enter protected mode,linux set the gdt,and after page was enabled,gdt was set again.why to do this.as I known ,gdt point to the physical address,is there any difference between the two gdt?
thanks for reply!

Re:gdt problem

Posted: Sat May 29, 2004 7:08 am
by DennisCGc
When paging is set the addresses in the GDT are virtual.
Only the pages contain the physical addresses, the addresses in the GDT refer to virtual addresses.

Re:gdt problem

Posted: Sat May 29, 2004 7:16 am
by ocean390
but as I known,there is only one gdt.and the cr1 is in the
gdt table,can gdt be virtual address

Re:gdt problem

Posted: Sat May 29, 2004 7:33 am
by DennisCGc
ocean390 wrote: but as I known,there is only one gdt.and the cr1 is in the
gdt table,can gdt be virtual address
Yes, there's only one GDT, the GDT is rebuilt, and they then change the GDTR, GDTR is physical.

Re:gdt problem

Posted: Mon May 31, 2004 11:57 am
by Tim
The GDTR base, and all base addresses in descriptors, are linear, not physical. So if you have paging enabled, and you use the LGDT instruction, you will need to use a virtual address. If you do not have paging enabled, you will need to use a physical address.

Re:gdt problem

Posted: Tue Jun 01, 2004 2:40 am
by Pype.Clicker
another thing: even if modifying GDT registers or contents could have been avoided when activating paging, it's common to replace the GDT while initializing the kernel, in order to offer more space in the GDT, or to get rid of a bootloader-installed GDT, or whatever ...