[1/3] x86/callthunks: Move call thunk template to .S file
Commit Message
Currently INCREMENT_CALL_DEPTH explicitly defines %gs: segment
register prefix for its percpu variable. This is not compatible
with !CONFIG_SMP, which requires non-prefixed percpu variables.
Move call thunk template to its own callthunks-tmpl.S assembly file
where PER_CPU_VAR macro from percpu.h can be used to conditionally
use %gs: segment register prefix, depending on CONFIG_SMP.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
---
arch/x86/kernel/Makefile | 2 +-
arch/x86/kernel/callthunks-tmpl.S | 11 +++++++++++
arch/x86/kernel/callthunks.c | 10 ----------
3 files changed, 12 insertions(+), 11 deletions(-)
create mode 100644 arch/x86/kernel/callthunks-tmpl.S
@@ -143,7 +143,7 @@ obj-$(CONFIG_AMD_MEM_ENCRYPT) += sev.o
obj-$(CONFIG_CFI_CLANG) += cfi.o
-obj-$(CONFIG_CALL_THUNKS) += callthunks.o
+obj-$(CONFIG_CALL_THUNKS) += callthunks.o callthunks-tmpl.o
obj-$(CONFIG_X86_CET) += cet.o
new file mode 100644
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <asm/nospec-branch.h>
+
+ .section .rodata
+ .global skl_call_thunk_template
+ .global skl_call_thunk_tail
+
+skl_call_thunk_template:
+ INCREMENT_CALL_DEPTH
+skl_call_thunk_tail:
@@ -62,16 +62,6 @@ static const struct core_text builtin_coretext = {
.name = "builtin",
};
-asm (
- ".pushsection .rodata \n"
- ".global skl_call_thunk_template \n"
- "skl_call_thunk_template: \n"
- __stringify(INCREMENT_CALL_DEPTH)" \n"
- ".global skl_call_thunk_tail \n"
- "skl_call_thunk_tail: \n"
- ".popsection \n"
-);
-
extern u8 skl_call_thunk_template[];
extern u8 skl_call_thunk_tail[];