* [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration
@ 2013-02-19 4:13 Scott Wood
2013-03-08 12:11 ` Alexander Graf
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Scott Wood @ 2013-02-19 4:13 UTC (permalink / raw)
To: agraf; +Cc: kvm, kvm-ppc
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration
2013-02-19 4:13 [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration Scott Wood
@ 2013-03-08 12:11 ` Alexander Graf
2013-03-08 20:25 ` Scott Wood
2013-04-26 6:43 ` Alexander Graf
2 siblings, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2013-03-08 12:11 UTC (permalink / raw)
To: Scott Wood; +Cc: kvm, kvm-ppc
On 19.02.2013, at 05:13, 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.
>
> 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];
Why not use DEFINE_PER_CPU?
Alex
>
> 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration
2013-02-19 4:13 [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration Scott Wood
2013-03-08 12:11 ` Alexander Graf
@ 2013-03-08 20:25 ` Scott Wood
2013-03-08 20:35 ` Alexander Graf
2013-04-26 6:43 ` Alexander Graf
2 siblings, 1 reply; 6+ messages in thread
From: Scott Wood @ 2013-03-08 20:25 UTC (permalink / raw)
To: agraf; +Cc: kvm-ppc, kvm, stable
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(-)
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);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration
2013-03-08 20:25 ` Scott Wood
@ 2013-03-08 20:35 ` Alexander Graf
2013-04-25 9:04 ` Caraman Mihai Claudiu-B02008
0 siblings, 1 reply; 6+ messages in thread
From: Alexander Graf @ 2013-03-08 20:35 UTC (permalink / raw)
To: Scott Wood; +Cc: kvm-ppc, kvm, stable
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration
2013-03-08 20:35 ` Alexander Graf
@ 2013-04-25 9:04 ` Caraman Mihai Claudiu-B02008
0 siblings, 0 replies; 6+ messages in thread
From: Caraman Mihai Claudiu-B02008 @ 2013-04-25 9:04 UTC (permalink / raw)
To: Alexander Graf, Wood Scott-B07421
Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org,
stable@vger.kernel.org
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration
2013-02-19 4:13 [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration Scott Wood
2013-03-08 12:11 ` Alexander Graf
2013-03-08 20:25 ` Scott Wood
@ 2013-04-26 6:43 ` Alexander Graf
2 siblings, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2013-04-26 6:43 UTC (permalink / raw)
To: kvm-ppc
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-04-26 6:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-19 4:13 [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration Scott Wood
2013-03-08 12:11 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox