Skip to content
Snippets Groups Projects
  • Eduardo Habkost's avatar
    485b1d25
    i386: kvm: Disable arch_capabilities if MSR can't be set · 485b1d25
    Eduardo Habkost authored
    
    KVM has two bugs in the handling of MSR_IA32_ARCH_CAPABILITIES:
    
    1) Linux commit commit 1eaafe91a0df ("kvm: x86: IA32_ARCH_CAPABILITIES
       is always supported") makes GET_SUPPORTED_CPUID return
       arch_capabilities even if running on SVM.  This makes "-cpu
       host,migratable=off" incorrectly expose arch_capabilities on CPUID on
       AMD hosts (where the MSR is not emulated by KVM).
    
    2) KVM_GET_MSR_INDEX_LIST does not return MSR_IA32_ARCH_CAPABILITIES if
       the MSR is not supported by the host CPU.  This makes QEMU not
       initialize the MSR properly at kvm_put_msrs() on those hosts.
    
    Work around both bugs on the QEMU side, by checking if the MSR
    was returned by KVM_GET_MSR_INDEX_LIST before returning the
    feature flag on kvm_arch_get_supported_cpuid().
    
    This has the unfortunate side effect of making arch_capabilities
    unavailable on hosts without hardware support for the MSR until bug #2
    is fixed on KVM, but I can't see another way to work around bug #1
    without that side effect.
    
    Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
    Message-Id: <20190125220606.4864-2-ehabkost@redhat.com>
    Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
    485b1d25
    History
    i386: kvm: Disable arch_capabilities if MSR can't be set
    Eduardo Habkost authored
    
    KVM has two bugs in the handling of MSR_IA32_ARCH_CAPABILITIES:
    
    1) Linux commit commit 1eaafe91a0df ("kvm: x86: IA32_ARCH_CAPABILITIES
       is always supported") makes GET_SUPPORTED_CPUID return
       arch_capabilities even if running on SVM.  This makes "-cpu
       host,migratable=off" incorrectly expose arch_capabilities on CPUID on
       AMD hosts (where the MSR is not emulated by KVM).
    
    2) KVM_GET_MSR_INDEX_LIST does not return MSR_IA32_ARCH_CAPABILITIES if
       the MSR is not supported by the host CPU.  This makes QEMU not
       initialize the MSR properly at kvm_put_msrs() on those hosts.
    
    Work around both bugs on the QEMU side, by checking if the MSR
    was returned by KVM_GET_MSR_INDEX_LIST before returning the
    feature flag on kvm_arch_get_supported_cpuid().
    
    This has the unfortunate side effect of making arch_capabilities
    unavailable on hosts without hardware support for the MSR until bug #2
    is fixed on KVM, but I can't see another way to work around bug #1
    without that side effect.
    
    Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
    Message-Id: <20190125220606.4864-2-ehabkost@redhat.com>
    Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>