From: Andrew Cooper Date: Fri, 13 Sep 2024 14:52:45 +0000 (+0100) Subject: selftest: Fix test_unhandled_exception_hook() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8d377f640739ecc96282e4340f33aa41e8f7bd7b;p=people%2Fandrewcoop%2Fxen-test-framework.git selftest: Fix test_unhandled_exception_hook() When the hook was replaced with a week function, selftest's do_unhandled_exception() became active for all unhandled exceptions, not just the one under test. Re-limit it to only test_unhandled_exception_hook(). Fixes: 7c575dc9c353 ("Simplify the unhandled_exception handling for tests") Signed-off-by: Andrew Cooper --- diff --git a/tests/selftest/main.c b/tests/selftest/main.c index 3a34ea3..6a04050 100644 --- a/tests/selftest/main.c +++ b/tests/selftest/main.c @@ -101,10 +101,14 @@ static void test_NULL_unmapped(void) xtf_failure("Fail: Expected #PF, got %pe\n", _p(got)); } +static volatile bool test_hook_active; bool do_unhandled_exception(struct cpu_regs *regs) { extern unsigned long hook_fault[], hook_fixup[]; + if ( !test_hook_active ) + return false; + if ( _p(regs->ip) != hook_fault ) { xtf_failure("Fail: Expected fault at %p, got %p\n", @@ -121,7 +125,9 @@ static void test_unhandled_exception_hook(void) printk("Test: Unhandled Exception Hook\n"); /* Check that the hook catches the exception, and fix it up. */ + test_hook_active = true; asm volatile ("hook_fault: ud2a; hook_fixup:"); + test_hook_active = false; } static bool test_extable_handler_handler_run;