public inbox for kvm-ppc@vger.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: agraf@suse.de
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration
Date: Tue, 19 Feb 2013 04:13:09 +0000	[thread overview]
Message-ID: <20130219041309.GA17075@home.buserror.net> (raw)

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 <scottwood@freescale.com>
---
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(-)

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


             reply	other threads:[~2013-02-19  4:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-19  4:13 Scott Wood [this message]
2013-03-08 12:11 ` [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration Alexander Graf
2013-03-08 20:25 ` Scott Wood
2013-03-08 20:35   ` Alexander Graf
2013-04-25  9:04     ` Caraman Mihai Claudiu-B02008
2013-04-26  6:43 ` Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130219041309.GA17075@home.buserror.net \
    --to=scottwood@freescale.com \
    --cc=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox