From: Jan Beulich Date: Tue, 6 Mar 2018 15:44:03 +0000 (+0100) Subject: x86emul: support SWAPGS X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~469 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6eb43fcf8a0bdff835d98a7146ddaffba2c61c37;p=xen.git x86emul: support SWAPGS Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index 95b792aad3..49b157d8cf 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -5019,6 +5019,28 @@ x86_emulate( goto done; break; + case 0xf8: /* swapgs */ + generate_exception_if(!mode_64bit(), EXC_UD); + generate_exception_if(!mode_ring0(), EXC_GP, 0); + fail_if(!ops->read_segment || !ops->read_msr || + !ops->write_segment || !ops->write_msr); + if ( (rc = ops->read_segment(x86_seg_gs, &sreg, + ctxt)) != X86EMUL_OKAY || + (rc = ops->read_msr(MSR_SHADOW_GS_BASE, &msr_val, + ctxt)) != X86EMUL_OKAY || + (rc = ops->write_msr(MSR_SHADOW_GS_BASE, sreg.base, + ctxt)) != X86EMUL_OKAY ) + goto done; + sreg.base = msr_val; + if ( (rc = ops->write_segment(x86_seg_gs, &sreg, + ctxt)) != X86EMUL_OKAY ) + { + /* Best effort unwind (i.e. no error checking). */ + ops->write_msr(MSR_SHADOW_GS_BASE, msr_val, ctxt); + goto done; + } + break; + case 0xf9: /* rdtscp */ fail_if(ops->read_msr == NULL); if ( (rc = ops->read_msr(MSR_TSC_AUX,