Commit 66c3322ab2 for qemu.org

commit 66c3322ab2a9b273640b39500a09197e55718d1f
Author: Xiaoyao Li <xiaoyao.li@intel.com>
Date:   Tue May 12 16:21:07 2026 +0800

    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>

diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index da4478cb21..e3c5eb9984 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -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,