All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] kvm/e500: Add tlb0 entry invalidate
@ 2009-04-27  6:58 Liu Yu
  0 siblings, 0 replies; only message in thread
From: Liu Yu @ 2009-04-27  6:58 UTC (permalink / raw)
  To: kvm-ppc

It's always needed to invalidate the tlb0 entry
which is overwritten by new one.

It was OK not to do this before is because that
we flushed TLB every time when we entered guest's userspace.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
---
 arch/powerpc/kvm/e500_tlb.c |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
index 7b614a9..2c0d58f 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -295,6 +295,30 @@ static void kvmppc_e500_shadow_release(struct kvmppc_vcpu_e500 *vcpu_e500,
 	}
 }
 
+static void kvmppc_e500_tlb0_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500,
+		int esel)
+{
+	struct tlbe *gtlbe = &vcpu_e500->guest_tlb[0][esel];
+	u32 eaddr, pid, val;
+
+	eaddr = get_tlb_eaddr(gtlbe);
+	pid = kvmppc_e500_get_sid(vcpu_e500, get_tlb_ts(gtlbe),
+				get_tlb_tid(gtlbe));
+	val = (pid << 16) | MAS6_SAS;
+
+	local_irq_disable();
+	mtspr(SPRN_MAS6, val);
+	__asm__ __volatile__ (
+			"tlbsx 0, %[eaddr]\n"
+			: : [eaddr] "a"(eaddr));
+	val = mfspr(SPRN_MAS1);
+	if (val & MAS1_VALID) {
+		mtspr(SPRN_MAS1, val & ~MAS1_VALID);
+		__asm__ __volatile__ ("tlbwe\n" : : );
+	}
+	local_irq_enable();
+}
+
 static void kvmppc_e500_tlb1_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500,
 		int esel)
 {
@@ -583,8 +607,11 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
 
 	gtlbe = &vcpu_e500->guest_tlb[tlbsel][esel];
 
-	if (get_tlb_v(gtlbe) && tlbsel = 1)
-		kvmppc_e500_tlb1_invalidate(vcpu_e500, esel);
+	if (get_tlb_v(gtlbe))
+		if (tlbsel = 0)
+			kvmppc_e500_tlb0_invalidate(vcpu_e500, esel);
+		else
+			kvmppc_e500_tlb1_invalidate(vcpu_e500, esel);
 
 	gtlbe->mas1 = vcpu_e500->mas1;
 	gtlbe->mas2 = vcpu_e500->mas2;
-- 
1.5.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-04-27  6:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-27  6:58 [PATCH 3/3] kvm/e500: Add tlb0 entry invalidate Liu Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.