Re: [PATCH v3 08/12] x86/tdx: Reimplement __tdx_hypercall() using TDX_MODULE_CALL asm

From: kirill . shutemov
Date: Sun Aug 06 2023 - 07:26:03 EST


On Wed, Jul 26, 2023 at 11:25:10PM +1200, Kai Huang wrote:
> 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.
>
> Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Signed-off-by: Kai Huang <kai.huang@xxxxxxxxx>

Reviewed-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>

--
Kiryl Shutsemau / Kirill A. Shutemov