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

Configure Feed

Select the types of activity you want to include in your feed.

compiler.h: Fix annotation macro misplacement with Clang

When building with Clang and CONFIG_TRACE_BRANCH_PROFILING, there are a
lot of unreachable warnings, like:

arch/x86/kernel/traps.o: warning: objtool: handle_xfd_event()+0x134: unreachable instruction

Without an input to the inline asm, 'volatile' is ignored for some
reason and Clang feels free to move the reachable() annotation away from
its intended location.

Fix that by re-adding the counter value to the inputs.

Fixes: f1069a8756b9 ("compiler.h: Avoid using inline asm operand modifiers")
Fixes: c199f64ff93c ("instrumentation.h: Avoid using inline asm operand modifiers")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/0417e96909b97a406323409210de7bf13df0b170.1636410380.git.jpoimboe@redhat.com
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Miroslav Benes <mbenes@suse.cz>

+4 -4
+2 -2
include/linux/compiler.h
··· 121 asm volatile(__stringify_label(c) ":\n\t" \ 122 ".pushsection .discard.reachable\n\t" \ 123 ".long " __stringify_label(c) "b - .\n\t" \ 124 - ".popsection\n\t"); \ 125 }) 126 #define annotate_reachable() __annotate_reachable(__COUNTER__) 127 ··· 129 asm volatile(__stringify_label(c) ":\n\t" \ 130 ".pushsection .discard.unreachable\n\t" \ 131 ".long " __stringify_label(c) "b - .\n\t" \ 132 - ".popsection\n\t"); \ 133 }) 134 #define annotate_unreachable() __annotate_unreachable(__COUNTER__) 135
··· 121 asm volatile(__stringify_label(c) ":\n\t" \ 122 ".pushsection .discard.reachable\n\t" \ 123 ".long " __stringify_label(c) "b - .\n\t" \ 124 + ".popsection\n\t" : : "i" (c)); \ 125 }) 126 #define annotate_reachable() __annotate_reachable(__COUNTER__) 127 ··· 129 asm volatile(__stringify_label(c) ":\n\t" \ 130 ".pushsection .discard.unreachable\n\t" \ 131 ".long " __stringify_label(c) "b - .\n\t" \ 132 + ".popsection\n\t" : : "i" (c)); \ 133 }) 134 #define annotate_unreachable() __annotate_unreachable(__COUNTER__) 135
+2 -2
include/linux/instrumentation.h
··· 11 asm volatile(__stringify(c) ": nop\n\t" \ 12 ".pushsection .discard.instr_begin\n\t" \ 13 ".long " __stringify(c) "b - .\n\t" \ 14 - ".popsection\n\t"); \ 15 }) 16 #define instrumentation_begin() __instrumentation_begin(__COUNTER__) 17 ··· 50 asm volatile(__stringify(c) ": nop\n\t" \ 51 ".pushsection .discard.instr_end\n\t" \ 52 ".long " __stringify(c) "b - .\n\t" \ 53 - ".popsection\n\t"); \ 54 }) 55 #define instrumentation_end() __instrumentation_end(__COUNTER__) 56 #else
··· 11 asm volatile(__stringify(c) ": nop\n\t" \ 12 ".pushsection .discard.instr_begin\n\t" \ 13 ".long " __stringify(c) "b - .\n\t" \ 14 + ".popsection\n\t" : : "i" (c)); \ 15 }) 16 #define instrumentation_begin() __instrumentation_begin(__COUNTER__) 17 ··· 50 asm volatile(__stringify(c) ": nop\n\t" \ 51 ".pushsection .discard.instr_end\n\t" \ 52 ".long " __stringify(c) "b - .\n\t" \ 53 + ".popsection\n\t" : : "i" (c)); \ 54 }) 55 #define instrumentation_end() __instrumentation_end(__COUNTER__) 56 #else