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

Re: [Xen-devel] [PATCH] VMX: disable SMEP feature when guest is in non-paging mode


  • To: Keir Fraser <keir.xen@xxxxxxxxx>, Tim Deegan <tim@xxxxxxx>
  • From: "Xu, Dongxiao" <dongxiao.xu@xxxxxxxxx>
  • Date: Thu, 31 Jan 2013 00:56:48 +0000
  • Accept-language: en-US
  • Cc: "xen-devel@xxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxx>
  • Delivery-date: Thu, 31 Jan 2013 00:57:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>
  • Thread-index: AQHN/xLqbFInoJVLd0+oNnQuL3LaqZhhqnWAgADxifA=
  • Thread-topic: [Xen-devel] [PATCH] VMX: disable SMEP feature when guest is in non-paging mode

> -----Original Message-----
> From: Keir Fraser [mailto:keir.xen@xxxxxxxxx]
> Sent: Thursday, January 31, 2013 2:27 AM
> To: Tim Deegan; Xu, Dongxiao
> Cc: xen-devel@xxxxxxxxxxxxx
> Subject: Re: [Xen-devel] [PATCH] VMX: disable SMEP feature when guest is in
> non-paging mode
> 
> On 30/01/2013 09:54, "Tim Deegan" <tim@xxxxxxx> wrote:
> 
> > At 17:26 +0800 on 30 Jan (1359566815), dongxiao.xu@xxxxxxxxx wrote:
> >> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> >> index 4d7c93f..6347f66 100644
> >> --- a/xen/arch/x86/hvm/vmx/vmx.c
> >> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> >> @@ -1167,6 +1167,14 @@ static void vmx_update_guest_cr(struct vcpu
> *v,
> >> unsigned int cr)
> >>          {
> >>              v->arch.hvm_vcpu.hw_cr[4] |= X86_CR4_PSE;
> >>              v->arch.hvm_vcpu.hw_cr[4] &= ~X86_CR4_PAE;
> >> +            /*
> >> +             * SMEP 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, SMEP needs to be manually
> disabled
> >> when
> >> +             * guest switches to non-paging mode.
> >> +             */
> >> +            v->arch.hvm_vcpu.hw_cr[4] &= ~X86_CR4_SMEP;
> >
> > Shouldn't this be handled on CR0 writes as well as CR4?  The SMEP bit of
> > hw_cr[4] ought to be cleared and set whenever CR0_PG is changed.
> 
> That's what I would expect too.

In the case 0 (CR0 update) in vmx_update_guest_cr(), it will call 
vmx_update_guest_cr(v, 4) to adjust CR4 related bits if certain bits (PG, PE) 
in CR0 changed.

Thanks,
Dongxiao

> 
>  -- Keir
> 
> > Cheers,
> >
> > Tim.
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@xxxxxxxxxxxxx
> > http://lists.xen.org/xen-devel
> 


_______________________________________________
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®.