• Liran Alon's avatar
    KVM: nVMX: Do not expose MPX VMX controls when guest MPX disabled · 5f76f6f5
    Liran Alon authored
    Before this commit, KVM exposes MPX VMX controls to L1 guest only based
    on if KVM and host processor supports MPX virtualization.
    However, these controls should be exposed to guest only in case guest
    vCPU supports MPX.
    
    Without this change, a L1 guest running with kernel which don't have
    commit 691bd434 ("kvm: vmx: allow host to access guest
    MSR_IA32_BNDCFGS") asserts in QEMU on the following:
    	qemu-kvm: error: failed to set MSR 0xd90 to 0x0
    	qemu-kvm: .../qemu-2.10.0/target/i386/kvm.c:1801 kvm_put_msrs:
    	Assertion 'ret == cpu->kvm_msr_buf->nmsrs failed'
    This is because L1 KVM kvm_init_msr_list() will see that
    vmx_mpx_supported() (As it only checks MPX VMX controls support) and
    therefore KVM_GET_MSR_INDEX_LIST IOCTL will include MSR_IA32_BNDCFGS.
    However, later when L1 will attempt to set this MSR via KVM_SET_MSRS
    IOCTL, it will fail because !guest_cpuid_has_mpx(vcpu).
    
    Therefore, fix the issue by exposing MPX VMX controls to L1 guest only
    when vCPU supports MPX.
    
    Fixes: 36be0b9d ("KVM: x86: Add nested virtualization support for MPX")
    Reported-by: default avatarEyal Moscovici <eyal.moscovici@oracle.com>
    Reviewed-by: default avatarNikita Leshchenko <nikita.leshchenko@oracle.com>
    Reviewed-by: default avatarDarren Kenny <darren.kenny@oracle.com>
    Signed-off-by: default avatarLiran Alon <liran.alon@oracle.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    5f76f6f5
vmx.c 403 KB