diff options
-rw-r--r-- | arch/x86/include/asm/bug.h | 98 | ||||
-rw-r--r-- | arch/x86/kernel/macros.S | 1 | ||||
-rw-r--r-- | include/asm-generic/bug.h | 8 |
3 files changed, 46 insertions, 61 deletions
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index 5090035e6d16..6804d6642767 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h | |||
@@ -4,8 +4,6 @@ | |||
4 | 4 | ||
5 | #include <linux/stringify.h> | 5 | #include <linux/stringify.h> |
6 | 6 | ||
7 | #ifndef __ASSEMBLY__ | ||
8 | |||
9 | /* | 7 | /* |
10 | * Despite that some emulators terminate on UD2, we use it for WARN(). | 8 | * Despite that some emulators terminate on UD2, we use it for WARN(). |
11 | * | 9 | * |
@@ -22,15 +20,53 @@ | |||
22 | 20 | ||
23 | #define LEN_UD2 2 | 21 | #define LEN_UD2 2 |
24 | 22 | ||
23 | #ifdef CONFIG_GENERIC_BUG | ||
24 | |||
25 | #ifdef CONFIG_X86_32 | ||
26 | # define __BUG_REL(val) ".long " __stringify(val) | ||
27 | #else | ||
28 | # define __BUG_REL(val) ".long " __stringify(val) " - 2b" | ||
29 | #endif | ||
30 | |||
31 | #ifdef CONFIG_DEBUG_BUGVERBOSE | ||
32 | |||
33 | #define _BUG_FLAGS(ins, flags) \ | ||
34 | do { \ | ||
35 | asm volatile("1:\t" ins "\n" \ | ||
36 | ".pushsection __bug_table,\"aw\"\n" \ | ||
37 | "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ | ||
38 | "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ | ||
39 | "\t.word %c1" "\t# bug_entry::line\n" \ | ||
40 | "\t.word %c2" "\t# bug_entry::flags\n" \ | ||
41 | "\t.org 2b+%c3\n" \ | ||
42 | ".popsection" \ | ||
43 | : : "i" (__FILE__), "i" (__LINE__), \ | ||
44 | "i" (flags), \ | ||
45 | "i" (sizeof(struct bug_entry))); \ | ||
46 | } while (0) | ||
47 | |||
48 | #else /* !CONFIG_DEBUG_BUGVERBOSE */ | ||
49 | |||
25 | #define _BUG_FLAGS(ins, flags) \ | 50 | #define _BUG_FLAGS(ins, flags) \ |
26 | do { \ | 51 | do { \ |
27 | asm volatile("ASM_BUG ins=\"" ins "\" file=%c0 line=%c1 " \ | 52 | asm volatile("1:\t" ins "\n" \ |
28 | "flags=%c2 size=%c3" \ | 53 | ".pushsection __bug_table,\"aw\"\n" \ |
29 | : : "i" (__FILE__), "i" (__LINE__), \ | 54 | "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ |
30 | "i" (flags), \ | 55 | "\t.word %c0" "\t# bug_entry::flags\n" \ |
56 | "\t.org 2b+%c1\n" \ | ||
57 | ".popsection" \ | ||
58 | : : "i" (flags), \ | ||
31 | "i" (sizeof(struct bug_entry))); \ | 59 | "i" (sizeof(struct bug_entry))); \ |
32 | } while (0) | 60 | } while (0) |
33 | 61 | ||
62 | #endif /* CONFIG_DEBUG_BUGVERBOSE */ | ||
63 | |||
64 | #else | ||
65 | |||
66 | #define _BUG_FLAGS(ins, flags) asm volatile(ins) | ||
67 | |||
68 | #endif /* CONFIG_GENERIC_BUG */ | ||
69 | |||
34 | #define HAVE_ARCH_BUG | 70 | #define HAVE_ARCH_BUG |
35 | #define BUG() \ | 71 | #define BUG() \ |
36 | do { \ | 72 | do { \ |
@@ -46,54 +82,4 @@ do { \ | |||
46 | 82 | ||
47 | #include <asm-generic/bug.h> | 83 | #include <asm-generic/bug.h> |
48 | 84 | ||
49 | #else /* __ASSEMBLY__ */ | ||
50 | |||
51 | #ifdef CONFIG_GENERIC_BUG | ||
52 | |||
53 | #ifdef CONFIG_X86_32 | ||
54 | .macro __BUG_REL val:req | ||
55 | .long \val | ||
56 | .endm | ||
57 | #else | ||
58 | .macro __BUG_REL val:req | ||
59 | .long \val - 2b | ||
60 | .endm | ||
61 | #endif | ||
62 | |||
63 | #ifdef CONFIG_DEBUG_BUGVERBOSE | ||
64 | |||
65 | .macro ASM_BUG ins:req file:req line:req flags:req size:req | ||
66 | 1: \ins | ||
67 | .pushsection __bug_table,"aw" | ||
68 | 2: __BUG_REL val=1b # bug_entry::bug_addr | ||
69 | __BUG_REL val=\file # bug_entry::file | ||
70 | .word \line # bug_entry::line | ||
71 | .word \flags # bug_entry::flags | ||
72 | .org 2b+\size | ||
73 | .popsection | ||
74 | .endm | ||
75 | |||
76 | #else /* !CONFIG_DEBUG_BUGVERBOSE */ | ||
77 | |||
78 | .macro ASM_BUG ins:req file:req line:req flags:req size:req | ||
79 | 1: \ins | ||
80 | .pushsection __bug_table,"aw" | ||
81 | 2: __BUG_REL val=1b # bug_entry::bug_addr | ||
82 | .word \flags # bug_entry::flags | ||
83 | .org 2b+\size | ||
84 | .popsection | ||
85 | .endm | ||
86 | |||
87 | #endif /* CONFIG_DEBUG_BUGVERBOSE */ | ||
88 | |||
89 | #else /* CONFIG_GENERIC_BUG */ | ||
90 | |||
91 | .macro ASM_BUG ins:req file:req line:req flags:req size:req | ||
92 | \ins | ||
93 | .endm | ||
94 | |||
95 | #endif /* CONFIG_GENERIC_BUG */ | ||
96 | |||
97 | #endif /* __ASSEMBLY__ */ | ||
98 | |||
99 | #endif /* _ASM_X86_BUG_H */ | 85 | #endif /* _ASM_X86_BUG_H */ |
diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S index 66ccb8e823b1..852487a9fc56 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S | |||
@@ -9,4 +9,3 @@ | |||
9 | #include <linux/compiler.h> | 9 | #include <linux/compiler.h> |
10 | #include <asm/refcount.h> | 10 | #include <asm/refcount.h> |
11 | #include <asm/alternative-asm.h> | 11 | #include <asm/alternative-asm.h> |
12 | #include <asm/bug.h> | ||
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index cdafa5edea49..20561a60db9c 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h | |||
@@ -17,8 +17,10 @@ | |||
17 | #ifndef __ASSEMBLY__ | 17 | #ifndef __ASSEMBLY__ |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | 19 | ||
20 | struct bug_entry { | 20 | #ifdef CONFIG_BUG |
21 | |||
21 | #ifdef CONFIG_GENERIC_BUG | 22 | #ifdef CONFIG_GENERIC_BUG |
23 | struct bug_entry { | ||
22 | #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS | 24 | #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS |
23 | unsigned long bug_addr; | 25 | unsigned long bug_addr; |
24 | #else | 26 | #else |
@@ -33,10 +35,8 @@ struct bug_entry { | |||
33 | unsigned short line; | 35 | unsigned short line; |
34 | #endif | 36 | #endif |
35 | unsigned short flags; | 37 | unsigned short flags; |
36 | #endif /* CONFIG_GENERIC_BUG */ | ||
37 | }; | 38 | }; |
38 | 39 | #endif /* CONFIG_GENERIC_BUG */ | |
39 | #ifdef CONFIG_BUG | ||
40 | 40 | ||
41 | /* | 41 | /* |
42 | * Don't use BUG() or BUG_ON() unless there's really no way out; one | 42 | * Don't use BUG() or BUG_ON() unless there's really no way out; one |