* [PATCH, REBASED] x86/runtime-const: Add RUNTIME_CONST_PTR assembly macro
@ 2025-03-04 15:33 Kirill A. Shutemov
2025-03-06 10:51 ` [tip: x86/asm] x86/runtime-const: Add the " tip-bot2 for Kirill A. Shutemov
2025-03-19 11:03 ` [tip: x86/core] " tip-bot2 for Kirill A. Shutemov
0 siblings, 2 replies; 3+ messages in thread
From: Kirill A. Shutemov @ 2025-03-04 15:33 UTC (permalink / raw)
To: Dave Hansen, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin
Cc: Linus Torvalds, linux-kernel, Kirill A. Shutemov
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>
---
arch/x86/include/asm/runtime-const.h | 13 +++++++++++++
arch/x86/lib/getuser.S | 7 ++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/runtime-const.h b/arch/x86/include/asm/runtime-const.h
index 6652ebddfd02..8d983cfd06ea 100644
--- a/arch/x86/include/asm/runtime-const.h
+++ b/arch/x86/include/asm/runtime-const.h
@@ -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
diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
index 71d8e7da4fc5..9d5654b8a72a 100644
--- a/arch/x86/lib/getuser.S
+++ b/arch/x86/lib/getuser.S
@@ -35,16 +35,13 @@
#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
--
2.47.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: x86/asm] x86/runtime-const: Add the RUNTIME_CONST_PTR assembly macro
2025-03-04 15:33 [PATCH, REBASED] x86/runtime-const: Add RUNTIME_CONST_PTR assembly macro Kirill A. Shutemov
@ 2025-03-06 10:51 ` tip-bot2 for Kirill A. Shutemov
2025-03-19 11:03 ` [tip: x86/core] " tip-bot2 for Kirill A. Shutemov
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Kirill A. Shutemov @ 2025-03-06 10:51 UTC (permalink / raw)
To: linux-tip-commits
Cc: Kirill A. Shutemov, Ingo Molnar, Brian Gerst, H. Peter Anvin,
Linus Torvalds, x86, linux-kernel
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: c84f87de474c9aec84f706ceb732b70751122746
Gitweb: https://git.kernel.org/tip/c84f87de474c9aec84f706ceb732b70751122746
Author: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
AuthorDate: Tue, 04 Mar 2025 17:33:42 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 06 Mar 2025 11:27:31 +01:00
x86/runtime-const: Add the RUNTIME_CONST_PTR assembly macro
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 | 13 +++++++++++++
arch/x86/lib/getuser.S | 7 ++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/runtime-const.h b/arch/x86/include/asm/runtime-const.h
index 6652ebd..8d983cf 100644
--- a/arch/x86/include/asm/runtime-const.h
+++ b/arch/x86/include/asm/runtime-const.h
@@ -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
diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
index 89ecd57..853a2e6 100644
--- a/arch/x86/lib/getuser.S
+++ b/arch/x86/lib/getuser.S
@@ -34,16 +34,13 @@
#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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: x86/core] x86/runtime-const: Add the RUNTIME_CONST_PTR assembly macro
2025-03-04 15:33 [PATCH, REBASED] x86/runtime-const: Add RUNTIME_CONST_PTR assembly macro Kirill A. Shutemov
2025-03-06 10:51 ` [tip: x86/asm] x86/runtime-const: Add the " tip-bot2 for Kirill A. Shutemov
@ 2025-03-19 11:03 ` tip-bot2 for Kirill A. Shutemov
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Kirill A. Shutemov @ 2025-03-19 11:03 UTC (permalink / raw)
To: linux-tip-commits
Cc: Kirill A. Shutemov, Ingo Molnar, Brian Gerst, H. Peter Anvin,
Linus Torvalds, x86, linux-kernel
The following commit has been merged into the x86/core branch of tip:
Commit-ID: bd72baff229920da1d57c14364c11ecdbaf5b458
Gitweb: https://git.kernel.org/tip/bd72baff229920da1d57c14364c11ecdbaf5b458
Author: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
AuthorDate: Tue, 04 Mar 2025 17:33:42 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 19 Mar 2025 11:26:24 +01:00
x86/runtime-const: Add the RUNTIME_CONST_PTR assembly macro
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 | 13 +++++++++++++
arch/x86/lib/getuser.S | 7 ++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/runtime-const.h b/arch/x86/include/asm/runtime-const.h
index 6652ebd..8d983cf 100644
--- a/arch/x86/include/asm/runtime-const.h
+++ b/arch/x86/include/asm/runtime-const.h
@@ -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
diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
index 71d8e7d..9d5654b 100644
--- a/arch/x86/lib/getuser.S
+++ b/arch/x86/lib/getuser.S
@@ -35,16 +35,13 @@
#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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-19 11:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-04 15:33 [PATCH, REBASED] x86/runtime-const: Add RUNTIME_CONST_PTR assembly macro Kirill A. Shutemov
2025-03-06 10:51 ` [tip: x86/asm] x86/runtime-const: Add the " tip-bot2 for Kirill A. Shutemov
2025-03-19 11:03 ` [tip: x86/core] " tip-bot2 for Kirill A. Shutemov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®