From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Gingell Subject: [PATCH 2/3] KVM: x86: request interrupt window when IRQ chip is split Date: Thu, 12 Nov 2015 11:08:00 -0800 Message-ID: <0F3C2194-AAA7-4F34-8EEA-9EA606198B2D@google.com> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT Cc: Steve Rutherford To: kvm@vger.kernel.org Return-path: Received: from mail-pa0-f46.google.com ([209.85.220.46]:32834 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752627AbbKLTIU convert rfc822-to-8bit (ORCPT ); Thu, 12 Nov 2015 14:08:20 -0500 Received: by pabfh17 with SMTP id fh17so73334619pab.0 for ; Thu, 12 Nov 2015 11:08:19 -0800 (PST) Sender: kvm-owner@vger.kernel.org List-ID: Before this patch we incorrectly enter the guest without requesting an interrupt window if the IRQ chip is split between user space and the kernel. Because lapic_in_kernel no longer implies the PIC is in the kernel, this patch tests pic_in_kernel to determining whether an interrupt window should be requested when entering the guest. If the APIC is in the kernel and we request an interrupt window the guest will return immediately. If the APIC is masked the guest will not not make forward progress and unmask it, leading to a loop when KVM reenters and requests again. This patch adds a check to ensure the APIC is ready to accept an interrupt before requesting a window. Reviewed-by: Andy Honig Signed-off-by: Matt Gingell --- arch/x86/kvm/x86.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 456973b..fd64dee 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6258,10 +6258,14 @@ void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm, static int vcpu_enter_guest(struct kvm_vcpu *vcpu) { int r; - bool req_int_win = !lapic_in_kernel(vcpu) && + bool req_int_win = !pic_in_kernel(vcpu->kvm) && vcpu->run->request_interrupt_window; + bool req_immediate_exit = false; + if (irqchip_split(vcpu->kvm)) + req_int_win = req_int_win && kvm_apic_accept_pic_intr(vcpu); + if (vcpu->requests) { if (kvm_check_request(KVM_REQ_MMU_RELOAD, vcpu)) kvm_mmu_unload(vcpu); -- 2.6.0.rc2.230.g3dd15c0