diff mbox

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

Message ID 20130308202510.GA9616@home.buserror.net
State New, archived
Headers show

Commit Message

Scott Wood March 8, 2013, 8:25 p.m. UTC
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: stable@vger.kernel.org # 3.8.x
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/kvm/e500mc.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Alexander Graf March 8, 2013, 8:35 p.m. UTC | #1
On 08.03.2013, at 21:25, Scott Wood wrote:

> 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: stable@vger.kernel.org # 3.8.x
> Signed-off-by: Scott Wood <scottwood@freescale.com>

Thanks, applied to kvm-ppc-3.9.


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Caraman Mihai Claudiu-B02008 April 25, 2013, 9:04 a.m. UTC | #2
> On 08.03.2013, at 21:25, Scott Wood wrote:
> 
> > 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: stable@vger.kernel.org # 3.8.x
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> 
> Thanks, applied to kvm-ppc-3.9.
> 
> 
> Alex

Can you pull it into kvm-ppc-queue?

Thanks,
Mike

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Graf April 26, 2013, 6:43 a.m. UTC | #3
On 25.04.2013, at 11:04, Caraman Mihai Claudiu-B02008 wrote:

>> On 08.03.2013, at 21:25, Scott Wood wrote:
>> 
>>> 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: stable@vger.kernel.org # 3.8.x
>>> Signed-off-by: Scott Wood <scottwood@freescale.com>
>> 
>> 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

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
index 1f89d26..2f4baa0 100644
--- a/arch/powerpc/kvm/e500mc.c
+++ b/arch/powerpc/kvm/e500mc.c
@@ -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);
 }