* [PATCH] powerpc/process: Enhance readability for trap types.
@ 2021-03-28 14:35 Xiongwei Song
2021-03-28 15:21 ` Christophe Leroy
0 siblings, 1 reply; 3+ messages in thread
From: Xiongwei Song @ 2021-03-28 14:35 UTC (permalink / raw)
To: mpe, benh, paulus, npiggin, christophe.leroy, ravi.bangoria,
mikey, aneesh.kumar, haren
Cc: Xiongwei Song, linuxppc-dev, linux-kernel
From: Xiongwei Song <sxwjean@gmail.com>
Define macros to enhance the code readability on ppc trap types.
Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
---
arch/powerpc/kernel/process.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 3231c2df9e26..3bbd3cf353a7 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1451,6 +1451,10 @@ static void print_msr_bits(unsigned long val)
#define LAST_VOLATILE 12
#endif
+#define TRAP_MC 0x200 /* Machine Check */
+#define TRAP_DSI 0x300 /* DSI exception */
+#define TRAP_AM 0x600 /* Alignment exception */
+
static void __show_regs(struct pt_regs *regs)
{
int i, trap;
@@ -1465,7 +1469,7 @@ static void __show_regs(struct pt_regs *regs)
trap = TRAP(regs);
if (!trap_is_syscall(regs) && cpu_has_feature(CPU_FTR_CFAR))
pr_cont("CFAR: "REG" ", regs->orig_gpr3);
- if (trap == 0x200 || trap == 0x300 || trap == 0x600) {
+ if (trap == TRAP_MC || trap == TRAP_DSI || trap == TRAP_AM) {
if (IS_ENABLED(CONFIG_4xx) || IS_ENABLED(CONFIG_BOOKE))
pr_cont("DEAR: "REG" ESR: "REG" ", regs->dar, regs->dsisr);
else
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/process: Enhance readability for trap types.
2021-03-28 14:35 [PATCH] powerpc/process: Enhance readability for trap types Xiongwei Song
@ 2021-03-28 15:21 ` Christophe Leroy
2021-03-28 23:11 ` Xiongwei Song
0 siblings, 1 reply; 3+ messages in thread
From: Christophe Leroy @ 2021-03-28 15:21 UTC (permalink / raw)
To: Xiongwei Song, mpe, benh, paulus, npiggin, ravi.bangoria, mikey,
aneesh.kumar, haren
Cc: Xiongwei Song, linuxppc-dev, linux-kernel
Le 28/03/2021 à 16:35, Xiongwei Song a écrit :
> From: Xiongwei Song <sxwjean@gmail.com>
>
> Define macros to enhance the code readability on ppc trap types.
Good idea
>
> Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
> ---
> arch/powerpc/kernel/process.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> index 3231c2df9e26..3bbd3cf353a7 100644
> --- a/arch/powerpc/kernel/process.c
> +++ b/arch/powerpc/kernel/process.c
> @@ -1451,6 +1451,10 @@ static void print_msr_bits(unsigned long val)
> #define LAST_VOLATILE 12
> #endif
>
> +#define TRAP_MC 0x200 /* Machine Check */
I think usually we use MCE, so TRAP_MCE would be better
> +#define TRAP_DSI 0x300 /* DSI exception */
> +#define TRAP_AM 0x600 /* Alignment exception */
Don't know what AM means. TRAP_ALIGN would be more explicit.
> +
The defines should go in a header file, for instance asm/ptrace.h in order to be re-used in other files.
You should do more. You can find other places to improve with:
git grep "trap ==" arch/powerpc/
git grep "TRAP(regs) ==" arch/powerpc/
> static void __show_regs(struct pt_regs *regs)
> {
> int i, trap;
> @@ -1465,7 +1469,7 @@ static void __show_regs(struct pt_regs *regs)
> trap = TRAP(regs);
> if (!trap_is_syscall(regs) && cpu_has_feature(CPU_FTR_CFAR))
> pr_cont("CFAR: "REG" ", regs->orig_gpr3);
> - if (trap == 0x200 || trap == 0x300 || trap == 0x600) {
> + if (trap == TRAP_MC || trap == TRAP_DSI || trap == TRAP_AM) {
> if (IS_ENABLED(CONFIG_4xx) || IS_ENABLED(CONFIG_BOOKE))
> pr_cont("DEAR: "REG" ESR: "REG" ", regs->dar, regs->dsisr);
> else
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/process: Enhance readability for trap types.
2021-03-28 15:21 ` Christophe Leroy
@ 2021-03-28 23:11 ` Xiongwei Song
0 siblings, 0 replies; 3+ messages in thread
From: Xiongwei Song @ 2021-03-28 23:11 UTC (permalink / raw)
To: Christophe Leroy
Cc: ravi.bangoria, mikey, Xiongwei Song, haren, linux-kernel,
npiggin, paulus, aneesh.kumar, linuxppc-dev
> On Mar 28, 2021, at 11:21 PM, Christophe Leroy <christophe.leroy@csgroup.eu> wrote:
>
>
>
> Le 28/03/2021 à 16:35, Xiongwei Song a écrit :
>> From: Xiongwei Song <sxwjean@gmail.com>
>> Define macros to enhance the code readability on ppc trap types.
>
> Good idea
>
>> Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
>> ---
>> arch/powerpc/kernel/process.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
>> index 3231c2df9e26..3bbd3cf353a7 100644
>> --- a/arch/powerpc/kernel/process.c
>> +++ b/arch/powerpc/kernel/process.c
>> @@ -1451,6 +1451,10 @@ static void print_msr_bits(unsigned long val)
>> #define LAST_VOLATILE 12
>> #endif
>> +#define TRAP_MC 0x200 /* Machine Check */
>
> I think usually we use MCE, so TRAP_MCE would be better
Ok.
>
>> +#define TRAP_DSI 0x300 /* DSI exception */
>> +#define TRAP_AM 0x600 /* Alignment exception */
>
> Don't know what AM means. TRAP_ALIGN would be more explicit.
No Problem.
>
>> +
>
> The defines should go in a header file, for instance asm/ptrace.h in order to be re-used in other files.
Agree.
>
> You should do more. You can find other places to improve with:
>
> git grep "trap ==" arch/powerpc/
> git grep "TRAP(regs) ==" arch/powerpc/
Just ran “git grep”, looks like the work is much bigger than what I imagined.
>
>> static void __show_regs(struct pt_regs *regs)
>> {
>> int i, trap;
>> @@ -1465,7 +1469,7 @@ static void __show_regs(struct pt_regs *regs)
>> trap = TRAP(regs);
>> if (!trap_is_syscall(regs) && cpu_has_feature(CPU_FTR_CFAR))
>> pr_cont("CFAR: "REG" ", regs->orig_gpr3);
>> - if (trap == 0x200 || trap == 0x300 || trap == 0x600) {
>> + if (trap == TRAP_MC || trap == TRAP_DSI || trap == TRAP_AM) {
>> if (IS_ENABLED(CONFIG_4xx) || IS_ENABLED(CONFIG_BOOKE))
>> pr_cont("DEAR: "REG" ESR: "REG" ", regs->dar, regs->dsisr);
>> else
Thanks for the response. I will send v2.
Regards,
Xiongwei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-28 23:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-28 14:35 [PATCH] powerpc/process: Enhance readability for trap types Xiongwei Song
2021-03-28 15:21 ` Christophe Leroy
2021-03-28 23:11 ` Xiongwei Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).