i386/tdx: TDX cleanup and CPUID fixes
cover i386/tdx: TDX cleanup and CPUID fixes
Patch 1 is the resend of a cleanup patch that was missed by the community[1].
Patch 2 fixes the warnings when booting TDX guest on the platforms (e.g., DMR) that support AMX alias bits.
Patch 3 allows AVX10 to be exposed/enabled for TDX guest.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
Xiaoyao Li (3):
i386/tdx: Use .has_gpa field to check if the gpa is valid i386/tdx: Make AMX alias bits supported i386/tdx: Add CPUID_24_0_EBX_AVX10_VL_MASK as supported
system/runstate.c | 2 +- target/i386/kvm/tdx.c | 28 +++++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/3 i386/tdx: Use .has_gpa field to check if the gpa is valid
When translating the QAPI type GuestPanicInformationTdx into its C struct, the generated code provides a .has_gpa boolean field to indicate whether the optional gpa field is present.
Replace the magic sentinel value -1ULL, previously used to signal "no valid GPA", with the idiomatic .has_gpa field. This removes the implicit sentinel coupling and makes the validity check self-documenting.
---
Refine the commit message when re-sending it.
--- system/runstate.c | 2 +- target/i386/kvm/tdx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
system/runstate.c +1 -1
@@ -704,7 +704,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)" error code: 0x%" PRIx32" error message:\"%s\"\n" , info->u.tdx.error_code, message);g_free (message); -if (info->u.tdx.gpa !=-1ull ) { +if (info->u.tdx.has_gpa) {qemu_log_mask (LOG_GUEST_ERROR ,"Additional error information " "can be found at gpa page: 0x%" PRIx64"\n" , info->u.tdx.gpa);
target/i386/kvm/tdx.c +1 -1
@@ -1403,7 +1403,7 @@ int tdx_handle_report_fatal_error(X86CPU *cpu, struct kvm_run *run)uint64_t reg_mask = run->system_event.data[R_ECX ];char *message =NULL ;uint64_t *tmp; -uint64_t gpa =-1ull ; +uint64_t gpa =0 ;bool has_gpa = false;if (error_code &0xffff ) {
Signature · 1 line
2.43.0
PATCH 2/3 i386/tdx: Make AMX alias bits supported
In reply to Xiaoyao LiWhen booting a TD guest on a platform that supports AMX alias bits, QEMU emits the warning such as:
qemu-system-x86_64: warning: TDX forcibly sets the feature: CPUID[eax=1Eh,ecx=01h].EAX.amx-int8-alias [bit 0]
...
Bit[3:0] of CPUID(0x1e,1).EAX alias the AMX CPUID bits from leaf 7. Their TDX virtualization type is "CPUID_Enabled & Native": the value is determined by the leaf-7 AMX bit they are aliased to and the native hardware value.
These bits must be added to the TDX supported bits list so that they can be enabled without triggering the forced-set warning. For simplicity, mark them as supported whenever the corresponding AMX XFAM bit is supported, rather than checking each aliased leaf-7 bit individually. This reduces code complexity. Any platform that supports the AMX XFAM bit but not these alias bits will still be handled correctly, since the TDX module provides the real value via tdx_check_features().
--- target/i386/kvm/tdx.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
target/i386/kvm/tdx.c +16 -6
@@ -560,13 +560,19 @@ typedef struct TdxXFAMDep { } TdxXFAMDep;/* -* Note, only the CPUID bits whose virtualization type are "XFAM & Native" are -* defiend here. +* Note, usually the CPUID bits whose virtualization type are "XFAM & Native" +* are defined here while "XFAM & Configured & Native" are not. Because the +* latter are reported as configurable bits by KVM when they are supported. +* And they are not supported when not in the configurable bits list from KVM +* even if the corresponding XFAM bit is supported. * -* For those whose virtualization type are "XFAM & Configured & Native", they -* are reported as configurable bits. And they are not supported if not in the -* configureable bits list from KVM even if the corresponding XFAM bit is -* supported. +* Special cases: +* +* - AMX alias bits, their type is "CPUID_Enabled & Native" which means their +* value is determined by the CPUID bit they are aliased to. +* +* For simplicity, relax the dependency to related XFAM bit. +* tdx_check_features() will eventually catch the unsupported configurations. */ TdxXFAMDep tdx_xfam_deps[] = { {XSTATE_YMM_BIT , {FEAT_1_ECX ,CPUID_EXT_FMA } },
@@ -580,6 +586,10 @@ TdxXFAMDep tdx_xfam_deps[] = { { XSTATE_XTILE_CFG_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AMX_BF16 } }, { XSTATE_XTILE_CFG_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AMX_TILE } }, { XSTATE_XTILE_CFG_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AMX_INT8 } }, + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_INT8_ALIAS } }, + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_BF16_ALIAS } }, + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_COMPLEX_ALIAS } }, + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_FP16_ALIAS } }, }; static struct kvm_cpuid_entry2 *find_in_supported_entry(uint32_t function,
Signature · 1 line
2.43.0
PATCH 3/3 i386/tdx: Add CPUID_24_0_EBX_AVX10_VL_MASK as supported
In reply to Xiaoyao LiAVX10 depends on CPUID_24_0_EBX_AVX10_VL_MASK as defined in feature_dependencies[]. Currently CPUID_24_0_EBX_AVX10_VL_MASK is always not supported for TDX, so AVX10 cannot be exposed to TD guest.
The TDX virtualization type of these bits is "XFAM & CPUID_Enabled & Native": their value is determined by XFAM[5:7], the AVX10 CPUID bit, and the native hardware value.
For simplicity, add CPUID_24_0_EBX_AVX10_VL_MASK to tdx_xfam_deps[] under the AVX512/XFAM dependency, without separately checking the AVX10 bit. It's safe because any invalid combination supplied by the user will be caught by tdx_check_features().
--- target/i386/kvm/tdx.c | 4 ++++ 1 file changed, 4 insertions(+)
target/i386/kvm/tdx.c +4 -0
@@ -571,6 +571,9 @@ typedef struct TdxXFAMDep {* - AMX alias bits, their type is "CPUID_Enabled & Native" which means their * value is determined by the CPUID bit they are aliased to. * +* - AVX10_VL_MASK, their type is "XFAM & CPUID_Enabled & Native" which means +* their value is determined by both the corresponding XFAM bit and CPUID bit. +* * For simplicity, relax the dependency to related XFAM bit. * tdx_check_features() will eventually catch the unsupported configurations. */
@@ -579,6 +582,7 @@ TdxXFAMDep tdx_xfam_deps[] = { { XSTATE_YMM_BIT, { FEAT_7_0_EBX, CPUID_7_0_EBX_AVX2 } }, { XSTATE_OPMASK_BIT, { FEAT_7_0_ECX, CPUID_7_0_ECX_AVX512_VBMI } }, { XSTATE_OPMASK_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AVX512_FP16 } }, + { XSTATE_OPMASK_BIT, { FEAT_24_0_EBX, CPUID_24_0_EBX_AVX10_VL_MASK } }, { XSTATE_PT_BIT, { FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT } }, { XSTATE_PKRU_BIT, { FEAT_7_0_ECX, CPUID_7_0_ECX_PKU } }, { XSTATE_CET_U_BIT, { FEAT_7_0_ECX, CPUID_7_0_ECX_CET_SHSTK } },
Signature · 1 line
2.43.0
Hi Paolo,
Could you please take a look at it?
I hope we can get them into QEMU 11.1
Quoted 19 lines · Xiaoyao Li
Patch 1 is the resend of a cleanup patch that was missed by the community[1].
Patch 2 fixes the warnings when booting TDX guest on the platforms (e.g., DMR) that support AMX alias bits.
Patch 3 allows AVX10 to be exposed/enabled for TDX guest.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
Xiaoyao Li (3):
i386/tdx: Use .has_gpa field to check if the gpa is valid i386/tdx: Make AMX alias bits supported i386/tdx: AddCPUID_24_0_EBX_AVX10_VL_MASKas supportedsystem/runstate.c | 2 +- target/i386/kvm/tdx.c | 28 +++++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-)
Paolo Bonzini
AppliedQueued, thanks.
Paolo