From: Jan Beulich Date: Mon, 12 Jan 2015 14:41:12 +0000 (+0100) Subject: x86emul: tighten CLFLUSH emulation X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3947 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9d03db6b81d1880bf3aa4fc83a60346bf02be251;p=xen.git x86emul: tighten CLFLUSH emulation While for us it's not as bad as it was for Linux, their commit 13e457e0ee ("KVM: x86: Emulator does not decode clflush well", by Nadav Amit ) nevertheless points out two shortcomings in our code: opcode 0F AE /7 is clflush only when it uses a memory mode (otherwise it's SFENCE) and when there's no REP prefix (an operand size prefix is fine, as that's CLFLUSHOPT). Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index be07ffb264..f13f07d214 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -4410,7 +4410,9 @@ x86_emulate( case 0xae: /* Grp15 */ switch ( modrm_reg & 7 ) { - case 7: /* clflush */ + case 7: /* clflush{,opt} */ + fail_if(modrm_mod == 3); + fail_if(rep_prefix()); fail_if(ops->wbinvd == NULL); if ( (rc = ops->wbinvd(ctxt)) != 0 ) goto done;