Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Chao Gao <chao.gao@intel.com>,
	linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev,
	kvm@vger.kernel.org
Cc: rick.p.edgecombe@intel.com, kas@kernel.org, dave.hansen@linux.intel.com
Subject: Re: [PATCH v1 2/8] x86/virt/tdx: Name the TDX module global metadata field IDs
Date: Tue, 4 Aug 2026 16:52:26 -0700	[thread overview]
Message-ID: <7ecd59df-1bae-487d-a7e4-bf7bc0c45615@intel.com> (raw)
In-Reply-To: <20260804112941.19894-3-chao.gao@intel.com>

On 8/4/26 04:29, Chao Gao wrote:
> From: Dave Hansen <dave@sr71.net>
> 
> tdx_global_metadata.c currently identifies each field by a bare 64-bit hex
> literal, extracted from the JSON file by an out-of-tree script:
> 
> 	if (!ret && !(ret = read_sys_metadata_field(0x9100000100000008, &val)))
> 		sysinfo_tdmr->max_tdmrs = val;
> 
> That is unreviewable on its own. Verifying any one line requires the
> reviewer to cross-reference the JSON file.

I'm looking at "global_metadata.pdf" from this[1]. I see a line with
"MAX_TDMRS" and "0x9100000100000008". That matches the lines above. That
seems *FAR* from unreviewable. There's also no JSON in sight.

What am I missing?

Listen, I don't like how this turned out. I'm asking for it to be
changed. But let's not justify it with things that just aren't true.

> The hex literals in tdx_global_metadata.c are left alone because that file
> will be replaced by a table-driven reader in the following patches.

This part of the changelog is good.

> No functional change intended.

This is a bit much. :)

> diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h
> index bdfd0e1e337a..5f567cb6c07a 100644
> --- a/arch/x86/virt/vmx/tdx/tdx.h
> +++ b/arch/x86/virt/vmx/tdx/tdx.h
> @@ -58,6 +58,57 @@
>   */
>  #define TDX_VERSION_SHIFT		16
>  
> +/*
> + * Global Scope Metadata field IDs.
> + *
> + * See "Global-Scope (TDX Module) Metadata" in the Intel TDX Module ABI
> + * spec.
> + *
> + * A field ID is a 64-bit value that encodes the metadata "Class"
> + * (which Linux mirrors in 'struct tdx_sys_info' sub-structures),
> + * the element size, and a per-class field index. Each ID below
> + * is paired with the C member that holds its value.
> + */

This is a bit verbose for my taste.

> +/* Class "TDX Module Version" */
> +#define MD_FIELD_ID_MINOR_VERSION		0x0800000100000003ULL
> +#define MD_FIELD_ID_MAJOR_VERSION		0x0800000100000004ULL
> +#define MD_FIELD_ID_UPDATE_VERSION		0x0800000100000005ULL
> +
> +/* Class "TDX Features" */
> +#define MD_FIELD_ID_TDX_FEATURES0		0x0A00000300000008ULL
> +
> +/* Class "TDMR Info" */
> +#define MD_FIELD_ID_MAX_TDMRS			0x9100000100000008ULL
> +#define MD_FIELD_ID_MAX_RESERVED_PER_TDMR	0x9100000100000009ULL
> +#define MD_FIELD_ID_PAMT_4K_ENTRY_SIZE		0x9100000100000010ULL
> +#define MD_FIELD_ID_PAMT_2M_ENTRY_SIZE		0x9100000100000011ULL
> +#define MD_FIELD_ID_PAMT_1G_ENTRY_SIZE		0x9100000100000012ULL
> +
> +/* Class "TD Control Structures" */
> +#define MD_FIELD_ID_TDR_BASE_SIZE		0x9800000100000000ULL
> +#define MD_FIELD_ID_TDCS_BASE_SIZE		0x9800000100000100ULL
> +#define MD_FIELD_ID_TDVPS_BASE_SIZE		0x9800000100000200ULL
> +
> +/* Class "TD Configuration" */
> +#define MD_FIELD_ID_ATTRIBUTES_FIXED0		0x1900000300000000ULL
> +#define MD_FIELD_ID_ATTRIBUTES_FIXED1		0x1900000300000001ULL
> +#define MD_FIELD_ID_XFAM_FIXED0			0x1900000300000002ULL
> +#define MD_FIELD_ID_XFAM_FIXED1			0x1900000300000003ULL
> +#define MD_FIELD_ID_NUM_CPUID_CONFIG		0x9900000100000004ULL
> +#define MD_FIELD_ID_MAX_VCPUS_PER_TD		0x9900000100000008ULL
> +
> +/* Class "TDX Module Handoff" */
> +#define MD_FIELD_ID_MODULE_HV			0x8900000100000000ULL

These are fine on their own.

> +/*
> + * Base IDs for the configurable-CPUID arrays.  The field ID of leaf
> + * index @i is BASE + i; for the values array, sub-entry @j of index
> + * @i is BASE + i*2 + j.
> + */
> +#define MD_FIELD_ID_CPUID_CONFIG_LEAVES		0x9900000300000400ULL
> +#define MD_FIELD_ID_CPUID_CONFIG_VALUES		0x9900000300000500ULL

This is complete jibberish without more context.

1,
https://www.intel.com/content/www/us/en/content-details/865803/abi-definitions-for-intel-tdx.html

  reply	other threads:[~2026-08-04 23:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 11:29 [PATCH v1 0/8] TDX: Stop auto-generating the global metadata code Chao Gao
2026-08-04 11:29 ` [PATCH v1 1/8] x86/virt/tdx: Stop treating tdx_global_metadata.h as auto-generated Chao Gao
2026-08-04 23:43   ` Dave Hansen
2026-08-05 12:06     ` Chao Gao
2026-08-05 15:26       ` Dave Hansen
2026-08-04 11:29 ` [PATCH v1 2/8] x86/virt/tdx: Name the TDX module global metadata field IDs Chao Gao
2026-08-04 23:52   ` Dave Hansen [this message]
2026-08-05 12:45     ` Chao Gao
2026-08-05 17:10   ` Edgecombe, Rick P
2026-08-04 11:29 ` [PATCH v1 3/8] x86/virt/tdx: Add a table-driven TDX global metadata reader Chao Gao
2026-08-05 17:48   ` Edgecombe, Rick P
2026-08-04 11:29 ` [PATCH v1 4/8] x86/virt/tdx: Convert version/tdmr/td_ctrl/handoff readers Chao Gao
2026-08-04 11:29 ` [PATCH v1 5/8] x86/virt/tdx: Convert td_conf reader Chao Gao
2026-08-04 11:29 ` [PATCH v1 6/8] x86/virt/tdx: Remove the auto-generated tdx_global_metadata.c Chao Gao
2026-08-04 11:29 ` [PATCH v1 7/8] x86/virt/tdx: Clean up error handling in get_tdx_sys_info() Chao Gao
2026-08-04 11:29 ` [PATCH v1 8/8] x86/virt/tdx: Verify the C member size against the metadata field ID Chao Gao
2026-08-04 23:38 ` [PATCH v1 0/8] TDX: Stop auto-generating the global metadata code Dave Hansen
2026-08-05 12:11   ` Chao Gao
2026-08-05 17:19 ` Edgecombe, Rick P

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7ecd59df-1bae-487d-a7e4-bf7bc0c45615@intel.com \
    --to=dave.hansen@intel.com \
    --cc=chao.gao@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=kas@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rick.p.edgecombe@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox