* [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* Re: [PATCH] KVM: MMU: make kvm_mmu_reset_context() flush the guest TLB
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
0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Tosatti @ 2011-06-20 18:32 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
On Sun, Jun 12, 2011 at 06:25:00PM +0300, Avi Kivity wrote:
> 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.
TLB flush should be done lazily during guest entry, in
kvm_mmu_load(). Don't see why this patch is needed.
>
> Fix by flushing the tlb (and syncing the new root as well).
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: MMU: make kvm_mmu_reset_context() flush the guest TLB
2011-06-20 18:32 ` Marcelo Tosatti
@ 2011-06-21 14:29 ` Avi Kivity
0 siblings, 0 replies; 3+ messages in thread
From: Avi Kivity @ 2011-06-21 14:29 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm
On 06/20/2011 09:32 PM, Marcelo Tosatti wrote:
> On Sun, Jun 12, 2011 at 06:25:00PM +0300, Avi Kivity wrote:
> > 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.
>
> TLB flush should be done lazily during guest entry, in
> kvm_mmu_load(). Don't see why this patch is needed.
You're right. It should be reverted.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [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