[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] x86/boot: turn the selftests ASSERT into a warning



commit b03e568ea9eb609f85a0a496c83a5f27ce18498e
Author:     Stefano Stabellini <sstabellini@xxxxxxxxxx>
AuthorDate: Fri Jan 26 09:19:31 2018 -0800
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Jan 26 18:28:47 2018 +0000

    x86/boot: turn the selftests ASSERT into a warning
    
    On selftests failure, print a very visible warning instead of crashing
    over an ASSERT.
    
    Signed-off-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    
    Adjust to print extra information in the case of a failure
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/extable.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 72f30d9..a6430a6 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -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);
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.