Re: [PATCH 2/3] KVM: x86: always expose VIRT_SSBD to guests

From: Eduardo Habkost
Date: Tue Oct 01 2019 - 18:17:10 EST


On Wed, Aug 21, 2019 at 10:26:41AM +0200, Paolo Bonzini wrote:
> Even though it is preferrable to use SPEC_CTRL (represented by
> X86_FEATURE_AMD_SSBD) instead of VIRT_SPEC, VIRT_SPEC is always
> supported anyway because otherwise it would be impossible to
> migrate from old to new CPUs. Make this apparent in the
> result of KVM_GET_SUPPORTED_CPUID as well.
>
> While at it, reuse X86_FEATURE_* constants for the SVM leaf too.
>
> However, we need to hide the bit on Intel processors, so move
> the setting to svm_set_supported_cpuid.
>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> Reported-by: Eduardo Habkost <ehabkost@xxxxxxxxxx>
> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> ---
[...]
> @@ -5944,6 +5944,11 @@ static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry)
> if (nested)
> entry->ecx |= (1 << 2); /* Set SVM bit */
> break;
> + case 0x80000008:
> + if (boot_cpu_has(X86_FEATURE_LS_CFG_SSBD) ||
> + boot_cpu_has(X86_FEATURE_AMD_SSBD))
> + entry->ebx |= F(VIRT_SSBD);
> + break;

Wasn't the old code at arch/x86/kvm/cpuid.c:__do_cpuid_func()
supposed to be deleted?

/*
* The preference is to use SPEC CTRL MSR instead of the
* VIRT_SPEC MSR.
*/
if (boot_cpu_has(X86_FEATURE_LS_CFG_SSBD) &&
!boot_cpu_has(X86_FEATURE_AMD_SSBD))
entry->ebx |= F(VIRT_SSBD);


--
Eduardo