x86emul: fix FXRSTOR test for most AMD CPUs
PATCH 1/1 x86emul: fix FXRSTOR test for most AMD CPUs
AMD CPUs that we classify as X86_BUG_FPU_PTRS don't touch the selector/ offset portion of the save image during FXSAVE unless an unmasked exception is pending. Hence the selector zapping done between the initial FXSAVE and the emulated FXRSTOR needs to be mirrored onto the second FXSAVE, output of which gets fed into memcmp() to compare with the input image.
tools/tests/x86_emulator/test_x86_emulator.c +1 -0
@@ -2577,6 +2577,7 @@ int main(int argc, char **argv) regs.ecx = (unsigned long )(res +0x81 ); rc =x86_emulate (&ctxt, &emulops); asmvolatile ("fxsave %0" :"=m" (res[0x100 ]) ::"memory" ); +zap_xfpsel (&res[0x100 ]);if ( (rc !=X86EMUL_OKAY ) ||memcmp (res +0x100 , res +0x80 ,0x200 ) || (regs.eip != (unsigned long )&instr[4 ]) )
Quoted 9 lines · Jan Beulich
AMD CPUs that we classify as
X86_BUG_FPU_PTRSdon't touch the selector/ offset portion of the save image during FXSAVE unless an unmasked exception is pending. Hence the selector zapping done between the initial FXSAVE and the emulated FXRSTOR needs to be mirrored onto the second FXSAVE, output of which gets fed intomemcmp()to compare with the input image.Reported-by Andrew Cooper <[email protected]>Signed-off-by Jan Beulich <[email protected]>
Quoted 15 lines
-----Original Message-----
From: Andrew Cooper <[email protected]>
Sent: 06 July 2020 16:47
To: Jan Beulich <[email protected]>; [email protected]
Cc: Wei Liu <[email protected]>; Roger Pau Monné <[email protected]>; Paul Durrant <[email protected]>
Subject: Re: [PATCH] x86emul: fix FXRSTOR test for most AMD CPUsQuoted 7 lines · Jan Beulich
AMD CPUs that we classify as
X86_BUG_FPU_PTRSdon't touch the selector/ offset portion of the save image during FXSAVE unless an unmasked exception is pending. Hence the selector zapping done between the initial FXSAVE and the emulated FXRSTOR needs to be mirrored onto the second FXSAVE, output of which gets fed intomemcmp()to compare with the input image.
Quoted 5 lines
Quoted 2 lines
Reported-by Andrew Cooper <[email protected]>Signed-off-by Jan Beulich <[email protected]>Acked-by Andrew Cooper <[email protected]>Tested-by Andrew Cooper <[email protected]>