return (exc < ARRAY_SIZE(names) && names[exc]) ? names[exc] : "??";
}
-int x86_exc_decode_ec(char *buf, size_t bufsz, unsigned int ev, unsigned int ec)
+static int x86_exc_decode_ec(char *buf, size_t bufsz,
+ unsigned int ev, unsigned int ec)
{
switch ( ev )
{
}
}
-int x86_decode_exinfo(char *buf, size_t bufsz, exinfo_t info)
+static int x86_decode_exinfo(char *buf, size_t bufsz, exinfo_t info)
{
if ( !info )
return snprintf(buf, bufsz, "nothing");
*/
const char *x86_exc_short_name(unsigned int ev);
-/**
- * Decodes an x86 error code into a readable form.
- *
- * @param buf Buffer to fill.
- * @param bufsz Size of @p buf.
- * @param ev Entry Vector.
- * @param ec Error Code.
- * @return snprintf(buf, bufsz, ...)
- */
-int x86_exc_decode_ec(char *buf, size_t bufsz,
- unsigned int ev, unsigned int ec);
-
-/**
- * Decodes an exinfo_t into a readable form.
- *
- * @param buf Buffer to fill.
- * @param bufsz Size of @p buf.
- * @param info exinfo_t value.
- * @return snprintf(buf, bufsz, ...)
- */
-int x86_decode_exinfo(char *buf, size_t bufsz, exinfo_t info);
-
#endif /* XTF_X86_DECODE_H */
/*
/* Still unresolved? Give up and panic() with some relevent information. */
if ( !safe )
{
- char buf[16];
-
- x86_exc_decode_ec(buf, ARRAY_SIZE(buf),
- regs->entry_vector, regs->error_code);
+ exinfo_t ex = EXINFO(regs->entry_vector, regs->error_code);
if ( regs->entry_vector == X86_EXC_PF )
{
unsigned long cr2 = read_cr2();
panic("Unhandled exception at %04x:%p\n"
- "Vec %u %s[%s] %%cr2 %p\n",
- regs->cs, _p(regs->ip), regs->entry_vector,
- x86_exc_short_name(regs->entry_vector), buf, _p(cr2));
+ "Vec %u %pe %%cr2 %p\n",
+ regs->cs, _p(regs->ip), regs->entry_vector, _p(ex), _p(cr2));
}
else
panic("Unhandled exception at %04x:%p\n"
- "Vec %u %s[%s]\n",
- regs->cs, _p(regs->ip), regs->entry_vector,
- x86_exc_short_name(regs->entry_vector), buf);
+ "Vec %u %pe\n",
+ regs->cs, _p(regs->ip), regs->entry_vector, _p(ex));
}
}
if ( res != exp )
{
- char expstr[12], gotstr[12], cr0str[12];
-
- x86_decode_exinfo(expstr, ARRAY_SIZE(expstr), exp);
- x86_decode_exinfo(gotstr, ARRAY_SIZE(gotstr), res);
+ char cr0str[12];
snprintf(cr0str, sizeof(cr0str), "%s%s%s",
t->cr0 & X86_CR0_EM ? " EM" : "",
t->cr0 & X86_CR0_MP ? " MP" : "",
t->cr0 & X86_CR0_TS ? " TS" : "");
- xtf_failure(" Expected %s, got %s (cr0:%s)\n",
- expstr, gotstr, cr0str[0] ? cr0str : " - ");
+ xtf_failure(" Expected %pe, got %pe (cr0:%s)\n",
+ _p(exp), _p(res), cr0str[0] ? cr0str : " - ");
}
}
}
*/
static bool ex_fail(struct cpu_regs *regs, const struct extable_entry *ex)
{
- char buf[16];
+ exinfo_t info = EXINFO(regs->entry_vector, regs->error_code);
- x86_exc_decode_ec(buf, ARRAY_SIZE(buf),
- regs->entry_vector, regs->error_code);
-
- xtf_failure(" Fail: Unexpected %s[%s]\n",
- x86_exc_short_name(regs->entry_vector), buf);
+ xtf_failure(" Fail: Unexpected fault %#x, %pe\n", info, _p(info));
regs->ip = ex->fixup;
return true;
if ( high == EXINFO_EXPECTED )
{
- x86_decode_exinfo(str, n, ex);
+ snprintf(str, n, "%pe", _p(ex));
return;
}
break;
default:
- {
- char str[20];
-
- x86_decode_exinfo(str, ARRAY_SIZE(str), fault);
- xtf_error(" Error: Unexpected fault %#x (%s)\n", fault, str);
+ xtf_error(" Error: Unexpected fault %#x, %pe\n", fault, _p(fault));
break;
}
- }
printk("Testing stale LDT:\n");
break;
default:
- {
- char str[20];
-
- x86_decode_exinfo(str, ARRAY_SIZE(str), fault);
- xtf_error(" Error: Unexpected fault %#x (%s)\n", fault, str);
+ xtf_error(" Error: Unexpected fault %#x, %pe\n", fault, _p(fault));
break;
}
- }
xtf_success(NULL);
}
xtf_success("Success: Got #DE as expected\n");
}
else
- {
- char gotstr[16];
-
- x86_decode_exinfo(gotstr, ARRAY_SIZE(gotstr), fault);
-
- xtf_error("Error: Got unexpected fault %s\n", gotstr);
- }
+ xtf_error(" Error: Unexpected fault %#x, %pe\n", fault, _p(fault));
break;
}