Skip to content

Commit 1fe67ae

Browse files
ubizjakingomolnar
authored andcommitted
x86/percpu: Fix operand constraint modifier in __raw_cpu_write()
__raw_cpu_write() with !USE_X86_SEG_SUPPORT config uses read/write operand constraint modifier "+" for its memory location. This signals the compiler that the location is both read and written by the asm. This is not true, because MOV insn only writes to the output. Correct the modifier to "=" to inform the compiler that the memory location is only written to. This also prevents the compiler from value tracking the undefined value from the uninitialized memory. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20240430091833.196482-5-ubizjak@gmail.com
1 parent 539615d commit 1fe67ae

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/include/asm/percpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ do { \
178178
(void)pto_tmp__; \
179179
} \
180180
asm qual(__pcpu_op2_##size("mov", "%[val]", __percpu_arg([var])) \
181-
: [var] "+m" (__my_cpu_var(_var)) \
181+
: [var] "=m" (__my_cpu_var(_var)) \
182182
: [val] __pcpu_reg_imm_##size(pto_val__)); \
183183
} while (0)
184184

0 commit comments

Comments
 (0)