From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v2 6/7] x86/hvm: Add SMAP support to HVM guest Date: Wed, 23 Apr 2014 11:49:25 +0100 Message-ID: <53579AB5.9030809@citrix.com> References: <1398263874-32227-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: <1398263874-32227-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:37, Feng Wu wrote: > > /* Go back and set accessed and dirty bits only if the walk was a > diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h > index 74a09ef..8dbb3f0 100644 > --- a/xen/include/asm-x86/hvm/hvm.h > +++ b/xen/include/asm-x86/hvm/hvm.h > @@ -257,6 +257,8 @@ int hvm_girq_dest_2_vcpu_id(struct domain *d, uint8_t dest, uint8_t dest_mode); > (hvm_paging_enabled(v) && ((v)->arch.hvm_vcpu.guest_cr[4] & X86_CR4_PAE)) > #define hvm_smep_enabled(v) \ > (hvm_paging_enabled(v) && ((v)->arch.hvm_vcpu.guest_cr[4] & X86_CR4_SMEP)) > +#define hvm_smap_enabled(v) \ > + (hvm_paging_enabled(v) && ((v)->arch.hvm_vcpu.guest_cr[4] & X86_CR4_SMAP)) > #define hvm_nx_enabled(v) \ > (!!((v)->arch.hvm_vcpu.guest_efer & EFER_NX)) > > @@ -360,6 +362,15 @@ static inline bool_t hvm_vcpu_has_smep(void) > return !!(ebx & cpufeat_mask(X86_FEATURE_SMEP)); > } > > +static inline bool_t hvm_vcpu_has_smap(void) > +{ > + unsigned int ebx = 0, leaf = 0x7; > + > + hvm_cpuid(leaf, NULL, &ebx, NULL, NULL); Same review as the SMEP fix earlier in the series. ~Andrew > + > + return !!(ebx & cpufeat_mask(X86_FEATURE_SMAP)); > +} > + > /* These reserved bits in lower 32 remain 0 after any load of CR0 */ > #define HVM_CR0_GUEST_RESERVED_BITS \ > (~((unsigned long) \ > @@ -380,6 +391,7 @@ static inline bool_t hvm_vcpu_has_smep(void) > X86_CR4_MCE | X86_CR4_PGE | X86_CR4_PCE | \ > X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT | \ > (hvm_vcpu_has_smep() ? X86_CR4_SMEP : 0) | \ > + (hvm_vcpu_has_smap() ? X86_CR4_SMAP : 0) | \ > (cpu_has_fsgsbase ? X86_CR4_FSGSBASE : 0) | \ > ((nestedhvm_enabled((_v)->domain) && cpu_has_vmx)\ > ? X86_CR4_VMXE : 0) | \