powerpc: Add dear as a synonym for pt_regs.dar register
authorXiongwei Song <sxwjean@gmail.com>
Sat, 7 Aug 2021 01:02:38 +0000 (09:02 +0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 26 Aug 2021 11:21:07 +0000 (21:21 +1000)
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>
[mpe: Reword commit title]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210807010239.416055-4-sxwjean@me.com
arch/powerpc/include/asm/ptrace.h
arch/powerpc/kernel/process.c
arch/powerpc/kernel/ptrace/ptrace.c

index ab58939653db67897a2804cfcd6172d78a323df1..5114ddba6f164ca426d7ca457309bbce796afe08 100644 (file)
@@ -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;
index f74af8f9133ca4168e3c2b681b68b6b5599cd1b7..50436b52c2133ee900250e49c0ad622d11948ab3 100644 (file)
@@ -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);
        }
index a222fd4d6334bafdcd196a65329e42acfeb2e908..7c7093c17c45e2014fc2094746cd76d248097a30 100644 (file)
@@ -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) !=