~(IS_DEFINED(CONFIG_PV) ? X86_EFLAGS_IF : 0);
unsigned long exec_user_efl_or_mask;
-bool (*xtf_unhandled_exception_hook)(struct cpu_regs *regs);
-
/*
* C entry-point for exceptions, after the per-environment stubs have suitably
* adjusted the stack.
}
}
- /*
- * If the test has installed an unhandled exception hook, call it in the
- * hope that it can resolve the exception.
- */
- if ( !safe && xtf_unhandled_exception_hook )
- safe = xtf_unhandled_exception_hook(regs);
+ /* Try the unhandled_exception() hook. */
+ if ( !safe )
+ safe = do_unhandled_exception(regs);
/* Still unresolved? Give up and panic() with some relevent information. */
if ( !safe )
}
}
+bool __weak do_unhandled_exception(struct cpu_regs *regs)
+{
+ return false;
+}
+
void __weak do_syscall(struct cpu_regs *regs)
{
panic("Unhandled syscall\n");
#include <arch/traps.h>
/**
- * Function pointer to allow tests to install an unhandled exception hook.
- *
- * Must only return true if action has been taken resolve the exception.
- * i.e. that it is now safe to iret back. If not, a panic() will occur.
+ * May be implemented by a guest to provide custom exception handling.
*/
-extern bool (*xtf_unhandled_exception_hook)(struct cpu_regs *regs);
+bool do_unhandled_exception(struct cpu_regs *regs);
#endif /* XTF_TRAPS_H */
.iopb = X86_TSS_INVALID_IO_BITMAP,
};
-static bool unhandled_exception(struct cpu_regs *regs)
+bool do_unhandled_exception(struct cpu_regs *regs)
{
if ( regs->entry_vector != X86_EXC_NMI )
return false;
/*
* Set up NMI handling to be a task gate.
*/
- xtf_unhandled_exception_hook = unhandled_exception;
pack_tss_desc(&gdt[GDTE_AVAIL0], &nmi_tss);
pack_task_gate(&idt[X86_EXC_NMI], GDTE_AVAIL0 * 8);
xtf_exlog_stop();
}
-static bool local_unhandled_exception_hook(struct cpu_regs *regs)
+bool do_unhandled_exception(struct cpu_regs *regs)
{
extern unsigned long hook_fault[], hook_fixup[];
printk("Test: Unhandled Exception Hook\n");
/* Check that the hook catches the exception, and fix it up. */
- xtf_unhandled_exception_hook = local_unhandled_exception_hook;
-
- asm volatile ("hook_fault: ud2a; hook_fixup:" ::: "memory");
-
- xtf_unhandled_exception_hook = NULL;
+ asm volatile ("hook_fault: ud2a; hook_fixup:");
}
static bool test_extable_handler_handler_run;
}
/** Print expected information in the case of an unexpected exception. */
-bool unhandled_exception(struct cpu_regs *regs)
+bool do_unhandled_exception(struct cpu_regs *regs)
{
printk("Unhandled Exception at %p\n", _p(regs));
check();
if ( !xtf_has_fep )
xtf_skip("FEP support not detected - some tests will be skipped\n");
- /* Setup. Hook unhandled exceptions for debugging purposes. */
- xtf_unhandled_exception_hook = unhandled_exception;
set_idt_entries_present(true);
set_idt_entries_dpl(3);