[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231102112850.3448745-2-ubizjak@gmail.com>
Date: Thu, 2 Nov 2023 12:25:46 +0100
From: Uros Bizjak <ubizjak@...il.com>
To: x86@...nel.org, linux-kernel@...r.kernel.org
Cc: Uros Bizjak <ubizjak@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
Peter Zijlstra <peterz@...radead.org>
Subject: [PATCH 1/3] x86/callthunks: Move call thunk template to .S file
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@...utronix.de>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Signed-off-by: Uros Bizjak <ubizjak@...il.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
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 3269a0e23d3a..6b6b68ef4c3b 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -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
diff --git a/arch/x86/kernel/callthunks-tmpl.S b/arch/x86/kernel/callthunks-tmpl.S
new file mode 100644
index 000000000000..e82c473bd1b1
--- /dev/null
+++ b/arch/x86/kernel/callthunks-tmpl.S
@@ -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:
diff --git a/arch/x86/kernel/callthunks.c b/arch/x86/kernel/callthunks.c
index e9ad518a5003..d0922cf94c90 100644
--- a/arch/x86/kernel/callthunks.c
+++ b/arch/x86/kernel/callthunks.c
@@ -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[];
--
2.41.0
Powered by blists - more mailing lists