Re: [PATCH v3] x86/virt/tdx: Formalize SEAMCALL version encoding support
From: Nikolay Borisov
Date: Thu Jul 23 2026 - 05:40:49 EST
On 7/22/26 11:46, Xu Yilun wrote:
SEAMCALL invokes TDX module functions using a function number and
parameters. To extend the functionality of existing SEAMCALLs while
keeping backward compatibility, TDX adds more numbered SEAMCALLs of the
same family. This is just like syscalls, except that TDX defines a
specific function number encoding pattern: a base function number and a
version together encode the full function number.
One concern is the compatibility with older TDX modules which don't
recognize the new SEAMCALLs. The kernel should decide which SEAMCALL
version to use at runtime, selecting the minimum version number for the
required functionality. It can't overwrite the function number with a
new value at compile time.
Another concern is the obscure usage of the 'fn' parameter for SEAMCALL
wrappers. An existing caller for TDH.VP.INIT packs the version into the
'fn' to match the low-level TDX ABI RAX layout. The RAX layout
interprets some bits differently, such as INTERRUPT_MODE, SEAMLDR flag,
which are not a good fit for the function number definition.
Refactor the SEAMCALL wrappers to allow for version selection. Add a
version field in struct tdx_module_args [1], so that most existing
callers get a default "version == 0" behavior without code churn, while
callers requiring extended functionalities can specify the version
descriptively. Enforce the 'fn' parameter as the base function number.
Encode the base function number and tdx_module_args.version in RAX
before invoking the SEAMCALL instruction in assembly code.
Link: https://lore.kernel.org/kvm/4f4b0f29-424b-45ed-8cfd-c77da2ea390f@xxxxxxxxx/ # [1]
Signed-off-by: Xu Yilun <yilun.xu@xxxxxxxxxxxxxxx>
---
Reviewed-by: Nikolay Borisov <nik.borisov@xxxxxxxx>