linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] KVM: PPC: Book3S HV: Invalidate ERAT when flushing guest TLB entries
@ 2019-06-20  1:46 Suraj Jitindar Singh
  2019-06-20  1:46 ` [PATCH 2/3] KVM: PPC: Book3S HV: Signed extend decrementer value if not using large decr Suraj Jitindar Singh
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Suraj Jitindar Singh @ 2019-06-20  1:46 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: clg, kvm-ppc, sjitindarsingh

When a guest vcpu moves from one physical thread to another it is
necessary for the host to perform a tlb flush on the previous core if
another vcpu from the same guest is going to run there. This is because the
guest may use the local form of the tlb invalidation instruction meaning
stale tlb entries would persist where it previously ran. This is handled
on guest entry in kvmppc_check_need_tlb_flush() which calls
flush_guest_tlb() to perform the tlb flush.

Previously the generic radix__local_flush_tlb_lpid_guest() function was
used, however the functionality was reimplemented in flush_guest_tlb()
to avoid the trace_tlbie() call as the flushing may be done in real
mode. The reimplementation in flush_guest_tlb() was missing an erat
invalidation after flushing the tlb.

This lead to observable memory corruption in the guest due to the
caching of stale translations. Fix this by adding the erat invalidation.

Fixes: 70ea13f6e609 "KVM: PPC: Book3S HV: Flush TLB on secondary radix threads"

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
---
 arch/powerpc/kvm/book3s_hv_builtin.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c
index 6035d24f1d1d..a46286f73eec 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -833,6 +833,7 @@ static void flush_guest_tlb(struct kvm *kvm)
 		}
 	}
 	asm volatile("ptesync": : :"memory");
+	asm volatile(PPC_INVALIDATE_ERAT : : :"memory");
 }
 
 void kvmppc_check_need_tlb_flush(struct kvm *kvm, int pcpu,
-- 
2.13.6


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

end of thread, other threads:[~2019-06-30  8:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-20  1:46 [PATCH 1/3] KVM: PPC: Book3S HV: Invalidate ERAT when flushing guest TLB entries Suraj Jitindar Singh
2019-06-20  1:46 ` [PATCH 2/3] KVM: PPC: Book3S HV: Signed extend decrementer value if not using large decr Suraj Jitindar Singh
2019-06-20  7:56   ` Laurent Vivier
2019-06-30  8:37   ` Michael Ellerman
2019-06-20  1:46 ` [PATCH 3/3] KVM: PPC: Book3S HV: Clear pending decr exceptions on nested guest entry Suraj Jitindar Singh
2019-06-20  7:57   ` Laurent Vivier
2019-06-20  8:19     ` Cédric Le Goater
2019-06-30  8:37   ` Michael Ellerman
2019-06-23 10:34 ` [PATCH 1/3] KVM: PPC: Book3S HV: Invalidate ERAT when flushing guest TLB entries Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).