Bochs invalidates SS when restored

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
stranger
Posts: 17
Joined: Thu Mar 03, 2011 4:05 am

Bochs invalidates SS when restored

Post by stranger »

Hi, It seems that bochs invalidates SS (sregs[2]->cache.valid=0) and any other register with selector->value & 0xfffc) == 0 in bx_cpu_c::param_restore_handler, thus simulation states before and after restore doesn't match.

Example:
before

Code: Select all

es:0xf000, dh=0x0000930f, dl=0x0000ffff, valid=1
        Data segment, base=0x000f0000, limit=0x0000ffff, Read/Write, Accessed
cs:0x9000, dh=0x00009309, dl=0x0000ffff, valid=1
        Data segment, base=0x00090000, limit=0x0000ffff, Read/Write, Accessed
ss:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7
        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
ds:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
fs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7
        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
gs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7
        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
ldtr:0x0000, dh=0x00008200, dl=0x0000ffff, valid=1
tr:0x0000, dh=0x00008b00, dl=0x0000ffff, valid=1
gdtr:base=0x00000000, limit=0xffff
idtr:base=0x00000000, limit=0xffff
after

Code: Select all

es:0xf000, dh=0x0000930f, dl=0x0000ffff, valid=1
        Data segment, base=0x000f0000, limit=0x0000ffff, Read/Write, Accessed
cs:0x9000, dh=0x00009309, dl=0x0000ffff, valid=1
        Data segment, base=0x00090000, limit=0x0000ffff, Read/Write, Accessed
ss:0x0000, dh=0x00009300, dl=0x0000ffff, valid=0
ds:0x0000, dh=0x00009300, dl=0x0000ffff, valid=0
fs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=0
gs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=0
ldtr:0x0000, dh=0x00008200, dl=0x0000ffff, valid=0
tr:0x0000, dh=0x00008b00, dl=0x0000ffff, valid=0
gdtr:base=0x00000000, limit=0xffff
idtr:base=0x00000000, limit=0xffff
I would like to know why. Thanks
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Bochs invalidates SS when restored

Post by bewing »

Because it's a bug. :wink:
Congrats, you found one. Stanislav will be along soon, and see this thread, and fix it.
stlw
Member
Member
Posts: 357
Joined: Fri Apr 04, 2008 6:43 am
Contact:

Re: Bochs invalidates SS when restored

Post by stlw »

stranger, you are running real mode, right ?

Bochs doesn't save the valid bit and tries to guess it when restoring the selector.
When simulating protected mode the currect behavior is correct, but in real or v8086 mode looks like it is not ...

Stanislav
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Bochs invalidates SS when restored

Post by Gigasoft »

It's necessary to save the entire descriptor cache including the valid bit. SS may have been 0 when entering protected mode. Then, when saving and restoring it would become invalid.
Post Reply