Skip to content

x86/asm: Use generic asm operand modifiers instead of %P in asm templates

Uros Bizjak lkml 1 version Applied

Status from this message: The following commit has been merged into the x86/asm branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/3x86/asm: Remove %P operand modifier from altinstr asm templatesarch/x86/include/asm/apic.h arch/x86/include/asm/processor.h arch/x86/include/asm/special_insns.h+6 -60 replies
2/3x86/asm: Use %c/%n instead of %P operand modifier in asm templatesarch/x86/boot/main.c arch/x86/include/asm/alternative.h arch/x86/include/asm/atomic64_32.h +3 more+18 -180 replies
3/3x86/asm: Use %a instead of %P operand modifier in asm templatesarch/x86/include/asm/cpufeature.h+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH -tip 0/3] x86/asm: Use generic asm operand modifiers instead of %P in asm templates

The "P" asm operand modifier is a x86 target-specific modifier.

For x86_64, when used with a symbol reference, the "P" modifier emits "sym" instead of "sym(%rip)". When used with a constant, the "P" modifier emits "cst" instead of "$cst". This property is used to emit bare symbol references and bare constants without all syntax-specific prefixes.

The generic "c", "n" and "a" operand modifiers should be used instead. The following table shows the modifiers supported by all targets and their effects:

Modifier Description
-----------------------------------------------------------
'c' Require a constant operand and print the
constant expression with no punctuation.
'n' Like '%c' except that the value of the constant
is negated before printing.
'a' Substitute a memory reference, with the actual
operand treated as the address. This may be useful when outputting a "load address" instruction, because often the assembler syntax for such an instruction requires you to write the operand as if it were a memory reference.

Also note that unlike GCC, clang emits %rip-relative symbol reference with "P" asm operand modifier, so the patch also unifies symbol handling with both compilers.

No functional changes intended.

Cc Andy Lutomirski <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Sean Christopherson <[email protected]>

Uros Bizjak (3):
x86/asm: Remove %P operand modifier from altinstr asm templates x86/asm: Use %c/%n instead of %P operand modifier in asm templates x86/asm: Use %a instead of %P operand modifier in asm templates

 arch/x86/boot/main.c                 |  4 ++--
 arch/x86/include/asm/alternative.h   | 22 +++++++++++-----------
 arch/x86/include/asm/apic.h          |  2 +-
 arch/x86/include/asm/atomic64_32.h   |  2 +-
 arch/x86/include/asm/cpufeature.h    |  4 ++--
 arch/x86/include/asm/irq_stack.h     |  2 +-
 arch/x86/include/asm/processor.h     |  6 +++---
 arch/x86/include/asm/special_insns.h |  4 ++--
 arch/x86/include/asm/uaccess.h       |  4 ++--
 9 files changed, 25 insertions(+), 25 deletions(-)
Signature · 1 line
2.44.0