-
-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crash while executing "ldmxcsr" instruction in bochscpu backend #140
Comments
Okay, according to the manual, ldmxcsr void BX_CPP_AttrRegparmN(1) BX_CPU_C::LDMXCSR(bxInstruction_c *i)
{
#if BX_CPU_LEVEL >= 6
bx_address eaddr = BX_CPU_RESOLVE_ADDR(i);
Bit32u new_mxcsr = read_virtual_dword(i->seg(), eaddr);
if(new_mxcsr & ~MXCSR_MASK)
exception(BX_GP_EXCEPTION, 0);
BX_MXCSR_REGISTER = new_mxcsr;
#endif
BX_NEXT_INSTR(i);
} This is #define MXCSR_MASK (BX_CPU_THIS_PTR mxcsr_mask) And this is how it looks like it gets initialized (init.cc): void BX_CPU_C::reset(unsigned source)
{
// ...
BX_CPU_THIS_PTR mxcsr_mask = 0x0000ffbf;
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_SSE2))
BX_CPU_THIS_PTR mxcsr_mask |= MXCSR_DAZ;
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_MISALIGNED_SSE))
BX_CPU_THIS_PTR mxcsr_mask |= MXCSR_MISALIGNED_EXCEPTION_MASK; Could you dump the value that's getting loaded? Cheers |
state of mxcsr (mem.dmp) : here: |
Okay, I made a mistake; the
So in your case,
Here's the description of those two bits:
To verify all of the above, can you change your Cheers |
Okay, we talked about the above and the suggestion didn't work. I did some digging today and I think I understand why; basically there might be a bug in bochscpu/mod.rs: pub unsafe fn set_state(&self, s: &State) {
// ...
self.set_mxcsr(s.mxcsr);
self.set_mxcsr_mask(s.mxcsr);
} So editing the I'll talk to Cheers |
…is used to have no effect. This was fixed in bx (see 0vercl0k#140), so old dumps running w/ newer version of wtf will fire #GPs on `ldmscxr` instructions. To avoid that issue, let's detect screwed up values and fix them up ourselves.
while this particular instruction(ldmxcsr) executes successfully on whv backend, it crashes on bochscpu backend.
crash detail: raises GP
CoolType!CTInit+0x2c167 (ldmxcsr)
nt!KiGeneralProtectionFault+0x0
crash instruction:
ldmxcsr dword ptr [rsp+8]
The text was updated successfully, but these errors were encountered: