@samitouri / QOSamiQemu / commits / 66c3322ab2

i386/tdx: Make AMX alias bits supported

When 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(). Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com> Tested-by: Chenyi Qiang <chenyi.qiang@intel.com> Link: https://lore.kernel.org/r/20260512082108.621596-3-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Xiaoyao Li committed May 12, 2026 at 16:21 UTC 66c3322ab2a9b273640b39500a09197e55718d1f
1 file changed +16 -6
target/i386/kvm/tdx.c
+16 -6
@@ -560,13 +560,19 @@ typedef struct TdxXFAMDep {
560 } TdxXFAMDep;
561
562 /*
563 - * Note, only the CPUID bits whose virtualization type are "XFAM & Native" are
564 - * defiend here.
563 + * Note, usually the CPUID bits whose virtualization type are "XFAM & Native"
564 + * are defined here while "XFAM & Configured & Native" are not. Because the
565 + * latter are reported as configurable bits by KVM when they are supported.
566 + * And they are not supported when not in the configurable bits list from KVM
567 + * even if the corresponding XFAM bit is supported.
568 *
566 - * For those whose virtualization type are "XFAM & Configured & Native", they
567 - * are reported as configurable bits. And they are not supported if not in the
568 - * configureable bits list from KVM even if the corresponding XFAM bit is
569 - * supported.
569 + * Special cases:
570 + *
571 + * - AMX alias bits, their type is "CPUID_Enabled & Native" which means their
572 + * value is determined by the CPUID bit they are aliased to.
573 + *
574 + * For simplicity, relax the dependency to related XFAM bit.
575 + * tdx_check_features() will eventually catch the unsupported configurations.
576 */
577 TdxXFAMDep tdx_xfam_deps[] = {
578 { XSTATE_YMM_BIT, { FEAT_1_ECX, CPUID_EXT_FMA } },
@@ -580,6 +586,10 @@ TdxXFAMDep tdx_xfam_deps[] = {
586 { XSTATE_XTILE_CFG_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AMX_BF16 } },
587 { XSTATE_XTILE_CFG_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AMX_TILE } },
588 { XSTATE_XTILE_CFG_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AMX_INT8 } },
589 + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_INT8_ALIAS } },
590 + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_BF16_ALIAS } },
591 + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_COMPLEX_ALIAS } },
592 + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_FP16_ALIAS } },
593 };
594
595 static struct kvm_cpuid_entry2 *find_in_supported_entry(uint32_t function,