Skip to content

Commit f1069a8

Browse files
Vasily Gorbikjpoimboe
authored andcommitted
compiler.h: Avoid using inline asm operand modifiers
The expansion of annotate_reachable/annotate_unreachable on s390 will result in a compiler error if the __COUNTER__ value is high enough. For example with "i" (154) the "%c0" operand of annotate_reachable will be expanded to -102: -102: .pushsection .discard.reachable .long -102b - . .popsection This is a quirk of the gcc backend for s390, it interprets the %c0 as a signed byte value. Avoid using operand modifiers in this case by simply converting __COUNTER__ to string, with the same result, but in an arch assembler independent way. Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lore.kernel.org/r/patch-1.thread-1a26be.git-930d1b44844a.your-ad-here.call-01621428935-ext-2104@work.hours Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Miroslav Benes <mbenes@suse.cz> Cc: Borislav Petkov <bp@suse.de> Cc: linux-kernel@vger.kernel.org
1 parent 8852c55 commit f1069a8

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

include/linux/compiler.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,24 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
115115
* The __COUNTER__ based labels are a hack to make each instance of the macros
116116
* unique, to convince GCC not to merge duplicate inline asm statements.
117117
*/
118-
#define annotate_reachable() ({ \
119-
asm volatile("%c0:\n\t" \
118+
#define __stringify_label(n) #n
119+
120+
#define __annotate_reachable(c) ({ \
121+
asm volatile(__stringify_label(c) ":\n\t" \
120122
".pushsection .discard.reachable\n\t" \
121-
".long %c0b - .\n\t" \
122-
".popsection\n\t" : : "i" (__COUNTER__)); \
123+
".long " __stringify_label(c) "b - .\n\t" \
124+
".popsection\n\t"); \
123125
})
124-
#define annotate_unreachable() ({ \
125-
asm volatile("%c0:\n\t" \
126+
#define annotate_reachable() __annotate_reachable(__COUNTER__)
127+
128+
#define __annotate_unreachable(c) ({ \
129+
asm volatile(__stringify_label(c) ":\n\t" \
126130
".pushsection .discard.unreachable\n\t" \
127-
".long %c0b - .\n\t" \
128-
".popsection\n\t" : : "i" (__COUNTER__)); \
131+
".long " __stringify_label(c) "b - .\n\t" \
132+
".popsection\n\t"); \
129133
})
134+
#define annotate_unreachable() __annotate_unreachable(__COUNTER__)
135+
130136
#define ASM_UNREACHABLE \
131137
"999:\n\t" \
132138
".pushsection .discard.unreachable\n\t" \

0 commit comments

Comments
 (0)