From: Andrew Cooper Date: Tue, 18 Oct 2016 15:55:26 +0000 (+0100) Subject: x86/emul: Implement the STAC and CLAC instructions X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~3177 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a29e10dd0b5f0b785e6389d71dc9847a51307246;p=xen.git x86/emul: Implement the STAC and CLAC instructions Note that unlike most privilege restricted instructions, STAC and CLAC are documented to raise #UD rather than #GP[0], and indeed do so. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index fe055cff8b..43c4a9d4b6 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -1295,6 +1295,7 @@ static bool vcpu_has( #define vcpu_has_bmi1() vcpu_has( 7, EBX, 3, ctxt, ops) #define vcpu_has_hle() vcpu_has( 7, EBX, 4, ctxt, ops) #define vcpu_has_rtm() vcpu_has( 7, EBX, 11, ctxt, ops) +#define vcpu_has_smap() vcpu_has( 7, EBX, 20, ctxt, ops) #define vcpu_must_have(feat) \ generate_exception_if(!vcpu_has_##feat(), EXC_UD) @@ -4354,6 +4355,17 @@ x86_emulate( switch( modrm ) { + case 0xca: /* clac */ + case 0xcb: /* stac */ + vcpu_must_have(smap); + generate_exception_if(lock_prefix || vex.pfx || !mode_ring0(), + EXC_UD); + + _regs.eflags &= ~EFLG_AC; + if ( modrm == 0xcb ) + _regs.eflags |= EFLG_AC; + goto no_writeback; + #ifdef __XEN__ case 0xd1: /* xsetbv */ {