From patchwork Thu Sep 3 14:12:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 45372 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n83EDYmj027185 for ; Thu, 3 Sep 2009 14:13:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755558AbZICOMd (ORCPT ); Thu, 3 Sep 2009 10:12:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755433AbZICOMc (ORCPT ); Thu, 3 Sep 2009 10:12:32 -0400 Received: from cantor.suse.de ([195.135.220.2]:34095 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755533AbZICOMa (ORCPT ); Thu, 3 Sep 2009 10:12:30 -0400 Received: from relay1.suse.de (relay-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 3C0A39295B; Thu, 3 Sep 2009 16:12:32 +0200 (CEST) From: Alexander Graf To: kvm@vger.kernel.org Cc: Joerg Roedel Subject: [PATCH] Don't map nested_vmcb on INTERCEPT_MSR_PROT Date: Thu, 3 Sep 2009 16:12:31 +0200 Message-Id: <1251987151-20572-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- arch/x86/kvm/svm.c | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 2df9b45..e597961 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1427,18 +1427,16 @@ 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); + msrpm = nested_svm_map(svm, svm->nested.vmcb_msrpm, KM_USER0); - if (!nested_vmcb || !msrpm) + if (!msrpm) goto out; - if (!(nested_vmcb->control.intercept & (1ULL << INTERCEPT_MSR_PROT))) + if (!(svm->nested.intercept & (1ULL << INTERCEPT_MSR_PROT))) return 0; switch (msr) { @@ -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; }