Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "x86/bug: Macrofy the BUG table section handling, to work around GCC inlining bugs"

This reverts commit f81f8ad56fd1c7b99b2ed1c314527f7d9ac447c6.

See this commit for details about the revert:

e769742d3584 ("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>

+46 -61
+42 -56
arch/x86/include/asm/bug.h
··· 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 * ··· 20 22 21 23 #define LEN_UD2 2 22 24 25 + #ifdef CONFIG_GENERIC_BUG 26 + 27 + #ifdef CONFIG_X86_32 28 + # define __BUG_REL(val) ".long " __stringify(val) 29 + #else 30 + # define __BUG_REL(val) ".long " __stringify(val) " - 2b" 31 + #endif 32 + 33 + #ifdef CONFIG_DEBUG_BUGVERBOSE 34 + 23 35 #define _BUG_FLAGS(ins, flags) \ 24 36 do { \ 25 - asm volatile("ASM_BUG ins=\"" ins "\" file=%c0 line=%c1 " \ 26 - "flags=%c2 size=%c3" \ 27 - : : "i" (__FILE__), "i" (__LINE__), \ 28 - "i" (flags), \ 37 + asm volatile("1:\t" ins "\n" \ 38 + ".pushsection __bug_table,\"aw\"\n" \ 39 + "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ 40 + "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ 41 + "\t.word %c1" "\t# bug_entry::line\n" \ 42 + "\t.word %c2" "\t# bug_entry::flags\n" \ 43 + "\t.org 2b+%c3\n" \ 44 + ".popsection" \ 45 + : : "i" (__FILE__), "i" (__LINE__), \ 46 + "i" (flags), \ 29 47 "i" (sizeof(struct bug_entry))); \ 30 48 } while (0) 49 + 50 + #else /* !CONFIG_DEBUG_BUGVERBOSE */ 51 + 52 + #define _BUG_FLAGS(ins, flags) \ 53 + do { \ 54 + asm volatile("1:\t" ins "\n" \ 55 + ".pushsection __bug_table,\"aw\"\n" \ 56 + "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ 57 + "\t.word %c0" "\t# bug_entry::flags\n" \ 58 + "\t.org 2b+%c1\n" \ 59 + ".popsection" \ 60 + : : "i" (flags), \ 61 + "i" (sizeof(struct bug_entry))); \ 62 + } while (0) 63 + 64 + #endif /* CONFIG_DEBUG_BUGVERBOSE */ 65 + 66 + #else 67 + 68 + #define _BUG_FLAGS(ins, flags) asm volatile(ins) 69 + 70 + #endif /* CONFIG_GENERIC_BUG */ 31 71 32 72 #define HAVE_ARCH_BUG 33 73 #define BUG() \ ··· 81 45 } while (0) 82 46 83 47 #include <asm-generic/bug.h> 84 - 85 - #else /* __ASSEMBLY__ */ 86 - 87 - #ifdef CONFIG_GENERIC_BUG 88 - 89 - #ifdef CONFIG_X86_32 90 - .macro __BUG_REL val:req 91 - .long \val 92 - .endm 93 - #else 94 - .macro __BUG_REL val:req 95 - .long \val - 2b 96 - .endm 97 - #endif 98 - 99 - #ifdef CONFIG_DEBUG_BUGVERBOSE 100 - 101 - .macro ASM_BUG ins:req file:req line:req flags:req size:req 102 - 1: \ins 103 - .pushsection __bug_table,"aw" 104 - 2: __BUG_REL val=1b # bug_entry::bug_addr 105 - __BUG_REL val=\file # bug_entry::file 106 - .word \line # bug_entry::line 107 - .word \flags # bug_entry::flags 108 - .org 2b+\size 109 - .popsection 110 - .endm 111 - 112 - #else /* !CONFIG_DEBUG_BUGVERBOSE */ 113 - 114 - .macro ASM_BUG ins:req file:req line:req flags:req size:req 115 - 1: \ins 116 - .pushsection __bug_table,"aw" 117 - 2: __BUG_REL val=1b # bug_entry::bug_addr 118 - .word \flags # bug_entry::flags 119 - .org 2b+\size 120 - .popsection 121 - .endm 122 - 123 - #endif /* CONFIG_DEBUG_BUGVERBOSE */ 124 - 125 - #else /* CONFIG_GENERIC_BUG */ 126 - 127 - .macro ASM_BUG ins:req file:req line:req flags:req size:req 128 - \ins 129 - .endm 130 - 131 - #endif /* CONFIG_GENERIC_BUG */ 132 - 133 - #endif /* __ASSEMBLY__ */ 134 48 135 49 #endif /* _ASM_X86_BUG_H */
-1
arch/x86/kernel/macros.S
··· 9 9 #include <linux/compiler.h> 10 10 #include <asm/refcount.h> 11 11 #include <asm/alternative-asm.h> 12 - #include <asm/bug.h>
+4 -4
include/asm-generic/bug.h
··· 17 17 #ifndef __ASSEMBLY__ 18 18 #include <linux/kernel.h> 19 19 20 - struct bug_entry { 20 + #ifdef CONFIG_BUG 21 + 21 22 #ifdef CONFIG_GENERIC_BUG 23 + struct bug_entry { 22 24 #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS 23 25 unsigned long bug_addr; 24 26 #else ··· 35 33 unsigned short line; 36 34 #endif 37 35 unsigned short flags; 38 - #endif /* CONFIG_GENERIC_BUG */ 39 36 }; 40 - 41 - #ifdef CONFIG_BUG 37 + #endif /* CONFIG_GENERIC_BUG */ 42 38 43 39 /* 44 40 * Don't use BUG() or BUG_ON() unless there's really no way out; one