]> www.infradead.org Git - users/dwmw2/linux.git/commit
x86/tdx: Reimplement __tdx_hypercall() using TDX_MODULE_CALL asm
authorKai Huang <kai.huang@intel.com>
Tue, 15 Aug 2023 11:02:02 +0000 (23:02 +1200)
committerDave Hansen <dave.hansen@linux.intel.com>
Tue, 12 Sep 2023 23:30:14 +0000 (16:30 -0700)
commit90f5ecd37faed9a59eb2788a56dac8deeee0a508
tree2c100cb8bc92233b7d5fbabb92480463c6b73069
parentc641cfb5c157b6c3062a824fd8ba190bf06fb952
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 <peterz@infradead.org>
Signed-off-by: Kai Huang <kai.huang@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/all/e68a2473fb6f5bcd78b078cae7510e9d0753b3df.1692096753.git.kai.huang%40intel.com
arch/x86/coco/tdx/tdcall.S
arch/x86/coco/tdx/tdx-shared.c
arch/x86/include/asm/shared/tdx.h
arch/x86/virt/vmx/tdx/tdxcall.S