4
4
5
5
#include <linux/stringify.h>
6
6
7
- #ifndef __ASSEMBLY__
8
-
9
7
/*
10
8
* Despite that some emulators terminate on UD2, we use it for WARN().
11
9
*
22
20
23
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
50
#define _BUG_FLAGS (ins , flags ) \
26
51
do { \
27
- asm volatile("ASM_BUG ins=\"" ins "\" file=%c0 line=%c1 " \
28
- "flags=%c2 size=%c3" \
29
- : : "i" (__FILE__), "i" (__LINE__), \
30
- "i" (flags), \
52
+ asm volatile("1:\t" ins "\n" \
53
+ ".pushsection __bug_table,\"aw\"\n" \
54
+ "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
55
+ "\t.word %c0" "\t# bug_entry::flags\n" \
56
+ "\t.org 2b+%c1\n" \
57
+ ".popsection" \
58
+ : : "i" (flags), \
31
59
"i" (sizeof(struct bug_entry))); \
32
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
70
#define HAVE_ARCH_BUG
35
71
#define BUG () \
36
72
do { \
@@ -46,54 +82,4 @@ do { \
46
82
47
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
85
#endif /* _ASM_X86_BUG_H */
0 commit comments