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

[Xen-changelog] [xen-unstable] Add WARN() and generic WARN_ON().



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1175007225 -3600
# Node ID 070cf119a7ec6b62161022502cf8ec7563ebfd76
# Parent  7c2e8bbe9ef8ec3d08390ecec4b406d5f592f32f
Add WARN() and generic WARN_ON().

Based on a patch by Jan Beulich <jbeulich@xxxxxxxxxx>

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/ia64/linux-xen/mca.c                |   10 ----------
 xen/arch/powerpc/backtrace.c                 |   15 ---------------
 xen/arch/x86/traps.c                         |   22 ++++++++++++++--------
 xen/drivers/char/console.c                   |   10 ++++++++--
 xen/include/asm-ia64/bug.h                   |    1 +
 xen/include/asm-ia64/linux-xen/asm/iosapic.h |    7 -------
 xen/include/asm-powerpc/bug.h                |    1 +
 xen/include/asm-powerpc/debugger.h           |    4 ----
 xen/include/asm-x86/bug.h                    |    6 +++---
 xen/include/asm-x86/x86_32/bug.h             |    6 ++++++
 xen/include/asm-x86/x86_64/bug.h             |    6 ++++++
 xen/include/xen/lib.h                        |    4 +++-
 12 files changed, 42 insertions(+), 50 deletions(-)

diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/arch/ia64/linux-xen/mca.c
--- a/xen/arch/ia64/linux-xen/mca.c     Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/arch/ia64/linux-xen/mca.c     Tue Mar 27 15:53:45 2007 +0100
@@ -396,16 +396,6 @@ ia64_log_queue(int sal_info_type, int vi
 #ifdef CONFIG_ACPI
 
 #ifdef XEN
-/**
- *     Copy from linux/include/asm-generic/bug.h
- */
-#define WARN_ON(condition) do { \
-       if (unlikely((condition)!=0)) { \
-               printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, 
__LINE__); \
-               dump_stack(); \
-       } \
-} while (0)
-
 /**
  *     Copy from linux/kernel/irq/manage.c
  *
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/arch/powerpc/backtrace.c
--- a/xen/arch/powerpc/backtrace.c      Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/arch/powerpc/backtrace.c      Tue Mar 27 15:53:45 2007 +0100
@@ -205,21 +205,6 @@ void show_backtrace_regs(struct cpu_user
     console_end_sync();
 }
 
-void __warn(char *file, int line)
-{
-    ulong sp;
-    ulong lr;
-
-    console_start_sync();
-    printk("WARN at %s:%d\n", file, line);
-
-    sp = (ulong)__builtin_frame_address(0);
-    lr = (ulong)__builtin_return_address(0);
-    backtrace(sp, lr, lr);
-
-    console_end_sync();
-}
-
 void dump_execution_state(void)
 {
     struct cpu_user_regs *regs = guest_cpu_user_regs();
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/arch/x86/traps.c      Tue Mar 27 15:53:45 2007 +0100
@@ -637,28 +637,34 @@ asmlinkage int do_invalid_op(struct cpu_
          memcmp(bug.ud2, "\xf\xb", sizeof(bug.ud2)) ||
          (bug.ret != 0xc2) )
         goto die;
+    eip += sizeof(bug);
 
     id = bug.id & 3;
-    if ( id == BUGFRAME_rsvd )
-        goto die;
 
     if ( id == BUGFRAME_dump )
     {
         show_execution_state(regs);
-        regs->eip += sizeof(bug);
+        regs->eip = (unsigned long)eip;
         return EXCRET_fault_fixed;
     }
 
-    /* BUG() or ASSERT(): decode the filename pointer and line number. */
-    ASSERT((id == BUGFRAME_bug) || (id == BUGFRAME_assert));
-    eip += sizeof(bug);
+    /* WARN, BUG or ASSERT: decode the filename pointer and line number. */
     if ( !is_kernel(eip) ||
          __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
          memcmp(bug_str.mov, BUG_MOV_STR, sizeof(bug_str.mov)) )
         goto die;
+    eip += sizeof(bug_str);
 
     filename = is_kernel(bug_str.str) ? (char *)bug_str.str : "<unknown>";
     lineno   = bug.id >> 2;
+
+    if ( id == BUGFRAME_warn )
+    {
+        printk("Xen WARN at %.50s:%d\n", filename, lineno);
+        show_execution_state(regs);
+        regs->eip = (unsigned long)eip;
+        return EXCRET_fault_fixed;
+    }
 
     if ( id == BUGFRAME_bug )
     {
@@ -668,13 +674,13 @@ asmlinkage int do_invalid_op(struct cpu_
         panic("Xen BUG at %.50s:%d\n", filename, lineno);
     }
 
-    /* ASSERT(): decode the predicate string pointer. */
+    /* ASSERT: decode the predicate string pointer. */
     ASSERT(id == BUGFRAME_assert);
-    eip += sizeof(bug_str);
     if ( !is_kernel(eip) ||
          __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
          memcmp(bug_str.mov, BUG_MOV_STR, sizeof(bug_str.mov)) )
         goto die;
+    eip += sizeof(bug_str);
 
     predicate = is_kernel(bug_str.str) ? (char *)bug_str.str : "<unknown>";
     printk("Assertion '%s' failed at %.50s:%d\n",
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/drivers/char/console.c
--- a/xen/drivers/char/console.c        Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/drivers/char/console.c        Tue Mar 27 15:53:45 2007 +0100
@@ -900,10 +900,16 @@ void __bug(char *file, int line)
 void __bug(char *file, int line)
 {
     console_start_sync();
-    printk("BUG at %s:%d\n", file, line);
+    printk("Xen BUG at %s:%d\n", file, line);
     dump_execution_state();
-    panic("BUG at %s:%d\n", file, line);
+    panic("Xen BUG at %s:%d\n", file, line);
     for ( ; ; ) ;
+}
+
+void __warn(char *file, int line)
+{
+    printk("Xen WARN at %s:%d\n", file, line);
+    dump_execution_state();
 }
 
 /*
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/include/asm-ia64/bug.h
--- a/xen/include/asm-ia64/bug.h        Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/include/asm-ia64/bug.h        Tue Mar 27 15:53:45 2007 +0100
@@ -2,5 +2,6 @@
 #define __IA64_BUG_H__
 
 #define BUG() __bug(__FILE__, __LINE__)
+#define WARN() __warn(__FILE__, __LINE__)
 
 #endif /* __IA64_BUG_H__ */
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec 
xen/include/asm-ia64/linux-xen/asm/iosapic.h
--- a/xen/include/asm-ia64/linux-xen/asm/iosapic.h      Tue Mar 27 14:50:17 
2007 +0100
+++ b/xen/include/asm-ia64/linux-xen/asm/iosapic.h      Tue Mar 27 15:53:45 
2007 +0100
@@ -123,13 +123,6 @@ static inline void list_move(struct list
 
 #define move_irq(x)
 
-#define WARN_ON(condition) do { \
-       if (unlikely((condition)!=0)) { \
-               printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, 
__LINE__); \
-               dump_stack(); \
-       } \
-} while (0)
-
 #ifdef nop
 #undef nop
 #endif
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/include/asm-powerpc/bug.h
--- a/xen/include/asm-powerpc/bug.h     Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/include/asm-powerpc/bug.h     Tue Mar 27 15:53:45 2007 +0100
@@ -2,5 +2,6 @@
 #define __POWERPC_BUG_H__
 
 #define BUG() __bug(__FILE__, __LINE__)
+#define WARN() __warn(__FILE__, __LINE__)
 
 #endif /* __POWERPC_BUG_H__ */
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/include/asm-powerpc/debugger.h
--- a/xen/include/asm-powerpc/debugger.h        Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/include/asm-powerpc/debugger.h        Tue Mar 27 15:53:45 2007 +0100
@@ -67,10 +67,6 @@ static inline void unimplemented(void)
 #endif
 }
 
-extern void __warn(char *file, int line);
-#define WARN() __warn(__FILE__, __LINE__)
-#define WARN_ON(_p) do { if (_p) WARN(); } while ( 0 )
-
 extern void __attn(void);
 #define ATTN() __attn();
 
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/include/asm-x86/bug.h
--- a/xen/include/asm-x86/bug.h Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/include/asm-x86/bug.h Tue Mar 27 15:53:45 2007 +0100
@@ -14,8 +14,8 @@ struct bug_frame {
 } __attribute__((packed));
 
 #define BUGFRAME_dump   0
-#define BUGFRAME_bug    1
-#define BUGFRAME_assert 2
-#define BUGFRAME_rsvd   3
+#define BUGFRAME_warn   1
+#define BUGFRAME_bug    2
+#define BUGFRAME_assert 3
 
 #endif /* __X86_BUG_H__ */
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/include/asm-x86/x86_32/bug.h
--- a/xen/include/asm-x86/x86_32/bug.h  Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/include/asm-x86/x86_32/bug.h  Tue Mar 27 15:53:45 2007 +0100
@@ -11,6 +11,12 @@ struct bug_frame_str {
     asm volatile (                                      \
         "ud2 ; ret $%c0"                                \
         : : "i" (BUGFRAME_dump) )
+
+#define WARN()                                          \
+    asm volatile (                                      \
+        "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
+        : : "i" (BUGFRAME_warn | (__LINE__<<2)),        \
+            "i" (__FILE__) )
 
 #define BUG()                                           \
     asm volatile (                                      \
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/include/asm-x86/x86_64/bug.h
--- a/xen/include/asm-x86/x86_64/bug.h  Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/include/asm-x86/x86_64/bug.h  Tue Mar 27 15:53:45 2007 +0100
@@ -11,6 +11,12 @@ struct bug_frame_str {
     asm volatile (                                      \
         "ud2 ; ret $%c0"                                \
         : : "i" (BUGFRAME_dump) )
+
+#define WARN()                                          \
+    asm volatile (                                      \
+        "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
+        : : "i" (BUGFRAME_warn | (__LINE__<<2)),        \
+            "i" (__FILE__) )
 
 #define BUG()                                           \
     asm volatile (                                      \
diff -r 7c2e8bbe9ef8 -r 070cf119a7ec xen/include/xen/lib.h
--- a/xen/include/xen/lib.h     Tue Mar 27 14:50:17 2007 +0100
+++ b/xen/include/xen/lib.h     Tue Mar 27 15:53:45 2007 +0100
@@ -10,8 +10,10 @@
 #include <asm/bug.h>
 
 void __bug(char *file, int line) __attribute__((noreturn));
+void __warn(char *file, int line);
 
-#define BUG_ON(_p) do { if (_p) BUG(); } while ( 0 )
+#define BUG_ON(p)  do { if (p) BUG();  } while (0)
+#define WARN_ON(p) do { if (p) WARN(); } while (0)
 
 /* Force a compilation error if condition is true */
 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))

_______________________________________________
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®.