Re: [PATCH 1/2] x86/virt/tdx: Retrieve TDX module version

From: Chao Gao

Date: Wed Nov 12 2025 - 20:25:05 EST


On Wed, Oct 22, 2025 at 03:55:01PM +0800, Chao Gao wrote:
>On Wed, Oct 01, 2025 at 08:15:46AM -0700, Dave Hansen wrote:
>>On 9/30/25 19:22, Chao Gao wrote:
>>> + if (!ret && !(ret = read_sys_metadata_field(0x0800000100000003, &val)))
>>> + sysinfo_version->minor_version = val;
>>> + if (!ret && !(ret = read_sys_metadata_field(0x0800000100000004, &val)))
>>> + sysinfo_version->major_version = val;
>>> + if (!ret && !(ret = read_sys_metadata_field(0x0800000100000005, &val)))
>>> + sysinfo_version->update_version = val;
>>
>>Heh, how long does this take in practice to get 6 bytes of data out of
>>the module?
>
>~8us. And the whole metadata reading process (i.e., get_tdx_sys_info()) takes
>~113us.
>
>>When is the point that we move over to TDH.SYS.RDALL?
>
>TDH.SYS.RDALL takes ~16us.
>
>I'm uncertain whether the saved CPU time of ~100us justifies implementing
>TDH.SYS.RDALL.

I chatted with Dave and Yilun offline. We think that saving 100us for this
one-off operation isn't worth the code churn.

For the record, the idea of moving over to TDH.SYS.RDALL is:

1. Call TDH.SYS.RDALL to dump all metadata into a data structure
2. Add a tdx_get_one() helper to look up the data structure and get the
metadata for a given field ID
3. Replace read_sys_metadata_field() with tdx_get_one()