About the use of FXSAVE/FXRSTOR

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
pini

About the use of FXSAVE/FXRSTOR

Post by pini »

What are the correct settings to make use of FXSAVE/FXRSTOR instructions ?
When I say "settings", I mean things like "NE", "MP", "TS", "EM" bits of CR0 and "OSFXSR", "OSXMMEXCPT" bits of CR4 ?

My current setting is:
NE=1
MP=1
TS=0
EM=0
OSFXSR=1
OSXMMEXCPT=1
on a Pentium 4 M
I also added a #XF exception handler

I tried to replace my existing fsave/frstor pair by the use of fxsave/fxrstor (I have also aligned the save area to a 16-byte boundary).

It seems to work for about 10-15 seconds (so there must be about 5-6 saves/restores done) and then suddenly, I get an #GP.

Where can it comes from ?
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:About the use of FXSAVE/FXRSTOR

Post by Candy »

pini wrote: When I say "settings", I mean things like "NE", "MP", "TS", "EM" bits of CR0 and "OSFXSR", "OSXMMEXCPT" bits of CR4 ?

My current setting is:
NE=1
MP=1
TS=0
EM=0
OSFXSR=1
OSXMMEXCPT=1
on a Pentium 4 M
I also added a #XF exception handler

I tried to replace my existing fsave/frstor pair by the use of fxsave/fxrstor (I have also aligned the save area to a 16-byte boundary).

It seems to work for about 10-15 seconds (so there must be about 5-6 saves/restores done) and then suddenly, I get an #GP.

Where can it comes from ?
Well, the two OS* are correct. You need to indicate you support it. TS=0 and EM=0 are also correct, you don't want to emulate these instructions, and you don't have them in use right now (note, if you always use this instruction when switching, it always has to be 0). The other two I have to check

Since you take some time to crash, can it be a complimentary bug? Something like a stack overflow or something similar?

Try tracing using debugging-bochs, figuring out what makes it crash and dump_cpu right before.
Post Reply