kvm/powerpc/e500mc: fix tlb invalidation on cpu migration
Subsystems (3)
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.
---
This seems to have been the cause of the userspace segfaults I was seeing (the other TLB patches I posted are still needed as well).
arch/powerpc/kvm/e500mc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/powerpc/kvm/e500mc.c +5 -1
@@ -111,6 +111,7 @@ void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr)void kvmppc_core_vcpu_load (struct kvm_vcpu *vcpu,int cpu) {struct kvmppc_vcpu_e500 *vcpu_e500 =to_e500 (vcpu); +static struct kvm_vcpu *last_vcpu_on_cpu[NR_CPUS ];kvmppc_booke_vcpu_load (vcpu, cpu);
@@ -136,8 +137,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 ) || + last_vcpu_on_cpu[smp_processor_id ()] != vcpu) {kvmppc_e500_tlbil_all (vcpu_e500); + last_vcpu_on_cpu[smp_processor_id ()] = vcpu; + }kvmppc_load_guest_fp (vcpu); }
Signature · 1 line
1.7.9.5
Quoted 18 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.
Signed-off-by Scott Wood <[email protected]>---
This seems to have been the cause of the userspace segfaults I was seeing (the other TLB patches I posted are still needed as well).
arch/powerpc/kvm/e500mc.c| 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)arch/powerpc/kvm/e500mc.c +0
-0
arch/powerpc/kvm/e500mc.c void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr) · line 114
Quoted 4 lines
arch/powerpc/kvm/e500mc.c +1
-0@@ -111,6 +111,7 @@ void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr)void kvmppc_core_vcpu_load (struct kvm_vcpu *vcpu,int cpu) {struct kvmppc_vcpu_e500 *vcpu_e500 =to_e500 (vcpu); +static struct kvm_vcpu *last_vcpu_on_cpu[NR_CPUS ];
Why not use DEFINE_PER_CPU?
Alex
Quoted 19 lines
arch/powerpc/kvm/e500mc.c +4
-1kvmppc_booke_vcpu_load (vcpu, cpu);@@ -136,8 +137,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 ) || + last_vcpu_on_cpu[smp_processor_id ()] != vcpu) {kvmppc_e500_tlbil_all (vcpu_e500); + last_vcpu_on_cpu[smp_processor_id ()] = vcpu; + }kvmppc_load_guest_fp (vcpu); }Signature · 1 line
1.7.9.5
Quoted 13 lines · On 25.04.2013, at 11:04, Caraman Mihai Claudiu-B02008 wrote:
Quoted 13 lines · Scott Wood
Quoted 11 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.
Cc [email protected] # 3.8.xSigned-off-by Scott Wood <[email protected]>
Quoted 6 lines
Quoted 4 lines
Thanks, applied to kvm-ppc-3.9.
Alex
Can you pull it into kvm-ppc-queue?
It's not in kvm/next, so it'd potentially screw things up again when I create a new pull request.
Please just do a manual git merge of kvm/master or linus/master into kvm-ppc-queue.
Alex