]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
selftest: Fix test_unhandled_exception_hook()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 13 Sep 2024 14:52:45 +0000 (15:52 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 13 Sep 2024 17:42:29 +0000 (18:42 +0100)
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 <andrew.cooper3@citrix.com>
tests/selftest/main.c

index 3a34ea322e1e65a479e842809af771a32e1b1f29..6a04050667f2c16e0bdb17c60a26bbaf081f9f40 100644 (file)
@@ -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;