Skip to content

Commit e39828d

Browse files
ubizjakIngo Molnar
authored andcommitted
x86/percpu: Use the correct asm operand modifier in percpu_stable_op()
The "P" asm operand modifier is a x86 target-specific modifier. When used for a constant, it drops all syntax-specific prefixes and issues the bare constant. This modifier is not correct for address handling, in this case a generic "a" operand modifier should be used. The "a" asm operand modifier substitutes a memory reference, with the actual operand treated as address. For x86_64, when a symbol is provided, the "a" modifier emits "sym(%rip)" instead of "sym", enabling shorter %rip-relative addressing. Clang allows only "i" and "r" operand constraints with an "a" modifier, so the patch normalizes the modifier/constraint pair to "a"/"i" which is consistent between both compilers. The patch reduces code size of a test build by 4072 bytes: text data bss dec hex filename 25523268 4388300 808452 30720020 1d4c014 vmlinux-old.o 25519196 4388300 808452 30715948 1d4b02c vmlinux-new.o [ mingo: Changelog clarity. ] Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Uros Bizjak <ubizjak@gmail.com> Cc: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20231016200755.287403-1-ubizjak@gmail.com
1 parent 1d10f3a commit e39828d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/include/asm/percpu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ do { \
194194
#define percpu_stable_op(size, op, _var) \
195195
({ \
196196
__pcpu_type_##size pfo_val__; \
197-
asm(__pcpu_op2_##size(op, __force_percpu_arg(P[var]), "%[val]") \
197+
asm(__pcpu_op2_##size(op, __force_percpu_arg(a[var]), "%[val]") \
198198
: [val] __pcpu_reg_##size("=", pfo_val__) \
199-
: [var] "p" (&(_var))); \
199+
: [var] "i" (&(_var))); \
200200
(typeof(_var))(unsigned long) pfo_val__; \
201201
})
202202

0 commit comments

Comments
 (0)