Index: 2007-01-31/xen/arch/powerpc/backtrace.c =================================================================== --- 2007-01-31.orig/xen/arch/powerpc/backtrace.c 2006-12-15 16:33:59.000000000 +0100 +++ 2007-01-31/xen/arch/powerpc/backtrace.c 2007-01-31 09:42:07.000000000 +0100 @@ -206,7 +206,7 @@ void show_backtrace_regs(struct cpu_user console_end_sync(); } -void __warn(char *file, int line) +void __warn(const char *file, int line) { ulong sp; ulong lr; Index: 2007-01-31/xen/arch/x86/mm/shadow/common.c =================================================================== --- 2007-01-31.orig/xen/arch/x86/mm/shadow/common.c 2007-01-31 09:36:44.000000000 +0100 +++ 2007-01-31/xen/arch/x86/mm/shadow/common.c 2007-01-31 09:42:07.000000000 +0100 @@ -940,6 +940,7 @@ mfn_t shadow_alloc(struct domain *d, * we might free up higher-level pages that the caller is working on. */ SHADOW_PRINTK("Can't allocate %i shadow pages!\n", 1 << order); BUG(); + return _mfn(0); } Index: 2007-01-31/xen/arch/x86/mm/shadow/multi.c =================================================================== --- 2007-01-31.orig/xen/arch/x86/mm/shadow/multi.c 2007-01-31 09:36:54.000000000 +0100 +++ 2007-01-31/xen/arch/x86/mm/shadow/multi.c 2007-01-31 09:42:07.000000000 +0100 @@ -3160,7 +3160,7 @@ sh_update_linear_entries(struct vcpu *v) */ { l2_pgentry_t *l2e, new_l2e; - shadow_l3e_t *guest_l3e = NULL, *shadow_l3e; + shadow_l3e_t *guest_l3e = NULL, *shadow_l3e = NULL; int i; int unmap_l2e = 0; Index: 2007-01-31/xen/arch/x86/traps.c =================================================================== --- 2007-01-31.orig/xen/arch/x86/traps.c 2007-01-31 09:41:54.000000000 +0100 +++ 2007-01-31/xen/arch/x86/traps.c 2007-01-31 09:42:07.000000000 +0100 @@ -635,14 +635,50 @@ asmlinkage int do_invalid_op(struct cpu_ if ( unlikely(!guest_mode(regs)) ) { - char sig[5]; - /* Signature (ud2; .ascii "dbg") indicates dump state and continue. */ - if ( (__copy_from_user(sig, (char *)regs->eip, sizeof(sig)) == 0) && - (memcmp(sig, "\xf\xb""dbg", sizeof(sig)) == 0) ) - { - show_execution_state(regs); - regs->eip += sizeof(sig); - return EXCRET_fault_fixed; + struct bug_frame f; + + if ( (__copy_from_user(&f, (char *)regs->eip, sizeof(f)) == 0) && + f.ud2[0] == 0x0f && f.ud2[1] == 0x0b && f.ret == 0xc2 ) + { + const char *text = NULL; + char file[40]; + + switch ( f.id ) + { + case bug_bug: + text = "BUG"; + break; + case bug_warn: + text = "Badness"; + break; + case bug_dump_state: + text = "State"; + break; + case bug_crash_dom: + text = "domain_crash called"; + break; + } + if ( text ) + { + const void *ptr; + + ptr = &((const struct bug_frame *)regs->eip)->id + f.file_rel; + if ( __addr_ok(ptr) || + __copy_from_user(file, ptr, sizeof(file) - 1) ) + text = NULL; + else + file[sizeof(file) - 1] = 0; + } + if ( text ) + { + printk("%s at %s:%d\n", text, file, f.line); + if ( f.id != bug_bug ) + { + show_execution_state(regs); + regs->eip += sizeof(f); + return EXCRET_fault_fixed; + } + } } DEBUGGER_trap_fatal(TRAP_invalid_op, regs); show_execution_state(regs); Index: 2007-01-31/xen/common/keyhandler.c =================================================================== --- 2007-01-31.orig/xen/common/keyhandler.c 2007-01-31 09:29:10.000000000 +0100 +++ 2007-01-31/xen/common/keyhandler.c 2007-01-31 09:42:07.000000000 +0100 @@ -94,7 +94,7 @@ static void show_handlers(unsigned char static void __dump_execstate(void *unused) { - dump_execution_state(); + DUMP_STATE(); } static void dump_registers(unsigned char key, struct cpu_user_regs *regs) Index: 2007-01-31/xen/drivers/char/console.c =================================================================== --- 2007-01-31.orig/xen/drivers/char/console.c 2006-12-15 16:33:59.000000000 +0100 +++ 2007-01-31/xen/drivers/char/console.c 2007-01-31 09:42:07.000000000 +0100 @@ -880,15 +880,21 @@ void panic(const char *fmt, ...) } } -void __bug(char *file, int line) +void __bug(const char *file, int line) { console_start_sync(); printk("BUG at %s:%d\n", file, line); - dump_execution_state(); + DUMP_STATE(); panic("BUG at %s:%d\n", file, line); for ( ; ; ) ; } +void __warn(const char *file, int line) __attribute__((__weak__)); +void __warn(const char *file, int line) +{ + printk("Badness at %s:%d\n", file, line); +} + /* * Local variables: * mode: C Index: 2007-01-31/xen/include/asm-ia64/bug.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2007-01-31/xen/include/asm-ia64/bug.h 2007-01-31 09:42:07.000000000 +0100 @@ -0,0 +1,6 @@ +#ifndef __ASM_IA64_BUG_H__ +#define __ASM_IA64_BUG_H__ + +#define DUMP_STATE() printk("FIXME: implement ia64 dump_execution_state()\n"); + +#endif /* __ASM_IA64_BUG_H__ */ Index: 2007-01-31/xen/include/asm-ia64/linux-xen/asm/iosapic.h =================================================================== --- 2007-01-31.orig/xen/include/asm-ia64/linux-xen/asm/iosapic.h 2006-12-13 11:15:55.000000000 +0100 +++ 2007-01-31/xen/include/asm-ia64/linux-xen/asm/iosapic.h 2007-01-31 09:42:07.000000000 +0100 @@ -123,11 +123,10 @@ 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(); \ - } \ +#undef WARN +#define WARN() do { \ + printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \ + dump_stack(); \ } while (0) #ifdef nop Index: 2007-01-31/xen/include/asm-ia64/xenprocessor.h =================================================================== --- 2007-01-31.orig/xen/include/asm-ia64/xenprocessor.h 2006-12-13 11:15:55.000000000 +0100 +++ 2007-01-31/xen/include/asm-ia64/xenprocessor.h 2007-01-31 09:42:07.000000000 +0100 @@ -237,6 +237,4 @@ typedef union { u64 itir; } ia64_itir_t; -#define dump_execution_state() printk("FIXME: implement ia64 dump_execution_state()\n"); - #endif // _ASM_IA64_XENPROCESSOR_H Index: 2007-01-31/xen/include/asm-powerpc/bug.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2007-01-31/xen/include/asm-powerpc/bug.h 2007-01-31 09:42:07.000000000 +0100 @@ -0,0 +1,7 @@ +#ifndef __ASM_PPC_BUG_H__ +#define __ASM_PPC_BUG_H__ + +extern void dump_execution_state(void); +#define DUMP_STATE() dump_execution_state() + +#endif /* __ASM_PPC_BUG_H__ */ Index: 2007-01-31/xen/include/asm-powerpc/debugger.h =================================================================== --- 2007-01-31.orig/xen/include/asm-powerpc/debugger.h 2006-12-15 16:33:59.000000000 +0100 +++ 2007-01-31/xen/include/asm-powerpc/debugger.h 2007-01-31 09:42:07.000000000 +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(); Index: 2007-01-31/xen/include/asm-x86/bug.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2007-01-31/xen/include/asm-x86/bug.h 2007-01-31 09:42:07.000000000 +0100 @@ -0,0 +1,60 @@ +#ifndef __ASM_X86_BUG_H__ +#define __ASM_X86_BUG_H__ + +enum bug_id { + bug_bug = 0xb8, + bug_warn, + bug_dump_state, + bug_crash_dom +} __attribute__((__packed__)); + +struct bug_frame { + unsigned char ud2[2]; + enum bug_id id; + signed int file_rel; + unsigned char ret; + unsigned short line; +} __attribute__((__packed__)); + +/* NB. These need interrupts enabled else we end up in fatal_trap(). */ + +#define BUG() __asm__ __volatile__( \ + "pushf\n\t" \ + "sti\n\t" \ + "ud2\n\t" \ + "movl $%c0-.,%%eax\n\t" \ + "ret $%c1\n\t" \ + "popf" \ + : : "i" (__FILE__), "i" (__LINE__)) + +#define WARN() __asm__ __volatile__( \ + "pushf\n\t" \ + "sti\n\t" \ + "ud2\n\t" \ + "movl $%c0-.,%%ecx\n\t" \ + "ret $%c1\n\t" \ + "popf" \ + : : "i" (__FILE__), "i" (__LINE__)) + +#define DUMP_STATE() __asm__ __volatile__( \ + "pushf\n\t" \ + "sti\n\t" \ + "ud2\n\t" \ + "movl $%c0-.,%%edx\n\t" \ + "ret $%c1\n\t" \ + "popf" \ + : : "i" (__FILE__), "i" (__LINE__)) + +#define CRASH_DOM(d) do { \ + __asm__ __volatile__( \ + "pushf\n\t" \ + "sti\n\t" \ + "ud2\n\t" \ + "movl $%c0-.,%%ebx\n\t" \ + "ret $%c1\n\t" \ + "popf" \ + : : "i" (__FILE__), "i" (__LINE__)); \ + __domain_crash(d); \ + } while (0) + +#endif /* __ASM_X86_BUG_H__ */ Index: 2007-01-31/xen/include/asm-x86/processor.h =================================================================== --- 2007-01-31.orig/xen/include/asm-x86/processor.h 2007-01-31 09:29:08.000000000 +0100 +++ 2007-01-31/xen/include/asm-x86/processor.h 2007-01-31 09:42:07.000000000 +0100 @@ -565,11 +565,6 @@ void compat_show_guest_stack(struct cpu_ #define compat_show_guest_stack(regs, lines) ((void)0) #endif -/* Dumps current register and stack state. */ -#define dump_execution_state() \ - /* NB. Needs interrupts enabled else we end up in fatal_trap(). */ \ - __asm__ __volatile__ ( "pushf ; sti ; ud2 ; .ascii \"dbg\" ; popf" ) - extern void mtrr_ap_init(void); extern void mtrr_bp_init(void); Index: 2007-01-31/xen/include/xen/lib.h =================================================================== --- 2007-01-31.orig/xen/include/xen/lib.h 2007-01-08 14:16:35.000000000 +0100 +++ 2007-01-31/xen/include/xen/lib.h 2007-01-31 09:42:07.000000000 +0100 @@ -7,10 +7,26 @@ #include #include #include +#include -extern void __bug(char *file, int line) __attribute__((noreturn)); +#ifndef BUG +extern void __bug(const char *file, int line) __attribute__((noreturn)); #define BUG() __bug(__FILE__, __LINE__) -#define BUG_ON(_p) do { if (_p) BUG(); } while ( 0 ) +#endif + +#ifndef WARN +extern void __warn(const char *file, int line); +#define WARN() __warn(__FILE__, __LINE__) +#endif + +#ifndef CRASH_DOM +#define CRASH_DOM(d) domain_crash(d) +#endif + +#define BUG_ON(_p) do { if (unlikely(_p)) BUG(); } while ( 0 ) +#define WARN_ON(_p) do { if (unlikely(_p)) WARN(); } while ( 0 ) +#define DUMP_STATE_ON(_p) do { if (unlikely(_p)) DUMP_STATE(); } while ( 0 ) +#define CRASH_DOM_ON(_d, _p) do { if (unlikely(_p)) CRASH_DOM(_d); } while ( 0 ) /* Force a compilation error if condition is true */ #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))