Skip to content

Commit 864b435

Browse files
jigpuIngo Molnar
authored andcommitted
x86/jump_label: Mark arguments as const to satisfy asm constraints
When compiling an external kernel module with `-O0` or `-O1`, the following compile error may be reported: ./arch/x86/include/asm/jump_label.h:25:2: error: impossible constraint in ‘asm’ 25 | asm_volatile_goto("1:" | ^~~~~~~~~~~~~~~~~ It appears that these lower optimization levels prevent GCC from detecting that the key/branch arguments can be treated as constants and used as immediate operands. To work around this, explicitly add the `const` label. Signed-off-by: Jason Gerecke <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Steven Rostedt (VMware) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent a5aabac commit 864b435

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/include/asm/jump_label.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <linux/stringify.h>
2121
#include <linux/types.h>
2222

23-
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
23+
static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch)
2424
{
2525
asm_volatile_goto("1:"
2626
".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
@@ -36,7 +36,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran
3636
return true;
3737
}
3838

39-
static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
39+
static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch)
4040
{
4141
asm_volatile_goto("1:"
4242
".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"

0 commit comments

Comments
 (0)