[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 5/5] x86/traps: Clean up diagnostics
do{_reserved,}_trap() should use fatal_trap() rather than opencoding part of it. This lets the remote stack trace logic work in more fatal error conditions. With do_trap() converted, there is only one single user of trapstr() remaining. Tweak the formatting in pv_inject_event(), and remove trapstr() entirely. Take the opportunity of exporting vec_name() to improve the diagnostics in stub_selftest(). Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> CC: Wei Liu <wl@xxxxxxx> --- xen/arch/x86/extable.c | 8 +++++--- xen/arch/x86/pv/traps.c | 6 +++--- xen/arch/x86/traps.c | 25 +++---------------------- xen/include/asm-x86/traps.h | 2 +- 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c index 109ab7da9811..3cb0352abe5f 100644 --- a/xen/arch/x86/extable.c +++ b/xen/arch/x86/extable.c @@ -124,6 +124,8 @@ search_exception_table(const struct cpu_user_regs *regs) } #ifndef NDEBUG +#include <asm/traps.h> + static int __init stub_selftest(void) { static const struct { @@ -172,10 +174,10 @@ static int __init stub_selftest(void) if ( res.raw != tests[i].res.raw ) { printk("Selftest %u failed: Opc %*ph " - "expected %u[%04x], got %u[%04x]\n", + "expected %s[%04x], got %s[%04x]\n", i, (int)ARRAY_SIZE(tests[i].opc), tests[i].opc, - tests[i].res.fields.trapnr, tests[i].res.fields.ec, - res.fields.trapnr, res.fields.ec); + vec_name(tests[i].res.fields.trapnr), tests[i].res.fields.ec, + vec_name(res.fields.trapnr), res.fields.ec); fail = true; } diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c index 1e05a9f1cdad..1d1cb0784c98 100644 --- a/xen/arch/x86/pv/traps.c +++ b/xen/arch/x86/pv/traps.c @@ -89,9 +89,9 @@ void pv_inject_event(const struct x86_event *event) if ( unlikely(null_trap_bounce(curr, tb)) ) { - gprintk(XENLOG_WARNING, - "Unhandled %s fault/trap [#%d, ec=%04x]\n", - trapstr(vector), vector, error_code); + gprintk(XENLOG_ERR, + "Unhandled: vec %u, %s[%04x]\n", + vector, vec_name(vector), error_code); if ( vector == TRAP_page_fault ) show_page_walk(event->cr2); diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index e82ab007abcf..7a178f030c73 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -759,21 +759,7 @@ static int nmi_show_execution_state(const struct cpu_user_regs *regs, int cpu) return 1; } -const char *trapstr(unsigned int trapnr) -{ - static const char * const strings[] = { - "divide error", "debug", "nmi", "bkpt", "overflow", "bounds", - "invalid opcode", "device not available", "double fault", - "coprocessor segment", "invalid tss", "segment not found", - "stack error", "general protection fault", "page fault", - "spurious interrupt", "coprocessor error", "alignment check", - "machine check", "simd error", "virtualisation exception" - }; - - return trapnr < ARRAY_SIZE(strings) ? strings[trapnr] : "???"; -} - -static const char *vec_name(unsigned int vec) +const char *vec_name(unsigned int vec) { static const char names[][4] = { #define P(x) [X86_EXC_ ## x] = "#" #x @@ -858,9 +844,7 @@ void do_unhandled_trap(struct cpu_user_regs *regs) if ( debugger_trap_fatal(trapnr, regs) ) return; - show_execution_state(regs); - panic("FATAL RESERVED TRAP: vec %u, %s[%04x]\n", - trapnr, vec_name(trapnr), regs->error_code); + fatal_trap(regs, false); } static void fixup_exception_return(struct cpu_user_regs *regs, @@ -970,10 +954,7 @@ void do_trap(struct cpu_user_regs *regs) if ( debugger_trap_fatal(trapnr, regs) ) return; - show_execution_state(regs); - panic("FATAL TRAP: vector = %d (%s)\n" - "[error_code=%04x]\n", - trapnr, trapstr(trapnr), regs->error_code); + fatal_trap(regs, false); } int guest_rdmsr_xen(const struct vcpu *v, uint32_t idx, uint64_t *val) diff --git a/xen/include/asm-x86/traps.h b/xen/include/asm-x86/traps.h index ec23d3a70b36..3c5feac5e4b1 100644 --- a/xen/include/asm-x86/traps.h +++ b/xen/include/asm-x86/traps.h @@ -19,7 +19,7 @@ #ifndef ASM_TRAP_H #define ASM_TRAP_H -const char *trapstr(unsigned int trapnr); +const char *vec_name(unsigned int vec); #endif /* ASM_TRAP_H */ -- 2.11.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |