diff options
Diffstat (limited to 'arch/x86/coco/tdx/tdx-shared.c')
| -rw-r--r-- | arch/x86/coco/tdx/tdx-shared.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/arch/x86/coco/tdx/tdx-shared.c b/arch/x86/coco/tdx/tdx-shared.c index a7396d0ddef9..b47c8cce91b0 100644 --- a/arch/x86/coco/tdx/tdx-shared.c +++ b/arch/x86/coco/tdx/tdx-shared.c @@ -69,3 +69,46 @@ bool tdx_accept_memory(phys_addr_t start, phys_addr_t end) return true; } + +noinstr u64 __tdx_hypercall(struct tdx_hypercall_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, + }; + + /* + * Failure of __tdcall_hypercall() 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_hypercall(TDG_VP_VMCALL, &margs)) + __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; +} |
