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

From: Eduardo Habkost
Date: Thu Aug 15 2019 - 13:15:01 EST


On Thu, Aug 15, 2019 at 09:41:23AM +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.
>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> Reported-by: Eduardo Habkost <ehabkost@xxxxxxxxxx>
> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> ---
> arch/x86/kvm/cpuid.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 145ec050d45d..5865bc73bbb5 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -747,11 +747,13 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function,
> entry->ebx &= kvm_cpuid_8000_0008_ebx_x86_features;
> cpuid_mask(&entry->ebx, CPUID_8000_0008_EBX);
> /*
> - * The preference is to use SPEC CTRL MSR instead of the
> - * VIRT_SPEC MSR.
> + * VIRT_SPEC is only implemented for AMD processors,
> + * but the host could set AMD_SSBD if it wanted even
> + * for Intel processors.
> */
> - if (boot_cpu_has(X86_FEATURE_LS_CFG_SSBD) &&
> - !boot_cpu_has(X86_FEATURE_AMD_SSBD))
> + if ((boot_cpu_has(X86_FEATURE_LS_CFG_SSBD) ||
> + boot_cpu_has(X86_FEATURE_AMD_SSBD)) &&
> + boot_cpu_has(X86_FEATURE_SVM))

Would it be desirable to move this code to
svm_set_supported_cpuid(), or is there a reason for keeping this
in cpuid.c?


> entry->ebx |= F(VIRT_SSBD);
> break;
> }
> --
> 1.8.3.1
>

--
Eduardo