public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: MMU: make kvm_mmu_reset_context() flush the guest TLB
@ 2011-06-12 15:25 Avi Kivity
  2011-06-20 18:32 ` Marcelo Tosatti
  0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2011-06-12 15:25 UTC (permalink / raw)
  To: Marcelo Tosatti, kvm

kvm_set_cr0() and kvm_set_cr4(), and possible other functions,
assume that kvm_mmu_reset_context() flushes the guest TLB.  However,
it does not.

Fix by flushing the tlb (and syncing the new root as well).

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/mmu.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 19ebb76..b439ab7 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3042,8 +3042,18 @@ static void destroy_kvm_mmu(struct kvm_vcpu *vcpu)
 
 int kvm_mmu_reset_context(struct kvm_vcpu *vcpu)
 {
+	int r;
+
 	destroy_kvm_mmu(vcpu);
-	return init_kvm_mmu(vcpu);
+	r = init_kvm_mmu(vcpu);
+
+	if (r)
+		goto err;
+
+	kvm_mmu_sync_roots(vcpu);
+	kvm_mmu_flush_tlb(vcpu);
+err:
+	return r;
 }
 EXPORT_SYMBOL_GPL(kvm_mmu_reset_context);
 
-- 
1.7.5.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-21 14:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-12 15:25 [PATCH] KVM: MMU: make kvm_mmu_reset_context() flush the guest TLB Avi Kivity
2011-06-20 18:32 ` Marcelo Tosatti
2011-06-21 14:29   ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox