gdt problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ocean390

gdt problem

Post 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!
DennisCGc

Re:gdt problem

Post 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.
ocean390

Re:gdt problem

Post by ocean390 »

but as I known,there is only one gdt.and the cr1 is in the
gdt table,can gdt be virtual address
DennisCGc

Re:gdt problem

Post 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.
Tim

Re:gdt problem

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:gdt problem

Post 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 ...
Post Reply