ia64/xen-unstable

changeset 14057:3c581edac93a

Merge
author Tim Deegan <Tim.Deegan@xensource.com>
date Wed Feb 21 14:44:09 2007 +0000 (2007-02-21)
parents 47db75f8cc76 43e9952b07ea
children 97826d77bd4d
files
line diff
     1.1 --- a/xen/arch/x86/extable.c	Tue Feb 13 12:30:23 2007 -0500
     1.2 +++ b/xen/arch/x86/extable.c	Wed Feb 21 14:44:09 2007 +0000
     1.3 @@ -1,14 +1,9 @@
     1.4  
     1.5  #include <xen/config.h>
     1.6 +#include <xen/perfc.h>
     1.7  #include <xen/spinlock.h>
     1.8  #include <asm/uaccess.h>
     1.9  
    1.10 -#ifdef PERF_COUNTERS
    1.11 -#include <xen/sched.h>
    1.12 -#include <xen/perfc.h>
    1.13 -#include <asm/current.h>
    1.14 -#endif
    1.15 -
    1.16  extern struct exception_table_entry __start___ex_table[];
    1.17  extern struct exception_table_entry __stop___ex_table[];
    1.18  extern struct exception_table_entry __start___pre_ex_table[];
    1.19 @@ -74,10 +69,10 @@ search_pre_exception_table(struct cpu_us
    1.20      unsigned long addr = (unsigned long)regs->eip;
    1.21      unsigned long fixup = search_one_table(
    1.22          __start___pre_ex_table, __stop___pre_ex_table-1, addr);
    1.23 -    dprintk(XENLOG_INFO, "Pre-exception: %p -> %p\n", _p(addr), _p(fixup));
    1.24 -#ifdef PERF_COUNTERS
    1.25      if ( fixup )
    1.26 +    {
    1.27 +        dprintk(XENLOG_INFO, "Pre-exception: %p -> %p\n", _p(addr), _p(fixup));
    1.28          perfc_incrc(exception_fixed);
    1.29 -#endif
    1.30 +    }
    1.31      return fixup;
    1.32  }
     2.1 --- a/xen/arch/x86/traps.c	Tue Feb 13 12:30:23 2007 -0500
     2.2 +++ b/xen/arch/x86/traps.c	Wed Feb 21 14:44:09 2007 +0000
     2.3 @@ -618,40 +618,77 @@ static int emulate_forced_invalid_op(str
     2.4  
     2.5  asmlinkage int do_invalid_op(struct cpu_user_regs *regs)
     2.6  {
     2.7 -    int rc;
     2.8 +    struct bug_frame bug;
     2.9 +    struct bug_frame_str bug_str;
    2.10 +    char *filename, *predicate, *eip = (char *)regs->eip;
    2.11 +    int rc, id, lineno;
    2.12  
    2.13      DEBUGGER_trap_entry(TRAP_invalid_op, regs);
    2.14  
    2.15 -    if ( unlikely(!guest_mode(regs)) )
    2.16 +    if ( likely(guest_mode(regs)) )
    2.17      {
    2.18 -        struct bug_frame bug;
    2.19 -        if ( is_kernel(regs->eip) &&
    2.20 -             (__copy_from_user(&bug, (char *)regs->eip, sizeof(bug)) == 0) &&
    2.21 -             (memcmp(bug.ud2, "\xf\xb",    sizeof(bug.ud2)) == 0) &&
    2.22 -             (memcmp(bug.mov, BUG_MOV_STR, sizeof(bug.mov)) == 0) &&
    2.23 -             (bug.ret == 0xc2) )
    2.24 -        {
    2.25 -            char *filename = (char *)bug.filename;
    2.26 -            unsigned int line = bug.line & 0x7fff;
    2.27 -            int is_bug = !(bug.line & 0x8000);
    2.28 -            printk("Xen %s at %.50s:%d\n",
    2.29 -                   is_bug ? "BUG" : "State Dump", filename, line);
    2.30 -            if ( !is_bug )
    2.31 -            {
    2.32 -                show_execution_state(regs);
    2.33 -                regs->eip += sizeof(bug);
    2.34 -                return EXCRET_fault_fixed;
    2.35 -            }
    2.36 -        }
    2.37 +        if ( (rc = emulate_forced_invalid_op(regs)) != 0 )
    2.38 +            return rc;
    2.39 +        return do_guest_trap(TRAP_invalid_op, regs, 0);
    2.40 +    }
    2.41 +
    2.42 +    if ( !is_kernel(eip) ||
    2.43 +         __copy_from_user(&bug, eip, sizeof(bug)) ||
    2.44 +         memcmp(bug.ud2, "\xf\xb", sizeof(bug.ud2)) ||
    2.45 +         (bug.ret != 0xc2) )
    2.46 +        goto die;
    2.47 +
    2.48 +    id = bug.id & 3;
    2.49 +    if ( id == BUGFRAME_rsvd )
    2.50 +        goto die;
    2.51 +
    2.52 +    if ( id == BUGFRAME_dump )
    2.53 +    {
    2.54 +        show_execution_state(regs);
    2.55 +        regs->eip += sizeof(bug);
    2.56 +        return EXCRET_fault_fixed;
    2.57 +    }
    2.58 +
    2.59 +    /* BUG() or ASSERT(): decode the filename pointer and line number. */
    2.60 +    ASSERT((id == BUGFRAME_bug) || (id == BUGFRAME_assert));
    2.61 +    eip += sizeof(bug);
    2.62 +    if ( !is_kernel(eip) ||
    2.63 +         __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
    2.64 +         memcmp(bug_str.mov, BUG_MOV_STR, sizeof(bug_str.mov)) )
    2.65 +        goto die;
    2.66 +
    2.67 +    filename = is_kernel(bug_str.str) ? (char *)bug_str.str : "<unknown>";
    2.68 +    lineno   = bug.id >> 2;
    2.69 +
    2.70 +    if ( id == BUGFRAME_bug )
    2.71 +    {
    2.72 +        printk("Xen BUG at %.50s:%d\n", filename, lineno);
    2.73          DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
    2.74          show_execution_state(regs);
    2.75 -        panic("FATAL TRAP: vector = %d (invalid opcode)\n", TRAP_invalid_op);
    2.76 +        panic("Xen BUG at %.50s:%d\n", filename, lineno);
    2.77      }
    2.78  
    2.79 -    if ( (rc = emulate_forced_invalid_op(regs)) != 0 )
    2.80 -        return rc;
    2.81 +    /* ASSERT(): decode the predicate string pointer. */
    2.82 +    ASSERT(id == BUGFRAME_assert);
    2.83 +    eip += sizeof(bug_str);
    2.84 +    if ( !is_kernel(eip) ||
    2.85 +         __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
    2.86 +         memcmp(bug_str.mov, BUG_MOV_STR, sizeof(bug_str.mov)) )
    2.87 +        goto die;
    2.88  
    2.89 -    return do_guest_trap(TRAP_invalid_op, regs, 0);
    2.90 +    predicate = is_kernel(bug_str.str) ? (char *)bug_str.str : "<unknown>";
    2.91 +    printk("Assertion '%s' failed at %.50s:%d\n",
    2.92 +           predicate, filename, lineno);
    2.93 +    DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
    2.94 +    show_execution_state(regs);
    2.95 +    panic("Assertion '%s' failed at %.50s:%d\n",
    2.96 +          predicate, filename, lineno);
    2.97 +
    2.98 + die:
    2.99 +    DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
   2.100 +    show_execution_state(regs);
   2.101 +    panic("FATAL TRAP: vector = %d (invalid opcode)\n", TRAP_invalid_op);
   2.102 +    return 0;
   2.103  }
   2.104  
   2.105  asmlinkage int do_int3(struct cpu_user_regs *regs)
     3.1 --- a/xen/include/asm-x86/bug.h	Tue Feb 13 12:30:23 2007 -0500
     3.2 +++ b/xen/include/asm-x86/bug.h	Wed Feb 21 14:44:09 2007 +0000
     3.3 @@ -7,7 +7,15 @@
     3.4  #include <asm/x86_32/bug.h>
     3.5  #endif
     3.6  
     3.7 -#define BUG()                  __BUG(__FILE__, __LINE__)
     3.8 -#define dump_execution_state() __BUG(__FILE__, __LINE__ | 0x8000)
     3.9 +struct bug_frame {
    3.10 +    unsigned char ud2[2];
    3.11 +    unsigned char ret;
    3.12 +    unsigned short id; /* BUGFRAME_??? */
    3.13 +} __attribute__((packed));
    3.14 +
    3.15 +#define BUGFRAME_dump   0
    3.16 +#define BUGFRAME_bug    1
    3.17 +#define BUGFRAME_assert 2
    3.18 +#define BUGFRAME_rsvd   3
    3.19  
    3.20  #endif /* __X86_BUG_H__ */
     4.1 --- a/xen/include/asm-x86/x86_32/bug.h	Tue Feb 13 12:30:23 2007 -0500
     4.2 +++ b/xen/include/asm-x86/x86_32/bug.h	Wed Feb 21 14:44:09 2007 +0000
     4.3 @@ -1,19 +1,28 @@
     4.4  #ifndef __X86_32_BUG_H__
     4.5  #define __X86_32_BUG_H__
     4.6  
     4.7 -struct bug_frame {
     4.8 -    unsigned char ud2[2];
     4.9 +struct bug_frame_str {
    4.10      unsigned char mov[1];
    4.11 -    unsigned long filename;
    4.12 -    unsigned char ret;
    4.13 -    unsigned short line;
    4.14 +    unsigned long str;
    4.15  } __attribute__((packed));
    4.16 -
    4.17  #define BUG_MOV_STR "\xbc"
    4.18  
    4.19 -#define __BUG(file, line)                               \
    4.20 +#define dump_execution_state()                          \
    4.21      asm volatile (                                      \
    4.22 -        "ud2 ; .byte 0xbc ; .long %c1 ; ret $%c0"       \
    4.23 -        : : "i" (line), "i" (file) )
    4.24 +        "ud2 ; ret $%c0"                                \
    4.25 +        : : "i" (BUGFRAME_dump) )
    4.26 +
    4.27 +#define BUG()                                           \
    4.28 +    asm volatile (                                      \
    4.29 +        "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
    4.30 +        : : "i" (BUGFRAME_bug | (__LINE__<<2)),         \
    4.31 +            "i" (__FILE__) )
    4.32 +
    4.33 +#define assert_failed(p)                                \
    4.34 +    asm volatile (                                      \
    4.35 +        "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
    4.36 +        " ; .byte 0xbc ; .long %c2"                     \
    4.37 +        : : "i" (BUGFRAME_assert | (__LINE__<<2)),      \
    4.38 +            "i" (__FILE__), "i" (#p) )
    4.39  
    4.40  #endif /* __X86_32_BUG_H__ */
     5.1 --- a/xen/include/asm-x86/x86_64/bug.h	Tue Feb 13 12:30:23 2007 -0500
     5.2 +++ b/xen/include/asm-x86/x86_64/bug.h	Wed Feb 21 14:44:09 2007 +0000
     5.3 @@ -1,19 +1,28 @@
     5.4  #ifndef __X86_64_BUG_H__
     5.5  #define __X86_64_BUG_H__
     5.6  
     5.7 -struct bug_frame {
     5.8 -    unsigned char ud2[2];
     5.9 +struct bug_frame_str {
    5.10      unsigned char mov[2];
    5.11 -    unsigned long filename;
    5.12 -    unsigned char ret;
    5.13 -    unsigned short line;
    5.14 +    unsigned long str;
    5.15  } __attribute__((packed));
    5.16 -
    5.17  #define BUG_MOV_STR "\x48\xbc"
    5.18  
    5.19 -#define __BUG(file, line)                               \
    5.20 +#define dump_execution_state()                          \
    5.21      asm volatile (                                      \
    5.22 -        "ud2 ; .byte 0x48,0xbc ; .quad %c1 ; ret $%c0"  \
    5.23 -        : : "i" (line), "i" (file) )
    5.24 +        "ud2 ; ret $%c0"                                \
    5.25 +        : : "i" (BUGFRAME_dump) )
    5.26 +
    5.27 +#define BUG()                                           \
    5.28 +    asm volatile (                                      \
    5.29 +        "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
    5.30 +        : : "i" (BUGFRAME_bug | (__LINE__<<2)),         \
    5.31 +            "i" (__FILE__) )
    5.32 +
    5.33 +#define assert_failed(p)                                \
    5.34 +    asm volatile (                                      \
    5.35 +        "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
    5.36 +        " ; .byte 0x48,0xbc ; .quad %c2"                \
    5.37 +        : : "i" (BUGFRAME_assert | (__LINE__<<2)),      \
    5.38 +            "i" (__FILE__), "i" (#p) )
    5.39  
    5.40  #endif /* __X86_64_BUG_H__ */
     6.1 --- a/xen/include/xen/lib.h	Tue Feb 13 12:30:23 2007 -0500
     6.2 +++ b/xen/include/xen/lib.h	Wed Feb 21 14:44:09 2007 +0000
     6.3 @@ -16,18 +16,20 @@ void __bug(char *file, int line) __attri
     6.4  /* Force a compilation error if condition is true */
     6.5  #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))
     6.6  
     6.7 +#ifndef assert_failed
     6.8 +#define assert_failed(p)                                        \
     6.9 +do {                                                            \
    6.10 +    printk("Assertion '%s' failed, line %d, file %s\n", #p ,    \
    6.11 +                   __LINE__, __FILE__);                         \
    6.12 +    BUG();                                                      \
    6.13 +} while (0)
    6.14 +#endif
    6.15 +
    6.16  #ifndef NDEBUG
    6.17 -#define ASSERT(_p)                                                      \
    6.18 -    do {                                                                \
    6.19 -        if ( unlikely(!(_p)) )                                          \
    6.20 -        {                                                               \
    6.21 -            printk("Assertion '%s' failed, line %d, file %s\n", #_p ,   \
    6.22 -                   __LINE__, __FILE__);                                 \
    6.23 -            BUG();                                                      \
    6.24 -        }                                                               \
    6.25 -    } while ( 0 )
    6.26 +#define ASSERT(p) \
    6.27 +    do { if ( unlikely(!(p)) ) assert_failed(p); } while (0)
    6.28  #else
    6.29 -#define ASSERT(_p) ((void)0)
    6.30 +#define ASSERT(p) ((void)0)
    6.31  #endif
    6.32  
    6.33  #define SWAP(_a, _b) \