From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org,
virtualization@lists.linux.dev
Cc: Juergen Gross <jgross@suse.com>,
Ajay Kaher <ajay.kaher@broadcom.com>,
Alexey Makhalov <alexey.makhalov@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH 04/14] x86/paravirt: move thunk macros to paravirt_types.h
Date: Thu, 11 Sep 2025 08:34:23 +0200 [thread overview]
Message-ID: <20250911063433.13783-5-jgross@suse.com> (raw)
In-Reply-To: <20250911063433.13783-1-jgross@suse.com>
The macros for generating PV-thunks are part of the generic paravirt
infrastructure, so they should be in paravirt_types.h.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/include/asm/paravirt.h | 68 ---------------------------
arch/x86/include/asm/paravirt_types.h | 68 +++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 68 deletions(-)
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 99291f3123a9..0d1e611f619c 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -585,74 +585,6 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
#endif /* SMP && PARAVIRT_SPINLOCKS */
-#ifdef CONFIG_X86_32
-/* save and restore all caller-save registers, except return value */
-#define PV_SAVE_ALL_CALLER_REGS "pushl %ecx;"
-#define PV_RESTORE_ALL_CALLER_REGS "popl %ecx;"
-#else
-/* save and restore all caller-save registers, except return value */
-#define PV_SAVE_ALL_CALLER_REGS \
- "push %rcx;" \
- "push %rdx;" \
- "push %rsi;" \
- "push %rdi;" \
- "push %r8;" \
- "push %r9;" \
- "push %r10;" \
- "push %r11;"
-#define PV_RESTORE_ALL_CALLER_REGS \
- "pop %r11;" \
- "pop %r10;" \
- "pop %r9;" \
- "pop %r8;" \
- "pop %rdi;" \
- "pop %rsi;" \
- "pop %rdx;" \
- "pop %rcx;"
-#endif
-
-/*
- * Generate a thunk around a function which saves all caller-save
- * registers except for the return value. This allows C functions to
- * be called from assembler code where fewer than normal registers are
- * available. It may also help code generation around calls from C
- * code if the common case doesn't use many registers.
- *
- * When a callee is wrapped in a thunk, the caller can assume that all
- * arg regs and all scratch registers are preserved across the
- * call. The return value in rax/eax will not be saved, even for void
- * functions.
- */
-#define PV_THUNK_NAME(func) "__raw_callee_save_" #func
-#define __PV_CALLEE_SAVE_REGS_THUNK(func, section) \
- extern typeof(func) __raw_callee_save_##func; \
- \
- asm(".pushsection " section ", \"ax\";" \
- ".globl " PV_THUNK_NAME(func) ";" \
- ".type " PV_THUNK_NAME(func) ", @function;" \
- ASM_FUNC_ALIGN \
- PV_THUNK_NAME(func) ":" \
- ASM_ENDBR \
- FRAME_BEGIN \
- PV_SAVE_ALL_CALLER_REGS \
- "call " #func ";" \
- PV_RESTORE_ALL_CALLER_REGS \
- FRAME_END \
- ASM_RET \
- ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
- ".popsection")
-
-#define PV_CALLEE_SAVE_REGS_THUNK(func) \
- __PV_CALLEE_SAVE_REGS_THUNK(func, ".text")
-
-/* Get a reference to a callee-save function */
-#define PV_CALLEE_SAVE(func) \
- ((struct paravirt_callee_save) { __raw_callee_save_##func })
-
-/* Promise that "func" already uses the right calling convention */
-#define __PV_IS_CALLEE_SAVE(func) \
- ((struct paravirt_callee_save) { func })
-
#ifdef CONFIG_PARAVIRT_XXL
static __always_inline unsigned long arch_local_save_flags(void)
{
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 085095f94f97..7acff40cc159 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -512,5 +512,73 @@ unsigned long pv_native_read_cr2(void);
#define ALT_NOT_XEN ALT_NOT(X86_FEATURE_XENPV)
+#ifdef CONFIG_X86_32
+/* save and restore all caller-save registers, except return value */
+#define PV_SAVE_ALL_CALLER_REGS "pushl %ecx;"
+#define PV_RESTORE_ALL_CALLER_REGS "popl %ecx;"
+#else
+/* save and restore all caller-save registers, except return value */
+#define PV_SAVE_ALL_CALLER_REGS \
+ "push %rcx;" \
+ "push %rdx;" \
+ "push %rsi;" \
+ "push %rdi;" \
+ "push %r8;" \
+ "push %r9;" \
+ "push %r10;" \
+ "push %r11;"
+#define PV_RESTORE_ALL_CALLER_REGS \
+ "pop %r11;" \
+ "pop %r10;" \
+ "pop %r9;" \
+ "pop %r8;" \
+ "pop %rdi;" \
+ "pop %rsi;" \
+ "pop %rdx;" \
+ "pop %rcx;"
+#endif
+
+/*
+ * Generate a thunk around a function which saves all caller-save
+ * registers except for the return value. This allows C functions to
+ * be called from assembler code where fewer than normal registers are
+ * available. It may also help code generation around calls from C
+ * code if the common case doesn't use many registers.
+ *
+ * When a callee is wrapped in a thunk, the caller can assume that all
+ * arg regs and all scratch registers are preserved across the
+ * call. The return value in rax/eax will not be saved, even for void
+ * functions.
+ */
+#define PV_THUNK_NAME(func) "__raw_callee_save_" #func
+#define __PV_CALLEE_SAVE_REGS_THUNK(func, section) \
+ extern typeof(func) __raw_callee_save_##func; \
+ \
+ asm(".pushsection " section ", \"ax\";" \
+ ".globl " PV_THUNK_NAME(func) ";" \
+ ".type " PV_THUNK_NAME(func) ", @function;" \
+ ASM_FUNC_ALIGN \
+ PV_THUNK_NAME(func) ":" \
+ ASM_ENDBR \
+ FRAME_BEGIN \
+ PV_SAVE_ALL_CALLER_REGS \
+ "call " #func ";" \
+ PV_RESTORE_ALL_CALLER_REGS \
+ FRAME_END \
+ ASM_RET \
+ ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
+ ".popsection")
+
+#define PV_CALLEE_SAVE_REGS_THUNK(func) \
+ __PV_CALLEE_SAVE_REGS_THUNK(func, ".text")
+
+/* Get a reference to a callee-save function */
+#define PV_CALLEE_SAVE(func) \
+ ((struct paravirt_callee_save) { __raw_callee_save_##func })
+
+/* Promise that "func" already uses the right calling convention */
+#define __PV_IS_CALLEE_SAVE(func) \
+ ((struct paravirt_callee_save) { func })
+
#endif /* CONFIG_PARAVIRT */
#endif /* _ASM_X86_PARAVIRT_TYPES_H */
--
2.51.0
next prev parent reply other threads:[~2025-09-11 6:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
2025-09-11 6:34 ` [PATCH 02/14] x86/paravirt: remove some unneeded struct declarations Juergen Gross
2025-09-11 6:34 ` [PATCH 03/14] x86/paravirt: remove PARAVIRT_DEBUG config option Juergen Gross
2025-09-11 6:34 ` Juergen Gross [this message]
2025-09-11 6:34 ` [PATCH 05/14] paravirt: remove asm/paravirt_api_clock.h Juergen Gross
2025-09-11 6:34 ` [PATCH 06/14] sched: move clock related paravirt code to kernel/sched Juergen Gross
2025-09-11 6:34 ` [PATCH 07/14] arm/paravirt: use common code for paravirt_steal_clock() Juergen Gross
2025-09-11 6:34 ` [PATCH 08/14] arm64/paravirt: " Juergen Gross
2025-09-11 6:34 ` [PATCH 09/14] loongarch/paravirt: " Juergen Gross
2025-09-11 6:34 ` [PATCH 10/14] riscv/paravirt: " Juergen Gross
2025-09-11 6:34 ` [PATCH 11/14] x86/paravirt: " Juergen Gross
2025-09-11 6:34 ` [PATCH 12/14] x86/paravirt: move paravirt_sched_clock() related code into tsc.c Juergen Gross
2025-09-11 6:34 ` [PATCH 13/14] x86/paravirt: allow pv-calls outside paravirt.h Juergen Gross
2025-09-11 6:34 ` [PATCH 14/14] x86/pvlocks: move paravirt spinlock functions into qspinlock.h Juergen Gross
2025-09-11 7:48 ` [PATCH 00/14] paravirt: cleanup and reorg Peter Zijlstra
2025-09-11 8:00 ` Jürgen Groß
2026-02-20 4:10 ` patchwork-bot+linux-riscv
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=20250911063433.13783-5-jgross@suse.com \
--to=jgross@suse.com \
--cc=ajay.kaher@broadcom.com \
--cc=alexey.makhalov@broadcom.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=virtualization@lists.linux.dev \
--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