x86/kvm/hyper-v: inject #GP only when invalid SINTx vector is unmasked
authorVitaly Kuznetsov <vkuznets@redhat.com>
Thu, 1 Mar 2018 14:15:14 +0000 (15:15 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 16 Mar 2018 21:01:33 +0000 (22:01 +0100)
commit915e6f78bd0641da692ffa7e0b766e633e12e628
treec5a86f11dcaeec6197b4a5d5ee6333d4138d6851
parent98f65ad458441ea3a243395345811132ee850093
x86/kvm/hyper-v: inject #GP only when invalid SINTx vector is unmasked

Hyper-V 2016 on KVM with SynIC enabled doesn't boot with the following
trace:

    kvm_entry:            vcpu 0
    kvm_exit:             reason MSR_WRITE rip 0xfffff8000131c1e5 info 0 0
    kvm_hv_synic_set_msr: vcpu_id 0 msr 0x40000090 data 0x10000 host 0
    kvm_msr:              msr_write 40000090 = 0x10000 (#GP)
    kvm_inj_exception:    #GP (0x0)

KVM acts according to the following statement from TLFS:

"
11.8.4 SINTx Registers
...
Valid values for vector are 16-255 inclusive. Specifying an invalid
vector number results in #GP.
"

However, I checked and genuine Hyper-V doesn't #GP when we write 0x10000
to SINTx. I checked with Microsoft and they confirmed that if either the
Masked bit (bit 16) or the Polling bit (bit 18) is set to 1, then they
ignore the value of Vector. Make KVM act accordingly.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
arch/x86/kvm/hyperv.c