x86/asm: Use %c/%n instead of %P operand modifier in asm templates
authorUros Bizjak <ubizjak@gmail.com>
Tue, 19 Mar 2024 10:40:13 +0000 (11:40 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 19 Mar 2024 12:15:35 +0000 (13:15 +0100)
The "P" asm operand modifier is a x86 target-specific modifier.

When used with a constant, the "P" modifier emits "cst" instead of
"$cst". This property is currently used to emit the bare constant
without all syntax-specific prefixes.

The generic "c" resp. "n" operand modifier should be used instead.

No functional changes intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20240319104418.284519-3-ubizjak@gmail.com
arch/x86/boot/main.c
arch/x86/include/asm/alternative.h
arch/x86/include/asm/atomic64_32.h
arch/x86/include/asm/cpufeature.h
arch/x86/include/asm/irq_stack.h
arch/x86/include/asm/uaccess.h

index c4ea5258ab558fc1773d7cef85796238b62da026..9049f390d8347f0d5acc848f9be78a4fcb42275a 100644 (file)
@@ -119,8 +119,8 @@ static void init_heap(void)
        char *stack_end;
 
        if (boot_params.hdr.loadflags & CAN_USE_HEAP) {
-               asm("leal %P1(%%esp),%0"
-                   : "=r" (stack_end) : "i" (-STACK_SIZE));
+               asm("leal %n1(%%esp),%0"
+                   : "=r" (stack_end) : "i" (STACK_SIZE));
 
                heap_end = (char *)
                        ((size_t)boot_params.hdr.heap_end_ptr + 0x200);
index fcd20c6dc7f90c6b462463969b63debf4ec02759..99432696b1814a0fad19d15f60f6a48b7d0f9e75 100644 (file)
@@ -294,10 +294,10 @@ static inline int alternatives_text_reserved(void *start, void *end)
  * Otherwise, if CPU has feature1, newinstr1 is used.
  * Otherwise, oldinstr is used.
  */
-#define alternative_input_2(oldinstr, newinstr1, ft_flags1, newinstr2,      \
-                          ft_flags2, input...)                              \
-       asm_inline volatile(ALTERNATIVE_2(oldinstr, newinstr1, ft_flags1,     \
-               newinstr2, ft_flags2)                                        \
+#define alternative_input_2(oldinstr, newinstr1, ft_flags1, newinstr2, \
+                          ft_flags2, input...)                         \
+       asm_inline volatile(ALTERNATIVE_2(oldinstr, newinstr1, ft_flags1, \
+               newinstr2, ft_flags2)                                   \
                : : "i" (0), ## input)
 
 /* Like alternative_input, but with a single output argument */
@@ -307,7 +307,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
 
 /* Like alternative_io, but for replacing a direct call with another one. */
 #define alternative_call(oldfunc, newfunc, ft_flags, output, input...) \
-       asm_inline volatile (ALTERNATIVE("call %P[old]", "call %P[new]", ft_flags) \
+       asm_inline volatile (ALTERNATIVE("call %c[old]", "call %c[new]", ft_flags) \
                : output : [old] "i" (oldfunc), [new] "i" (newfunc), ## input)
 
 /*
@@ -316,12 +316,12 @@ static inline int alternatives_text_reserved(void *start, void *end)
  * Otherwise, if CPU has feature1, function1 is used.
  * Otherwise, old function is used.
  */
-#define alternative_call_2(oldfunc, newfunc1, ft_flags1, newfunc2, ft_flags2,   \
-                          output, input...)                                  \
-       asm_inline volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", ft_flags1,\
-               "call %P[new2]", ft_flags2)                                   \
-               : output, ASM_CALL_CONSTRAINT                                 \
-               : [old] "i" (oldfunc), [new1] "i" (newfunc1),                 \
+#define alternative_call_2(oldfunc, newfunc1, ft_flags1, newfunc2, ft_flags2, \
+                          output, input...)                            \
+       asm_inline volatile (ALTERNATIVE_2("call %c[old]", "call %c[new1]", ft_flags1, \
+               "call %c[new2]", ft_flags2)                             \
+               : output, ASM_CALL_CONSTRAINT                           \
+               : [old] "i" (oldfunc), [new1] "i" (newfunc1),           \
                  [new2] "i" (newfunc2), ## input)
 
 /*
index 3486d91b8595f1dffa03d718dc671dc8000c8770..d510405e4e1de2bfdda828fff8a412f1a5228a01 100644 (file)
@@ -24,7 +24,7 @@ typedef struct {
 
 #ifdef CONFIG_X86_CMPXCHG64
 #define __alternative_atomic64(f, g, out, in...) \
-       asm volatile("call %P[func]" \
+       asm volatile("call %c[func]" \
                     : out : [func] "i" (atomic64_##g##_cx8), ## in)
 
 #define ATOMIC64_DECL(sym) ATOMIC64_DECL_ONE(sym##_cx8)
index a1273698fc430b41951c241b6b76dfa9b7887692..fa938ed96506dafb4683a75e0a14355352bdbb6c 100644 (file)
@@ -169,7 +169,7 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit);
 static __always_inline bool _static_cpu_has(u16 bit)
 {
        asm goto(
-               ALTERNATIVE_TERNARY("jmp 6f", %P[feature], "", "jmp %l[t_no]")
+               ALTERNATIVE_TERNARY("jmp 6f", %c[feature], "", "jmp %l[t_no]")
                ".pushsection .altinstr_aux,\"ax\"\n"
                "6:\n"
                " testb %[bitnum]," _ASM_RIP(%P[cap_byte]) "\n"
index 798183867d78969b2a7fd7cc3169cf310926fa8e..b71ad173f8776fa986840f4a6567c8ee588a8a51 100644 (file)
 }
 
 #define ASM_CALL_ARG0                                                  \
-       "call %P[__func]                                \n"             \
+       "call %c[__func]                                \n"             \
        ASM_REACHABLE
 
 #define ASM_CALL_ARG1                                                  \
index 237dc8cdd12b9482f38f8543b85dbde88fb98d65..0f9bab92a43d763b8be7a28a9c560b270eed44d6 100644 (file)
@@ -78,7 +78,7 @@ extern int __get_user_bad(void);
        int __ret_gu;                                                   \
        register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX);            \
        __chk_user_ptr(ptr);                                            \
-       asm volatile("call __" #fn "_%P4"                               \
+       asm volatile("call __" #fn "_%c4"                               \
                     : "=a" (__ret_gu), "=r" (__val_gu),                \
                        ASM_CALL_CONSTRAINT                             \
                     : "0" (ptr), "i" (sizeof(*(ptr))));                \
@@ -177,7 +177,7 @@ extern void __put_user_nocheck_8(void);
        __chk_user_ptr(__ptr);                                          \
        __ptr_pu = __ptr;                                               \
        __val_pu = __x;                                                 \
-       asm volatile("call __" #fn "_%P[size]"                          \
+       asm volatile("call __" #fn "_%c[size]"                          \
                     : "=c" (__ret_pu),                                 \
                        ASM_CALL_CONSTRAINT                             \
                     : "0" (__ptr_pu),                                  \