Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp1085969pxt; Sat, 7 Aug 2021 00:03:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyY0Bq6pSw90iB9/Tb7uvtKIq+YuvvwasLmGZmU8FBTMF2r5/Ynq81NkkRAUFMxbEKoFwoA X-Received: by 2002:a92:cac5:: with SMTP id m5mr338381ilq.66.1628319803782; Sat, 07 Aug 2021 00:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628319803; cv=none; d=google.com; s=arc-20160816; b=YjnpfuwrhTxe3ZnJY3RvjTOj+WyPabMsQiWvQ178T6SHIh+zfjUjmIIojlEImR1MeS 9rkYEIfOBzRC0XuucgMsdJGtr1lJsHrKTp+gJQBVkTj8aqklq43lKX89L7E8RcZNIPmK xaDjk7TvPrZn4/PED0gDfACcXHGWAmalwdjjfTSmqCtdkGWMtGJlYhSOYKZM1900w5sE HqS5R9JGQVqi77qhxyu3QeqeEF4IL4UmFmVwmjscBGyAtTxkcuKKGldyXXFQ8DVVBYX6 W1DAWr4txdvnFc0Sn/BrP8riI/CVuYWNfFrSy4tJseZLPfutpXKTWVadrwMTmYeOtM76 qnrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=yi+IPmXTUw34BcgPadWqlEJ9zl2LnS1NL2KiOQg9mXs=; b=fcg7SeHAHCdNgYTDg72ZbZ+fRXMlHX4E0XLYGsl/2ZHgRyFHzYW0PJIFm/YpukzwOL FfbklDA2Rafp7O2l2z6op2M4xcX/OZVzOkbUN14/N8oetFKBBfr5SGR0OQMJwN1xGEru nclvdjQi2OdlXHqmpch7fY61F21MsDG6IPCMIQcbn3uqPkmH85aT94sW8z/p4sZrn+I9 LPY50dcBpUwhrKdREdOCKhcOE7Elh2H0icABmDKiJ0YhXnuLS2V0yGEWFCsLOJuUX5G5 eA08blDhHRcx8oCvUPPF87sIcJ75DDUUSFliQ8fkTDC4uqMcgXVo9Y9OaBZbjX3tkDPK R/kA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i16si11383915jan.31.2021.08.07.00.02.58; Sat, 07 Aug 2021 00:03:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231326AbhHGG6D (ORCPT + 99 others); Sat, 7 Aug 2021 02:58:03 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:42455 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230297AbhHGG6C (ORCPT ); Sat, 7 Aug 2021 02:58:02 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4GhY7r0XKFz9sTr; Sat, 7 Aug 2021 08:57:44 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D2RQ1Ao3thCU; Sat, 7 Aug 2021 08:57:43 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4GhY7q6W8kz9sTq; Sat, 7 Aug 2021 08:57:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id BBB248B76D; Sat, 7 Aug 2021 08:57:43 +0200 (CEST) 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 fQtPJIfsPKYH; Sat, 7 Aug 2021 08:57:43 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2AF9B8B766; Sat, 7 Aug 2021 08:57:42 +0200 (CEST) Subject: Re: [PATCH v2 1/4] powerpc: Optimize register usage for esr register To: sxwjean@me.com, linuxppc-dev@lists.ozlabs.org Cc: oleg@redhat.com, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, npiggin@gmail.com, ravi.bangoria@linux.ibm.com, aneesh.kumar@linux.ibm.com, efremov@linux.com, linux-kernel@vger.kernel.org, Xiongwei Song References: <20210807010239.416055-1-sxwjean@me.com> <20210807010239.416055-2-sxwjean@me.com> From: Christophe Leroy Message-ID: <127de0c7-5e30-6797-1e72-6414d4a60119@csgroup.eu> Date: Sat, 7 Aug 2021 08:56:52 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210807010239.416055-2-sxwjean@me.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 07/08/2021 à 03:02, sxwjean@me.com a écrit : > From: Xiongwei Song > > Create an anonymous union for dsisr and esr regsiters, we can reference > esr to get the exception detail when CONFIG_4xx=y or CONFIG_BOOKE=y. > Otherwise, reference dsisr. This makes code more clear. > > Signed-off-by: Xiongwei Song > --- > arch/powerpc/include/asm/ptrace.h | 5 ++++- > arch/powerpc/kernel/process.c | 2 +- > arch/powerpc/kernel/ptrace/ptrace.c | 2 ++ > arch/powerpc/kernel/traps.c | 2 +- > arch/powerpc/platforms/44x/machine_check.c | 4 ++-- > arch/powerpc/platforms/4xx/machine_check.c | 2 +- > 6 files changed, 11 insertions(+), 6 deletions(-) > > diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h > index 3e5d470a6155..c252d04b1206 100644 > --- a/arch/powerpc/include/asm/ptrace.h > +++ b/arch/powerpc/include/asm/ptrace.h > @@ -44,7 +44,10 @@ struct pt_regs > #endif > unsigned long trap; > unsigned long dar; > - unsigned long dsisr; > + union { > + unsigned long dsisr; > + unsigned long esr; > + }; > unsigned long result; > }; > }; > diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c > index 185beb290580..f74af8f9133c 100644 > --- a/arch/powerpc/kernel/process.c > +++ b/arch/powerpc/kernel/process.c > @@ -1499,7 +1499,7 @@ static void __show_regs(struct pt_regs *regs) > trap == INTERRUPT_DATA_STORAGE || > trap == INTERRUPT_ALIGNMENT) { > if (IS_ENABLED(CONFIG_4xx) || IS_ENABLED(CONFIG_BOOKE)) > - pr_cont("DEAR: "REG" ESR: "REG" ", regs->dar, regs->dsisr); > + pr_cont("DEAR: "REG" ESR: "REG" ", regs->dar, regs->esr); > else > pr_cont("DAR: "REG" DSISR: %08lx ", regs->dar, regs->dsisr); > } > diff --git a/arch/powerpc/kernel/ptrace/ptrace.c b/arch/powerpc/kernel/ptrace/ptrace.c > index 0a0a33eb0d28..a222fd4d6334 100644 > --- a/arch/powerpc/kernel/ptrace/ptrace.c > +++ b/arch/powerpc/kernel/ptrace/ptrace.c > @@ -375,6 +375,8 @@ void __init pt_regs_check(void) > offsetof(struct user_pt_regs, dar)); > BUILD_BUG_ON(offsetof(struct pt_regs, dsisr) != > offsetof(struct user_pt_regs, dsisr)); > + BUILD_BUG_ON(offsetof(struct pt_regs, esr) != > + offsetof(struct user_pt_regs, dsisr)); esr and dsisr are the same, so checking the same thing a second time is pointless. > BUILD_BUG_ON(offsetof(struct pt_regs, result) != > offsetof(struct user_pt_regs, result)); > > diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c > index dfbce527c98e..2164f5705a0b 100644 > --- a/arch/powerpc/kernel/traps.c > +++ b/arch/powerpc/kernel/traps.c > @@ -562,7 +562,7 @@ static inline int check_io_access(struct pt_regs *regs) > #ifdef CONFIG_PPC_ADV_DEBUG_REGS > /* On 4xx, the reason for the machine check or program exception > is in the ESR. */ > -#define get_reason(regs) ((regs)->dsisr) > +#define get_reason(regs) ((regs)->esr) > #define REASON_FP ESR_FP > #define REASON_ILLEGAL (ESR_PIL | ESR_PUO) > #define REASON_PRIVILEGED ESR_PPR > diff --git a/arch/powerpc/platforms/44x/machine_check.c b/arch/powerpc/platforms/44x/machine_check.c > index a5c898bb9bab..5d19daacd78a 100644 > --- a/arch/powerpc/platforms/44x/machine_check.c > +++ b/arch/powerpc/platforms/44x/machine_check.c > @@ -11,7 +11,7 @@ > > int machine_check_440A(struct pt_regs *regs) > { > - unsigned long reason = regs->dsisr; > + unsigned long reason = regs->esr; > > printk("Machine check in kernel mode.\n"); > if (reason & ESR_IMCP){ > @@ -48,7 +48,7 @@ int machine_check_440A(struct pt_regs *regs) > #ifdef CONFIG_PPC_47x > int machine_check_47x(struct pt_regs *regs) > { > - unsigned long reason = regs->dsisr; > + unsigned long reason = regs->esr; > u32 mcsr; > > printk(KERN_ERR "Machine check in kernel mode.\n"); > diff --git a/arch/powerpc/platforms/4xx/machine_check.c b/arch/powerpc/platforms/4xx/machine_check.c > index a71c29892a91..a905da1d6f41 100644 > --- a/arch/powerpc/platforms/4xx/machine_check.c > +++ b/arch/powerpc/platforms/4xx/machine_check.c > @@ -10,7 +10,7 @@ > > int machine_check_4xx(struct pt_regs *regs) > { > - unsigned long reason = regs->dsisr; > + unsigned long reason = regs->esr; > > if (reason & ESR_IMCP) { > printk("Instruction"); >