]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
x86: re-run exception-from-stub recovery selftests with CET-SS enabled
authorJan Beulich <jbeulich@suse.com>
Thu, 4 Jul 2024 12:17:03 +0000 (14:17 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 4 Jul 2024 12:17:03 +0000 (14:17 +0200)
On the BSP, shadow stacks are enabled only relatively late in the
booting process. They in particular aren't active yet when initcalls are
run. Keep the testing there, but invoke that testing a 2nd time when
shadow stacks are active, to make sure we won't regress that case after
addressing XSA-451.

While touching this code, switch the guard from NDEBUG to CONFIG_DEBUG,
such that IS_ENABLED() can validly be used at the new call site.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: cfe3ad67127b86e1b1c06993b86422673a51b050
master date: 2024-02-27 13:49:52 +0100

xen/arch/x86/extable.c
xen/arch/x86/include/asm/setup.h
xen/arch/x86/setup.c

index dd9583f2a54837fbc31376f87d955f7d3541d2e7..f05c16def68b07ed0189150b1abb4dd1cc9d4bde 100644 (file)
@@ -128,10 +128,11 @@ search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
     return 0;
 }
 
-#ifndef NDEBUG
+#ifdef CONFIG_DEBUG
+#include <asm/setup.h>
 #include <asm/traps.h>
 
-static int __init cf_check stub_selftest(void)
+int __init cf_check stub_selftest(void)
 {
     static const struct {
         uint8_t opc[8];
@@ -155,7 +156,8 @@ static int __init cf_check stub_selftest(void)
     unsigned int i;
     bool fail = false;
 
-    printk("Running stub recovery selftests...\n");
+    printk("%s stub recovery selftests...\n",
+           system_state < SYS_STATE_active ? "Running" : "Re-running");
 
     for ( i = 0; i < ARRAY_SIZE(tests); ++i )
     {
index 21037b7f3139f5c75c27d6b3c58a695d033abde9..a870c61b3f6570a52f605b9f911d86e7c4046d2e 100644 (file)
@@ -48,6 +48,8 @@ int xen_in_range(unsigned long mfn);
 void microcode_grab_module(
     unsigned long *, const multiboot_info_t *);
 
+int cf_check stub_selftest(void);
+
 extern uint8_t kbd_shift_flags;
 
 #ifdef NDEBUG
index d47f1567117df8fd9b796322399a8a7d1061de0a..2d2eb791e41f8264e0283de2e4e01940960e964b 100644 (file)
@@ -622,6 +622,10 @@ static void noreturn init_done(void)
 
     system_state = SYS_STATE_active;
 
+    /* Re-run stub recovery self-tests with CET-SS active. */
+    if ( IS_ENABLED(CONFIG_DEBUG) && cpu_has_xen_shstk )
+        stub_selftest();
+
     domain_unpause_by_systemcontroller(dom0);
 
     /* MUST be done prior to removing .init data. */