Re: [PATCH 1/6] x86/virt/tdx: Wrap TDH.SYS.CONFIG/UPDATE operations in helpers

From: Nikolay Borisov

Date: Wed Aug 26 2026 - 09:57:25 EST




On 8/21/26 06:29, Xu Yilun wrote:
As part of the TDX module initialization, the kernel configures the TDX
module with several information, such as TDX-usable memory regions
(TDMRs) and the global KeyID for protecting TDX metadata. During the
configuration, the kernel does 2 operations: constructing kernel data
types for the SEAMCALL leaf arguments and turning these data types into
u64's according to TDX ABI.

Both operations are implemented in one function - config_tdx_module().
This blurs the boundary between kernel managed structures and TDX ABI
definitions. Moreover, future kernel change will need to add more
nuances mandated by TDX ABI, such as setting the TDH.SYS.CONFIG leaf
version to allow configuring add-on features. Keeping these operations
tangled would further clutter the code.

Just like other SEAMCALL leaf helpers, wrap the invocation of
TDH.SYS.CONFIG in a helper. Introduce a more descriptive kernel data
type for the physical address array of TDMR information. This data type
is similar to struct seamldr_params in that it is the container of the
PA array layout which is an in-memory ABI. So the previous u64 * type
for the array is not wrong, but a named structure provides better type
safety and self-documentation. Use the data type as the argument of the
TDH.SYS.CONFIG helper.

Future kernel change will also need to set the TDH.SYS.UPDATE leaf
version for the same purpose. Add a similar helper to prepare for the
change.

Signed-off-by: Xu Yilun <yilun.xu@xxxxxxxxxxxxxxx>

Reviewed-by: Nikolay Borisov <nik.borisov@xxxxxxxx>