Re: [PATCH v4 05/12] x86/tdx: Pass TDCALL/SEAMCALL input/output registers via a structure

From: kirill . shutemov
Date: Fri Aug 25 2023 - 19:29:19 EST


On Tue, Aug 15, 2023 at 11:01:59PM +1200, Kai Huang wrote:
> Currently, the TDX_MODULE_CALL asm macro, which handles both TDCALL and
> SEAMCALL, takes one parameter for each input register and an optional
> 'struct tdx_module_output' (a collection of output registers) as output.
> This is different from the TDX_HYPERCALL macro which uses a single
> 'struct tdx_hypercall_args' to carry all input/output registers.
>
> The newer TDX versions introduce more TDCALLs/SEAMCALLs which use more
> input/output registers. Also, the TDH.VP.ENTER (which isn't covered
> by the current TDX_MODULE_CALL macro) basically can use all registers
> that the TDX_HYPERCALL does. The current TDX_MODULE_CALL macro isn't
> extendible to cover those cases.
>
> Similar to the TDX_HYPERCALL macro, simplify the TDX_MODULE_CALL macro
> to use a single structure 'struct tdx_module_args' to carry all the
> input/output registers. Currently, R10/R11 are only used as output
> register but not as input by any TDCALL/SEAMCALL. Change to also use
> R10/R11 as input register to make input/output registers symmetric.
>
> Currently, the TDX_MODULE_CALL macro depends on the caller to pass a
> non-NULL 'struct tdx_module_output' to get additional output registers.
> Similar to the TDX_HYPERCALL macro, change the TDX_MODULE_CALL macro to
> take a new 'ret' macro argument to indicate whether to save the output
> registers to the 'struct tdx_module_args'. Also introduce a new
> __tdcall_ret() for that purpose, similar to the __tdx_hypercall_ret().
>
> Note the tdcall(), which is a wrapper of __tdcall(), is called by three
> callers: tdx_parse_tdinfo(), tdx_get_ve_info() and tdx_early_init().
> The former two need the additional output but the last one doesn't. For
> simplicity, make tdcall() always call __tdcall_ret() to avoid another
> "_ret()" wrapper. The last caller tdx_early_init() isn't performance
> critical anyway.
>
> 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