Re: [PATCH v3 1/6] x86/virt/tdx: Move TDH.SYS.CONFIG operations into a wrapper

From: Kiryl Shutsemau

Date: Fri Oct 09 2026 - 09:23:58 EST


On Tue, Oct 06, 2026 at 01:41:45AM +0800, Xu Yilun wrote:
> In Linux, SEAMCALL wrappers are introduced to avoid broad SEAMCALL
> access by exposing only a selection of SEAMCALL leafs, but also to
> abstract the SEAMCALL register ABIs. The abstraction improves
> readability and reuse for SEAMCALL leafs that are called multiple times.
>
> Some SEAMCALL leafs are not explicitly wrapped because the level of TDX
> ABI details needed to perform the call is low enough to flow well with
> the calling code.
>
> For some of the currently unwrapped SEAMCALL leafs, the TDX architecture
> has evolved the ABI to introduce new leaf versions. The host can select
> the version to call based on what is supported by the loaded TDX module.
> When future kernel implements this version selection, more ABI details
> will leak into the surrounding caller code, which decreases the
> readability of the caller logic. To keep the ABI details contained, move
> the SEAMCALL leaf that will need version selection into a wrapper.
>
> When defining the wrapper, the cleanest separation would be to have
> kernel data types for the SEAMCALL wrapper arguments, and have them
> marshaled into SEAMCALL leaf ABI types (often u64s) inside the wrapper.
> This works for many SEAMCALL leafs but becomes cumbersome when the
> register ABI type is a physical address which points to a buffer for an
> in-memory ABI. If the SEAMCALL wrapper only accepts kernel data types,
> it may need duplicate buffer allocation and copies to match the
> in-memory ABI. Another solution is to define a named helper structure
> that mirrors the in-memory ABI, populate it in a separate flow, then
> pass it to the SEAMCALL wrapper. struct seamldr_params is an existing
> example of this pattern.
>
> TDH.SYS.CONFIG requires a list of TDMR information in the form of a PA
> array. The PA array is the in-memory ABI. Create a structure for the PA
> array, use it as the argument when creating the wrapper for
> TDH.SYS.CONFIG.
>
> For readability, adjust a bit of the existing PA array size calculation:
> use the new PA array structure's element type instead of hardcoding u64.
>
> Signed-off-by: Xu Yilun <yilun.xu@xxxxxxxxxxxxxxx>
> Reviewed-by: Nikolay Borisov <nik.borisov@xxxxxxxx>
> Reviewed-by: Tony Lindgren <tony.lindgren@xxxxxxxxxxxxxxx>

Reviewed-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>

--
Kiryl Shutsemau / Kirill A. Shutemov