Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp540095imu; Tue, 11 Dec 2018 03:35:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/U3gxFGhQc7x//u91/HOt5lNsS3orKW8u87+Z9OsaTCS2hrT4GW7iZF4HntmVocxGDqnSuS X-Received: by 2002:a17:902:1005:: with SMTP id b5mr15770320pla.310.1544528118134; Tue, 11 Dec 2018 03:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544528118; cv=none; d=google.com; s=arc-20160816; b=SIZmIlRTiuR/jIGGMerDjB7SY10+55NMWtWckMbNz8TP9gIrKwCAq37HWOtJ8eqyLd hX6W4ZoMIM/vV9BzFUtzXd46v6b3qDTA+1EDfJAJE+TtJJCFTTEDKtkgHombcHdWd8FA RUTFMca3it6xruyQDvGa5Ol/gWdCF6rCDQdjdpDy1CslXT3ljJ2UZJjsiCVLC5jFZ2/d EiBDjS04WiCmpLikhCVUg7D4XU3XHBotU990mNkT8gu2lFlm++bS76MRRBHYj89IojoU aZpQStH8L40qcfcNE9c3oBlK69Zc8hPk1bMKFUKnYZy8yblxWA4/YPmKjuZAajDtUzQ2 51jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=DB1X+TsROncrdkZZHJDSSjBAicdY6gC2d1Z7kE6RpvM=; b=SyToQ8IYMvcBEcbfoHRSFqTD+4sIdLYXvZhoLL+OFZ4ymK2Fl5HUPH/KsUeRi2sjMa okknhW7GS1pWlwiJduS+5KX6GeiTbecPxSXUIjDFVkrDKIwF6QzoRXY80YkPzkPJowiY 7y6Hl+6aDlWBIWEFvFtMoWdsEyf4C2OXBtenvgBeOadY9m7NQ3ORA4LFfcpv/F7VQiSb Ykp9UPxxciyBcXQve5K5g4TxxTK5Q2/w91e2plvJDgyfR4zVVfLSu9r3ZItgK5gDo2ni 1eWls+k2QkdFGW/AY9ktGS9ldSXEs70PgkBb2+BV8r0tvE2DCj0EN6GdNJ7+oFAaFtAo hlZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si11672834pgg.279.2018.12.11.03.34.47; Tue, 11 Dec 2018 03:35:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726437AbeLKLYH (ORCPT + 99 others); Tue, 11 Dec 2018 06:24:07 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:24418 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbeLKLX5 (ORCPT ); Tue, 11 Dec 2018 06:23:57 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43Dcyf2mJ3zB09bD; Tue, 11 Dec 2018 12:23:54 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id HUbKGje754L0; Tue, 11 Dec 2018 12:23:54 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 43Dcyf2900zB09b7; Tue, 11 Dec 2018 12:23:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4BF8B8B7EB; Tue, 11 Dec 2018 12:23:55 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id jTvfNQYz33mw; Tue, 11 Dec 2018 12:23:55 +0100 (CET) Received: from PO15451.localdomain (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 0095D8B7E7; Tue, 11 Dec 2018 12:23:54 +0100 (CET) Received: by localhost.localdomain (Postfix, from userid 0) id 987FC71702; Tue, 11 Dec 2018 11:23:54 +0000 (UTC) Message-Id: <9550a94258520c4706aaa05ce2816ae943c6fe3d.1544519035.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [RFC PATCH v1 2/3] powerpc/8xx: Use alternative scratch registers in DTLB miss handler To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 11 Dec 2018 11:23:54 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation of handling CONFIG_VMAP_STACK, we need DTLB miss handler to use different scratch registers than other exception handlers in order to not jeopardise exception entry on stack DTLB misses. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_8xx.S | 27 ++++++++++++++------------- arch/powerpc/perf/8xx-pmu.c | 12 ++++++++---- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S index 5f5f89e87e3a..48996a424075 100644 --- a/arch/powerpc/kernel/head_8xx.S +++ b/arch/powerpc/kernel/head_8xx.S @@ -421,8 +421,8 @@ ITLBMissLinear: . = 0x1200 DataStoreTLBMiss: - mtspr SPRN_SPRG_SCRATCH0, r10 - mtspr SPRN_SPRG_SCRATCH1, r11 + mtspr SPRN_DAR, r10 + mtspr SPRN_M_TW, r11 mfcr r11 /* If we are faulting a kernel address, we have to use the @@ -487,10 +487,10 @@ DataStoreTLBMiss: mtspr SPRN_MD_RPN, r10 /* Update TLB entry */ /* Restore registers */ - mtspr SPRN_DAR, r11 /* Tag DAR */ -0: mfspr r10, SPRN_SPRG_SCRATCH0 - mfspr r11, SPRN_SPRG_SCRATCH1 +0: mfspr r10, SPRN_DAR + mtspr SPRN_DAR, r11 /* Tag DAR */ + mfspr r11, SPRN_M_TW rfi patch_site 0b, patch__dtlbmiss_exit_1 @@ -499,8 +499,9 @@ DataStoreTLBMiss: 0: lwz r10, (dtlb_miss_counter - PAGE_OFFSET)@l(0) addi r10, r10, 1 stw r10, (dtlb_miss_counter - PAGE_OFFSET)@l(0) - mfspr r10, SPRN_SPRG_SCRATCH0 - mfspr r11, SPRN_SPRG_SCRATCH1 + mfspr r10, SPRN_DAR + mtspr SPRN_DAR, r11 /* Tag DAR */ + mfspr r11, SPRN_M_TW rfi #endif @@ -516,10 +517,10 @@ DTLBMissIMMR: mtspr SPRN_MD_RPN, r10 /* Update TLB entry */ li r11, RPN_PATTERN - mtspr SPRN_DAR, r11 /* Tag DAR */ -0: mfspr r10, SPRN_SPRG_SCRATCH0 - mfspr r11, SPRN_SPRG_SCRATCH1 +0: mfspr r10, SPRN_DAR + mtspr SPRN_DAR, r11 /* Tag DAR */ + mfspr r11, SPRN_M_TW rfi patch_site 0b, patch__dtlbmiss_exit_2 @@ -534,10 +535,10 @@ DTLBMissLinear: mtspr SPRN_MD_RPN, r10 /* Update TLB entry */ li r11, RPN_PATTERN - mtspr SPRN_DAR, r11 /* Tag DAR */ -0: mfspr r10, SPRN_SPRG_SCRATCH0 - mfspr r11, SPRN_SPRG_SCRATCH1 +0: mfspr r10, SPRN_DAR + mtspr SPRN_DAR, r11 /* Tag DAR */ + mfspr r11, SPRN_M_TW rfi patch_site 0b, patch__dtlbmiss_exit_3 diff --git a/arch/powerpc/perf/8xx-pmu.c b/arch/powerpc/perf/8xx-pmu.c index e38f74e9e7a4..4556c8837575 100644 --- a/arch/powerpc/perf/8xx-pmu.c +++ b/arch/powerpc/perf/8xx-pmu.c @@ -161,10 +161,6 @@ static void mpc8xx_pmu_read(struct perf_event *event) static void mpc8xx_pmu_del(struct perf_event *event, int flags) { - /* mfspr r10, SPRN_SPRG_SCRATCH0 */ - unsigned int insn = PPC_INST_MFSPR | __PPC_RS(R10) | - __PPC_SPR(SPRN_SPRG_SCRATCH0); - mpc8xx_pmu_read(event); /* If it was the last user, stop counting to avoid useles overhead */ @@ -177,6 +173,10 @@ static void mpc8xx_pmu_del(struct perf_event *event, int flags) break; case PERF_8xx_ID_ITLB_LOAD_MISS: if (atomic_dec_return(&itlb_miss_ref) == 0) { + /* mfspr r10, SPRN_SPRG_SCRATCH0 */ + unsigned int insn = PPC_INST_MFSPR | __PPC_RS(R10) | + __PPC_SPR(SPRN_SPRG_SCRATCH0); + patch_instruction_site(&patch__itlbmiss_exit_1, insn); #ifndef CONFIG_PIN_TLB_TEXT patch_instruction_site(&patch__itlbmiss_exit_2, insn); @@ -185,6 +185,10 @@ static void mpc8xx_pmu_del(struct perf_event *event, int flags) break; case PERF_8xx_ID_DTLB_LOAD_MISS: if (atomic_dec_return(&dtlb_miss_ref) == 0) { + /* mfspr r10, SPRN_DAR */ + unsigned int insn = PPC_INST_MFSPR | __PPC_RS(R10) | + __PPC_SPR(SPRN_DAR); + patch_instruction_site(&patch__dtlbmiss_exit_1, insn); patch_instruction_site(&patch__dtlbmiss_exit_2, insn); patch_instruction_site(&patch__dtlbmiss_exit_3, insn); -- 2.13.3