KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq
authorVitaly Kuznetsov <vkuznets@redhat.com>
Wed, 10 Aug 2022 20:26:54 +0000 (23:26 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:11:29 +0000 (11:11 +0200)
commita4bd692a950ada6d9757dbb78a6aea129ff8a943
treebfaecac15fca6652d3cbe03a48a7053aeef7ec5a
parent2566c4cff2e75c3f85c6c7e932f8f30a9aec5a67
KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq

commit 7ec37d1cbe17d8189d9562178d8b29167fe1c31a upstream

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>
Signed-off-by: Stefan Ghinea <stefan.ghinea@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/hyperv.c