From: Matt Gingell Subject: [PATCH 3/3] KVM: x86: fix ready_for_interrupt reporting in split IRQ chip case Date: Thu, 12 Nov 2015 11:07:56 -0800 Message-ID: Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Steve Rutherford To: kvm@vger.kernel.org Return-path: Received: from mail-pa0-f42.google.com ([209.85.220.42]:34286 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750944AbbKLTH6 (ORCPT ); Thu, 12 Nov 2015 14:07:58 -0500 Received: by padhx2 with SMTP id hx2so73273512pad.1 for ; Thu, 12 Nov 2015 11:07:57 -0800 (PST) Sender: kvm-owner@vger.kernel.org List-ID: This patch adds a call to kvm_arch_interrupt_allowed to ensure ready for interrupt is reported to user space correctly. This addresses a problem observed in QEMU when kvm->ready_for_interrupt is set but the x86 interrupt flag is clear. Additionally, test that the APIC is ready to accept an interrupt before reporting we are ready for injection. Reviewed-by: Andy Honig Signed-off-by: Matt Gingell --- arch/x86/kvm/x86.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index fd64dee..962003b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5835,15 +5835,13 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu) kvm_run->flags = is_smm(vcpu) ? KVM_RUN_X86_SMM : 0; kvm_run->cr8 = kvm_get_cr8(vcpu); kvm_run->apic_base = kvm_get_apic_base(vcpu); - if (!irqchip_in_kernel(vcpu->kvm)) + if (!pic_in_kernel(vcpu->kvm)) kvm_run->ready_for_interrupt_injection = kvm_arch_interrupt_allowed(vcpu) && !kvm_cpu_has_interrupt(vcpu) && - !kvm_event_needs_reinjection(vcpu); - else if (!pic_in_kernel(vcpu->kvm)) - kvm_run->ready_for_interrupt_injection = - kvm_apic_accept_pic_intr(vcpu) && - !kvm_cpu_has_interrupt(vcpu); + !kvm_event_needs_reinjection(vcpu) && + (!lapic_in_kernel(vcpu) || + kvm_apic_accept_pic_intr(vcpu)); else kvm_run->ready_for_interrupt_injection = 1; } -- 2.6.0.rc2.230.g3dd15c0