From patchwork Tue Feb 19 04:13:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 221613 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 35E582C0089 for ; Tue, 19 Feb 2013 15:13:31 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758193Ab3BSENR (ORCPT ); Mon, 18 Feb 2013 23:13:17 -0500 Received: from ch1ehsobe001.messaging.microsoft.com ([216.32.181.181]:6618 "EHLO ch1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758191Ab3BSENQ (ORCPT ); Mon, 18 Feb 2013 23:13:16 -0500 Received: from mail231-ch1-R.bigfish.com (10.43.68.230) by CH1EHSOBE011.bigfish.com (10.43.70.61) with Microsoft SMTP Server id 14.1.225.23; Tue, 19 Feb 2013 04:13:15 +0000 Received: from mail231-ch1 (localhost [127.0.0.1]) by mail231-ch1-R.bigfish.com (Postfix) with ESMTP id 374DDE4007E; Tue, 19 Feb 2013 04:13:15 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: -3 X-BigFish: VS-3(zz15bfKzz1f42h1ee6h1de0h1202h1e76h1d1ah1d2ahzz8275bhz2dh2a8h668h839h944hd25hf0ah1220h1288h12a5h12a9h12bdh137ah13b6h1441h14ddh1504h1537h153bh162dh1631h1758h18e1h1946h19b5h1155h) Received: from mail231-ch1 (localhost.localdomain [127.0.0.1]) by mail231-ch1 (MessageSwitch) id 1361247192966288_29678; Tue, 19 Feb 2013 04:13:12 +0000 (UTC) Received: from CH1EHSMHS015.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.248]) by mail231-ch1.bigfish.com (Postfix) with ESMTP id E9900B80072; Tue, 19 Feb 2013 04:13:12 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS015.bigfish.com (10.43.70.15) with Microsoft SMTP Server (TLS) id 14.1.225.23; Tue, 19 Feb 2013 04:13:12 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.2.328.11; Tue, 19 Feb 2013 04:13:11 +0000 Received: from home.buserror.net ([10.214.84.249]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id r1J4DABD025911; Mon, 18 Feb 2013 21:13:10 -0700 Date: Mon, 18 Feb 2013 22:13:09 -0600 From: Scott Wood To: CC: , Subject: [PATCH] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration Message-ID: <20130219041309.GA17075@home.buserror.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-OriginatorOrg: freescale.com Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org 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 --- 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); }