* [PATCH] KVM: PPC: Book3S HV: Always flush TLB in kvmppc_alloc_reset_hpt()
@ 2018-01-10 6:04 David Gibson
2018-01-11 9:54 ` Paul Mackerras
0 siblings, 1 reply; 2+ messages in thread
From: David Gibson @ 2018-01-10 6:04 UTC (permalink / raw)
To: paulus, surajjs, spopovyc; +Cc: kvm, kvm-ppc, linux-kernel, David Gibson
The KVM_PPC_ALLOCATE_HTAB ioctl(), implemented by kvmppc_alloc_reset_hpt()
is supposed to completely clear and reset a guest's Hashed Page Table (HPT)
allocating or re-allocating it if necessary.
In the case where an HPT of the right size already exists and it just
zeroes it, it forces a TLB flush on all guest CPUs, to remove any stale TLB
entries loaded from the old HPT.
However, that situation can arise when the HPT is resizing as well - or
even when switching from an RPT to HPT - so those cases need a TLB flush as
well.
So, move the TLB flush to trigger in all cases except for errors.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
arch/powerpc/kvm/book3s_64_mmu_hv.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Paul, this is based on Paolo's KVM tree, but it should apply without
modification to pretty much any vaguely current tree. It's a pretty
nasty bug - the case we've found hitting it in the wild is a bit
esoteric, but it could in theory affect other situations as well.
Please apply ASAP, and should probably be queued for the stable
branches as well.
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index 966097232d21..51a275cc8a4d 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -159,8 +159,6 @@ long kvmppc_alloc_reset_hpt(struct kvm *kvm, int order)
* Reset all the reverse-mapping chains for all memslots
*/
kvmppc_rmap_reset(kvm);
- /* Ensure that each vcpu will flush its TLB on next entry. */
- cpumask_setall(&kvm->arch.need_tlb_flush);
err = 0;
goto out;
}
@@ -176,6 +174,10 @@ long kvmppc_alloc_reset_hpt(struct kvm *kvm, int order)
kvmppc_set_hpt(kvm, &info);
out:
+ if (err == 0)
+ /* Ensure that each vcpu will flush its TLB on next entry. */
+ cpumask_setall(&kvm->arch.need_tlb_flush);
+
mutex_unlock(&kvm->lock);
return err;
}
--
2.14.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV: Always flush TLB in kvmppc_alloc_reset_hpt()
2018-01-10 6:04 [PATCH] KVM: PPC: Book3S HV: Always flush TLB in kvmppc_alloc_reset_hpt() David Gibson
@ 2018-01-11 9:54 ` Paul Mackerras
0 siblings, 0 replies; 2+ messages in thread
From: Paul Mackerras @ 2018-01-11 9:54 UTC (permalink / raw)
To: David Gibson; +Cc: surajjs, spopovyc, kvm, kvm-ppc, linux-kernel
On Wed, Jan 10, 2018 at 05:04:39PM +1100, David Gibson wrote:
> The KVM_PPC_ALLOCATE_HTAB ioctl(), implemented by kvmppc_alloc_reset_hpt()
> is supposed to completely clear and reset a guest's Hashed Page Table (HPT)
> allocating or re-allocating it if necessary.
>
> In the case where an HPT of the right size already exists and it just
> zeroes it, it forces a TLB flush on all guest CPUs, to remove any stale TLB
> entries loaded from the old HPT.
>
> However, that situation can arise when the HPT is resizing as well - or
> even when switching from an RPT to HPT - so those cases need a TLB flush as
> well.
>
> So, move the TLB flush to trigger in all cases except for errors.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> arch/powerpc/kvm/book3s_64_mmu_hv.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Paul, this is based on Paolo's KVM tree, but it should apply without
> modification to pretty much any vaguely current tree. It's a pretty
> nasty bug - the case we've found hitting it in the wild is a bit
> esoteric, but it could in theory affect other situations as well.
>
> Please apply ASAP, and should probably be queued for the stable
> branches as well.
Thanks, applied to my kvm-ppc-fixes branch, and I added
cc: stable@vger.kernel.org.
Paul.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-11 10:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-10 6:04 [PATCH] KVM: PPC: Book3S HV: Always flush TLB in kvmppc_alloc_reset_hpt() David Gibson
2018-01-11 9:54 ` Paul Mackerras
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®