diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/bug.h | 16 | ||||
-rw-r--r-- | include/asm-generic/vmlinux.lds.h | 8 | ||||
-rw-r--r-- | include/linux/bug.h | 47 | ||||
-rw-r--r-- | include/linux/module.h | 7 |
4 files changed, 78 insertions, 0 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index c92ae0f166ff..47e3561638b1 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h | |||
@@ -4,6 +4,22 @@ | |||
4 | #include <linux/compiler.h> | 4 | #include <linux/compiler.h> |
5 | 5 | ||
6 | #ifdef CONFIG_BUG | 6 | #ifdef CONFIG_BUG |
7 | |||
8 | #ifdef CONFIG_GENERIC_BUG | ||
9 | #ifndef __ASSEMBLY__ | ||
10 | struct bug_entry { | ||
11 | unsigned long bug_addr; | ||
12 | #ifdef CONFIG_DEBUG_BUGVERBOSE | ||
13 | const char *file; | ||
14 | unsigned short line; | ||
15 | #endif | ||
16 | unsigned short flags; | ||
17 | }; | ||
18 | #endif /* __ASSEMBLY__ */ | ||
19 | |||
20 | #define BUGFLAG_WARNING (1<<0) | ||
21 | #endif /* CONFIG_GENERIC_BUG */ | ||
22 | |||
7 | #ifndef HAVE_ARCH_BUG | 23 | #ifndef HAVE_ARCH_BUG |
8 | #define BUG() do { \ | 24 | #define BUG() do { \ |
9 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ | 25 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ |
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 4d4c62d11059..6e9fcebbf89f 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -218,6 +218,14 @@ | |||
218 | .stab.indexstr 0 : { *(.stab.indexstr) } \ | 218 | .stab.indexstr 0 : { *(.stab.indexstr) } \ |
219 | .comment 0 : { *(.comment) } | 219 | .comment 0 : { *(.comment) } |
220 | 220 | ||
221 | #define BUG_TABLE \ | ||
222 | . = ALIGN(8); \ | ||
223 | __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \ | ||
224 | __start___bug_table = .; \ | ||
225 | *(__bug_table) \ | ||
226 | __stop___bug_table = .; \ | ||
227 | } | ||
228 | |||
221 | #define NOTES \ | 229 | #define NOTES \ |
222 | .notes : { *(.note.*) } :note | 230 | .notes : { *(.note.*) } :note |
223 | 231 | ||
diff --git a/include/linux/bug.h b/include/linux/bug.h new file mode 100644 index 000000000000..42aa0a54b6f4 --- /dev/null +++ b/include/linux/bug.h | |||
@@ -0,0 +1,47 @@ | |||
1 | #ifndef _LINUX_BUG_H | ||
2 | #define _LINUX_BUG_H | ||
3 | |||
4 | #include <linux/module.h> | ||
5 | #include <asm/bug.h> | ||
6 | |||
7 | enum bug_trap_type { | ||
8 | BUG_TRAP_TYPE_NONE = 0, | ||
9 | BUG_TRAP_TYPE_WARN = 1, | ||
10 | BUG_TRAP_TYPE_BUG = 2, | ||
11 | }; | ||
12 | |||
13 | #ifdef CONFIG_GENERIC_BUG | ||
14 | #include <asm-generic/bug.h> | ||
15 | |||
16 | static inline int is_warning_bug(const struct bug_entry *bug) | ||
17 | { | ||
18 | return bug->flags & BUGFLAG_WARNING; | ||
19 | } | ||
20 | |||
21 | const struct bug_entry *find_bug(unsigned long bugaddr); | ||
22 | |||
23 | enum bug_trap_type report_bug(unsigned long bug_addr); | ||
24 | |||
25 | int module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *, | ||
26 | struct module *); | ||
27 | void module_bug_cleanup(struct module *); | ||
28 | |||
29 | /* These are defined by the architecture */ | ||
30 | int is_valid_bugaddr(unsigned long addr); | ||
31 | |||
32 | #else /* !CONFIG_GENERIC_BUG */ | ||
33 | |||
34 | static inline enum bug_trap_type report_bug(unsigned long bug_addr) | ||
35 | { | ||
36 | return BUG_TRAP_TYPE_BUG; | ||
37 | } | ||
38 | static inline int module_bug_finalize(const Elf_Ehdr *hdr, | ||
39 | const Elf_Shdr *sechdrs, | ||
40 | struct module *mod) | ||
41 | { | ||
42 | return 0; | ||
43 | } | ||
44 | static inline void module_bug_cleanup(struct module *mod) {} | ||
45 | |||
46 | #endif /* CONFIG_GENERIC_BUG */ | ||
47 | #endif /* _LINUX_BUG_H */ | ||
diff --git a/include/linux/module.h b/include/linux/module.h index d33df2408e05..10f771a49997 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -319,6 +319,13 @@ struct module | |||
319 | 319 | ||
320 | unsigned int taints; /* same bits as kernel:tainted */ | 320 | unsigned int taints; /* same bits as kernel:tainted */ |
321 | 321 | ||
322 | #ifdef CONFIG_GENERIC_BUG | ||
323 | /* Support for BUG */ | ||
324 | struct list_head bug_list; | ||
325 | struct bug_entry *bug_table; | ||
326 | unsigned num_bugs; | ||
327 | #endif | ||
328 | |||
322 | #ifdef CONFIG_MODULE_UNLOAD | 329 | #ifdef CONFIG_MODULE_UNLOAD |
323 | /* Reference counts */ | 330 | /* Reference counts */ |
324 | struct module_ref ref[NR_CPUS]; | 331 | struct module_ref ref[NR_CPUS]; |