Commit c8538a7a authored by Matt Mackall's avatar Matt Mackall Committed by Linus Torvalds

[PATCH] remove all kernel BUGs

This patch eliminates all kernel BUGs, trims about 35k off the typical
kernel, and makes the system slightly faster.
Signed-off-by: default avatarMatt Mackall <mpm@selenic.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e43379f1
#ifndef _ALPHA_BUG_H #ifndef _ALPHA_BUG_H
#define _ALPHA_BUG_H #define _ALPHA_BUG_H
#ifdef CONFIG_BUG
#include <asm/pal.h> #include <asm/pal.h>
/* ??? Would be nice to use .gprel32 here, but we can't be sure that the /* ??? Would be nice to use .gprel32 here, but we can't be sure that the
...@@ -10,6 +11,8 @@ ...@@ -10,6 +11,8 @@
: : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__)) : : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__))
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/config.h> #include <linux/config.h>
#ifdef CONFIG_BUG
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
extern volatile void __bug(const char *file, int line, void *data); extern volatile void __bug(const char *file, int line, void *data);
...@@ -17,6 +18,8 @@ extern volatile void __bug(const char *file, int line, void *data); ...@@ -17,6 +18,8 @@ extern volatile void __bug(const char *file, int line, void *data);
#endif #endif
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/config.h> #include <linux/config.h>
#ifdef CONFIG_BUG
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
extern volatile void __bug(const char *file, int line, void *data); extern volatile void __bug(const char *file, int line, void *data);
/* give file/line information */ /* give file/line information */
...@@ -12,6 +13,8 @@ extern volatile void __bug(const char *file, int line, void *data); ...@@ -12,6 +13,8 @@ extern volatile void __bug(const char *file, int line, void *data);
#endif #endif
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/config.h> #include <linux/config.h>
#ifdef CONFIG_BUG
/* /*
* Tell the user there is some problem. * Tell the user there is some problem.
*/ */
...@@ -45,6 +46,7 @@ do { \ ...@@ -45,6 +46,7 @@ do { \
#define HAVE_ARCH_KGDB_BAD_PAGE #define HAVE_ARCH_KGDB_BAD_PAGE
#define kgdb_bad_page(page) do { kgdb_raise(SIGABRT); } while(0) #define kgdb_bad_page(page) do { kgdb_raise(SIGABRT); } while(0)
#endif #endif
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/config.h> #include <linux/config.h>
#ifdef CONFIG_BUG
#ifndef HAVE_ARCH_BUG #ifndef HAVE_ARCH_BUG
#define BUG() do { \ #define BUG() do { \
printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
...@@ -31,4 +32,22 @@ ...@@ -31,4 +32,22 @@
} while (0) } while (0)
#endif #endif
#else /* !CONFIG_BUG */
#ifndef HAVE_ARCH_BUG
#define BUG()
#endif
#ifndef HAVE_ARCH_PAGE_BUG
#define PAGE_BUG(page) do { if (page) ; } while (0)
#endif
#ifndef HAVE_ARCH_BUG_ON
#define BUG_ON(condition) do { if (condition) ; } while(0)
#endif
#ifndef HAVE_ARCH_WARN_ON
#define WARN_ON(condition) do { if (condition) ; } while(0)
#endif
#endif
#endif #endif
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* undefined" opcode for parsing in the trap handler. * undefined" opcode for parsing in the trap handler.
*/ */
#ifdef CONFIG_BUG
#define HAVE_ARCH_BUG
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
#define BUG() \ #define BUG() \
__asm__ __volatile__( "ud2\n" \ __asm__ __volatile__( "ud2\n" \
...@@ -18,8 +20,7 @@ ...@@ -18,8 +20,7 @@
#else #else
#define BUG() __asm__ __volatile__("ud2\n") #define BUG() __asm__ __volatile__("ud2\n")
#endif #endif
#endif
#define HAVE_ARCH_BUG
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
#ifndef _ASM_IA64_BUG_H #ifndef _ASM_IA64_BUG_H
#define _ASM_IA64_BUG_H #define _ASM_IA64_BUG_H
#ifdef CONFIG_BUG
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
# define ia64_abort() __builtin_trap() # define ia64_abort() __builtin_trap()
#else #else
...@@ -8,8 +9,10 @@ ...@@ -8,8 +9,10 @@
#endif #endif
#define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0) #define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0)
/* should this BUG should be made generic? */ /* should this BUG be made generic? */
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/config.h> #include <linux/config.h>
#ifdef CONFIG_BUG
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
#ifndef CONFIG_SUN3 #ifndef CONFIG_SUN3
#define BUG() do { \ #define BUG() do { \
...@@ -22,6 +23,8 @@ ...@@ -22,6 +23,8 @@
#endif #endif
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
...@@ -3,12 +3,14 @@ ...@@ -3,12 +3,14 @@
#include <asm/break.h> #include <asm/break.h>
#ifdef CONFIG_BUG
#define HAVE_ARCH_BUG
#define BUG() \ #define BUG() \
do { \ do { \
__asm__ __volatile__("break %0" : : "i" (BRK_BUG)); \ __asm__ __volatile__("break %0" : : "i" (BRK_BUG)); \
} while (0) } while (0)
#endif
#define HAVE_ARCH_BUG
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
#ifndef _PARISC_BUG_H #ifndef _PARISC_BUG_H
#define _PARISC_BUG_H #define _PARISC_BUG_H
#ifdef CONFIG_BUG
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#define BUG() do { \ #define BUG() do { \
printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
dump_stack(); \ dump_stack(); \
panic("BUG!"); \ panic("BUG!"); \
} while (0) } while (0)
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
...@@ -14,6 +14,7 @@ struct bug_entry { ...@@ -14,6 +14,7 @@ struct bug_entry {
*/ */
#define BUG_WARNING_TRAP 0x1000000 #define BUG_WARNING_TRAP 0x1000000
#ifdef CONFIG_BUG
#define BUG() do { \ #define BUG() do { \
__asm__ __volatile__( \ __asm__ __volatile__( \
"1: twi 31,0,0\n" \ "1: twi 31,0,0\n" \
...@@ -50,6 +51,8 @@ struct bug_entry { ...@@ -50,6 +51,8 @@ struct bug_entry {
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#define HAVE_ARCH_BUG_ON #define HAVE_ARCH_BUG_ON
#define HAVE_ARCH_WARN_ON #define HAVE_ARCH_WARN_ON
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
...@@ -26,6 +26,8 @@ struct bug_entry *find_bug(unsigned long bugaddr); ...@@ -26,6 +26,8 @@ struct bug_entry *find_bug(unsigned long bugaddr);
*/ */
#define BUG_WARNING_TRAP 0x1000000 #define BUG_WARNING_TRAP 0x1000000
#ifdef CONFIG_BUG
#define BUG() do { \ #define BUG() do { \
__asm__ __volatile__( \ __asm__ __volatile__( \
"1: twi 31,0,0\n" \ "1: twi 31,0,0\n" \
...@@ -55,11 +57,12 @@ struct bug_entry *find_bug(unsigned long bugaddr); ...@@ -55,11 +57,12 @@ struct bug_entry *find_bug(unsigned long bugaddr);
"i" (__FILE__), "i" (__FUNCTION__)); \ "i" (__FILE__), "i" (__FUNCTION__)); \
} while (0) } while (0)
#endif
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#define HAVE_ARCH_BUG_ON #define HAVE_ARCH_BUG_ON
#define HAVE_ARCH_WARN_ON #define HAVE_ARCH_WARN_ON
#endif
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
...@@ -3,12 +3,15 @@ ...@@ -3,12 +3,15 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#ifdef CONFIG_BUG
#define BUG() do { \ #define BUG() do { \
printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
__asm__ __volatile__(".long 0"); \ __asm__ __volatile__(".long 0"); \
} while (0) } while (0)
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/config.h> #include <linux/config.h>
#ifdef CONFIG_BUG
/* /*
* Tell the user there is some problem. * Tell the user there is some problem.
*/ */
...@@ -12,6 +13,8 @@ ...@@ -12,6 +13,8 @@
} while (0) } while (0)
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
#ifndef _SPARC_BUG_H #ifndef _SPARC_BUG_H
#define _SPARC_BUG_H #define _SPARC_BUG_H
#ifdef CONFIG_BUG
/* Only use the inline asm until a gcc release that can handle __builtin_trap /* Only use the inline asm until a gcc release that can handle __builtin_trap
* -rob 2003-06-25 * -rob 2003-06-25
* *
...@@ -26,6 +27,8 @@ extern void do_BUG(const char *file, int line); ...@@ -26,6 +27,8 @@ extern void do_BUG(const char *file, int line);
#endif #endif
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
#ifndef _SPARC64_BUG_H #ifndef _SPARC64_BUG_H
#define _SPARC64_BUG_H #define _SPARC64_BUG_H
#ifdef CONFIG_BUG
#include <linux/compiler.h> #include <linux/compiler.h>
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
...@@ -14,6 +15,8 @@ extern void do_BUG(const char *file, int line); ...@@ -14,6 +15,8 @@ extern void do_BUG(const char *file, int line);
#endif #endif
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif #endif
...@@ -14,9 +14,12 @@ ...@@ -14,9 +14,12 @@
#ifndef __V850_BUG_H__ #ifndef __V850_BUG_H__
#define __V850_BUG_H__ #define __V850_BUG_H__
#ifdef CONFIG_BUG
extern void __bug (void) __attribute__ ((noreturn)); extern void __bug (void) __attribute__ ((noreturn));
#define BUG() __bug() #define BUG() __bug()
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
#endif /* __V850_BUG_H__ */ #endif /* __V850_BUG_H__ */
...@@ -15,11 +15,13 @@ struct bug_frame { ...@@ -15,11 +15,13 @@ struct bug_frame {
unsigned short line; unsigned short line;
} __attribute__((packed)); } __attribute__((packed));
#ifdef CONFIG_BUG
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#define BUG() \ #define BUG() \
asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \ asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \
"i"(__LINE__), "i" (__stringify(__FILE__))) "i"(__LINE__), "i" (__stringify(__FILE__)))
void out_of_line_bug(void); void out_of_line_bug(void);
#include <asm-generic/bug.h> #endif
#include <asm-generic/bug.h>
#endif #endif
...@@ -275,6 +275,16 @@ config KALLSYMS_EXTRA_PASS ...@@ -275,6 +275,16 @@ config KALLSYMS_EXTRA_PASS
reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while
you wait for kallsyms to be fixed. you wait for kallsyms to be fixed.
config BUG
bool "BUG() support" if EMBEDDED
default y
help
Disabling this option eliminates support for BUG and WARN, reducing
the size of your kernel image and potentially quietly ignoring
numerous fatal conditions. You should only consider disabling this
option for embedded systems with no facilities for reporting errors.
Just say Y.
config BASE_FULL config BASE_FULL
default y default y
bool "Enable full-sized data structures for core" if EMBEDDED bool "Enable full-sized data structures for core" if EMBEDDED
......
...@@ -108,6 +108,7 @@ config DEBUG_HIGHMEM ...@@ -108,6 +108,7 @@ config DEBUG_HIGHMEM
config DEBUG_BUGVERBOSE config DEBUG_BUGVERBOSE
bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED
depends on BUG
depends on ARM || ARM26 || M32R || M68K || SPARC32 || SPARC64 || (X86 && !X86_64) || FRV depends on ARM || ARM26 || M32R || M68K || SPARC32 || SPARC64 || (X86 && !X86_64) || FRV
default !EMBEDDED default !EMBEDDED
help help
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment