Skip to contentSkip to conversation

kvm/powerpc/e500mc: fix tlb invalidation on cpu migration

PATCH Applied Scott Wood 3 participants 3 messages Mar 8, 2013 – Apr 25, 2013

Subsystems (4)
lore
Share & tools
lore

Scott Wood

author
#0 lore raw

PATCH 1/1 kvm/powerpc/e500mc: fix tlb invalidation on cpu migration

The existing check handles the case where we've migrated to a different core than we last ran on, but it doesn't handle the case where we're still on the same cpu we last ran on, but some other vcpu has run on this cpu in the meantime.

Without this, guest segfaults (and other misbehavior) have been seen in smp guests.

---
 arch/powerpc/kvm/e500mc.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/powerpc/kvm/e500mc.c +6 -1
index 1f89d26..2f4baa0 100644
@@ -108,6 +108,8 @@ void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr)
 {
 }
 
+static DEFINE_PER_CPU(struct kvm_vcpu *, last_vcpu_on_cpu);
+
 void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 {
 	struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
@@ -136,8 +138,11 @@ void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 	mtspr(SPRN_GDEAR, vcpu->arch.shared->dar);
 	mtspr(SPRN_GESR, vcpu->arch.shared->esr);
 
-	if (vcpu->arch.oldpir != mfspr(SPRN_PIR))
+	if (vcpu->arch.oldpir != mfspr(SPRN_PIR) ||
+	    __get_cpu_var(last_vcpu_on_cpu) != vcpu) {
 		kvmppc_e500_tlbil_all(vcpu_e500);
+		__get_cpu_var(last_vcpu_on_cpu) = vcpu;
+	}
 
 	kvmppc_load_guest_fp(vcpu);
 }
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 10 lines · Scott Wood

The existing check handles the case where we've migrated to a different core than we last ran on, but it doesn't handle the case where we're still on the same cpu we last ran on, but some other vcpu has run on this cpu in the meantime.

Without this, guest segfaults (and other misbehavior) have been seen in smp guests.

Thanks, applied to kvm-ppc-3.9.

Alex

#2 lore raw
Quoted 10 lines · Scott Wood
Quoted 9 lines

The existing check handles the case where we've migrated to a different core than we last ran on, but it doesn't handle the case where we're still on the same cpu we last ran on, but some other vcpu has run on this cpu in the meantime.

Without this, guest segfaults (and other misbehavior) have been seen in smp guests.

Quoted 7 lines
Quoted 2 lines

Thanks, applied to kvm-ppc-3.9.

Alex

Can you pull it into kvm-ppc-queue?

Thanks,
Mike