}
#ifndef NDEBUG
+#include <asm/traps.h>
+
static int __init stub_selftest(void)
{
static const struct {
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);
+ vector_name(tests[i].res.fields.trapnr), tests[i].res.fields.ec,
+ vector_name(res.fields.trapnr), res.fields.ec);
fail = true;
}
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, vector_name(vector), error_code);
if ( vector == TRAP_page_fault )
show_page_walk(event->cr2);
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 *vector_name(unsigned int vec)
{
static const char names[][4] = {
#define P(x) [X86_EXC_ ## x] = "#" #x
}
panic("FATAL TRAP: vec %u, %s[%04x]%s\n",
- trapnr, vec_name(trapnr), regs->error_code,
+ trapnr, vector_name(trapnr), regs->error_code,
(regs->eflags & X86_EFLAGS_IF) ? "" : " IN INTERRUPT CONTEXT");
}
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,
*/
if ( IS_ENABLED(CONFIG_DEBUG) && print )
printk(XENLOG_GUEST XENLOG_WARNING "Fixup %s[%04x]: %p [%ps] -> %p\n",
- vec_name(regs->entry_vector), regs->error_code,
+ vector_name(regs->entry_vector), regs->error_code,
_p(regs->rip), _p(regs->rip), _p(fixup));
fixup_exception_return(regs, fixup);
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)