gdt question

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
sancho1980
Member
Member
Posts: 199
Joined: Fri Jul 13, 2007 6:37 am
Location: Stuttgart/Germany
Contact:

gdt question

Post by sancho1980 »

hi

i have a question to ask:

suppose i load my gdt with

Code: Select all

lgdt gdt_desc
and then load my ds with

Code: Select all

mov ds,8
.

now suppose that i modify that same descriptor whose selector is currently loaded in ds. when should this change become effective:

1) immediately
2) the next time i do

Code: Select all

mov ds,8
3) the next time i do

Code: Select all

lgdt gdt_desc
???
urxae
Member
Member
Posts: 149
Joined: Sun Jul 30, 2006 8:16 am
Location: The Netherlands

Post by urxae »

The next time you load the register.
sancho1980
Member
Member
Posts: 199
Joined: Fri Jul 13, 2007 6:37 am
Location: Stuttgart/Germany
Contact:

Post by sancho1980 »

do you just say that or are you 100% sure? the reason being that i am doing that and i dont see how my newly written descriptor is having any effect on my active segment, so im trying to figure out if its because i am not correctly writing to the descriptor or if i have to load the gdt anew...
should i be able to do lgdt once i am in 32-pm? or can i do that only in preparation, i.e. BEFORE switching to pm?
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Post by jnc100 »

The hidden parts of the segment register are loaded from the gdt when you load the selector into the register (see the Intel manual on mov). You can change the gdt at any time with lgdt (either real mode or protected mode) although the hidden parts of the segment registers will still have their old values.

Regards,
John.
sancho1980
Member
Member
Posts: 199
Joined: Fri Jul 13, 2007 6:37 am
Location: Stuttgart/Germany
Contact:

Post by sancho1980 »

is there a way to find out what the values in the hidden parts are?
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Post by jnc100 »

Bochs debugger? Try 'info cpu'.

Regards,
John.
sancho1980
Member
Member
Posts: 199
Joined: Fri Jul 13, 2007 6:37 am
Location: Stuttgart/Germany
Contact:

Post by sancho1980 »

im using qemu

ive tried to compile bochs under linux w/o success
then i ran bochs under windows, but everytime i specify a floppy image to boot from (one that works perfectly with qemu), i get "couldnt load boot disk error"
bochs hates me
is there anything i can do to read these registers in qemu?
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Use QEMU monitor, if in a Unix environment just invoke QEMU with the "-monitor stdio" flag..

Perhaps next time, you should try reading the documentation for something you're about to use.. makes sense right? :roll:

http://fabrice.bellard.free.fr/qemu/qemu-doc.html#SEC12

As mentioned in the QEMU Documentation, You can also view the monitor directly inside the SDL display window by using the key combo Ctrl-Alt-2 and then Ctrl-Alt-1 to return.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
sancho1980
Member
Member
Posts: 199
Joined: Fri Jul 13, 2007 6:37 am
Location: Stuttgart/Germany
Contact:

Post by sancho1980 »

i know that document
i couldnt find anywhere in there that describes how to view the content of cpu registers (especially the hidden ones, as all the others can be printed out at runtime)
the only thing said about debugging is that you can use gdb in your host machine and somehow connect to your vm on qemu
i got it working once or twice but found it pretty complicated and not very useful so i ditched it

nevermind, for some strange reason the bochs god was nice to me yesterday and i was able to compile :-) *yeah
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Are you blind? read it! :roll:

"info registers" - show the cpu registers

I posted a direct link to the QEMU monitor FAQ, QEMU "does" have debugging features beyond the GDB backend..
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Post Reply