KVM: x86: Inject pending interrupt even if pending nmi exist
authorYuki Shibuya <shibuya.yk@ncos.nec.co.jp>
Thu, 24 Mar 2016 05:17:03 +0000 (05:17 +0000)
committerSasha Levin <sasha.levin@oracle.com>
Wed, 20 Apr 2016 05:03:43 +0000 (01:03 -0400)
commitcc157620a5ac58f16660f269ec4226cc4e85937d
tree5637b5fbedb2412ad5bb686cff699ebdce681542
parent031b34ddc5b7714d957f7e8ed229e1c1a4c22a8f
KVM: x86: Inject pending interrupt even if pending nmi exist

[ Upstream commit 321c5658c5e9192dea0d58ab67cf1791e45b2b26 ]

Non maskable interrupts (NMI) are preferred to interrupts in current
implementation. If a NMI is pending and NMI is blocked by the result
of nmi_allowed(), pending interrupt is not injected and
enable_irq_window() is not executed, even if interrupts injection is
allowed.

In old kernel (e.g. 2.6.32), schedule() is often called in NMI context.
In this case, interrupts are needed to execute iret that intends end
of NMI. The flag of blocking new NMI is not cleared until the guest
execute the iret, and interrupts are blocked by pending NMI. Due to
this, iret can't be invoked in the guest, and the guest is starved
until block is cleared by some events (e.g. canceling injection).

This patch injects pending interrupts, when it's allowed, even if NMI
is blocked. And, If an interrupts is pending after executing
inject_pending_event(), enable_irq_window() is executed regardless of
NMI pending counter.

Cc: stable@vger.kernel.org
Signed-off-by: Yuki Shibuya <shibuya.yk@ncos.nec.co.jp>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
arch/x86/kvm/x86.c