linux/bug.h and asm/bug.h
As the number of bug-related macros grows, this makes sense.
1) Introduce linux/bug.h and #include it from linux/kernel.h so noone breaks.
2) Move BUG() macro from asm*/page.h to asm*/bug.h, and #include it.
Thanks,
Rusty.
include/linux/bug.h +21 -0
@@ -0,0 +1,21 @@ +#ifndef _LINUX_BUG_H +#define _LINUX_BUG_H +#include <linux/compiler.h> /* likely/unlikely */ +#include <asm/bug.h> /* BUG() */ + +extern void dump_stack (void ); + +#define BUG_ON (condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) +#define WARN_ON (condition) do { \ + if (unlikely((condition)!=0)) { \ + printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \ + dump_stack(); \ + } \ +} while (0) + +/* Fail at build-time (condition must be a constant expression: +BUILD_BUG does not exist). */ +extern void BUILD_BUG (void ); +#define BUILD_BUG_ON (condition) do { if (condition) BUILD_BUG(); } while(0) + +#endif /* _LINUX_BUG_H */
include/linux/kernel.h +1 -14
@@ -11,7 +11,7 @@#include <linux/linkage.h> #include <linux/stddef.h> #include <linux/types.h> -#include <linux/compiler.h> +#include <linux/bug.h> #include <asm/byteorder.h> /* Optimization barrier */
@@ -103,8 +103,6 @@ extern const char *print_tainted(void);#define TAINT_FORCED_MODULE (1<<1)#define TAINT_UNSAFE_SMP (1<<2) -extern void dump_stack (void ); -#if DEBUG #define pr_debug(fmt,arg...) \ printk(KERN_DEBUG fmt,##arg)
@@ -199,17 +197,6 @@ struct sysinfo {char _f[20 -2 *sizeof (long )-sizeof (int )];/* Padding: libc5 uses this.. */ }; -#define BUG_ON (condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) -#define WARN_ON (condition) do { \ - if (unlikely((condition)!=0)) { \ - printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \ - dump_stack(); \ - } \ -} while (0) - -extern void BUILD_BUG (void ); -#define BUILD_BUG_ON (condition) do { if (condition) BUILD_BUG(); } while(0) -/* Trap pasters of __FUNCTION__ at compile-time */ #if __GNUC__ >2 || __GNUC_MINOR__ >=95 #define __FUNCTION__ (__func__)
include/asm-alpha/bug.h +11 -0
@@ -0,0 +1,11 @@ +#ifndef _ALPHA_BUG_H +#define _ALPHA_BUG_H +#include <asm/pal.h> + +/* ??? Would be nice to use .gprel32 here, but we can't be sure that the +function loaded the GP, so this could fail in modules. */ +#define BUG () \ + __asm__ __volatile__("call_pal %0 # bugchk\n\t"".long %1\n\t.8byte %2" \ + : : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__)) + +#endif /* _ALPHA_BUG_H */
include/asm-alpha/page.h +1 -6
@@ -2,6 +2,7 @@#define _ALPHA_PAGE_H#include <asm/pal.h> +#include <asm/bug.h> /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 13
@@ -59,12 +60,6 @@ typedef unsigned long pgprot_t;#endif /* STRICT_MM_TYPECHECKS */ -/* ??? Would be nice to use .gprel32 here, but we can't be sure that the -function loaded the GP, so this could fail in modules. */ -#define BUG () \ - __asm__ __volatile__("call_pal %0 # bugchk\n\t"".long %1\n\t.8byte %2" \ - : : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__)) -#define PAGE_BUG (page) BUG()/* Pure 2^n version of get_order */
include/asm-arm/bug.h +20 -0
@@ -0,0 +1,20 @@ +#ifndef _ASMARM_BUG_H +#define _ASMARM_BUG_H +#include <linux/config.h> + +#ifdef CONFIG_DEBUG_BUGVERBOSE +extern void __bug (const char *file,int line,void *data); + +/* give file/line information */ +#define BUG () __bug(__FILE__, __LINE__, NULL) +#define PAGE_BUG (page) __bug(__FILE__, __LINE__, page) + +#else + +/* these just cause an oops */ +#define BUG () (*(int *)0 = 0) +#define PAGE_BUG (page) (*(int *)0 = 0) + +#endif + +#endif /* _ASMARM_BUG_H */
include/asm-arm/page.h +1 -15
@@ -7,6 +7,7 @@#ifndef __ASSEMBLY__#include <asm/glue.h> +#include <asm/bug.h> /* * User Space Model
@@ -160,21 +161,6 @@ typedef unsigned long pgprot_t; #ifdef __KERNEL__ #ifndef __ASSEMBLY__ -#ifdef CONFIG_DEBUG_BUGVERBOSE -extern void __bug(const char *file, int line, void *data); - -/* give file/line information */ -#define BUG() __bug(__FILE__, __LINE__, NULL) -#define PAGE_BUG(page) __bug(__FILE__, __LINE__, page) - -#else - -/* these just cause an oops */ -#define BUG() (*(int *)0 = 0) -#define PAGE_BUG(page) (*(int *)0 = 0) - -#endif - /* Pure 2^n version of get_order */ static inline int get_order(unsigned long size) {
include/asm-cris/bug.h +8 -0
@@ -0,0 +1,8 @@ +#ifndef _CRIS_BUG_H +#define _CRIS_BUG_H + +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ +} while (0) + +#endif /* _CRIS_BUG_H */
include/asm-cris/page.h +1 -8
@@ -3,6 +3,7 @@#include <linux/config.h> #include <asm/mmu.h> +#include <asm/bug.h> /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 13
@@ -70,18 +71,10 @@ typedef unsigned long pgprot_t;#define PAGE_OFFSET KSEG_C/* kseg_c is mapped to physical ram */ #endif -#ifndef __ASSEMBLY__ - -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ -} while (0) -#define PAGE_BUG (page) do { \ BUG(); \ } while (0) -#endif /* __ASSEMBLY__ */ -/* macros to convert between really physical and virtual addresses * by stripping a selected bit, we can convert between KSEG_x and 0x40000000 where * the DRAM really resides
include/asm-i386/bug.h +20 -0
@@ -0,0 +1,20 @@ +#ifndef _I386_BUG_H +#define _I386_BUG_H +/* +* Tell the user there is some problem. Beep too, so we can +* see^H^H^Hhear bugs in early bootup as well! +* The offending file and line are encoded after the "officially +* undefined" opcode for parsing in the trap handler. +*/ + +#if 1 /* Set to zero for a slightly smaller kernel */ +#define BUG () \ + __asm__ __volatile__( "ud2\n" \ + "\t.word %c0\n" \ + "\t.long %c1\n" \ + : : "i" (__LINE__), "i" (__FILE__)) +#else +#define BUG () __asm__ __volatile__("ud2\n") +#endif + +#endif /* _I386_BUG_H */
include/asm-i386/page.h +1 -17
@@ -13,6 +13,7 @@#ifndef __ASSEMBLY__#include <linux/config.h> +#include <asm/bug.h> #ifdef CONFIG_X86_USE_3DNOW
@@ -99,23 +100,6 @@ typedef struct { unsigned long pgprot; }#ifndef __ASSEMBLY__ -/* -* Tell the user there is some problem. Beep too, so we can -* see^H^H^Hhear bugs in early bootup as well! -* The offending file and line are encoded after the "officially -* undefined" opcode for parsing in the trap handler. -*/ - -#if 1 /* Set to zero for a slightly smaller kernel */ -#define BUG () \ - __asm__ __volatile__( "ud2\n" \ - "\t.word %c0\n" \ - "\t.long %c1\n" \ - : : "i" (__LINE__), "i" (__FILE__)) -#else -#define BUG () __asm__ __volatile__("ud2\n") -#endif -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-ia64/bug.h +11 -0
@@ -0,0 +1,11 @@ +#ifndef _ASM_IA64_BUG_H +#define _ASM_IA64_BUG_H + +#if (__GNUC__ >3 ) || (__GNUC__ ==3 && __GNUC_MINOR__ >=1 ) +# define ia64_abort () __builtin_trap() +#else +# define ia64_abort () (*(volatile int *) 0 = 0) +#endif +#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0) + +#endif /* _ASM_IA64_BUG_H */
include/asm-ia64/page.h +1 -6
@@ -10,6 +10,7 @@#include <linux/config.h> #include <asm/types.h> +#include <asm/bug.h> /* * PAGE_SHIFT determines the actual kernel page size.
@@ -122,12 +123,6 @@ typedef union ia64_va {# define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)#endif -#if (__GNUC__ >3 ) || (__GNUC__ ==3 && __GNUC_MINOR__ >=1 ) -# define ia64_abort () __builtin_trap() -#else -# define ia64_abort () (*(volatile int *) 0 = 0) -#endif -#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0)#define PAGE_BUG (page) do { BUG(); } while (0) static __inline__ int
include/asm-m68k/bug.h +24 -0
@@ -0,0 +1,24 @@ +#ifndef _M68K_BUG_H +#define _M68K_BUG_H + +#include <linux/config.h> + +#ifdef CONFIG_DEBUG_BUGVERBOSE +#ifndef CONFIG_SUN3 +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + asm volatile("illegal"); \ +} while (0) +#else +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + panic("BUG!"); \ +} while (0) +#endif +#else +#define BUG () do { \ + asm volatile("illegal"); \ +} while (0) +#endif + +#endif /* _M68K_BUG_H */
include/asm-m68k/page.h +1 -18
@@ -16,6 +16,7 @@#ifdef __KERNEL__#include <asm/setup.h> +#include <asm/bug.h> #if PAGE_SHIFT <13 #define THREAD_SIZE (8192)
@@ -177,24 +178,6 @@ static inline void *__va(unsigned long x#define virt_addr_valid (kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)#define pfn_valid (pfn) virt_addr_valid(pfn_to_virt(pfn)) -#ifdef CONFIG_DEBUG_BUGVERBOSE -#ifndef CONFIG_SUN3 -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - asm volatile("illegal"); \ -} while (0) -#else -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - panic("BUG!"); \ -} while (0) -#endif -#else -#define BUG () do { \ - asm volatile("illegal"); \ -} while (0) -#endif -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-mips/bug.h +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ASM_BUG_H +#define __ASM_BUG_H + +#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0) + +#endif /* __ASM_BUG_H */
include/asm-mips/page.h +1 -1
@@ -17,10 +17,10 @@#define PAGE_MASK (~(PAGE_SIZE-1))#ifdef __KERNEL__ +#include <asm/bug.h> #ifndef _LANGUAGE_ASSEMBLY -#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0)#define PAGE_BUG (page) do { BUG(); } while (0)extern void (*_clear_page)(void * page);
include/asm-mips64/bug.h +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_BUG_H +#define _ASM_BUG_H + +#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0) + +#endif /* _ASM_BUG_H */
include/asm-mips64/page.h +1 -1
@@ -10,6 +10,7 @@#define _ASM_PAGE_H#include <linux/config.h> +#include <asm/bug.h> /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 12
@@ -20,7 +21,6 @@#ifndef _LANGUAGE_ASSEMBLY -#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0)#define PAGE_BUG (page) do { BUG(); } while (0)extern void (*_clear_page)(void * page);
include/asm-parisc/bug.h +14 -0
@@ -0,0 +1,14 @@ +#ifndef _PARISC_BUG_H +#define _PARISC_BUG_H + +/* +* Tell the user there is some problem. Beep too, so we can +* see^H^H^Hhear bugs in early bootup as well! +* +* We don't beep yet. prumpf +*/ +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ +} while (0) + +#endif /* _PARISC_BUG_H */
include/asm-parisc/page.h +1 -10
@@ -10,6 +10,7 @@#ifndef __ASSEMBLY__#include <asm/cache.h> +#include <asm/bug.h> #define clear_page (page) memset((void *)(page), 0, PAGE_SIZE)#define copy_page (to,from) copy_user_page_asm((void *)(to), (void *)(from))
@@ -86,16 +87,6 @@ extern int npmem_ranges;/* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN (addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) -/* -* Tell the user there is some problem. Beep too, so we can -* see^H^H^Hhear bugs in early bootup as well! -* -* We don't beep yet. prumpf -*/ -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ -} while (0) -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-ppc/bug.h +22 -0
@@ -0,0 +1,22 @@ +#ifndef _PPC_PAGE_H +#define _PPC_PAGE_H + +#include <linux/config.h> + +#ifndef __ASSEMBLY__ +#include <asm/system.h> /* for xmon definition */ + +#ifdef CONFIG_XMON +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + xmon(0); \ +} while (0) +#else +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + __asm__ __volatile__(".long 0x0"); \ +} while (0) +#endif +#endif /* !__ASSEMBLY__ */ + +#endif /* _PPC_PAGE_H */
include/asm-ppc/page.h +1 -13
@@ -8,6 +8,7 @@#ifdef __KERNEL__#include <linux/config.h> +#include <asm/bug.h> /* Be sure to change arch/ppc/Makefile to match */ #ifdef CONFIG_KERNEL_START_BOOL
@@ -18,19 +19,6 @@#define KERNELBASE PAGE_OFFSET#ifndef __ASSEMBLY__ -#include <asm/system.h> /* for xmon definition */ - -#ifdef CONFIG_XMON -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - xmon(0); \ -} while (0) -#else -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - __asm__ __volatile__(".long 0x0"); \ -} while (0) -#endif #define PAGE_BUG (page) do { BUG(); } while (0)#define STRICT_MM_TYPECHECKS
include/asm-ppc64/bug.h +27 -0
@@ -0,0 +1,27 @@ +#ifndef _PPC64_BUG_H +#define _PPC64_BUG_H +#include <linux/config.h> + +/* Define an illegal instr to trap on the bug. +* We don't use 0 because that marks the end of a function +* in the ELF ABI. That's "Boo Boo" in case you wonder... +*/ +#define BUG_OPCODE .long 0x00b00b00/* For asm */ +#define BUG_ILLEGAL_INSTR "0x00b00b00"/* For BUG macro */ + +#ifndef __ASSEMBLY__ +#ifdef CONFIG_XMON +extern void xmon (struct pt_regs *excp); +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + xmon(0); \ +} while (0) +#else +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + __asm__ __volatile__(".long " BUG_ILLEGAL_INSTR); \ +} while (0) +#endif +#endif /* __ASSEMBLY__ */ + +#endif /* _PPC64_BUG_H */
include/asm-ppc64/page.h +1 -21
@@ -22,14 +22,8 @@#define SID_MASK 0xfffffffff#define GET_ESID (x) (((x) >> SID_SHIFT) & SID_MASK) -/* Define an illegal instr to trap on the bug. -* We don't use 0 because that marks the end of a function -* in the ELF ABI. That's "Boo Boo" in case you wonder... -*/ -#define BUG_OPCODE .long 0x00b00b00/* For asm */ -#define BUG_ILLEGAL_INSTR "0x00b00b00"/* For BUG macro */ -#ifdef __KERNEL__ +#include <asm/bug.h> #ifndef __ASSEMBLY__#include <asm/naca.h>
@@ -103,20 +97,6 @@ typedef unsigned long pgprot_t;#endif -#ifdef CONFIG_XMON -#include <asm/ptrace.h> -extern void xmon (struct pt_regs *excp); -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - xmon(0); \ -} while (0) -#else -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - __asm__ __volatile__(".long " BUG_ILLEGAL_INSTR); \ -} while (0) -#endif -#define PAGE_BUG (page) do { BUG(); } while (0)/* Pure 2^n version of get_order */
include/asm-s390/bug.h +9 -0
@@ -0,0 +1,9 @@ +#ifndef _S390_PAGE_H +#define _S390_PAGE_H + +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + __asm__ __volatile__(".word 0x0000"); \ +} while (0) + +#endif /* _S390_PAGE_H */
include/asm-s390/page.h +2 -5
@@ -20,6 +20,8 @@ #ifdef __KERNEL__ #ifndef __ASSEMBLY__ +#include <asm/bug.h> + static inline void clear_page(void *page) { register_pair rp;
@@ -62,11 +64,6 @@ static inline void copy_page(void *to, v#define clear_user_page (page, vaddr, pg) clear_page(page)#define copy_user_page (to, from, vaddr, pg) copy_page(to, from) -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - __asm__ __volatile__(".word 0x0000"); \ -} while (0) -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-s390x/bug.h +10 -0
@@ -0,0 +1,10 @@ +#ifndef _S390_PAGE_H +#define _S390_PAGE_H + +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + __asm__ __volatile__(".long 0"); \ +} while (0) + +#endif /* _S390_PAGE_H */ +
include/asm-s390x/page.h +2 -5
@@ -19,6 +19,8 @@ #ifdef __KERNEL__ #ifndef __ASSEMBLY__ +#include <asm/bug.h> + static inline void clear_page(void *page) { asm volatile (" lgr 2,%0\n"
@@ -60,11 +62,6 @@ static inline void copy_page(void *to, v#define clear_user_page (page, vaddr, pg) clear_page(page)#define copy_user_page (to, from, vaddr, pg) copy_page(to, from) -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - __asm__ __volatile__(".long 0"); \ -} while (0) -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-sh/bug.h +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_SH_BUG_H +#define __ASM_SH_BUG_H + +/* +* Tell the user there is some problem. +*/ +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + asm volatile("nop"); \ +} while (0) + +#endif /* __ASM_SH_BUG_H */
include/asm-sh/page.h +2 -8
@@ -24,6 +24,8 @@#ifdef __KERNEL__#ifndef __ASSEMBLY__ +#include <asm/bug.h> +extern void clear_page (void *to);extern void copy_page (void *to,void *from);
@@ -90,14 +92,6 @@ typedef struct { unsigned long pgprot; }#ifndef __ASSEMBLY__ -/* -* Tell the user there is some problem. -*/ -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - asm volatile("nop"); \ -} while (0) -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-sparc/bug.h +22 -0
@@ -0,0 +1,22 @@ +#ifndef _SPARC_BUG_H +#define _SPARC_BUG_H + +/* +* XXX I am hitting compiler bugs with __builtin_trap. This has +* hit me before and rusty was blaming his netfilter bugs on +* this so lets disable it. - Anton +*/ +#if 0 +/* We need the mb()'s so we don't trigger a compiler bug - Anton */ +#define BUG () do { \ + mb(); \ + __builtin_trap(); \ + mb(); \ +} while(0) +#else +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; \ +} while (0) +#endif + +#endif /* _SPARC_BUG_H */
include/asm-sparc/page.h +1 -18
@@ -28,24 +28,7 @@#include <asm/btfixup.h> #ifndef __ASSEMBLY__ - -/* -* XXX I am hitting compiler bugs with __builtin_trap. This has -* hit me before and rusty was blaming his netfilter bugs on -* this so lets disable it. - Anton -*/ -#if 0 -/* We need the mb()'s so we don't trigger a compiler bug - Anton */ -#define BUG () do { \ - mb(); \ - __builtin_trap(); \ - mb(); \ -} while(0) -#else -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; \ -} while (0) -#endif +#include <asm/bug.h> #define PAGE_BUG (page) BUG()
include/asm-sparc64/bug.h +15 -0
@@ -0,0 +1,15 @@ +#ifndef _SPARC64_BUG_H +#define _SPARC64_BUG_H +#include <linux/config.h> + +#ifdef CONFIG_DEBUG_BUGVERBOSE +extern void do_BUG (const char *file,int line); +#define BUG () do { \ + do_BUG(__FILE__, __LINE__); \ + __builtin_trap(); \ +} while (0) +#else +#define BUG () __builtin_trap() +#endif + +#endif /* _SPARC64_BUG_H */
include/asm-sparc64/page.h +1 -10
@@ -19,16 +19,7 @@#ifdef __KERNEL__#ifndef __ASSEMBLY__ - -#ifdef CONFIG_DEBUG_BUGVERBOSE -extern void do_BUG (const char *file,int line); -#define BUG () do { \ - do_BUG(__FILE__, __LINE__); \ - __builtin_trap(); \ -} while (0) -#else -#define BUG () __builtin_trap() -#endif +#include <asm/bug.h> #define PAGE_BUG (page) BUG()
include/asm-um/bug.h +8 -0
@@ -0,0 +1,8 @@ +#ifndef __UM_BUG_H +#define __UM_BUG_H + +#define BUG () do { \ + panic("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ +} while (0) + +#endif /* __UM_BUG_H */
include/asm-um/page.h +1 -4
@@ -25,10 +25,7 @@ struct page;extern void stop (void ); -#define BUG () do { \ - panic("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ -} while (0) - +#include <asm/bug.h> #define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-x86_64/bug.h +18 -0
@@ -0,0 +1,18 @@ +#ifndef _X86_64_BUG_H +#define _X86_64_BUG_H + +#include <linux/stringify.h> +/* +* Tell the user there is some problem. The exception handler decodes this frame. +*/ +struct bug_frame { +unsigned char ud2[2 ]; +char *filename;/* should use 32bit offset instead, but the assembler doesn't like it */ +unsigned short line; +} __attribute__((packed)); +#define BUG () \ + asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \ + "i"(__LINE__), "i" (__stringify(KBUILD_BASENAME))) +void out_of_line_bug (void ); + +#endif /* _X86_64_BUG_H */
include/asm-x86_64/page.h +1 -13
@@ -64,21 +64,9 @@ typedef struct { unsigned long pgprot; }#ifndef __ASSEMBLY__ -#include <linux/stringify.h> +#include <asm/bug.h> -/* -* Tell the user there is some problem. The exception handler decodes this frame. -*/ -struct bug_frame { -unsigned char ud2[2 ]; -char *filename;/* should use 32bit offset instead, but the assembler doesn't like it */ -unsigned short line; -} __attribute__((packed)); -#define BUG () \ - asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \ - "i"(__LINE__), "i" (__stringify(KBUILD_BASENAME)))#define PAGE_BUG (page) BUG() -void out_of_line_bug (void );/* Pure 2^n version of get_order */ extern __inline__int get_order (unsigned long size)
Quoted 6 lines · Rusty Russell
As the number of bug-related macros grows, this makes sense.
1) Introducelinux/bug.hand #include it fromlinux/kernel.hso noone breaks.
2) MoveBUG()macro fromasm*/page.htoasm*/bug.h, and #include it. Thanks,
Rusty.
Thank you, this is a longstanding source of irritation (from the standpoint of mere cleanliness) here.
Bill
Quoted 5 lines · Rusty Russell
As the number of bug-related macros grows, this makes sense.
1) Introduce
linux/bug.hand #include it fromlinux/kernel.hso noone breaks.
2) MoveBUG()macro fromasm*/page.htoasm*/bug.h, and #include it.
Great, people were talking about the mess caused by this just last night. Just one request, move the BUG_ON definition into <asm/bug.h> also. This permits the use of conditional trap instructions for those architecture that have them.
Ralf
Quoted 11 lines · Ralf Baechle
Quoted 5 lines · Rusty Russell
As the number of bug-related macros grows, this makes sense.
1) Introduce
linux/bug.hand #include it fromlinux/kernel.hso noone breaks.
2) MoveBUG()macro fromasm*/page.htoasm*/bug.h, and #include it.Great, people were talking about the mess caused by this just last night. Just one request, move the
BUG_ONdefinition into <asm/bug.h> also. This permits the use of conditional trap instructions for those architecture that have them.
I'm a little peeved since everyone's likes this from Rusty, but ignored exactly the same thing from me. Sigh, life is cruel some times.
Message-Id: [email protected]
Subject: [PATCH] 2.5.43-bug
Date: Thu, 17 Oct 2002 11:45:27 +0100
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Quoted 5 lines · Russell King
I'm a little peeved since everyone's likes this from Rusty, but ignored exactly the same thing from me. Sigh, life is cruel some times.
Message-Id: [email protected]
Subject: [PATCH] 2.5.43-bug
Date: Thu, 17 Oct 2002 11:45:27 +0100
Sorry about that, I didn't notice it then. I was distracted by other things around 2.5.43 ...
Bill
In message <[email protected]> you write:
Quoted 12 lines · Rusty Russell
Quoted 6 lines
As the number of bug-related macros grows, this makes sense.
1) Introduce
linux/bug.hand #include it fromlinux/kernel.hso noone breaks.
2) MoveBUG()macro fromasm*/page.htoasm*/bug.h, and #include it.Great, people were talking about the mess caused by this just last night. Just one request, move the
BUG_ONdefinition into <asm/bug.h> also. This permits the use of conditional trap instructions for those architecture that have them.
Hmm, I decided to use #ifndef BUG_ON instead, since most archs will not bother.
BTW, looks like Russell did this first. Wish I'd noticed 8(
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Name: bug.h
Author: Rusty Russell and Russell King
Status: Trivial
D: As the number of bug-related macros grows, this makes sense. D:
D: 1) Introduce linux/bug.h and #include it from linux/kernel.h so noone D: breaks. D: 2) Move BUG() and BUG_ON() macro from asm*/page.h to asm*/bug.h, D: and #include it.
include/asm-alpha/bug.h +11 -0
@@ -0,0 +1,11 @@ +#ifndef _ALPHA_BUG_H +#define _ALPHA_BUG_H +#include <asm/pal.h> + +/* ??? Would be nice to use .gprel32 here, but we can't be sure that the +function loaded the GP, so this could fail in modules. */ +#define BUG () \ + __asm__ __volatile__("call_pal %0 # bugchk\n\t"".long %1\n\t.8byte %2" \ + : : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__)) + +#endif /* _ALPHA_BUG_H */
include/asm-alpha/page.h +1 -6
@@ -2,6 +2,7 @@#define _ALPHA_PAGE_H#include <asm/pal.h> +#include <asm/bug.h> /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 13
@@ -59,12 +60,6 @@ typedef unsigned long pgprot_t;#endif /* STRICT_MM_TYPECHECKS */ -/* ??? Would be nice to use .gprel32 here, but we can't be sure that the -function loaded the GP, so this could fail in modules. */ -#define BUG () \ - __asm__ __volatile__("call_pal %0 # bugchk\n\t"".long %1\n\t.8byte %2" \ - : : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__)) -#define PAGE_BUG (page) BUG()/* Pure 2^n version of get_order */
include/asm-arm/bug.h +20 -0
@@ -0,0 +1,20 @@ +#ifndef _ASMARM_BUG_H +#define _ASMARM_BUG_H +#include <linux/config.h> + +#ifdef CONFIG_DEBUG_BUGVERBOSE +extern void __bug (const char *file,int line,void *data); + +/* give file/line information */ +#define BUG () __bug(__FILE__, __LINE__, NULL) +#define PAGE_BUG (page) __bug(__FILE__, __LINE__, page) + +#else + +/* these just cause an oops */ +#define BUG () (*(int *)0 = 0) +#define PAGE_BUG (page) (*(int *)0 = 0) + +#endif + +#endif /* _ASMARM_BUG_H */
include/asm-arm/page.h +1 -15
@@ -7,6 +7,7 @@#ifndef __ASSEMBLY__#include <asm/glue.h> +#include <asm/bug.h> /* * User Space Model
@@ -160,21 +161,6 @@ typedef unsigned long pgprot_t; #ifdef __KERNEL__ #ifndef __ASSEMBLY__ -#ifdef CONFIG_DEBUG_BUGVERBOSE -extern void __bug(const char *file, int line, void *data); - -/* give file/line information */ -#define BUG() __bug(__FILE__, __LINE__, NULL) -#define PAGE_BUG(page) __bug(__FILE__, __LINE__, page) - -#else - -/* these just cause an oops */ -#define BUG() (*(int *)0 = 0) -#define PAGE_BUG(page) (*(int *)0 = 0) - -#endif - /* Pure 2^n version of get_order */ static inline int get_order(unsigned long size) {
include/asm-cris/bug.h +8 -0
@@ -0,0 +1,8 @@ +#ifndef _CRIS_BUG_H +#define _CRIS_BUG_H + +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ +} while (0) + +#endif /* _CRIS_BUG_H */
include/asm-cris/page.h +1 -8
@@ -3,6 +3,7 @@#include <linux/config.h> #include <asm/mmu.h> +#include <asm/bug.h> /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 13
@@ -70,18 +71,10 @@ typedef unsigned long pgprot_t;#define PAGE_OFFSET KSEG_C/* kseg_c is mapped to physical ram */ #endif -#ifndef __ASSEMBLY__ - -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ -} while (0) -#define PAGE_BUG (page) do { \ BUG(); \ } while (0) -#endif /* __ASSEMBLY__ */ -/* macros to convert between really physical and virtual addresses * by stripping a selected bit, we can convert between KSEG_x and 0x40000000 where * the DRAM really resides
include/asm-i386/bug.h +20 -0
@@ -0,0 +1,20 @@ +#ifndef _I386_BUG_H +#define _I386_BUG_H +/* +* Tell the user there is some problem. Beep too, so we can +* see^H^H^Hhear bugs in early bootup as well! +* The offending file and line are encoded after the "officially +* undefined" opcode for parsing in the trap handler. +*/ + +#if 1 /* Set to zero for a slightly smaller kernel */ +#define BUG () \ + __asm__ __volatile__( "ud2\n" \ + "\t.word %c0\n" \ + "\t.long %c1\n" \ + : : "i" (__LINE__), "i" (__FILE__)) +#else +#define BUG () __asm__ __volatile__("ud2\n") +#endif + +#endif /* _I386_BUG_H */
include/asm-i386/page.h +1 -17
@@ -13,6 +13,7 @@#ifndef __ASSEMBLY__#include <linux/config.h> +#include <asm/bug.h> #ifdef CONFIG_X86_USE_3DNOW
@@ -99,23 +100,6 @@ typedef struct { unsigned long pgprot; }#ifndef __ASSEMBLY__ -/* -* Tell the user there is some problem. Beep too, so we can -* see^H^H^Hhear bugs in early bootup as well! -* The offending file and line are encoded after the "officially -* undefined" opcode for parsing in the trap handler. -*/ - -#if 1 /* Set to zero for a slightly smaller kernel */ -#define BUG () \ - __asm__ __volatile__( "ud2\n" \ - "\t.word %c0\n" \ - "\t.long %c1\n" \ - : : "i" (__LINE__), "i" (__FILE__)) -#else -#define BUG () __asm__ __volatile__("ud2\n") -#endif -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-ia64/bug.h +11 -0
@@ -0,0 +1,11 @@ +#ifndef _ASM_IA64_BUG_H +#define _ASM_IA64_BUG_H + +#if (__GNUC__ >3 ) || (__GNUC__ ==3 && __GNUC_MINOR__ >=1 ) +# define ia64_abort () __builtin_trap() +#else +# define ia64_abort () (*(volatile int *) 0 = 0) +#endif +#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0) + +#endif /* _ASM_IA64_BUG_H */
include/asm-ia64/page.h +1 -6
@@ -10,6 +10,7 @@#include <linux/config.h> #include <asm/types.h> +#include <asm/bug.h> /* * PAGE_SHIFT determines the actual kernel page size.
@@ -125,12 +126,6 @@ typedef union ia64_va {# define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)#endif -#if (__GNUC__ >3 ) || (__GNUC__ ==3 && __GNUC_MINOR__ >=1 ) -# define ia64_abort () __builtin_trap() -#else -# define ia64_abort () (*(volatile int *) 0 = 0) -#endif -#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0)#define PAGE_BUG (page) do { BUG(); } while (0) static __inline__ int
include/asm-m68k/bug.h +24 -0
@@ -0,0 +1,24 @@ +#ifndef _M68K_BUG_H +#define _M68K_BUG_H + +#include <linux/config.h> + +#ifdef CONFIG_DEBUG_BUGVERBOSE +#ifndef CONFIG_SUN3 +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + asm volatile("illegal"); \ +} while (0) +#else +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + panic("BUG!"); \ +} while (0) +#endif +#else +#define BUG () do { \ + asm volatile("illegal"); \ +} while (0) +#endif + +#endif /* _M68K_BUG_H */
include/asm-m68k/page.h +1 -18
@@ -16,6 +16,7 @@#ifdef __KERNEL__#include <asm/setup.h> +#include <asm/bug.h> #if PAGE_SHIFT <13 #define THREAD_SIZE (8192)
@@ -178,24 +179,6 @@ static inline void *__va(unsigned long x#define virt_addr_valid (kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)#define pfn_valid (pfn) virt_addr_valid(pfn_to_virt(pfn)) -#ifdef CONFIG_DEBUG_BUGVERBOSE -#ifndef CONFIG_SUN3 -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - asm volatile("illegal"); \ -} while (0) -#else -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - panic("BUG!"); \ -} while (0) -#endif -#else -#define BUG () do { \ - asm volatile("illegal"); \ -} while (0) -#endif -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-mips/bug.h +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ASM_BUG_H +#define __ASM_BUG_H + +#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0) + +#endif /* __ASM_BUG_H */
include/asm-mips/page.h +1 -1
@@ -17,10 +17,10 @@#define PAGE_MASK (~(PAGE_SIZE-1))#ifdef __KERNEL__ +#include <asm/bug.h> #ifndef _LANGUAGE_ASSEMBLY -#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0)#define PAGE_BUG (page) do { BUG(); } while (0)extern void (*_clear_page)(void * page);
include/asm-mips64/bug.h +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_BUG_H +#define _ASM_BUG_H + +#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0) + +#endif /* _ASM_BUG_H */
include/asm-mips64/page.h +1 -1
@@ -10,6 +10,7 @@#define _ASM_PAGE_H#include <linux/config.h> +#include <asm/bug.h> /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 12
@@ -20,7 +21,6 @@#ifndef _LANGUAGE_ASSEMBLY -#define BUG () do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0)#define PAGE_BUG (page) do { BUG(); } while (0)extern void (*_clear_page)(void * page);
include/asm-parisc/bug.h +14 -0
@@ -0,0 +1,14 @@ +#ifndef _PARISC_BUG_H +#define _PARISC_BUG_H + +/* +* Tell the user there is some problem. Beep too, so we can +* see^H^H^Hhear bugs in early bootup as well! +* +* We don't beep yet. prumpf +*/ +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ +} while (0) + +#endif /* _PARISC_BUG_H */
include/asm-parisc/page.h +1 -10
@@ -10,6 +10,7 @@#ifndef __ASSEMBLY__#include <asm/cache.h> +#include <asm/bug.h> #define clear_page (page) memset((void *)(page), 0, PAGE_SIZE)#define copy_page (to,from) copy_user_page_asm((void *)(to), (void *)(from))
@@ -86,16 +87,6 @@ extern int npmem_ranges;/* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN (addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) -/* -* Tell the user there is some problem. Beep too, so we can -* see^H^H^Hhear bugs in early bootup as well! -* -* We don't beep yet. prumpf -*/ -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ -} while (0) -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-ppc/bug.h +22 -0
@@ -0,0 +1,22 @@ +#ifndef _PPC_PAGE_H +#define _PPC_PAGE_H + +#include <linux/config.h> + +#ifndef __ASSEMBLY__ +#include <asm/system.h> /* for xmon definition */ + +#ifdef CONFIG_XMON +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + xmon(0); \ +} while (0) +#else +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + __asm__ __volatile__(".long 0x0"); \ +} while (0) +#endif +#endif /* !__ASSEMBLY__ */ + +#endif /* _PPC_PAGE_H */
include/asm-ppc/page.h +1 -13
@@ -8,6 +8,7 @@#ifdef __KERNEL__#include <linux/config.h> +#include <asm/bug.h> /* Be sure to change arch/ppc/Makefile to match */ #ifdef CONFIG_KERNEL_START_BOOL
@@ -18,19 +19,6 @@#define KERNELBASE PAGE_OFFSET#ifndef __ASSEMBLY__ -#include <asm/system.h> /* for xmon definition */ - -#ifdef CONFIG_XMON -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - xmon(0); \ -} while (0) -#else -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - __asm__ __volatile__(".long 0x0"); \ -} while (0) -#endif #define PAGE_BUG (page) do { BUG(); } while (0)#define STRICT_MM_TYPECHECKS
include/asm-ppc64/bug.h +27 -0
@@ -0,0 +1,27 @@ +#ifndef _PPC64_BUG_H +#define _PPC64_BUG_H +#include <linux/config.h> + +/* Define an illegal instr to trap on the bug. +* We don't use 0 because that marks the end of a function +* in the ELF ABI. That's "Boo Boo" in case you wonder... +*/ +#define BUG_OPCODE .long 0x00b00b00/* For asm */ +#define BUG_ILLEGAL_INSTR "0x00b00b00"/* For BUG macro */ + +#ifndef __ASSEMBLY__ +#ifdef CONFIG_XMON +extern void xmon (struct pt_regs *excp); +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + xmon(0); \ +} while (0) +#else +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + __asm__ __volatile__(".long " BUG_ILLEGAL_INSTR); \ +} while (0) +#endif +#endif /* __ASSEMBLY__ */ + +#endif /* _PPC64_BUG_H */
include/asm-ppc64/page.h +1 -21
@@ -22,14 +22,8 @@#define SID_MASK 0xfffffffff#define GET_ESID (x) (((x) >> SID_SHIFT) & SID_MASK) -/* Define an illegal instr to trap on the bug. -* We don't use 0 because that marks the end of a function -* in the ELF ABI. That's "Boo Boo" in case you wonder... -*/ -#define BUG_OPCODE .long 0x00b00b00/* For asm */ -#define BUG_ILLEGAL_INSTR "0x00b00b00"/* For BUG macro */ -#ifdef __KERNEL__ +#include <asm/bug.h> #ifndef __ASSEMBLY__#include <asm/naca.h>
@@ -103,20 +97,6 @@ typedef unsigned long pgprot_t;#endif -#ifdef CONFIG_XMON -#include <asm/ptrace.h> -extern void xmon (struct pt_regs *excp); -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - xmon(0); \ -} while (0) -#else -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - __asm__ __volatile__(".long " BUG_ILLEGAL_INSTR); \ -} while (0) -#endif -#define PAGE_BUG (page) do { BUG(); } while (0)/* Pure 2^n version of get_order */
include/asm-s390/bug.h +9 -0
@@ -0,0 +1,9 @@ +#ifndef _S390_PAGE_H +#define _S390_PAGE_H + +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + __asm__ __volatile__(".word 0x0000"); \ +} while (0) + +#endif /* _S390_PAGE_H */
include/asm-s390/page.h +2 -5
@@ -20,6 +20,8 @@ #ifdef __KERNEL__ #ifndef __ASSEMBLY__ +#include <asm/bug.h> + static inline void clear_page(void *page) { register_pair rp;
@@ -62,11 +64,6 @@ static inline void copy_page(void *to, v#define clear_user_page (page, vaddr, pg) clear_page(page)#define copy_user_page (to, from, vaddr, pg) copy_page(to, from) -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - __asm__ __volatile__(".word 0x0000"); \ -} while (0) -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-s390x/bug.h +10 -0
@@ -0,0 +1,10 @@ +#ifndef _S390_PAGE_H +#define _S390_PAGE_H + +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + __asm__ __volatile__(".long 0"); \ +} while (0) + +#endif /* _S390_PAGE_H */ +
include/asm-s390x/page.h +2 -5
@@ -19,6 +19,8 @@ #ifdef __KERNEL__ #ifndef __ASSEMBLY__ +#include <asm/bug.h> + static inline void clear_page(void *page) { asm volatile (" lgr 2,%0\n"
@@ -60,11 +62,6 @@ static inline void copy_page(void *to, v#define clear_user_page (page, vaddr, pg) clear_page(page)#define copy_user_page (to, from, vaddr, pg) copy_page(to, from) -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - __asm__ __volatile__(".long 0"); \ -} while (0) -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-sh/bug.h +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_SH_BUG_H +#define __ASM_SH_BUG_H + +/* +* Tell the user there is some problem. +*/ +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ + asm volatile("nop"); \ +} while (0) + +#endif /* __ASM_SH_BUG_H */
include/asm-sh/page.h +2 -8
@@ -24,6 +24,8 @@#ifdef __KERNEL__#ifndef __ASSEMBLY__ +#include <asm/bug.h> +extern void clear_page (void *to);extern void copy_page (void *to,void *from);
@@ -90,14 +92,6 @@ typedef struct { unsigned long pgprot; }#ifndef __ASSEMBLY__ -/* -* Tell the user there is some problem. -*/ -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ - asm volatile("nop"); \ -} while (0) -#define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-sparc/bug.h +22 -0
@@ -0,0 +1,22 @@ +#ifndef _SPARC_BUG_H +#define _SPARC_BUG_H + +/* +* XXX I am hitting compiler bugs with __builtin_trap. This has +* hit me before and rusty was blaming his netfilter bugs on +* this so lets disable it. - Anton +*/ +#if 0 +/* We need the mb()'s so we don't trigger a compiler bug - Anton */ +#define BUG () do { \ + mb(); \ + __builtin_trap(); \ + mb(); \ +} while(0) +#else +#define BUG () do { \ + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; \ +} while (0) +#endif + +#endif /* _SPARC_BUG_H */
include/asm-sparc/page.h +1 -18
@@ -28,24 +28,7 @@#include <asm/btfixup.h> #ifndef __ASSEMBLY__ - -/* -* XXX I am hitting compiler bugs with __builtin_trap. This has -* hit me before and rusty was blaming his netfilter bugs on -* this so lets disable it. - Anton -*/ -#if 0 -/* We need the mb()'s so we don't trigger a compiler bug - Anton */ -#define BUG () do { \ - mb(); \ - __builtin_trap(); \ - mb(); \ -} while(0) -#else -#define BUG () do { \ - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; \ -} while (0) -#endif +#include <asm/bug.h> #define PAGE_BUG (page) BUG()
include/asm-sparc64/bug.h +15 -0
@@ -0,0 +1,15 @@ +#ifndef _SPARC64_BUG_H +#define _SPARC64_BUG_H +#include <linux/config.h> + +#ifdef CONFIG_DEBUG_BUGVERBOSE +extern void do_BUG (const char *file,int line); +#define BUG () do { \ + do_BUG(__FILE__, __LINE__); \ + __builtin_trap(); \ +} while (0) +#else +#define BUG () __builtin_trap() +#endif + +#endif /* _SPARC64_BUG_H */
include/asm-sparc64/page.h +1 -10
@@ -19,16 +19,7 @@#ifdef __KERNEL__#ifndef __ASSEMBLY__ - -#ifdef CONFIG_DEBUG_BUGVERBOSE -extern void do_BUG (const char *file,int line); -#define BUG () do { \ - do_BUG(__FILE__, __LINE__); \ - __builtin_trap(); \ -} while (0) -#else -#define BUG () __builtin_trap() -#endif +#include <asm/bug.h> #define PAGE_BUG (page) BUG()
include/asm-um/bug.h +8 -0
@@ -0,0 +1,8 @@ +#ifndef __UM_BUG_H +#define __UM_BUG_H + +#define BUG () do { \ + panic("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ +} while (0) + +#endif /* __UM_BUG_H */
include/asm-um/page.h +1 -4
@@ -25,10 +25,7 @@ struct page;extern void stop (void ); -#define BUG () do { \ - panic("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ -} while (0) - +#include <asm/bug.h> #define PAGE_BUG (page) do { \ BUG(); \ } while (0)
include/asm-x86_64/bug.h +18 -0
@@ -0,0 +1,18 @@ +#ifndef _X86_64_BUG_H +#define _X86_64_BUG_H + +#include <linux/stringify.h> +/* +* Tell the user there is some problem. The exception handler decodes this frame. +*/ +struct bug_frame { +unsigned char ud2[2 ]; +char *filename;/* should use 32bit offset instead, but the assembler doesn't like it */ +unsigned short line; +} __attribute__((packed)); +#define BUG () \ + asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \ + "i"(__LINE__), "i" (__stringify(KBUILD_BASENAME))) +void out_of_line_bug (void ); + +#endif /* _X86_64_BUG_H */
include/asm-x86_64/page.h +1 -13
@@ -64,21 +64,9 @@ typedef struct { unsigned long pgprot; }#ifndef __ASSEMBLY__ -#include <linux/stringify.h> +#include <asm/bug.h> -/* -* Tell the user there is some problem. The exception handler decodes this frame. -*/ -struct bug_frame { -unsigned char ud2[2 ]; -char *filename;/* should use 32bit offset instead, but the assembler doesn't like it */ -unsigned short line; -} __attribute__((packed)); -#define BUG () \ - asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \ - "i"(__LINE__), "i" (__stringify(KBUILD_BASENAME)))#define PAGE_BUG (page) BUG() -void out_of_line_bug (void );/* Pure 2^n version of get_order */ extern __inline__int get_order (unsigned long size)
include/linux/bug.h +27 -0
@@ -0,0 +1,27 @@ +#ifndef _LINUX_BUG_H +#define _LINUX_BUG_H +#include <linux/compiler.h> /* likely/unlikely */ +#include <asm/bug.h> /* BUG() */ + +extern void dump_stack (void ); + +/* This permits the use of conditional trap instructions for those +architecture that have them -- Ralf Baechle */ +#ifndef BUG_ON +#define BUG_ON (condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) +#endif + +#define WARN_ON (condition) do { \ + if (unlikely((condition)!=0)) { \ + printk("Badness in %s at %s:%d\n", \ + __FUNCTION__, __FILE__, __LINE__); \ + dump_stack(); \ + } \ +} while (0) + +/* Fail at build-time (condition must be a constant expression: +BUILD_BUG does not exist). */ +extern void BUILD_BUG (void ); +#define BUILD_BUG_ON (condition) do { if (condition) BUILD_BUG(); } while(0) + +#endif /* _LINUX_BUG_H */
include/linux/kernel.h +1 -14
@@ -11,7 +11,7 @@#include <linux/linkage.h> #include <linux/stddef.h> #include <linux/types.h> -#include <linux/compiler.h> +#include <linux/bug.h> #include <asm/byteorder.h> /* Optimization barrier */
@@ -103,8 +103,6 @@ extern const char *print_tainted(void);#define TAINT_FORCED_MODULE (1<<1)#define TAINT_UNSAFE_SMP (1<<2) -extern void dump_stack (void ); -#if DEBUG #define pr_debug(fmt,arg...) \ printk(KERN_DEBUG fmt,##arg)
@@ -199,17 +197,6 @@ struct sysinfo {char _f[20 -2 *sizeof (long )-sizeof (int )];/* Padding: libc5 uses this.. */ }; -#define BUG_ON (condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) -#define WARN_ON (condition) do { \ - if (unlikely((condition)!=0)) { \ - printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \ - dump_stack(); \ - } \ -} while (0) - -extern void BUILD_BUG (void ); -#define BUILD_BUG_ON (condition) do { if (condition) BUILD_BUG(); } while(0) -/* Trap pasters of __FUNCTION__ at compile-time */ #if __GNUC__ >2 || __GNUC_MINOR__ >=95 #define __FUNCTION__ (__func__)