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

[Xen-changelog] [xen-unstable] tools: hvmloader: attempt to SHUTDOWN_crash on BUG



# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1303148085 -3600
# Node ID 3539ef956a378ad7fe39654ff9aca5b0e7bf8843
# Parent  024b06de81caad72465a942e0f2f7feb30e322a0
tools: hvmloader: attempt to SHUTDOWN_crash on BUG

Executing UD2 (invalid opcode) triggers a triple fault which signals
reboot to the toolstack, rather than crash.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 024b06de81ca -r 3539ef956a37 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Mon Apr 18 18:08:47 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Mon Apr 18 18:34:45 2011 +0100
@@ -370,6 +370,9 @@
     int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0, smbios_sz = 0;
     uint32_t etherboot_phys_addr, option_rom_phys_addr;
 
+    /* Initialise hypercall stubs with RET, rendering them no-ops. */
+    memset((void *)HYPERCALL_PHYSICAL_ADDRESS, 0xc3 /* RET */, PAGE_SIZE);
+
     printf("HVM Loader\n");
 
     init_hypercalls();
diff -r 024b06de81ca -r 3539ef956a37 tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c   Mon Apr 18 18:08:47 2011 +0100
+++ b/tools/firmware/hvmloader/util.c   Mon Apr 18 18:34:45 2011 +0100
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/memory.h>
+#include <xen/sched.h>
 
 void wrmsr(uint32_t idx, uint64_t v)
 {
@@ -537,19 +538,27 @@
     return 0;
 }
 
+static void __attribute__((noreturn)) crash(void)
+{
+    struct sched_shutdown shutdown = { .reason = SHUTDOWN_crash };
+    printf("*** HVMLoader crashed.\n");
+    hypercall_sched_op(SCHEDOP_shutdown, &shutdown);
+    printf("*** Failed to crash. Halting.\n");
+    for ( ; ; )
+        asm volatile ( "hlt" );
+}
+
 void __assert_failed(char *assertion, char *file, int line)
 {
-    printf("HVMLoader assertion '%s' failed at %s:%d\n",
+    printf("*** HVMLoader assertion '%s' failed at %s:%d\n",
            assertion, file, line);
-    for ( ; ; )
-        asm volatile ( "ud2" );
+    crash();
 }
 
 void __bug(char *file, int line)
 {
-    printf("HVMLoader bug at %s:%d\n", file, line);
-    for ( ; ; )
-        asm volatile ( "ud2" );
+    printf("*** HVMLoader bug at %s:%d\n", file, line);
+    crash();
 }
 
 static void validate_hvm_info(struct hvm_info_table *t)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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