ia64/xen-unstable

changeset 14590:070cf119a7ec

Add WARN() and generic WARN_ON().

Based on a patch by Jan Beulich <jbeulich@novell.com>

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Mar 27 15:53:45 2007 +0100 (2007-03-27)
parents 7c2e8bbe9ef8
children f1014cbe906a
files xen/arch/ia64/linux-xen/mca.c xen/arch/powerpc/backtrace.c xen/arch/x86/traps.c xen/drivers/char/console.c xen/include/asm-ia64/bug.h xen/include/asm-ia64/linux-xen/asm/iosapic.h xen/include/asm-powerpc/bug.h xen/include/asm-powerpc/debugger.h xen/include/asm-x86/bug.h xen/include/asm-x86/x86_32/bug.h xen/include/asm-x86/x86_64/bug.h xen/include/xen/lib.h
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/mca.c	Tue Mar 27 14:50:17 2007 +0100
     1.2 +++ b/xen/arch/ia64/linux-xen/mca.c	Tue Mar 27 15:53:45 2007 +0100
     1.3 @@ -397,16 +397,6 @@ ia64_log_queue(int sal_info_type, int vi
     1.4  
     1.5  #ifdef XEN
     1.6  /**
     1.7 - *	Copy from linux/include/asm-generic/bug.h
     1.8 - */
     1.9 -#define WARN_ON(condition) do { \
    1.10 -	if (unlikely((condition)!=0)) { \
    1.11 -		printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
    1.12 -		dump_stack(); \
    1.13 -	} \
    1.14 -} while (0)
    1.15 -
    1.16 -/**
    1.17   *	Copy from linux/kernel/irq/manage.c
    1.18   *
    1.19   *	disable_irq_nosync - disable an irq without waiting
     2.1 --- a/xen/arch/powerpc/backtrace.c	Tue Mar 27 14:50:17 2007 +0100
     2.2 +++ b/xen/arch/powerpc/backtrace.c	Tue Mar 27 15:53:45 2007 +0100
     2.3 @@ -205,21 +205,6 @@ void show_backtrace_regs(struct cpu_user
     2.4      console_end_sync();
     2.5  }
     2.6  
     2.7 -void __warn(char *file, int line)
     2.8 -{
     2.9 -    ulong sp;
    2.10 -    ulong lr;
    2.11 -
    2.12 -    console_start_sync();
    2.13 -    printk("WARN at %s:%d\n", file, line);
    2.14 -
    2.15 -    sp = (ulong)__builtin_frame_address(0);
    2.16 -    lr = (ulong)__builtin_return_address(0);
    2.17 -    backtrace(sp, lr, lr);
    2.18 -
    2.19 -    console_end_sync();
    2.20 -}
    2.21 -
    2.22  void dump_execution_state(void)
    2.23  {
    2.24      struct cpu_user_regs *regs = guest_cpu_user_regs();
     3.1 --- a/xen/arch/x86/traps.c	Tue Mar 27 14:50:17 2007 +0100
     3.2 +++ b/xen/arch/x86/traps.c	Tue Mar 27 15:53:45 2007 +0100
     3.3 @@ -637,29 +637,35 @@ asmlinkage int do_invalid_op(struct cpu_
     3.4           memcmp(bug.ud2, "\xf\xb", sizeof(bug.ud2)) ||
     3.5           (bug.ret != 0xc2) )
     3.6          goto die;
     3.7 +    eip += sizeof(bug);
     3.8  
     3.9      id = bug.id & 3;
    3.10 -    if ( id == BUGFRAME_rsvd )
    3.11 -        goto die;
    3.12  
    3.13      if ( id == BUGFRAME_dump )
    3.14      {
    3.15          show_execution_state(regs);
    3.16 -        regs->eip += sizeof(bug);
    3.17 +        regs->eip = (unsigned long)eip;
    3.18          return EXCRET_fault_fixed;
    3.19      }
    3.20  
    3.21 -    /* BUG() or ASSERT(): decode the filename pointer and line number. */
    3.22 -    ASSERT((id == BUGFRAME_bug) || (id == BUGFRAME_assert));
    3.23 -    eip += sizeof(bug);
    3.24 +    /* WARN, BUG or ASSERT: decode the filename pointer and line number. */
    3.25      if ( !is_kernel(eip) ||
    3.26           __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
    3.27           memcmp(bug_str.mov, BUG_MOV_STR, sizeof(bug_str.mov)) )
    3.28          goto die;
    3.29 +    eip += sizeof(bug_str);
    3.30  
    3.31      filename = is_kernel(bug_str.str) ? (char *)bug_str.str : "<unknown>";
    3.32      lineno   = bug.id >> 2;
    3.33  
    3.34 +    if ( id == BUGFRAME_warn )
    3.35 +    {
    3.36 +        printk("Xen WARN at %.50s:%d\n", filename, lineno);
    3.37 +        show_execution_state(regs);
    3.38 +        regs->eip = (unsigned long)eip;
    3.39 +        return EXCRET_fault_fixed;
    3.40 +    }
    3.41 +
    3.42      if ( id == BUGFRAME_bug )
    3.43      {
    3.44          printk("Xen BUG at %.50s:%d\n", filename, lineno);
    3.45 @@ -668,13 +674,13 @@ asmlinkage int do_invalid_op(struct cpu_
    3.46          panic("Xen BUG at %.50s:%d\n", filename, lineno);
    3.47      }
    3.48  
    3.49 -    /* ASSERT(): decode the predicate string pointer. */
    3.50 +    /* ASSERT: decode the predicate string pointer. */
    3.51      ASSERT(id == BUGFRAME_assert);
    3.52 -    eip += sizeof(bug_str);
    3.53      if ( !is_kernel(eip) ||
    3.54           __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
    3.55           memcmp(bug_str.mov, BUG_MOV_STR, sizeof(bug_str.mov)) )
    3.56          goto die;
    3.57 +    eip += sizeof(bug_str);
    3.58  
    3.59      predicate = is_kernel(bug_str.str) ? (char *)bug_str.str : "<unknown>";
    3.60      printk("Assertion '%s' failed at %.50s:%d\n",
     4.1 --- a/xen/drivers/char/console.c	Tue Mar 27 14:50:17 2007 +0100
     4.2 +++ b/xen/drivers/char/console.c	Tue Mar 27 15:53:45 2007 +0100
     4.3 @@ -900,12 +900,18 @@ void panic(const char *fmt, ...)
     4.4  void __bug(char *file, int line)
     4.5  {
     4.6      console_start_sync();
     4.7 -    printk("BUG at %s:%d\n", file, line);
     4.8 +    printk("Xen BUG at %s:%d\n", file, line);
     4.9      dump_execution_state();
    4.10 -    panic("BUG at %s:%d\n", file, line);
    4.11 +    panic("Xen BUG at %s:%d\n", file, line);
    4.12      for ( ; ; ) ;
    4.13  }
    4.14  
    4.15 +void __warn(char *file, int line)
    4.16 +{
    4.17 +    printk("Xen WARN at %s:%d\n", file, line);
    4.18 +    dump_execution_state();
    4.19 +}
    4.20 +
    4.21  /*
    4.22   * Local variables:
    4.23   * mode: C
     5.1 --- a/xen/include/asm-ia64/bug.h	Tue Mar 27 14:50:17 2007 +0100
     5.2 +++ b/xen/include/asm-ia64/bug.h	Tue Mar 27 15:53:45 2007 +0100
     5.3 @@ -2,5 +2,6 @@
     5.4  #define __IA64_BUG_H__
     5.5  
     5.6  #define BUG() __bug(__FILE__, __LINE__)
     5.7 +#define WARN() __warn(__FILE__, __LINE__)
     5.8  
     5.9  #endif /* __IA64_BUG_H__ */
     6.1 --- a/xen/include/asm-ia64/linux-xen/asm/iosapic.h	Tue Mar 27 14:50:17 2007 +0100
     6.2 +++ b/xen/include/asm-ia64/linux-xen/asm/iosapic.h	Tue Mar 27 15:53:45 2007 +0100
     6.3 @@ -123,13 +123,6 @@ static inline void list_move(struct list
     6.4  
     6.5  #define move_irq(x)
     6.6  
     6.7 -#define WARN_ON(condition) do { \
     6.8 -	if (unlikely((condition)!=0)) { \
     6.9 -		printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
    6.10 -		dump_stack(); \
    6.11 -	} \
    6.12 -} while (0)
    6.13 -
    6.14  #ifdef nop
    6.15  #undef nop
    6.16  #endif
     7.1 --- a/xen/include/asm-powerpc/bug.h	Tue Mar 27 14:50:17 2007 +0100
     7.2 +++ b/xen/include/asm-powerpc/bug.h	Tue Mar 27 15:53:45 2007 +0100
     7.3 @@ -2,5 +2,6 @@
     7.4  #define __POWERPC_BUG_H__
     7.5  
     7.6  #define BUG() __bug(__FILE__, __LINE__)
     7.7 +#define WARN() __warn(__FILE__, __LINE__)
     7.8  
     7.9  #endif /* __POWERPC_BUG_H__ */
     8.1 --- a/xen/include/asm-powerpc/debugger.h	Tue Mar 27 14:50:17 2007 +0100
     8.2 +++ b/xen/include/asm-powerpc/debugger.h	Tue Mar 27 15:53:45 2007 +0100
     8.3 @@ -67,10 +67,6 @@ static inline void unimplemented(void)
     8.4  #endif
     8.5  }
     8.6  
     8.7 -extern void __warn(char *file, int line);
     8.8 -#define WARN() __warn(__FILE__, __LINE__)
     8.9 -#define WARN_ON(_p) do { if (_p) WARN(); } while ( 0 )
    8.10 -
    8.11  extern void __attn(void);
    8.12  #define ATTN() __attn();
    8.13  
     9.1 --- a/xen/include/asm-x86/bug.h	Tue Mar 27 14:50:17 2007 +0100
     9.2 +++ b/xen/include/asm-x86/bug.h	Tue Mar 27 15:53:45 2007 +0100
     9.3 @@ -14,8 +14,8 @@ struct bug_frame {
     9.4  } __attribute__((packed));
     9.5  
     9.6  #define BUGFRAME_dump   0
     9.7 -#define BUGFRAME_bug    1
     9.8 -#define BUGFRAME_assert 2
     9.9 -#define BUGFRAME_rsvd   3
    9.10 +#define BUGFRAME_warn   1
    9.11 +#define BUGFRAME_bug    2
    9.12 +#define BUGFRAME_assert 3
    9.13  
    9.14  #endif /* __X86_BUG_H__ */
    10.1 --- a/xen/include/asm-x86/x86_32/bug.h	Tue Mar 27 14:50:17 2007 +0100
    10.2 +++ b/xen/include/asm-x86/x86_32/bug.h	Tue Mar 27 15:53:45 2007 +0100
    10.3 @@ -12,6 +12,12 @@ struct bug_frame_str {
    10.4          "ud2 ; ret $%c0"                                \
    10.5          : : "i" (BUGFRAME_dump) )
    10.6  
    10.7 +#define WARN()                                          \
    10.8 +    asm volatile (                                      \
    10.9 +        "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
   10.10 +        : : "i" (BUGFRAME_warn | (__LINE__<<2)),        \
   10.11 +            "i" (__FILE__) )
   10.12 +
   10.13  #define BUG()                                           \
   10.14      asm volatile (                                      \
   10.15          "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
    11.1 --- a/xen/include/asm-x86/x86_64/bug.h	Tue Mar 27 14:50:17 2007 +0100
    11.2 +++ b/xen/include/asm-x86/x86_64/bug.h	Tue Mar 27 15:53:45 2007 +0100
    11.3 @@ -12,6 +12,12 @@ struct bug_frame_str {
    11.4          "ud2 ; ret $%c0"                                \
    11.5          : : "i" (BUGFRAME_dump) )
    11.6  
    11.7 +#define WARN()                                          \
    11.8 +    asm volatile (                                      \
    11.9 +        "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
   11.10 +        : : "i" (BUGFRAME_warn | (__LINE__<<2)),        \
   11.11 +            "i" (__FILE__) )
   11.12 +
   11.13  #define BUG()                                           \
   11.14      asm volatile (                                      \
   11.15          "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
    12.1 --- a/xen/include/xen/lib.h	Tue Mar 27 14:50:17 2007 +0100
    12.2 +++ b/xen/include/xen/lib.h	Tue Mar 27 15:53:45 2007 +0100
    12.3 @@ -10,8 +10,10 @@
    12.4  #include <asm/bug.h>
    12.5  
    12.6  void __bug(char *file, int line) __attribute__((noreturn));
    12.7 +void __warn(char *file, int line);
    12.8  
    12.9 -#define BUG_ON(_p) do { if (_p) BUG(); } while ( 0 )
   12.10 +#define BUG_ON(p)  do { if (p) BUG();  } while (0)
   12.11 +#define WARN_ON(p) do { if (p) WARN(); } while (0)
   12.12  
   12.13  /* Force a compilation error if condition is true */
   12.14  #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))