diff options
author | Keir Fraser <keir@xen.org> | 2011-04-25 13:34:20 +0100 |
---|---|---|
committer | Keir Fraser <keir@xen.org> | 2011-04-25 13:34:20 +0100 |
commit | a619245a1e226abe8a1d334663fa233118094c19 (patch) | |
tree | 3b5d6b0be986ce031fe656bc9777171e1051a01b | |
parent | a8bb2c6ec1ea9239b7b65ac40d549b057e6b8aa2 (diff) | |
download | xen-a619245a1e226abe8a1d334663fa233118094c19.tar.gz xen-a619245a1e226abe8a1d334663fa233118094c19.tar.bz2 xen-a619245a1e226abe8a1d334663fa233118094c19.zip |
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@citrix.com>
Signed-off-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 23245:3539ef956a37
xen-unstable date: Mon Apr 18 18:34:45 2011 +0100
-rw-r--r-- | tools/firmware/hvmloader/hvmloader.c | 3 | ||||
-rw-r--r-- | tools/firmware/hvmloader/util.c | 21 |
2 files changed, 18 insertions, 6 deletions
diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index 5ba71f6217..b052f33543 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -704,6 +704,9 @@ int main(void) uint32_t etherboot_phys_addr, option_rom_phys_addr, bios32_addr; struct bios_info *bios_info; + /* 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 --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index c58ea1071a..0daa84fbf2 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -25,6 +25,7 @@ #include <stdint.h> #include <xen/xen.h> #include <xen/memory.h> +#include <xen/sched.h> void wrmsr(uint32_t idx, uint64_t v) { @@ -538,19 +539,27 @@ int vprintf(const char *fmt, va_list ap) 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) |