]> xenbits.xensource.com Git - xen.git/commitdiff
x86: Generalise BUGFRAME_dump mechanism to allow polled UART irq to
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 24 Feb 2010 10:44:30 +0000 (10:44 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 24 Feb 2010 10:44:30 +0000 (10:44 +0000)
get proper regs argument.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/traps.c
xen/drivers/acpi/utilities/utglobal.c
xen/drivers/char/ns16550.c
xen/include/asm-x86/bug.h
xen/include/asm-x86/processor.h

index fda92163d484a61f1a9efa423ec3a73cb1e6fdd9..932ff43a69c368a7380ad42eb4a05a2a07c13722 100644 (file)
@@ -892,6 +892,7 @@ asmlinkage void do_invalid_op(struct cpu_user_regs *regs)
 {
     struct bug_frame bug;
     struct bug_frame_str bug_str;
+    const void *p;
     const char *filename, *predicate, *eip = (char *)regs->eip;
     unsigned long fixup;
     int id, lineno;
@@ -913,26 +914,29 @@ asmlinkage void do_invalid_op(struct cpu_user_regs *regs)
         goto die;
     eip += sizeof(bug);
 
+    /* Decode first pointer argument. */
+    if ( !is_kernel(eip) ||
+         __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
+         (bug_str.mov != 0xbc) )
+        goto die;
+    p = bug_str(bug_str, eip);
+    if ( !is_kernel(p) )
+        goto die;
+    eip += sizeof(bug_str);
+
     id = bug.id & 3;
 
-    if ( id == BUGFRAME_dump )
+    if ( id == BUGFRAME_run_fn )
     {
-        show_execution_state(regs);
+        const void (*fn)(struct cpu_user_regs *) = p;
+        (*fn)(regs);
         regs->eip = (unsigned long)eip;
         return;
     }
 
     /* WARN, BUG or ASSERT: decode the filename pointer and line number. */
-    if ( !is_kernel(eip) ||
-         __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
-         (bug_str.mov != 0xbc) )
-        goto die;
-    filename = bug_str(bug_str, eip);
-    eip += sizeof(bug_str);
-
-    if ( !is_kernel(filename) )
-        filename = "<unknown>";
-    lineno   = bug.id >> 2;
+    filename = p;
+    lineno = bug.id >> 2;
 
     if ( id == BUGFRAME_warn )
     {
index 8cb5e8de3e2d77ac2f6aeb1aea0f4fd4db84d9da..2f792000ff3c538f19f8f724bb004b264074da21 100644 (file)
@@ -45,6 +45,7 @@
 
 #include <xen/config.h>
 #include <xen/lib.h>
+#include <asm/processor.h>
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
 
index a819a80da6cda8017a31f296232255702f752ba4..f1981a24badc2b1a07d5d2c897baa304dec3dfdc 100644 (file)
@@ -145,11 +145,13 @@ static void ns16550_interrupt(
     }
 }
 
-static void ns16550_poll(void *data)
+/* Safe: ns16550_poll() runs in softirq context so not reentrant on a given CPU. */
+static DEFINE_PER_CPU(struct serial_port *, poll_port);
+
+static void __ns16550_poll(struct cpu_user_regs *regs)
 {
-    struct serial_port *port = data;
+    struct serial_port *port = this_cpu(poll_port);
     struct ns16550 *uart = port->uart;
-    struct cpu_user_regs *regs = guest_cpu_user_regs();
 
     if ( uart->intr_works )
         return;     /* Interrupts work - no more polling */
@@ -169,6 +171,16 @@ static void ns16550_poll(void *data)
     set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms));
 }
 
+static void ns16550_poll(void *data)
+{
+    this_cpu(poll_port) = data;
+#ifdef run_in_exception_handler
+    run_in_exception_handler(__ns16550_poll);
+#else
+    __ns16550_poll(guest_cpu_user_regs());
+#endif
+}
+
 static int ns16550_tx_empty(struct serial_port *port)
 {
     struct ns16550 *uart = port->uart;
index df64549e4463fb7e2f800bd81b342f4718ffc803..60efca2244b8d8bb2cf289cc8876f8311ef24426 100644 (file)
@@ -13,15 +13,16 @@ struct bug_frame {
     unsigned short id; /* BUGFRAME_??? */
 } __attribute__((packed));
 
-#define BUGFRAME_dump   0
+#define BUGFRAME_run_fn 0
 #define BUGFRAME_warn   1
 #define BUGFRAME_bug    2
 #define BUGFRAME_assert 3
 
-#define dump_execution_state()                     \
+#define run_in_exception_handler(fn)               \
     asm volatile (                                 \
-        "ud2 ; ret $0"                             \
-        : : "i" (BUGFRAME_dump) )
+        "ud2 ; ret %0" BUG_STR(1)                  \
+        : : "i" (BUGFRAME_run_fn),                 \
+            "i" (fn) )
 
 #define WARN()                                     \
     asm volatile (                                 \
index 90d8806b6572520bb8cedacd10d681dbb71548b7..62f8aea8800402a3b99547dfe49be55b4b8f927f 100644 (file)
@@ -535,6 +535,7 @@ void show_stack(struct cpu_user_regs *regs);
 void show_stack_overflow(unsigned int cpu, unsigned long esp);
 void show_registers(struct cpu_user_regs *regs);
 void show_execution_state(struct cpu_user_regs *regs);
+#define dump_execution_state() run_in_exception_handler(show_execution_state)
 void show_page_walk(unsigned long addr);
 asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs);