diff options
author | Kai Huang <[email protected]> | 2023-08-15 23:02:02 +1200 |
---|---|---|
committer | Dave Hansen <[email protected]> | 2023-09-12 16:30:14 -0700 |
commit | 90f5ecd37faed9a59eb2788a56dac8deeee0a508 (patch) | |
tree | 2c100cb8bc92233b7d5fbabb92480463c6b73069 /arch/x86/coco/tdx/tdx-shared.c | |
parent | c641cfb5c157b6c3062a824fd8ba190bf06fb952 (diff) |
x86/tdx: Reimplement __tdx_hypercall() using TDX_MODULE_CALL asm
Now the TDX_HYPERCALL asm is basically identical to the TDX_MODULE_CALL
with both '\saved' and '\ret' enabled, with two minor things though:
1) The way to restore the structure pointer is different
The TDX_HYPERCALL uses RCX as spare to restore the structure pointer,
but the TDX_MODULE_CALL assumes no spare register can be used. In other
words, TDX_MODULE_CALL already covers what TDX_HYPERCALL does.
2) TDX_MODULE_CALL only clears shared registers for TDH.VP.ENTER
For this just need to make that code available for the non-host case.
Thus, remove the TDX_HYPERCALL and reimplement the __tdx_hypercall()
using the TDX_MODULE_CALL.
Extend the TDX_MODULE_CALL to cover "clear shared registers" for
TDG.VP.VMCALL. Introduce a new __tdcall_saved_ret() to replace the
temporary __tdcall_hypercall().
The __tdcall_saved_ret() can also be used for those new TDCALLs which
require more input/output registers than the basic TDCALLs do.
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/e68a2473fb6f5bcd78b078cae7510e9d0753b3df.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.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/coco/tdx/tdx-shared.c b/arch/x86/coco/tdx/tdx-shared.c index b47c8cce91b0..344b3818f4c3 100644 --- a/arch/x86/coco/tdx/tdx-shared.c +++ b/arch/x86/coco/tdx/tdx-shared.c @@ -89,11 +89,11 @@ noinstr u64 __tdx_hypercall(struct tdx_hypercall_args *args) }; /* - * Failure of __tdcall_hypercall() indicates a failure of the TDVMCALL + * 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_hypercall(TDG_VP_VMCALL, &margs)) + if (__tdcall_saved_ret(TDG_VP_VMCALL, &margs)) __tdx_hypercall_failed(); args->r8 = margs.r8; |