From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [patch 3/5] KVM: MMU: add kvm_mmu_shadow_walk helper Date: Wed, 10 Jun 2009 09:14:48 -0300 Message-ID: <20090610121448.GB6672@amt.cnet> References: <20090609213009.436123773@amt.cnet> <20090609213312.838419569@amt.cnet> <4A2F7A15.2080302@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, sheng.yang@intel.com To: Avi Kivity Return-path: Received: from mx2.redhat.com ([66.187.237.31]:46138 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751283AbZFJMSv (ORCPT ); Wed, 10 Jun 2009 08:18:51 -0400 Content-Disposition: inline In-Reply-To: <4A2F7A15.2080302@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Jun 10, 2009 at 12:17:09PM +0300, Avi Kivity wrote: > Marcelo Tosatti wrote: >> Required by EPT misconfiguration handler. >> >> Signed-off-by: Marcelo Tosatti >> >> Index: kvm/arch/x86/kvm/mmu.c >> =================================================================== >> --- kvm.orig/arch/x86/kvm/mmu.c >> +++ kvm/arch/x86/kvm/mmu.c >> @@ -3013,6 +3013,26 @@ out: >> return r; >> } >> +void kvm_mmu_shadow_walk(struct kvm_vcpu *vcpu, u64 addr, >> + struct mmu_shadow_walk *walk) >> +{ >> + struct kvm_shadow_walk_iterator iterator; >> + >> + spin_lock(&vcpu->kvm->mmu_lock); >> + for_each_shadow_entry(vcpu, addr, iterator) { >> + int err; >> + >> + err = walk->fn(vcpu, iterator.sptep, iterator.level, walk); >> + if (err) >> + break; >> + >> + if (!is_shadow_present_pte(*iterator.sptep)) >> + break; >> + } >> + spin_unlock(&vcpu->kvm->mmu_lock); >> +} >> +EXPORT_SYMBOL(kvm_mmu_shadow_walk); >> + >> > > Isn't it simpler to invoke for_each_shadow_entry(), instead of defining > a callback and calling it? > > We had those callbacks once, then switched to for_each. The point is its exported to use in a external module (kvm-intel.ko), so you hide the details (such as locking) in the kvm_mmu_shadow_walk helper. Let me know how do you prefer this to be.