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

[Xen-devel] [PATCH 2 of 4 RFC] xen/panic: Introduce panic_in_progress



The panic() function will re-enable NMIs.  In addition, because of the
private spinlock, panic() is not safe to reentry on the same pcpu, due
to an NMI or MCE.

We introduce a panic_in_progress flag and is_panic_in_progress() helper,
to be used in subsequent patches.  (And also fix a whitespace error.)

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

diff -r b15d3ae525af -r 48a60a407e15 xen/drivers/char/console.c
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -65,6 +65,8 @@ static int __read_mostly sercon_handle =
 
 static DEFINE_SPINLOCK(console_lock);
 
+static atomic_t panic_in_progress = ATOMIC_INIT(0);
+
 /*
  * To control the amount of printing, thresholds are added.
  * These thresholds correspond to the XENLOG logging levels.
@@ -980,13 +982,22 @@ static int __init debugtrace_init(void)
  * **************************************************************
  */
 
+/* Is a panic() in progress? Used to prevent reentrancy of panic() from
+ * NMIs/MCEs, as there is potential to deadlock from those contexts. */
+long is_panic_in_progress(void)
+{
+    return atomic_read(&panic_in_progress);
+}
+
 void panic(const char *fmt, ...)
 {
     va_list args;
     unsigned long flags;
     static DEFINE_SPINLOCK(lock);
     static char buf[128];
-    
+
+    atomic_set(&panic_in_progress, 1);
+
     debugtrace_dump();
 
     /* Protects buf[] and ensure multi-line message prints atomically. */
diff -r b15d3ae525af -r 48a60a407e15 xen/include/xen/lib.h
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -78,6 +78,7 @@ extern void debugtrace_printk(const char
 #define _p(_x) ((void *)(unsigned long)(_x))
 extern void printk(const char *format, ...)
     __attribute__ ((format (printf, 1, 2)));
+extern long is_panic_in_progress(void);
 extern void panic(const char *format, ...)
     __attribute__ ((format (printf, 1, 2)));
 extern long vm_assist(struct domain *, unsigned int, unsigned int);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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