Commit 4f8e78c0 authored by Xiongwei Song's avatar Xiongwei Song Committed by Michael Ellerman

powerpc: Add esr as a synonym for pt_regs.dsisr

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: default avatarXiongwei Song <sxwjean@gmail.com>
[mpe: Reword commit title]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210807010239.416055-2-sxwjean@me.com
parent e42edf9b
...@@ -44,7 +44,10 @@ struct pt_regs ...@@ -44,7 +44,10 @@ struct pt_regs
#endif #endif
unsigned long trap; unsigned long trap;
unsigned long dar; unsigned long dar;
unsigned long dsisr; union {
unsigned long dsisr;
unsigned long esr;
};
unsigned long result; unsigned long result;
}; };
}; };
......
...@@ -1499,7 +1499,7 @@ static void __show_regs(struct pt_regs *regs) ...@@ -1499,7 +1499,7 @@ static void __show_regs(struct pt_regs *regs)
trap == INTERRUPT_DATA_STORAGE || trap == INTERRUPT_DATA_STORAGE ||
trap == INTERRUPT_ALIGNMENT) { trap == INTERRUPT_ALIGNMENT) {
if (IS_ENABLED(CONFIG_4xx) || IS_ENABLED(CONFIG_BOOKE)) 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 else
pr_cont("DAR: "REG" DSISR: %08lx ", regs->dar, regs->dsisr); pr_cont("DAR: "REG" DSISR: %08lx ", regs->dar, regs->dsisr);
} }
......
...@@ -375,6 +375,8 @@ void __init pt_regs_check(void) ...@@ -375,6 +375,8 @@ void __init pt_regs_check(void)
offsetof(struct user_pt_regs, dar)); offsetof(struct user_pt_regs, dar));
BUILD_BUG_ON(offsetof(struct pt_regs, dsisr) != BUILD_BUG_ON(offsetof(struct pt_regs, dsisr) !=
offsetof(struct user_pt_regs, dsisr)); offsetof(struct user_pt_regs, dsisr));
BUILD_BUG_ON(offsetof(struct pt_regs, esr) !=
offsetof(struct user_pt_regs, dsisr));
BUILD_BUG_ON(offsetof(struct pt_regs, result) != BUILD_BUG_ON(offsetof(struct pt_regs, result) !=
offsetof(struct user_pt_regs, result)); offsetof(struct user_pt_regs, result));
......
...@@ -562,7 +562,7 @@ static inline int check_io_access(struct pt_regs *regs) ...@@ -562,7 +562,7 @@ static inline int check_io_access(struct pt_regs *regs)
#ifdef CONFIG_PPC_ADV_DEBUG_REGS #ifdef CONFIG_PPC_ADV_DEBUG_REGS
/* On 4xx, the reason for the machine check or program exception /* On 4xx, the reason for the machine check or program exception
is in the ESR. */ is in the ESR. */
#define get_reason(regs) ((regs)->dsisr) #define get_reason(regs) ((regs)->esr)
#define REASON_FP ESR_FP #define REASON_FP ESR_FP
#define REASON_ILLEGAL (ESR_PIL | ESR_PUO) #define REASON_ILLEGAL (ESR_PIL | ESR_PUO)
#define REASON_PRIVILEGED ESR_PPR #define REASON_PRIVILEGED ESR_PPR
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
int machine_check_440A(struct pt_regs *regs) 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"); printk("Machine check in kernel mode.\n");
if (reason & ESR_IMCP){ if (reason & ESR_IMCP){
...@@ -48,7 +48,7 @@ int machine_check_440A(struct pt_regs *regs) ...@@ -48,7 +48,7 @@ int machine_check_440A(struct pt_regs *regs)
#ifdef CONFIG_PPC_47x #ifdef CONFIG_PPC_47x
int machine_check_47x(struct pt_regs *regs) int machine_check_47x(struct pt_regs *regs)
{ {
unsigned long reason = regs->dsisr; unsigned long reason = regs->esr;
u32 mcsr; u32 mcsr;
printk(KERN_ERR "Machine check in kernel mode.\n"); printk(KERN_ERR "Machine check in kernel mode.\n");
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
int machine_check_4xx(struct pt_regs *regs) int machine_check_4xx(struct pt_regs *regs)
{ {
unsigned long reason = regs->dsisr; unsigned long reason = regs->esr;
if (reason & ESR_IMCP) { if (reason & ESR_IMCP) {
printk("Instruction"); printk("Instruction");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment