[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v6 07/10] VMX: Disable SMAP feature when guest is in non-paging mode



> From: Wu, Feng
> Sent: Wednesday, May 07, 2014 4:20 PM
> 
> 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 <feng.wu@xxxxxxxxx>
> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Acked-by: Kevin Tian <kevin.tian@xxxxxxxxx>

> ---
>  xen/arch/x86/hvm/vmx/vmx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index ecdbc17..f0f6f83 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -1319,12 +1319,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;
> --
> 1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.