From: Avi Kivity Subject: [PATCH] KVM: MMU: make kvm_mmu_reset_context() flush the guest TLB Date: Sun, 12 Jun 2011 18:25:00 +0300 Message-ID: <1307892300-3288-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:45109 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751920Ab1FLPZE (ORCPT ); Sun, 12 Jun 2011 11:25:04 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5CFP4sH000829 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 12 Jun 2011 11:25:04 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5CFP3SJ032127 for ; Sun, 12 Jun 2011 11:25:03 -0400 Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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