mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joerg Roedel <joerg.roedel@amd.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 7/7] KVM: SVM: Don't change host intercepts in vmrun emulation
Date: Wed, 13 Jul 2011 17:32:25 +0200	[thread overview]
Message-ID: <1310571145-28930-8-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1310571145-28930-1-git-send-email-joerg.roedel@amd.com>

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 <joerg.roedel@amd.com>
---
 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;
-- 
1.7.4.1



      parent reply	other threads:[~2011-07-13 15:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-13 15:32 [PATCH 0/7] Implement Shadow VMCB for Nested SVM Joerg Roedel
2011-07-13 15:32 ` [PATCH 1/7] KVM: SVM: Keep seperate pointer to host-vmcb Joerg Roedel
2011-07-14 10:13   ` Avi Kivity
2011-07-13 15:32 ` [PATCH 2/7] KVM: SVM: Use host_vmcb_pa for vmload and vmsave Joerg Roedel
2011-07-14 11:29   ` Avi Kivity
2011-07-14 13:10     ` Joerg Roedel
2011-07-14 13:20       ` Avi Kivity
2011-07-14 13:52         ` Joerg Roedel
2011-07-14 14:01           ` Avi Kivity
2011-07-13 15:32 ` [PATCH 3/7] KVM: SVM: Reorder nested_svm_vmrun Joerg Roedel
2011-07-13 15:32 ` [PATCH 4/7] KVM: SVM: Use seperate VMCB for L2 guests Joerg Roedel
2011-07-14 11:38   ` Avi Kivity
2011-07-14 13:12     ` Joerg Roedel
2011-07-14 13:26       ` Avi Kivity
2011-07-14 13:40         ` Joerg Roedel
2011-07-14 13:43           ` Avi Kivity
2011-07-13 15:32 ` [PATCH 5/7] KVM: SVM: Remove nested.hsave state Joerg Roedel
2011-07-13 15:32 ` [PATCH 6/7] KVM: SVM: Rework hflags handling Joerg Roedel
2011-07-13 15:32 ` Joerg Roedel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1310571145-28930-8-git-send-email-joerg.roedel@amd.com \
    --to=joerg.roedel@amd.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®