KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq
authorVitaly Kuznetsov <vkuznets@redhat.com>
Fri, 25 Mar 2022 13:21:38 +0000 (14:21 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 29 Mar 2022 17:21:21 +0000 (13:21 -0400)
commita7757a396fba2125923b4d2425cfaa78146721ec
tree0109bfd3ab51fd0b929481f3ea8c45aa76ae1e18
parenta8bf9382a1729c6fce2569045f2077fb8cba5aaa
KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq

When KVM_CAP_HYPERV_SYNIC{,2} is activated, KVM already checks for
irqchip_in_kernel() so normally SynIC irqs should never be set. It is,
however,  possible for a misbehaving VMM to write to SYNIC/STIMER MSRs
causing erroneous behavior.

The immediate issue being fixed is that kvm_irq_delivery_to_apic()
(kvm_irq_delivery_to_apic_fast()) crashes when called with
'irq.shorthand = APIC_DEST_SELF' and 'src == NULL'.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20220325132140.25650-2-vkuznets@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/hyperv.c