From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v2 4/7] VMX: Disable SMAP feature when guest is in non-paging mode Date: Wed, 23 Apr 2014 11:35:43 +0100 Message-ID: <5357977F.20301@citrix.com> References: <1398263814-32141-1-git-send-email-feng.wu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1398263814-32141-1-git-send-email-feng.wu@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Feng Wu Cc: kevin.tian@intel.com, ian.campbell@citrix.com, eddie.dong@intel.com, xen-devel@lists.xen.org, JBeulich@suse.com, jun.nakajima@intel.com List-Id: xen-devel@lists.xenproject.org On 23/04/14 15:36, Feng Wu wrote: > 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 > --- > 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 94f3db2..79dd272 100644 > --- a/xen/arch/x86/hvm/vmx/vmx.c > +++ b/xen/arch/x86/hvm/vmx/vmx.c > @@ -1310,12 +1310,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;