From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [patch 3/5] KVM: MMU: add kvm_mmu_get_spte_hierarchy helper Date: Thu, 11 Jun 2009 17:31:05 +0300 Message-ID: <4A311529.3070907@redhat.com> References: <20090611140224.457657937@localhost.localdomain> <20090611140416.759106501@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx2.redhat.com ([66.187.237.31]:34786 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752465AbZFKObF (ORCPT ); Thu, 11 Jun 2009 10:31:05 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5BEV8ZB002230 for ; Thu, 11 Jun 2009 10:31:08 -0400 In-Reply-To: <20090611140416.759106501@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: 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,24 @@ out: > return r; > } > > +int kvm_mmu_get_spte_hierarchy(struct kvm_vcpu *vcpu, u64 addr, u64 *sptes[4]) > +{ > + struct kvm_shadow_walk_iterator iterator; > + int nr_sptes = 0; > + > + spin_lock(&vcpu->kvm->mmu_lock); > + for_each_shadow_entry(vcpu, addr, iterator) { > + sptes[iterator.level-1] = iterator.sptep; > Returning a pointer... > + nr_sptes++; > + if (!is_shadow_present_pte(*iterator.sptep)) > + break; > + } > + spin_unlock(&vcpu->kvm->mmu_lock); > ... and unlocking the lock that protects it. True, this is called in extreme cases, but I think you can dereference the pointer in the function just as easily. -- error compiling committee.c: too many arguments to function