diff options
author | Xiaoyao Li <xiaoyao.li@intel.com> | 2025-05-08 10:59:54 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-05-28 19:35:54 +0200 |
commit | 9f5771c57dbe92d46361afd992a5851c846d0322 (patch) | |
tree | 5ddeecf3884a93368216abf2db97a50f08120604 | |
parent | 8c94c84cb9e0140b48acc9c9d404525ca7ef7457 (diff) | |
download | qemu-9f5771c57dbe92d46361afd992a5851c846d0322.zip qemu-9f5771c57dbe92d46361afd992a5851c846d0322.tar.gz qemu-9f5771c57dbe92d46361afd992a5851c846d0322.tar.bz2 |
i386/tdx: Add XFD to supported bit of TDX
Just mark XFD as always supported for TDX. This simple solution relies
on the fact KVM will report XFD as 0 when it's not supported by the
hardware.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250508150002.689633-49-xiaoyao.li@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | target/i386/cpu.h | 1 | ||||
-rw-r--r-- | target/i386/kvm/tdx.c | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/target/i386/cpu.h b/target/i386/cpu.h index b38e691..8a4b421 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1122,6 +1122,7 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWord w); #define CPUID_XSAVE_XSAVEC (1U << 1) #define CPUID_XSAVE_XGETBV1 (1U << 2) #define CPUID_XSAVE_XSAVES (1U << 3) +#define CPUID_XSAVE_XFD (1U << 4) #define CPUID_6_EAX_ARAT (1U << 2) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 188c224..0f7f47c 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -621,6 +621,12 @@ static void tdx_add_supported_cpuid_by_xfam(void) e->edx |= (tdx_caps->supported_xfam & CPUID_XSTATE_XCR0_MASK) >> 32; e = find_in_supported_entry(0xd, 1); + /* + * Mark XFD always support for TDX, it will be cleared finally in + * tdx_adjust_cpuid_features() if XFD is unavailable on the hardware + * because in this case the original data has it as 0. + */ + e->eax |= CPUID_XSAVE_XFD; e->ecx |= (tdx_caps->supported_xfam & CPUID_XSTATE_XSS_MASK); e->edx |= (tdx_caps->supported_xfam & CPUID_XSTATE_XSS_MASK) >> 32; } |