lkml.org 
[lkml]   [2021]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2] powerpc/traps: Enhance readability for trap types
Date
Xiongwei Song <sxwjean@me.com> writes:
> From: Xiongwei Song <sxwjean@gmail.com>
>
> Create a new header named traps.h, define macros to list ppc exception
> types in traps.h, replace the reference of the real trap values with
> these macros.

Personally I find the hex values easier to recognise, but I realise
that's probably not true of other people :)

...
> diff --git a/arch/powerpc/include/asm/traps.h b/arch/powerpc/include/asm/traps.h
> new file mode 100644
> index 000000000000..a31b6122de23
> --- /dev/null
> +++ b/arch/powerpc/include/asm/traps.h
> @@ -0,0 +1,19 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_PPC_TRAPS_H
> +#define _ASM_PPC_TRAPS_H
> +
> +#define TRAP_RESET 0x100 /* System reset */
> +#define TRAP_MCE 0x200 /* Machine check */
> +#define TRAP_DSI 0x300 /* Data storage */
> +#define TRAP_DSEGI 0x380 /* Data segment */
> +#define TRAP_ISI 0x400 /* Instruction storage */
> +#define TRAP_ISEGI 0x480 /* Instruction segment */
> +#define TRAP_ALIGN 0x600 /* Alignment */
> +#define TRAP_PROG 0x700 /* Program */
> +#define TRAP_DEC 0x900 /* Decrementer */
> +#define TRAP_SYSCALL 0xc00 /* System call */
> +#define TRAP_TRACEI 0xd00 /* Trace */
> +#define TRAP_FPA 0xe00 /* Floating-point Assist */
> +#define TRAP_PMI 0xf00 /* Performance monitor */

I know the macro is called TRAP and the field in pt_regs is called trap,
but the terminology in the architecture is "exception", and we already
have many uses of that. In particular we have a lot of uses of "exc" as
an abbreviation for "exception". So I think I'd rather we use that than
"TRAP".

I think we should probably use the names from the ISA, unless they are
really over long.

Which are:

0x100 System Reset
0x200 Machine Check
0x300 Data Storage
0x380 Data Segment
0x400 Instruction Storage
0x480 Instruction Segment
0x500 External
0x600 Alignment
0x700 Program
0x800 Floating-Point Unavailable
0x900 Decrementer
0x980 Hypervisor Decrementer
0xA00 Directed Privileged Doorbell
0xC00 System Call
0xD00 Trace
0xE00 Hypervisor Data Storage
0xE20 Hypervisor Instruction Storage
0xE40 Hypervisor Emulation Assistance
0xE60 Hypervisor Maintenance
0xE80 Directed Hypervisor Doorbell
0xEA0 Hypervisor Virtualization
0xF00 Performance Monitor
0xF20 Vector Unavailable
0xF40 VSX Unavailable
0xF60 Facility Unavailable
0xF80 Hypervisor Facility Unavailable
0xFA0 Directed Ultravisor Doorbell


So perhaps:

EXC_SYSTEM_RESET
EXC_MACHINE_CHECK
EXC_DATA_STORAGE
EXC_DATA_SEGMENT
EXC_INST_STORAGE
EXC_INST_SEGMENT
EXC_EXTERNAL_INTERRUPT
EXC_ALIGNMENT
EXC_PROGRAM_CHECK
EXC_FP_UNAVAILABLE
EXC_DECREMENTER
EXC_HV_DECREMENTER
EXC_SYSTEM_CALL
EXC_HV_DATA_STORAGE
EXC_PERF_MONITOR


cheers

\
 
 \ /
  Last update: 2021-03-31 11:59    [W:0.079 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site