x86: use enum instead of literals for trap values
PATCH v2 1/1 x86: use enum instead of literals for trap values
The traps are referred to by their numbers and it can be difficult to understand them while reading the code without context. This patch adds enumeration of the trap numbers and replaces the numbers with the correct enum for x86.
Signed-off-by Kees Cook <[email protected]>
---
v2:
- drop IRQ 13 confusions, change enum naming (Ingo Molnar).
v1:
- updated Aditya Kali's earlier patch: https://lkml.org/lkml/2011/4/22/328
--- arch/x86/include/asm/traps.h | 25 +++++++++ arch/x86/kernel/irqinit.c | 2 +- arch/x86/kernel/traps.c | 123 +++++++++++++++++++++++------------------- 3 files changed, 94 insertions(+), 56 deletions(-)
arch/x86/include/asm/traps.h +25 -0
@@ -89,4 +89,29 @@ asmlinkage void smp_thermal_interrupt(void); asmlinkage void mce_threshold_interrupt(void);#endif +/* Processor Fault Vectors */ +enum { +X86_DIV_BY_ZERO_FAULT_VEC =0 ,/* 0 */ +X86_DEBUG_FAULT_VEC ,/* 1 */ +X86_NMI_FAULT_VEC ,/* 2 */ +X86_BREAKPOINT_FAULT_VEC ,/* 3 */ +X86_OVERFLOW_FAULT_VEC ,/* 4 */ +X86_BOUNDS_CHECK_FAULT_VEC ,/* 5 */ +X86_INVALID_OP_FAULT_VEC ,/* 6 */ +X86_NO_DEV_FAULT_VEC ,/* 7 */ +X86_DOUBLE_FAULT_VEC ,/* 8 */ +X86_SEG_OVERRUN_FAULT_VEC ,/* 9 */ +X86_INVALID_TSS_FAULT_VEC ,/* 10 */ +X86_NO_SEG_FAULT_VEC ,/* 11 */ +X86_STACK_FAULT_VEC ,/* 12 */ +X86_GPF_FAULT_VEC ,/* 13 */ +X86_PAGE_FAULT_VEC ,/* 14 */ +X86_SPURIOUS_FAULT_VEC ,/* 15 */ +X86_COPROCESSOR_FAULT_VEC ,/* 16 */ +X86_ALIGNMENT_FAULT_VEC ,/* 17 */ +X86_MCE_FAULT_VEC ,/* 18 */ +X86_SIMD_COPROCESSOR_FAULT_VEC ,/* 19 */ +X86_IRET_FAULT_VEC =32 ,/* 32 */ +}; +#endif /* _ASM_X86_TRAPS_H */
arch/x86/kernel/irqinit.c +1 -1
@@ -61,7 +61,7 @@ static irqreturn_t math_error_irq(int cpl, void *dev_id)outb (0 ,0xF0 );if (ignore_fpu_irq || !boot_cpu_data.hard_math)return IRQ_NONE ; -math_error (get_irq_regs (),0 ,16 ); +math_error (get_irq_regs (),0 ,X86_COPROCESSOR_FAULT_VEC );return IRQ_HANDLED ; }
arch/x86/kernel/traps.c +68 -55
246 lines not on this page · raw message
Signature · 5 lines
1.7.0.4 -- Kees Cook ChromeOS Security