From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: Re: [PATCH] Don't map nested_vmcb on INTERCEPT_MSR_PROT Date: Thu, 3 Sep 2009 18:00:32 +0200 Message-ID: <20090903160032.GC30765@amd.com> References: <1251989512-22072-1-git-send-email-agraf@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Cc: kvm@vger.kernel.org To: Alexander Graf Return-path: Received: from va3ehsobe002.messaging.microsoft.com ([216.32.180.12]:28786 "EHLO VA3EHSOBE002.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753130AbZICQBh (ORCPT ); Thu, 3 Sep 2009 12:01:37 -0400 Content-Disposition: inline In-Reply-To: <1251989512-22072-1-git-send-email-agraf@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: Indeed. Good catch. Thanks :-) On Thu, Sep 03, 2009 at 04:51:52PM +0200, Alexander Graf wrote: > Thanks to Joerg's previous series of cleanups, we now have almost all > information we need to decide what to do on #VMEXIT because we get > the variables from the VMCB on VMRUN. > > Unfortunately there's one piece that slipped through the conversion, > namely the MSR intercept which still tries to map the nested VMCB > to find out if MSRs are intercepted. > > So let's use the cached value, removing the need for two atomic maps > (which breaks anyways) and fix an oops along the way. > > CC: Joerg Roedel > Signed-off-by: Alexander Graf Acked-by: Joerg Roedel > > --- > > v1 -> v2: > > - Don't break when MSR is not intercepted > --- > arch/x86/kvm/svm.c | 15 ++++++--------- > 1 files changed, 6 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 2df9b45..a5f90c7 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -1427,19 +1427,17 @@ static bool nested_svm_exit_handled_msr(struct vcpu_svm *svm) > { > u32 param = svm->vmcb->control.exit_info_1 & 1; > u32 msr = svm->vcpu.arch.regs[VCPU_REGS_RCX]; > - struct vmcb *nested_vmcb; > bool ret = false; > u32 t0, t1; > u8 *msrpm; > > - nested_vmcb = nested_svm_map(svm, svm->nested.vmcb, KM_USER0); > - msrpm = nested_svm_map(svm, svm->nested.vmcb_msrpm, KM_USER1); > + if (!(svm->nested.intercept & (1ULL << INTERCEPT_MSR_PROT))) > + return false; > > - if (!nested_vmcb || !msrpm) > - goto out; > + msrpm = nested_svm_map(svm, svm->nested.vmcb_msrpm, KM_USER0); > > - if (!(nested_vmcb->control.intercept & (1ULL << INTERCEPT_MSR_PROT))) > - return 0; > + if (!msrpm) > + goto out; > > switch (msr) { > case 0 ... 0x1fff: > @@ -1464,8 +1462,7 @@ static bool nested_svm_exit_handled_msr(struct vcpu_svm *svm) > ret = msrpm[t1] & ((1 << param) << t0); > > out: > - nested_svm_unmap(nested_vmcb, KM_USER0); > - nested_svm_unmap(msrpm, KM_USER1); > + nested_svm_unmap(msrpm, KM_USER0); > > return ret; > } > -- > 1.6.0.2 > > --