From: Feng Wu Date: Mon, 12 May 2014 15:03:09 +0000 (+0200) Subject: VMX: disable SMAP feature when guest is in non-paging mode X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5023 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=67fa47753f55cbfdada11f8f517ddd07bc9f6be8;p=xen.git VMX: disable SMAP feature when guest is in non-paging mode SMAP is disabled if CPU is in non-paging mode in hardware. However Xen always uses paging mode to emulate guest non-paging mode with HAP. To emulate this behavior, SMAP needs to be manually disabled when guest switches to non-paging mode. This logic is similiar with SMEP. Signed-off-by: Feng Wu Reviewed-by: Andrew Cooper Acked-by: Kevin Tian --- diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 00cab8aa96..b6c022b21d 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1320,12 +1320,12 @@ static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr) if ( !hvm_paging_enabled(v) ) { /* - * SMEP is disabled if CPU is in non-paging mode in hardware. + * SMEP/SMAP is disabled if CPU is in non-paging mode in hardware. * However Xen always uses paging mode to emulate guest non-paging - * mode. To emulate this behavior, SMEP needs to be manually + * mode. To emulate this behavior, SMEP/SMAP needs to be manually * disabled when guest VCPU is in non-paging mode. */ - v->arch.hvm_vcpu.hw_cr[4] &= ~X86_CR4_SMEP; + v->arch.hvm_vcpu.hw_cr[4] &= ~(X86_CR4_SMEP | X86_CR4_SMAP); } __vmwrite(GUEST_CR4, v->arch.hvm_vcpu.hw_cr[4]); break;