WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] tools: hvmloader: attempt to SHUTDOWN_crash on BUG

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] tools: hvmloader: attempt to SHUTDOWN_crash on BUG
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 18 Apr 2011 17:21:52 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Mon, 18 Apr 2011 09:22:31 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1303143704 -3600
# Node ID 05abea47f4dc670974cd513a0e74db54d22eacc9
# Parent  052ffd72382924eee479ca479fd1574750a8adf7
tools: hvmloader: attempt to SHUTDOWN_crash on BUG

If we have got as far as having enabled hypercalls then this signals to the
toolstack that something went wrong. Otherwise they tend to assume the guest
has either shutdown or rebooted which can lead to simply trying again
repeatedly.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 052ffd723829 -r 05abea47f4dc tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Mon Apr 18 14:53:03 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Mon Apr 18 17:21:44 2011 +0100
@@ -114,6 +114,8 @@ unsigned long pci_mem_end = PCI_MEM_END;
 
 enum virtual_vga virtual_vga = VGA_none;
 
+int hypercalls_available = 0;
+
 static void init_hypercalls(void)
 {
     uint32_t eax, ebx, ecx, edx;
@@ -146,6 +148,7 @@ static void init_hypercalls(void)
     cpuid(base + 1, &eax, &ebx, &ecx, &edx);
     hypercall_xen_version(XENVER_extraversion, extraversion);
     printf("Detected Xen v%u.%u%s\n", eax >> 16, eax & 0xffff, extraversion);
+    hypercalls_available = 1;
 }
 
 /*
diff -r 052ffd723829 -r 05abea47f4dc tools/firmware/hvmloader/hypercall.h
--- a/tools/firmware/hvmloader/hypercall.h      Mon Apr 18 14:53:03 2011 +0100
+++ b/tools/firmware/hvmloader/hypercall.h      Mon Apr 18 17:21:44 2011 +0100
@@ -35,6 +35,9 @@
 #include <xen/xen.h>
 #include "config.h"
 
+/* Have hypercalls been successfully enabled */
+extern int hypercalls_available;
+
 /*
  * NB. Hypercall address needs to be relative to a linkage symbol for
  * some version of ld to relocate the relative calls properly.
diff -r 052ffd723829 -r 05abea47f4dc tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c   Mon Apr 18 14:53:03 2011 +0100
+++ b/tools/firmware/hvmloader/util.c   Mon Apr 18 17:21:44 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)
 {
@@ -547,7 +548,15 @@ void __assert_failed(char *assertion, ch
 
 void __bug(char *file, int line)
 {
+    struct sched_shutdown shutdown = {
+        .reason = SHUTDOWN_crash,
+    };
+
     printf("HVMLoader bug at %s:%d\n", file, line);
+    if (hypercalls_available) {
+        printf("SCHEDOP_shutdown: reason=SHUTDOWN_crash\n");
+        hypercall_sched_op(SCHEDOP_shutdown, &shutdown);
+    }
     for ( ; ; )
         asm volatile ( "ud2" );
 }

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