Skip to content

Commit 89fd4a1

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: jump_label: mark arguments as const to satisfy asm constraints
Samuel reported that the static branch usage in cpu_relax() breaks building with CONFIG_CC_OPTIMIZE_FOR_SIZE: In file included from <command-line>: ./arch/riscv/include/asm/jump_label.h: In function 'cpu_relax': ././include/linux/compiler_types.h:285:33: warning: 'asm' operand 0 probably does not match constraints 285 | #define asm_volatile_goto(x...) asm goto(x) | ^~~ ./arch/riscv/include/asm/jump_label.h:41:9: note: in expansion of macro 'asm_volatile_goto' 41 | asm_volatile_goto( | ^~~~~~~~~~~~~~~~~ ././include/linux/compiler_types.h:285:33: error: impossible constraint in 'asm' 285 | #define asm_volatile_goto(x...) asm goto(x) | ^~~ ./arch/riscv/include/asm/jump_label.h:41:9: note: in expansion of macro 'asm_volatile_goto' 41 | asm_volatile_goto( | ^~~~~~~~~~~~~~~~~ make[1]: *** [scripts/Makefile.build:249: arch/riscv/kernel/vdso/vgettimeofday.o] Error 1 make: *** [arch/riscv/Makefile:128: vdso_prepare] Error 2 Maybe "-Os" prevents GCC from detecting that the key/branch arguments can be treated as constants and used as immediate operands. Inspired by x86's commit 864b435("x86/jump_label: Mark arguments as const to satisfy asm constraints"), and as pointed out by Steven: "The "i" constraint needs to be a constant.", let's do similar modifications to riscv. Tested by CC_OPTIMIZE_FOR_SIZE + gcc and CC_OPTIMIZE_FOR_SIZE + clang. Link: https://lore.kernel.org/linux-riscv/[email protected]/ Link: https://lore.kernel.org/all/[email protected]/ Fixes: 8eb060e ("arch/riscv: add Zihintpause support") Reported-by: Samuel Holland <[email protected]> Signed-off-by: Jisheng Zhang <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 9abf231 commit 89fd4a1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/riscv/include/asm/jump_label.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
#define JUMP_LABEL_NOP_SIZE 4
1616

17-
static __always_inline bool arch_static_branch(struct static_key *key,
18-
bool branch)
17+
static __always_inline bool arch_static_branch(struct static_key * const key,
18+
const bool branch)
1919
{
2020
asm_volatile_goto(
2121
" .option push \n\t"
@@ -35,8 +35,8 @@ static __always_inline bool arch_static_branch(struct static_key *key,
3535
return true;
3636
}
3737

38-
static __always_inline bool arch_static_branch_jump(struct static_key *key,
39-
bool branch)
38+
static __always_inline bool arch_static_branch_jump(struct static_key * const key,
39+
const bool branch)
4040
{
4141
asm_volatile_goto(
4242
" .option push \n\t"

0 commit comments

Comments
 (0)