Re: [PATCH v2 16/25] KVM: TDX: Get system-wide info about TDX module on initialization

From: Xiaoyao Li
Date: Thu Oct 31 2024 - 10:27:32 EST


On 10/31/2024 5:37 PM, Tony Lindgren wrote:
On Thu, Oct 31, 2024 at 05:23:57PM +0800, Xiaoyao Li wrote:
here it is to initialize the configurable CPUID bits that get reported to
userspace. Though TDX module doesn't allow them to be set in TD_PARAM for
KVM_TDX_INIT_VM, they get set to 0xff because KVM reuse these bits
EBX[23:16] as the interface for userspace to configure GPAW of TD guest
(implemented in setup_tdparams_eptp_controls() in patch 19). That's why they
need to be set as all-1 to allow userspace to configure.

And the comment above it is wrong and vague. we need to change it to
something like

/*
* Though TDX module doesn't allow the configuration of guest
* phys addr bits (EBX[23:16]), KVM uses it as the interface for
* userspace to configure the GPAW. So need to report these bits
* as configurable to userspace.
*/

That sounds good to me.

Hmm so care to check if we can also just leave out another "old module"
comment in tdx_read_cpuid()?

That one did relate to old module, the module that without TDX_CONFIG_FLAGS_MAXGPA_VIRT reported in tdx_feature0.

I will sent an follow up patch to complement the handling if TDX module supports TDX_CONFIG_FLAGS_MAXGPA_VIRT.

Regards,

Tony