Page 1 of 1
GDT Help
Posted: Mon Aug 25, 2003 9:57 am
by beyondsociety
Im at the point where I want to implement the gdt trick for addressing 4GB of memory without enabling paging. How do I set this up?
0xA0000000 + base = 0x100000
base = 0x100000 - 0xA0000000
base = -9FF00000 = 60100000
Do I have to add this base to the gdt segments: code, data? Or do I need to add the base to the gdt pointer that gets loaded by lgdt? For instance:
Code: Select all
gdt_ptr: gdt_end - gdt_start - 1 ; Limit
gdt ;base
Re:GDT Help
Posted: Mon Aug 25, 2003 10:23 am
by Adek336
Only GDT.base.
Look:
JMP CS:0xA000_0000
CS.base = 0x6010_0000
CS.base + offset = 0x6010_0000 + 0xA000_0000 = 0x1_0010_0000.
When you put 1_0010_0000 into a longword you get 10_0000. So what you have to do, is to get this overflow. By setting the GDT.base to 6010_0000. Not GDTR. Do you understand how this trick works?
Btw, you don?t access 4Gb with this technique, all it is useful for is to allow a kernel linked at 0xa000_0000 init paging.
Cheers,
Adrian.
Re:GDT Help
Posted: Mon Aug 25, 2003 10:37 am
by beyondsociety
Do you understand how this trick works?
Could you explain it more throughly.
Re:GDT Help
Posted: Mon Aug 25, 2003 10:47 am
by Adek336
JMP CS:0xA000_0000
the CPU puts the logical adress into a longword:
A000_0000
adds the cs.base:
A000_0000
6010_0000 +
and the value is
0010_0000 because the 33 bit is not saved in a longword.
So it is an overflow, where the 33 bit is ignored.
Cheers,
Adrian.
Re:GDT Help
Posted: Mon Aug 25, 2003 11:58 am
by Pype.Clicker
there's a nice
previous thread which discuss the whole trick. Hope it'll help