]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
x86/boot: turn the selftests ASSERT into a warning
authorStefano Stabellini <sstabellini@kernel.org>
Fri, 26 Jan 2018 17:19:31 +0000 (09:19 -0800)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 26 Jan 2018 18:28:47 +0000 (18:28 +0000)
On selftests failure, print a very visible warning instead of crashing
over an ASSERT.

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Adjust to print extra information in the case of a failure

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/extable.c

index 72f30d9060b7be302eef93a9bb06690fc5b73553..a6430a6d8dc902392bd78462db816d7bff846542 100644 (file)
@@ -9,6 +9,7 @@
 #include <xen/domain_page.h>
 #include <xen/virtual_region.h>
 #include <xen/livepatch.h>
+#include <xen/warning.h>
 
 #define EX_FIELD(ptr, field) ((unsigned long)&(ptr)->field + (ptr)->field)
 
@@ -145,6 +146,7 @@ static int __init stub_selftest(void)
     };
     unsigned long addr = this_cpu(stubs.addr) + STUB_BUF_SIZE / 2;
     unsigned int i;
+    bool fail = false;
 
     printk("Running stub recovery selftests...\n");
 
@@ -152,7 +154,7 @@ static int __init stub_selftest(void)
     {
         uint8_t *ptr = map_domain_page(_mfn(this_cpu(stubs.mfn))) +
                        (addr & ~PAGE_MASK);
-        unsigned long res = ~0;
+        union stub_exception_token res = { .raw = ~0 };
 
         memset(ptr, 0xcc, STUB_BUF_SIZE / 2);
         memcpy(ptr, tests[i].opc, ARRAY_SIZE(tests[i].opc));
@@ -168,9 +170,22 @@ static int __init stub_selftest(void)
                        _ASM_EXTABLE(.Lret%=, .Lfix%=)
                        : [exn] "+m" (res)
                        : [stb] "r" (addr), "a" (tests[i].rax));
-        ASSERT(res == tests[i].res.raw);
+
+        if ( res.raw != tests[i].res.raw )
+        {
+            printk("Selftest %u failed: Opc %*ph "
+                   "expected %u[%04x], got %u[%04x]\n",
+                   i, (int)ARRAY_SIZE(tests[i].opc), tests[i].opc,
+                   tests[i].res.fields.trapnr, tests[i].res.fields.ec,
+                   res.fields.trapnr, res.fields.ec);
+
+            fail = true;
+        }
     }
 
+    if ( fail )
+        warning_add("SELFTEST FAILURE: CORRECT BEHAVIOR CANNOT BE GUARANTEED\n");
+
     return 0;
 }
 __initcall(stub_selftest);