aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/coco/tdx/tdx-shared.c
diff options
context:
space:
mode:
authorKai Huang <[email protected]>2023-08-15 23:02:03 +1200
committerDave Hansen <[email protected]>2023-09-12 16:30:14 -0700
commit8a8544bde858e5d62d79df6baaa387e0b6587dc7 (patch)
tree5d92a4096a19646c64cfd323f991f597c08a970b /arch/x86/coco/tdx/tdx-shared.c
parent90f5ecd37faed9a59eb2788a56dac8deeee0a508 (diff)
x86/tdx: Remove 'struct tdx_hypercall_args'
Now 'struct tdx_hypercall_args' is basically 'struct tdx_module_args' minus RCX. Although from __tdx_hypercall()'s perspective RCX isn't used as shared register thus not part of input/output registers, it's not worth to have a separate structure just due to one register. Remove the 'struct tdx_hypercall_args' and use 'struct tdx_module_args' instead in __tdx_hypercall() related code. This also saves the memory copy between the two structures within __tdx_hypercall(). Suggested-by: Peter Zijlstra <[email protected]> Signed-off-by: Kai Huang <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Reviewed-by: Kirill A. Shutemov <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/all/798dad5ce24e9d745cf0e16825b75ccc433ad065.1692096753.git.kai.huang%40intel.com
Diffstat (limited to 'arch/x86/coco/tdx/tdx-shared.c')
-rw-r--r--arch/x86/coco/tdx/tdx-shared.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/arch/x86/coco/tdx/tdx-shared.c b/arch/x86/coco/tdx/tdx-shared.c
index 344b3818f4c3..78e413269791 100644
--- a/arch/x86/coco/tdx/tdx-shared.c
+++ b/arch/x86/coco/tdx/tdx-shared.c
@@ -70,45 +70,22 @@ bool tdx_accept_memory(phys_addr_t start, phys_addr_t end)
return true;
}
-noinstr u64 __tdx_hypercall(struct tdx_hypercall_args *args)
+noinstr u64 __tdx_hypercall(struct tdx_module_args *args)
{
- struct tdx_module_args margs = {
- .rcx = TDVMCALL_EXPOSE_REGS_MASK,
- .rdx = args->rdx,
- .r8 = args->r8,
- .r9 = args->r9,
- .r10 = args->r10,
- .r11 = args->r11,
- .r12 = args->r12,
- .r13 = args->r13,
- .r14 = args->r14,
- .r15 = args->r15,
- .rbx = args->rbx,
- .rdi = args->rdi,
- .rsi = args->rsi,
- };
+ /*
+ * For TDVMCALL explicitly set RCX to the bitmap of shared registers.
+ * The caller isn't expected to set @args->rcx anyway.
+ */
+ args->rcx = TDVMCALL_EXPOSE_REGS_MASK;
/*
* Failure of __tdcall_saved_ret() indicates a failure of the TDVMCALL
* mechanism itself and that something has gone horribly wrong with
* the TDX module. __tdx_hypercall_failed() never returns.
*/
- if (__tdcall_saved_ret(TDG_VP_VMCALL, &margs))
+ if (__tdcall_saved_ret(TDG_VP_VMCALL, args))
__tdx_hypercall_failed();
- args->r8 = margs.r8;
- args->r9 = margs.r9;
- args->r10 = margs.r10;
- args->r11 = margs.r11;
- args->r12 = margs.r12;
- args->r13 = margs.r13;
- args->r14 = margs.r14;
- args->r15 = margs.r15;
- args->rdi = margs.rdi;
- args->rsi = margs.rsi;
- args->rbx = margs.rbx;
- args->rdx = margs.rdx;
-
/* TDVMCALL leaf return code is in R10 */
return args->r10;
}