]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/runtime-const: Add the RUNTIME_CONST_PTR assembly macro
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Tue, 4 Mar 2025 15:33:42 +0000 (17:33 +0200)
committerIngo Molnar <mingo@kernel.org>
Wed, 19 Mar 2025 10:26:24 +0000 (11:26 +0100)
Add an assembly macro to refer runtime cost. It hides linker magic and
makes assembly more readable.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250304153342.2016569-1-kirill.shutemov@linux.intel.com
arch/x86/include/asm/runtime-const.h
arch/x86/lib/getuser.S

index 6652ebddfd02f89086de06713410039b283ad6b5..8d983cfd06ea62a0ad71cd0b8388cb1271e3c35e 100644 (file)
@@ -2,6 +2,18 @@
 #ifndef _ASM_RUNTIME_CONST_H
 #define _ASM_RUNTIME_CONST_H
 
+#ifdef __ASSEMBLY__
+
+.macro RUNTIME_CONST_PTR sym reg
+       movq    $0x0123456789abcdef, %\reg
+       1:
+       .pushsection runtime_ptr_\sym, "a"
+       .long   1b - 8 - .
+       .popsection
+.endm
+
+#else /* __ASSEMBLY__ */
+
 #define runtime_const_ptr(sym) ({                              \
        typeof(sym) __ret;                                      \
        asm_inline("mov %1,%0\n1:\n"                            \
@@ -58,4 +70,5 @@ static inline void runtime_const_fixup(void (*fn)(void *, unsigned long),
        }
 }
 
+#endif /* __ASSEMBLY__ */
 #endif
index 71d8e7da4fc5549de1ec5c645a4ebbeecda2c4d2..9d5654b8a72a86fc1834ee886d024bd0f5496f61 100644 (file)
 #include <asm/thread_info.h>
 #include <asm/asm.h>
 #include <asm/smap.h>
+#include <asm/runtime-const.h>
 
 #define ASM_BARRIER_NOSPEC ALTERNATIVE "", "lfence", X86_FEATURE_LFENCE_RDTSC
 
 .macro check_range size:req
 .if IS_ENABLED(CONFIG_X86_64)
-       movq $0x0123456789abcdef,%rdx
-  1:
-  .pushsection runtime_ptr_USER_PTR_MAX,"a"
-       .long 1b - 8 - .
-  .popsection
+       RUNTIME_CONST_PTR USER_PTR_MAX, rdx
        cmp %rdx, %rax
        cmova %rdx, %rax
 .else