Skip to content

Commit 427f720

Browse files
compiler.h: use compiler barrier for reachable annotations
Partial revert of commit dcce50e ("compiler.h: Fix annotation macro misplacement with Clang") volatile is not a compiler barrier. Signed-off-by: Nick Desaulniers <[email protected]>
1 parent 384c4cb commit 427f720

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

include/linux/compiler.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,27 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
112112
#ifdef CONFIG_STACK_VALIDATION
113113
/*
114114
* These macros help objtool understand GCC code flow for unreachable code.
115-
* The __COUNTER__ based labels are a hack to make each instance of the macros
116-
* unique, to convince GCC not to merge duplicate inline asm statements.
115+
* The __COUNTER__ based labels are to make each instance of the macros unique,
116+
* to convince GCC not to merge duplicate inline asm statements. This was
117+
* recommended by GCC developers in
118+
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104236#c4. %= output templates
119+
* are not a substitute to prevent asm statements from appearing as duplicates.
117120
*/
118121
#define __stringify_label(n) #n
119122

120123
#define __annotate_reachable(c) ({ \
121-
asm volatile(__stringify_label(c) ":\n\t" \
124+
asm (__stringify_label(c) ":\n\t" \
122125
".pushsection .discard.reachable\n\t" \
123126
".long " __stringify_label(c) "b - .\n\t" \
124-
".popsection\n\t" : : "i" (c)); \
127+
".popsection" ::: "memory"); \
125128
})
126129
#define annotate_reachable() __annotate_reachable(__COUNTER__)
127130

128131
#define __annotate_unreachable(c) ({ \
129-
asm volatile(__stringify_label(c) ":\n\t" \
132+
asm (__stringify_label(c) ":\n\t" \
130133
".pushsection .discard.unreachable\n\t" \
131134
".long " __stringify_label(c) "b - .\n\t" \
132-
".popsection\n\t" : : "i" (c)); \
135+
".popsection" ::: "memory"); \
133136
})
134137
#define annotate_unreachable() __annotate_unreachable(__COUNTER__)
135138

0 commit comments

Comments
 (0)