Page 1 of 1
GDT Questions...
Posted: Thu Jan 09, 2003 11:39 am
by jrfritz
I'll just post some GDT questions here as they come up:
Can I make a CodeSel that can be read/write/exec?
Can I make a Stack Sel? If yes...how?
Re:GDT Questions...
Posted: Thu Jan 09, 2003 11:41 am
by jrfritz
Ok..I can make a stack sel...bit 010/011...
Could someone show me a example of a stack sel that is read/write? ( bit 011 )?
Also...
Can I make a CodeSel that can be read/write/exec?
Re:GDT Questions...
Posted: Thu Jan 09, 2003 12:46 pm
by beyondsociety
[attachment deleted by admin]
Re:GDT Questions...
Posted: Thu Jan 09, 2003 12:47 pm
by jrfritz
Also...if I made a stack selector...how would I push values into there?
Re:GDT Questions...
Posted: Thu Jan 09, 2003 2:12 pm
by Pype.Clicker
a code selector can *never* be written. If you need to write to a code chunk, use a data segment that maps the same memory region (though is discourage such ancient technique
a stack segment is simply a data segment, though the "EXPAND DOWN" bit may sometimes be useful for stacks only: it will define the valid addresses ranging from
limit to
0xffffffff instead of the usual [0..limit-1], which means you can easily protect from stack overflow
Re:GDT Questions...
Posted: Thu Jan 09, 2003 4:59 pm
by Guest
hi,
i no dis is a lil off topic, but can neone give me links to some good online GDT, tutorials or docs that explain the GDT thoroughly and easily.
links would be most appreciated.
thnx
Re:GDT Questions...
Posted: Thu Jan 09, 2003 5:10 pm
by jrfritz
My GDT:
gdtr
dw gdt_end
dd gdt
gdt
nullsel equ $-gdt
gdt0
dd 0
dd 0
codesel equ $-gdt
dw 0ffffh
dw 0
db 0
db 09ah
db 0cfh
db 0h
datasel equ $-gdt
dw 0ffffh
dw 0h
db 0h
db 092h
db 0cfh
db 0
gdt_end
And some Links:
http://osdev.neopages.net/tutorials/descripters.php
http://www.csee.umbc.edu/~plusquel/310/slides/micro_arch2.pdf
Re:GDT Questions...
Posted: Thu Jan 09, 2003 6:40 pm
by Curufir
I thought I'd already explained why this is wrong in another thread. This part of the gdt register is the
size of the gdt.
Ok, let's make it simpler by describing a scenario. Let's say you load your gdt to a base above 64k linear. Now the maximum value you can stick into that word is 0xFFFF. Do you see why it cannot possibly be the memory location of the end of the gdt?
In your GDT the correct value is:
Why -1? Because the gdt_end label refers to the instruction following it. Ie 1 more than the actual length of your gdt.
I dunno who came up with the idea that this part of the GDTR is a memory reference but they need shooting, or pointing at the intel manuals
.
Re:GDT Questions...
Posted: Thu Jan 09, 2003 6:42 pm
by jrfritz
Do I remove the gdt_end or how do I edit it to make it correct? code please?
Re:GDT Questions...
Posted: Thu Jan 09, 2003 6:50 pm
by jrfritz
Ok...I had that in my code before...I must have gotton confused...