From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v3 04/13] nEPT: Define EPT-specific link_shadow_page() Date: Mon, 20 May 2013 14:43:18 +0200 Message-ID: <519A1A66.3040209@redhat.com> References: <1368939152-11406-1-git-send-email-jun.nakajima@intel.com> <1368939152-11406-4-git-send-email-jun.nakajima@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Gleb Natapov To: Jun Nakajima Return-path: Received: from mx1.redhat.com ([209.132.183.28]:49799 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756277Ab3ETMnZ (ORCPT ); Mon, 20 May 2013 08:43:25 -0400 In-Reply-To: <1368939152-11406-4-git-send-email-jun.nakajima@intel.com> Sender: kvm-owner@vger.kernel.org List-ID: Il 19/05/2013 06:52, Jun Nakajima ha scritto: > From: Nadav Har'El > > Since link_shadow_page() is used by a routine in mmu.c, add an > EPT-specific link_shadow_page() in paging_tmp.h, rather than moving > it. > > Signed-off-by: Nadav Har'El > Signed-off-by: Jun Nakajima > Signed-off-by: Xinhao Xu > --- > arch/x86/kvm/paging_tmpl.h | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h > index 4c45654..dc495f9 100644 > --- a/arch/x86/kvm/paging_tmpl.h > +++ b/arch/x86/kvm/paging_tmpl.h > @@ -461,6 +461,18 @@ static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, struct guest_walker *gw, > } > } > > +#if PTTYPE == PTTYPE_EPT > +static void FNAME(link_shadow_page)(u64 *sptep, struct kvm_mmu_page *sp) > +{ > + u64 spte; > + > + spte = __pa(sp->spt) | VMX_EPT_READABLE_MASK | VMX_EPT_WRITABLE_MASK | > + VMX_EPT_EXECUTABLE_MASK; > + > + mmu_spte_set(sptep, spte); > +} > +#endif The function is small enough that likely the compiler will inline it. You can just handle it unconditionally with FNAME(). Paolo > /* > * Fetch a shadow pte for a specific level in the paging hierarchy. > * If the guest tries to write a write-protected page, we need to > @@ -513,7 +525,11 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, > goto out_gpte_changed; > > if (sp) > +#if PTTYPE == PTTYPE_EPT > + FNAME(link_shadow_page)(it.sptep, sp); > +#else > link_shadow_page(it.sptep, sp); > +#endif > } > > for (; > @@ -533,7 +549,11 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, > > sp = kvm_mmu_get_page(vcpu, direct_gfn, addr, it.level-1, > true, direct_access, it.sptep); > +#if PTTYPE == PTTYPE_EPT > + FNAME(link_shadow_page)(it.sptep, sp); > +#else > link_shadow_page(it.sptep, sp); > +#endif > } > > clear_sp_write_flooding_count(it.sptep); >