From patchwork Wed Jul 13 15:32:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 972622 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6DFRZ3v016052 for ; Wed, 13 Jul 2011 15:34:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755743Ab1GMPd5 (ORCPT ); Wed, 13 Jul 2011 11:33:57 -0400 Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13]:59791 "EHLO TX2EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755549Ab1GMPdS (ORCPT ); Wed, 13 Jul 2011 11:33:18 -0400 Received: from mail130-tx2-R.bigfish.com (10.9.14.243) by TX2EHSOBE005.bigfish.com (10.9.40.25) with Microsoft SMTP Server id 14.1.225.22; Wed, 13 Jul 2011 15:33:17 +0000 Received: from mail130-tx2 (localhost.localdomain [127.0.0.1]) by mail130-tx2-R.bigfish.com (Postfix) with ESMTP id A1C6DBE0142; Wed, 13 Jul 2011 15:33:17 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzz8275bhz32i668h839h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: CIP:163.181.249.109; KIP:(null); UIP:(null); IPVD:NLI; H:ausb3twp02.amd.com; RD:none; EFVD:NLI Received: from mail130-tx2 (localhost.localdomain [127.0.0.1]) by mail130-tx2 (MessageSwitch) id 131057119684205_15330; Wed, 13 Jul 2011 15:33:16 +0000 (UTC) Received: from TX2EHSMHS038.bigfish.com (unknown [10.9.14.241]) by mail130-tx2.bigfish.com (Postfix) with ESMTP id 0671F8F0059; Wed, 13 Jul 2011 15:33:16 +0000 (UTC) Received: from ausb3twp02.amd.com (163.181.249.109) by TX2EHSMHS038.bigfish.com (10.9.99.138) with Microsoft SMTP Server id 14.1.225.22; Wed, 13 Jul 2011 15:33:15 +0000 X-WSS-ID: 0LOA37B-02-9JI-02 X-M-MSG: Received: from sausexedgep01.amd.com (sausexedgep01-ext.amd.com [163.181.249.72]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Axway MailGate 3.8.1) with ESMTP id 25517FCC115; Wed, 13 Jul 2011 10:33:10 -0500 (CDT) Received: from sausexhtp01.amd.com (163.181.3.165) by sausexedgep01.amd.com (163.181.36.54) with Microsoft SMTP Server (TLS) id 8.3.106.1; Wed, 13 Jul 2011 10:34:11 -0500 Received: from storexhtp02.amd.com (172.24.4.4) by sausexhtp01.amd.com (163.181.3.165) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 13 Jul 2011 10:33:12 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp02.amd.com (172.24.4.4) with Microsoft SMTP Server id 8.3.83.0; Wed, 13 Jul 2011 11:33:12 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id 4B3D649C5EF; Wed, 13 Jul 2011 16:33:11 +0100 (BST) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 3072710002D; Wed, 13 Jul 2011 17:33:11 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: , , Joerg Roedel Subject: [PATCH 7/7] KVM: SVM: Don't change host intercepts in vmrun emulation Date: Wed, 13 Jul 2011 17:32:25 +0200 Message-ID: <1310571145-28930-8-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1310571145-28930-1-git-send-email-joerg.roedel@amd.com> References: <1310571145-28930-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 13 Jul 2011 15:34:38 +0000 (UTC) Rather than changing the host intercepts in nested_svm_vmrun, mask the intercepts we only want to see from the guest out in recalc_intercepts. Signed-off-by: Joerg Roedel --- arch/x86/kvm/svm.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index c83315a..ab48dd4 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -102,6 +102,9 @@ struct nested_state { u32 intercept_exceptions; u64 intercept; + /* Mask of relevant host intercepts for recalculation */ + u32 intercept_cr_mask; + /* Nested Paging related state */ u64 nested_cr3; @@ -250,10 +253,11 @@ static void recalc_intercepts(struct vcpu_svm *svm) h = &svm->host_vmcb->control; g = &svm->nested; - c->intercept_cr = h->intercept_cr | g->intercept_cr; + c->intercept_cr = (h->intercept_cr & g->intercept_cr_mask) | + g->intercept_cr; c->intercept_dr = h->intercept_dr | g->intercept_dr; c->intercept_exceptions = h->intercept_exceptions | g->intercept_exceptions; - c->intercept = h->intercept | g->intercept; + c->intercept = (h->intercept & ~(INTERCEPT_VMMCALL)) | g->intercept; } static inline void set_cr_intercept(struct vcpu_svm *svm, int bit) @@ -2376,13 +2380,12 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) svm->vcpu.arch.hflags |= HF_VINTR_MASK; /* We only want the cr8 intercept bits of the guest */ - clr_cr_intercept(svm, INTERCEPT_CR8_READ); - clr_cr_intercept(svm, INTERCEPT_CR8_WRITE); + svm->nested.intercept_cr_mask = ~(INTERCEPT_CR8_READ | + INTERCEPT_CR8_WRITE); + } else { + svm->nested.intercept_cr_mask = 0ULL; } - /* We don't want to see VMMCALLs from a nested guest */ - clr_intercept(svm, INTERCEPT_VMMCALL); - if (nested_vmcb->control.nested_ctl) { kvm_mmu_unload(&svm->vcpu); svm->nested.nested_cr3 = nested_vmcb->control.nested_cr3;