Commit 42964a18 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'objtool_urgent_for_v5.17_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull objtool fix from Borislav Petkov:
 "Fix a case where objtool would mistakenly warn about instructions
  being unreachable"

* tag 'objtool_urgent_for_v5.17_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/bug: Merge annotate_reachable() into _BUG_FLAGS() asm
parents 6f357367 bfb1a7c9
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
#define _BUG_FLAGS(ins, flags) \ #define _BUG_FLAGS(ins, flags, extra) \
do { \ do { \
asm_inline volatile("1:\t" ins "\n" \ asm_inline volatile("1:\t" ins "\n" \
".pushsection __bug_table,\"aw\"\n" \ ".pushsection __bug_table,\"aw\"\n" \
...@@ -31,7 +31,8 @@ do { \ ...@@ -31,7 +31,8 @@ do { \
"\t.word %c1" "\t# bug_entry::line\n" \ "\t.word %c1" "\t# bug_entry::line\n" \
"\t.word %c2" "\t# bug_entry::flags\n" \ "\t.word %c2" "\t# bug_entry::flags\n" \
"\t.org 2b+%c3\n" \ "\t.org 2b+%c3\n" \
".popsection" \ ".popsection\n" \
extra \
: : "i" (__FILE__), "i" (__LINE__), \ : : "i" (__FILE__), "i" (__LINE__), \
"i" (flags), \ "i" (flags), \
"i" (sizeof(struct bug_entry))); \ "i" (sizeof(struct bug_entry))); \
...@@ -39,14 +40,15 @@ do { \ ...@@ -39,14 +40,15 @@ do { \
#else /* !CONFIG_DEBUG_BUGVERBOSE */ #else /* !CONFIG_DEBUG_BUGVERBOSE */
#define _BUG_FLAGS(ins, flags) \ #define _BUG_FLAGS(ins, flags, extra) \
do { \ do { \
asm_inline volatile("1:\t" ins "\n" \ asm_inline volatile("1:\t" ins "\n" \
".pushsection __bug_table,\"aw\"\n" \ ".pushsection __bug_table,\"aw\"\n" \
"2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
"\t.word %c0" "\t# bug_entry::flags\n" \ "\t.word %c0" "\t# bug_entry::flags\n" \
"\t.org 2b+%c1\n" \ "\t.org 2b+%c1\n" \
".popsection" \ ".popsection\n" \
extra \
: : "i" (flags), \ : : "i" (flags), \
"i" (sizeof(struct bug_entry))); \ "i" (sizeof(struct bug_entry))); \
} while (0) } while (0)
...@@ -55,7 +57,7 @@ do { \ ...@@ -55,7 +57,7 @@ do { \
#else #else
#define _BUG_FLAGS(ins, flags) asm volatile(ins) #define _BUG_FLAGS(ins, flags, extra) asm volatile(ins)
#endif /* CONFIG_GENERIC_BUG */ #endif /* CONFIG_GENERIC_BUG */
...@@ -63,8 +65,8 @@ do { \ ...@@ -63,8 +65,8 @@ do { \
#define BUG() \ #define BUG() \
do { \ do { \
instrumentation_begin(); \ instrumentation_begin(); \
_BUG_FLAGS(ASM_UD2, 0); \ _BUG_FLAGS(ASM_UD2, 0, ""); \
unreachable(); \ __builtin_unreachable(); \
} while (0) } while (0)
/* /*
...@@ -75,9 +77,9 @@ do { \ ...@@ -75,9 +77,9 @@ do { \
*/ */
#define __WARN_FLAGS(flags) \ #define __WARN_FLAGS(flags) \
do { \ do { \
__auto_type f = BUGFLAG_WARNING|(flags); \
instrumentation_begin(); \ instrumentation_begin(); \
_BUG_FLAGS(ASM_UD2, BUGFLAG_WARNING|(flags)); \ _BUG_FLAGS(ASM_UD2, f, ASM_REACHABLE); \
annotate_reachable(); \
instrumentation_end(); \ instrumentation_end(); \
} while (0) } while (0)
......
...@@ -117,14 +117,6 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, ...@@ -117,14 +117,6 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
*/ */
#define __stringify_label(n) #n #define __stringify_label(n) #n
#define __annotate_reachable(c) ({ \
asm volatile(__stringify_label(c) ":\n\t" \
".pushsection .discard.reachable\n\t" \
".long " __stringify_label(c) "b - .\n\t" \
".popsection\n\t" : : "i" (c)); \
})
#define annotate_reachable() __annotate_reachable(__COUNTER__)
#define __annotate_unreachable(c) ({ \ #define __annotate_unreachable(c) ({ \
asm volatile(__stringify_label(c) ":\n\t" \ asm volatile(__stringify_label(c) ":\n\t" \
".pushsection .discard.unreachable\n\t" \ ".pushsection .discard.unreachable\n\t" \
...@@ -133,24 +125,21 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, ...@@ -133,24 +125,21 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
}) })
#define annotate_unreachable() __annotate_unreachable(__COUNTER__) #define annotate_unreachable() __annotate_unreachable(__COUNTER__)
#define ASM_UNREACHABLE \ #define ASM_REACHABLE \
"999:\n\t" \ "998:\n\t" \
".pushsection .discard.unreachable\n\t" \ ".pushsection .discard.reachable\n\t" \
".long 999b - .\n\t" \ ".long 998b - .\n\t" \
".popsection\n\t" ".popsection\n\t"
/* Annotate a C jump table to allow objtool to follow the code flow */ /* Annotate a C jump table to allow objtool to follow the code flow */
#define __annotate_jump_table __section(".rodata..c_jump_table") #define __annotate_jump_table __section(".rodata..c_jump_table")
#else #else
#define annotate_reachable()
#define annotate_unreachable() #define annotate_unreachable()
# define ASM_REACHABLE
#define __annotate_jump_table #define __annotate_jump_table
#endif #endif
#ifndef ASM_UNREACHABLE
# define ASM_UNREACHABLE
#endif
#ifndef unreachable #ifndef unreachable
# define unreachable() do { \ # define unreachable() do { \
annotate_unreachable(); \ annotate_unreachable(); \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment