Skip to content

Commit ffb61c6

Browse files
author
Ingo Molnar
committed
Revert "x86/bug: Macrofy the BUG table section handling, to work around GCC inlining bugs"
This reverts commit f81f8ad. See this commit for details about the revert: e769742 ("Revert "x86/jump-labels: Macrofy inline assembly code to work around GCC inlining bugs"") Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Borislav Petkov <bp@alien8.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Cc: Juergen Gross <jgross@suse.com> Cc: Richard Biener <rguenther@suse.de> Cc: Kees Cook <keescook@chromium.org> Cc: Segher Boessenkool <segher@kernel.crashing.org> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Nadav Amit <namit@vmware.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent a4da3d8 commit ffb61c6

File tree

3 files changed

+46
-61
lines changed

3 files changed

+46
-61
lines changed

arch/x86/include/asm/bug.h

Lines changed: 42 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
#include <linux/stringify.h>
66

7-
#ifndef __ASSEMBLY__
8-
97
/*
108
* Despite that some emulators terminate on UD2, we use it for WARN().
119
*
@@ -22,15 +20,53 @@
2220

2321
#define LEN_UD2 2
2422

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+
2550
#define _BUG_FLAGS(ins, flags) \
2651
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), \
3159
"i" (sizeof(struct bug_entry))); \
3260
} while (0)
3361

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+
3470
#define HAVE_ARCH_BUG
3571
#define BUG() \
3672
do { \
@@ -46,54 +82,4 @@ do { \
4682

4783
#include <asm-generic/bug.h>
4884

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-
9985
#endif /* _ASM_X86_BUG_H */

arch/x86/kernel/macros.S

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99
#include <linux/compiler.h>
1010
#include <asm/refcount.h>
1111
#include <asm/alternative-asm.h>
12-
#include <asm/bug.h>

include/asm-generic/bug.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
#ifndef __ASSEMBLY__
1818
#include <linux/kernel.h>
1919

20-
struct bug_entry {
20+
#ifdef CONFIG_BUG
21+
2122
#ifdef CONFIG_GENERIC_BUG
23+
struct bug_entry {
2224
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
2325
unsigned long bug_addr;
2426
#else
@@ -33,10 +35,8 @@ struct bug_entry {
3335
unsigned short line;
3436
#endif
3537
unsigned short flags;
36-
#endif /* CONFIG_GENERIC_BUG */
3738
};
38-
39-
#ifdef CONFIG_BUG
39+
#endif /* CONFIG_GENERIC_BUG */
4040

4141
/*
4242
* Don't use BUG() or BUG_ON() unless there's really no way out; one

0 commit comments

Comments
 (0)