mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
KVM: TDX: Disable support for TSX and WAITPKG
Support for restoring IA32_TSX_CTRL MSR and IA32_UMWAIT_CONTROL MSR is not yet implemented, so disable support for TSX and WAITPKG for now. Clear the associated CPUID bits returned by KVM_TDX_CAPABILITIES, and return an error if those bits are set in KVM_TDX_INIT_VM. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Message-ID: <20250129095902.16391-11-adrian.hunter@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
e0b4f31a3c
commit
6d415778f1
|
|
@ -107,6 +107,44 @@ static u32 tdx_set_guest_phys_addr_bits(const u32 eax, int addr_bits)
|
|||
return (eax & ~GENMASK(23, 16)) | (addr_bits & 0xff) << 16;
|
||||
}
|
||||
|
||||
#define TDX_FEATURE_TSX (__feature_bit(X86_FEATURE_HLE) | __feature_bit(X86_FEATURE_RTM))
|
||||
|
||||
static bool has_tsx(const struct kvm_cpuid_entry2 *entry)
|
||||
{
|
||||
return entry->function == 7 && entry->index == 0 &&
|
||||
(entry->ebx & TDX_FEATURE_TSX);
|
||||
}
|
||||
|
||||
static void clear_tsx(struct kvm_cpuid_entry2 *entry)
|
||||
{
|
||||
entry->ebx &= ~TDX_FEATURE_TSX;
|
||||
}
|
||||
|
||||
static bool has_waitpkg(const struct kvm_cpuid_entry2 *entry)
|
||||
{
|
||||
return entry->function == 7 && entry->index == 0 &&
|
||||
(entry->ecx & __feature_bit(X86_FEATURE_WAITPKG));
|
||||
}
|
||||
|
||||
static void clear_waitpkg(struct kvm_cpuid_entry2 *entry)
|
||||
{
|
||||
entry->ecx &= ~__feature_bit(X86_FEATURE_WAITPKG);
|
||||
}
|
||||
|
||||
static void tdx_clear_unsupported_cpuid(struct kvm_cpuid_entry2 *entry)
|
||||
{
|
||||
if (has_tsx(entry))
|
||||
clear_tsx(entry);
|
||||
|
||||
if (has_waitpkg(entry))
|
||||
clear_waitpkg(entry);
|
||||
}
|
||||
|
||||
static bool tdx_unsupported_cpuid(const struct kvm_cpuid_entry2 *entry)
|
||||
{
|
||||
return has_tsx(entry) || has_waitpkg(entry);
|
||||
}
|
||||
|
||||
#define KVM_TDX_CPUID_NO_SUBLEAF ((__u32)-1)
|
||||
|
||||
static void td_init_cpuid_entry2(struct kvm_cpuid_entry2 *entry, unsigned char idx)
|
||||
|
|
@ -130,6 +168,8 @@ static void td_init_cpuid_entry2(struct kvm_cpuid_entry2 *entry, unsigned char i
|
|||
*/
|
||||
if (entry->function == 0x80000008)
|
||||
entry->eax = tdx_set_guest_phys_addr_bits(entry->eax, 0xff);
|
||||
|
||||
tdx_clear_unsupported_cpuid(entry);
|
||||
}
|
||||
|
||||
static int init_kvm_tdx_caps(const struct tdx_sys_info_td_conf *td_conf,
|
||||
|
|
@ -1244,6 +1284,9 @@ static int setup_tdparams_cpuids(struct kvm_cpuid2 *cpuid,
|
|||
if (!entry)
|
||||
continue;
|
||||
|
||||
if (tdx_unsupported_cpuid(entry))
|
||||
return -EINVAL;
|
||||
|
||||
copy_cnt++;
|
||||
|
||||
value = &td_params->cpuid_values[i];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user