LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sxwjean@me.com
To: linuxppc-dev@lists.ozlabs.org
Cc: ravi.bangoria@linux.ibm.com, Xiongwei Song <sxwjean@gmail.com>,
	aneesh.kumar@linux.ibm.com, oleg@redhat.com, npiggin@gmail.com,
	linux-kernel@vger.kernel.org, efremov@linux.com,
	paulus@samba.org
Subject: [PATCH v2 3/4] powerpc: Optimize register usage for dear register
Date: Sat,  7 Aug 2021 09:02:38 +0800	[thread overview]
Message-ID: <20210807010239.416055-4-sxwjean@me.com> (raw)
In-Reply-To: <20210807010239.416055-1-sxwjean@me.com>

From: Xiongwei Song <sxwjean@gmail.com>

Create an anonymous union for dar and dear regsiters, we can reference
dear to get the effective address when CONFIG_4xx=y or CONFIG_BOOKE=y.
Otherwise, reference dar. This makes code more clear.

Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
---
 arch/powerpc/include/asm/ptrace.h   | 5 ++++-
 arch/powerpc/kernel/process.c       | 2 +-
 arch/powerpc/kernel/ptrace/ptrace.c | 2 ++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index c252d04b1206..fa725e3238c2 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -43,7 +43,10 @@ struct pt_regs
 			unsigned long mq;
 #endif
 			unsigned long trap;
-			unsigned long dar;
+			union {
+				unsigned long dar;
+				unsigned long dear;
+			};
 			union {
 				unsigned long dsisr;
 				unsigned long esr;
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index f74af8f9133c..50436b52c213 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->esr);
+			pr_cont("DEAR: "REG" ESR: "REG" ", regs->dear, 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 a222fd4d6334..7c7093c17c45 100644
--- a/arch/powerpc/kernel/ptrace/ptrace.c
+++ b/arch/powerpc/kernel/ptrace/ptrace.c
@@ -373,6 +373,8 @@ void __init pt_regs_check(void)
 		     offsetof(struct user_pt_regs, trap));
 	BUILD_BUG_ON(offsetof(struct pt_regs, dar) !=
 		     offsetof(struct user_pt_regs, dar));
+	BUILD_BUG_ON(offsetof(struct pt_regs, dear) !=
+		     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) !=
-- 
2.30.2


  parent reply	other threads:[~2021-08-07  1:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-07  1:02 [PATCH v2 0/4] Some improvements on regs usage sxwjean
2021-08-07  1:02 ` [PATCH v2 1/4] powerpc: Optimize register usage for esr register sxwjean
2021-08-07  6:56   ` Christophe Leroy
2021-08-10  8:33     ` Xiongwei Song
2021-08-07  1:02 ` [PATCH v2 2/4] powerpc/64e: Get esr offset with _ESR macro sxwjean
2021-08-07  1:02 ` sxwjean [this message]
2021-08-07  6:57   ` [PATCH v2 3/4] powerpc: Optimize register usage for dear register Christophe Leroy
2021-08-10  8:33     ` Xiongwei Song
2021-08-07  1:02 ` [PATCH v2 4/4] powerpc/64e: Get dear offset with _DEAR macro sxwjean
2021-08-27 13:16 ` [PATCH v2 0/4] Some improvements on regs usage Michael Ellerman

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=20210807010239.416055-4-sxwjean@me.com \
    --to=sxwjean@me.com \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=efremov@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=npiggin@gmail.com \
    --cc=oleg@redhat.com \
    --cc=paulus@samba.org \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=sxwjean@gmail.com \
    /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