diff options
Diffstat (limited to 'arch/x86/include/asm/bug.h')
-rw-r--r-- | arch/x86/include/asm/bug.h | 98 |
1 files changed, 56 insertions, 42 deletions
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index 6804d6642767..5090035e6d16 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h | |||
@@ -4,6 +4,8 @@ | |||
4 | 4 | ||
5 | #include <linux/stringify.h> | 5 | #include <linux/stringify.h> |
6 | 6 | ||
7 | #ifndef __ASSEMBLY__ | ||
8 | |||
7 | /* | 9 | /* |
8 | * Despite that some emulators terminate on UD2, we use it for WARN(). | 10 | * Despite that some emulators terminate on UD2, we use it for WARN(). |
9 | * | 11 | * |
@@ -20,53 +22,15 @@ | |||
20 | 22 | ||
21 | #define LEN_UD2 2 | 23 | #define LEN_UD2 2 |
22 | 24 | ||
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 | |||
50 | #define _BUG_FLAGS(ins, flags) \ | 25 | #define _BUG_FLAGS(ins, flags) \ |
51 | do { \ | 26 | do { \ |
52 | asm volatile("1:\t" ins "\n" \ | 27 | asm volatile("ASM_BUG ins=\"" ins "\" file=%c0 line=%c1 " \ |
53 | ".pushsection __bug_table,\"aw\"\n" \ | 28 | "flags=%c2 size=%c3" \ |
54 | "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ | 29 | : : "i" (__FILE__), "i" (__LINE__), \ |
55 | "\t.word %c0" "\t# bug_entry::flags\n" \ | 30 | "i" (flags), \ |
56 | "\t.org 2b+%c1\n" \ | ||
57 | ".popsection" \ | ||
58 | : : "i" (flags), \ | ||
59 | "i" (sizeof(struct bug_entry))); \ | 31 | "i" (sizeof(struct bug_entry))); \ |
60 | } while (0) | 32 | } while (0) |
61 | 33 | ||
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 | |||
70 | #define HAVE_ARCH_BUG | 34 | #define HAVE_ARCH_BUG |
71 | #define BUG() \ | 35 | #define BUG() \ |
72 | do { \ | 36 | do { \ |
@@ -82,4 +46,54 @@ do { \ | |||
82 | 46 | ||
83 | #include <asm-generic/bug.h> | 47 | #include <asm-generic/bug.h> |
84 | 48 | ||
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 | |||
85 | #endif /* _ASM_X86_BUG_H */ | 99 | #endif /* _ASM_X86_BUG_H */ |