Message ID | 29986a8f-47bf-43c2-98e9-e08c1c5925af@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | x86emul: fix FXRSTOR test for most AMD CPUs | expand |
On 06/07/2020 16:14, Jan Beulich wrote: > 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. > > Reported-by: Andrew Cooper <andrew.cooper3@citrix.com> > Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com> Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> -----Original Message----- > From: Andrew Cooper <andrew.cooper3@citrix.com> > Sent: 06 July 2020 16:47 > To: Jan Beulich <jbeulich@suse.com>; xen-devel@lists.xenproject.org > Cc: Wei Liu <wl@xen.org>; Roger Pau Monné <roger.pau@citrix.com>; Paul Durrant <paul@xen.org> > Subject: Re: [PATCH] x86emul: fix FXRSTOR test for most AMD CPUs > > On 06/07/2020 16:14, Jan Beulich wrote: > > 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. > > > > Reported-by: Andrew Cooper <andrew.cooper3@citrix.com> > > Signed-off-by: Jan Beulich <jbeulich@suse.com> > > Acked-by: Andrew Cooper <andrew.cooper3@citrix.com> > Tested-by: Andrew Cooper <andrew.cooper3@citrix.com> Release-acked-by: Paul Durrant <paul@xen.org>
--- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -2577,6 +2577,7 @@ int main(int argc, char **argv) regs.ecx = (unsigned long)(res + 0x81); rc = x86_emulate(&ctxt, &emulops); asm volatile ( "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]) )
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. Reported-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Jan Beulich <jbeulich@suse.com>