[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240517141938.4177174-3-kirill.shutemov@linux.intel.com>
Date: Fri, 17 May 2024 17:19:20 +0300
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Wei Liu <wei.liu@...nel.org>,
Dexuan Cui <decui@...rosoft.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Peter Zijlstra <peterz@...radead.org>
Cc: linux-coco@...ts.linux.dev,
linux-kernel@...r.kernel.org,
linux-hyperv@...r.kernel.org,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: [PATCH 02/20] x86/tdx: Add macros to generate TDVMCALL wrappers
Introduce a set of macros that allow to generate wrappers for TDVMCALL
leafs. The macros uses tdvmcall_trmapoline() and provides SYSV-complaint
ABI on top of it.
There are three macros differentiated by number of return parameters.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
---
arch/x86/include/asm/shared/tdx.h | 54 +++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/shared/tdx.h
index 89f7fcade8ae..ddf2cc4a45da 100644
--- a/arch/x86/include/asm/shared/tdx.h
+++ b/arch/x86/include/asm/shared/tdx.h
@@ -76,6 +76,60 @@
#include <linux/compiler_attributes.h>
+#define TDVMCALL_0(reason, in_r12, in_r13, in_r14, in_r15) \
+({ \
+ long __ret; \
+ \
+ asm( \
+ "call tdvmcall_trampoline\n\t" \
+ "movq %%r10, %[r10_out]\n\t" \
+ : [r10_out] "=r" (__ret), ASM_CALL_CONSTRAINT \
+ : "a" (TDX_HYPERCALL_STANDARD), "b" (reason), \
+ "D" (in_r12), "S"(in_r13), "d"(in_r14), "c" (in_r15) \
+ : "r12", "r13", "r14", "r15" \
+ ); \
+ __ret; \
+})
+
+#define TDVMCALL_1(reason, in_r12, in_r13, in_r14, in_r15, out_r11) \
+({ \
+ long __ret; \
+ \
+ asm( \
+ "call tdvmcall_trampoline\n\t" \
+ "movq %%r10, %[r10_out]\n\t" \
+ "movq %%r11, %[r11_out]\n\t" \
+ : [r10_out] "=r" (__ret), [r11_out] "=r" (out_r11), \
+ ASM_CALL_CONSTRAINT \
+ : "a" (TDX_HYPERCALL_STANDARD), "b" (reason), \
+ "D" (in_r12), "S"(in_r13), "d"(in_r14), "c" (in_r15) \
+ : "r10", "r11", "r12", "r13", "r14", "r15" \
+ ); \
+ __ret; \
+})
+
+#define TDVMCALL_4(reason, in_r12, in_r13, in_r14, in_r15, \
+ out_r12, out_r13, out_r14, out_r15) \
+({ \
+ long __ret; \
+ \
+ asm( \
+ "call tdvmcall_trampoline\n\t" \
+ "movq %%r10, %[r10_out]\n\t" \
+ "movq %%r12, %[r12_out]\n\t" \
+ "movq %%r13, %[r13_out]\n\t" \
+ "movq %%r14, %[r14_out]\n\t" \
+ "movq %%r15, %[r15_out]\n\t" \
+ : [r10_out] "=r" (__ret), ASM_CALL_CONSTRAINT, \
+ [r12_out] "=r" (out_r12), [r13_out] "=r" (out_r13), \
+ [r14_out] "=r" (out_r14), [r15_out] "=r" (out_r15) \
+ : "a" (TDX_HYPERCALL_STANDARD), "b" (reason), \
+ "D" (in_r12), "S"(in_r13), "d"(in_r14), "c" (in_r15) \
+ : "r10", "r12", "r13", "r14", "r15" \
+ ); \
+ __ret; \
+})
+
/*
* Used in __tdcall*() to gather the input/output registers' values of the
* TDCALL instruction when requesting services from the TDX module. This is a
--
2.43.0
Powered by blists - more mailing lists