hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/arch/x86/include/asm/bug.h
....@@ -3,6 +3,7 @@
33 #define _ASM_X86_BUG_H
44
55 #include <linux/stringify.h>
6
+#include <linux/instrumentation.h>
67
78 /*
89 * Despite that some emulators terminate on UD2, we use it for WARN().
....@@ -32,7 +33,7 @@
3233
3334 #define _BUG_FLAGS(ins, flags) \
3435 do { \
35
- asm volatile("1:\t" ins "\n" \
36
+ asm_inline volatile("1:\t" ins "\n" \
3637 ".pushsection __bug_table,\"aw\"\n" \
3738 "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
3839 "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \
....@@ -49,7 +50,7 @@
4950
5051 #define _BUG_FLAGS(ins, flags) \
5152 do { \
52
- asm volatile("1:\t" ins "\n" \
53
+ asm_inline volatile("1:\t" ins "\n" \
5354 ".pushsection __bug_table,\"aw\"\n" \
5455 "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
5556 "\t.word %c0" "\t# bug_entry::flags\n" \
....@@ -70,14 +71,23 @@
7071 #define HAVE_ARCH_BUG
7172 #define BUG() \
7273 do { \
74
+ instrumentation_begin(); \
7375 _BUG_FLAGS(ASM_UD2, 0); \
7476 unreachable(); \
7577 } while (0)
7678
79
+/*
80
+ * This instrumentation_begin() is strictly speaking incorrect; but it
81
+ * suppresses the complaints from WARN()s in noinstr code. If such a WARN()
82
+ * were to trigger, we'd rather wreck the machine in an attempt to get the
83
+ * message out than not know about it.
84
+ */
7785 #define __WARN_FLAGS(flags) \
7886 do { \
87
+ instrumentation_begin(); \
7988 _BUG_FLAGS(ASM_UD2, BUGFLAG_WARNING|(flags)); \
8089 annotate_reachable(); \
90
+ instrumentation_end(); \
8191 } while (0)
8292
8393 #include <asm-generic/bug.h>