]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: nVMX: Do not expose MPX VMX controls when guest MPX disabled
authorLiran Alon <liran.alon@oracle.com>
Fri, 14 Sep 2018 00:25:52 +0000 (03:25 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 1 Oct 2018 13:40:57 +0000 (15:40 +0200)
commit0ac4218317419527f2b738a8da6498dafcaccf41
tree2bf618ad8060f0907b34aa17eabdec37cfc74b7a
parent790dc3f0a8ab9fc53822390723ac34e12502e06b
KVM: nVMX: Do not expose MPX VMX controls when guest MPX disabled

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 03285973c03b ("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: 3aef6492bcdb ("KVM: x86: Add nested virtualization support for MPX")
Reported-by: Eyal Moscovici <eyal.moscovici@oracle.com>
Reviewed-by: Nikita Leshchenko <nikita.leshchenko@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx.c