public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Uros Bizjak <ubizjak@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH 1/3] x86/callthunks: Move call thunk template to .S file
Date: Thu,  2 Nov 2023 12:25:46 +0100	[thread overview]
Message-ID: <20231102112850.3448745-2-ubizjak@gmail.com> (raw)
In-Reply-To: <20231102112850.3448745-1-ubizjak@gmail.com>

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

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


  reply	other threads:[~2023-11-02 11:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 11:25 [PATCH 0/3] Fix and unify call thunks assembly snippets Uros Bizjak
2023-11-02 11:25 ` Uros Bizjak [this message]
2023-11-02 11:25 ` [PATCH 2/3] x86/callthunks: Handle %rip-relative relocations in call thunk template Uros Bizjak
2023-11-02 11:44   ` Peter Zijlstra
2023-11-02 11:50     ` Uros Bizjak
2023-11-02 11:56       ` Peter Zijlstra
2023-11-02 12:34         ` Uros Bizjak
2023-11-02 11:25 ` [PATCH 3/3] x86/callthunks: Fix and unify call thunks assembly snippets Uros Bizjak
2023-11-05  8:23   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231102112850.3448745-2-ubizjak@gmail.com \
    --to=ubizjak@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox