linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Steve Rutherford <srutherford@google.com>, rkrcmar@redhat.com
Subject: [PATCH 5/9] KVM: x86: unify handling of interrupt window
Date: Wed,  5 Aug 2015 17:23:44 +0200	[thread overview]
Message-ID: <1438788228-34856-6-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1438788228-34856-1-git-send-email-pbonzini@redhat.com>

The interrupt window is currently checked twice, once in vmx.c/svm.c and
once in dm_request_for_irq_injection.  The only difference is the extra
check for kvm_arch_interrupt_allowed in dm_request_for_irq_injection,
and the different return value (EINTR/KVM_EXIT_INTR for vmx.c/svm.c vs.
0/KVM_EXIT_IRQ_WINDOW_OPEN for dm_request_for_irq_injection).

However, dm_request_for_irq_injection is basically dead code!  Revive it
by removing the checks in vmx.c and svm.c's vmexit handlers, and
fixing the returned values for the dm_request_for_irq_injection case.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/svm.c | 13 -------------
 arch/x86/kvm/vmx.c | 11 -----------
 arch/x86/kvm/x86.c |  4 ++--
 3 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 222439fd73d4..189e46479dd5 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3396,24 +3396,11 @@ static int msr_interception(struct vcpu_svm *svm)
 
 static int interrupt_window_interception(struct vcpu_svm *svm)
 {
-	struct kvm_run *kvm_run = svm->vcpu.run;
-
 	kvm_make_request(KVM_REQ_EVENT, &svm->vcpu);
 	svm_clear_vintr(svm);
 	svm->vmcb->control.int_ctl &= ~V_IRQ_MASK;
 	mark_dirty(svm->vmcb, VMCB_INTR);
 	++svm->vcpu.stat.irq_window_exits;
-	/*
-	 * If the user space waits to inject interrupts, exit as soon as
-	 * possible
-	 */
-	if (!lapic_in_kernel(&svm->vcpu) &&
-	    kvm_run->request_interrupt_window &&
-	    !kvm_cpu_has_interrupt(&svm->vcpu)) {
-		kvm_run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
-		return 0;
-	}
-
 	return 1;
 }
 
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ef15dc72284b..4cf25b90dbe0 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5524,17 +5524,6 @@ static int handle_interrupt_window(struct kvm_vcpu *vcpu)
 	kvm_make_request(KVM_REQ_EVENT, vcpu);
 
 	++vcpu->stat.irq_window_exits;
-
-	/*
-	 * If the user space waits to inject interrupts, exit as soon as
-	 * possible
-	 */
-	if (!lapic_in_kernel(vcpu) &&
-	    vcpu->run->request_interrupt_window &&
-	    !kvm_cpu_has_interrupt(vcpu)) {
-		vcpu->run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
-		return 0;
-	}
 	return 1;
 }
 
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index daa6d4fe97fe..62362fed4169 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6475,8 +6475,8 @@ static int vcpu_run(struct kvm_vcpu *vcpu)
 			kvm_inject_pending_timer_irqs(vcpu);
 
 		if (dm_request_for_irq_injection(vcpu)) {
-			r = -EINTR;
-			vcpu->run->exit_reason = KVM_EXIT_INTR;
+			r = 0;
+			vcpu->run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
 			++vcpu->stat.request_irq_exits;
 			break;
 		}
-- 
1.8.3.1



  parent reply	other threads:[~2015-08-05 15:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-05 15:23 [PATCH 0/9] split irqchip series Paolo Bonzini
2015-08-05 15:23 ` [PATCH 1/9] KVM: x86: set TMR when the interrupt is accepted Paolo Bonzini
2015-08-05 15:23 ` [PATCH 2/9] KVM: x86: store IOAPIC-handled vectors in each VCPU Paolo Bonzini
2015-08-05 15:23 ` [PATCH 3/9] KVM: x86: replace vm_has_apicv hook with cpu_uses_apicv Paolo Bonzini
2015-08-05 15:23 ` [PATCH 4/9] KVM: x86: introduce lapic_in_kernel Paolo Bonzini
2015-08-05 15:23 ` Paolo Bonzini [this message]
2015-08-06  6:50   ` [PATCH 5/9] KVM: x86: unify handling of interrupt window Wu, Feng
2015-08-06 11:55     ` Paolo Bonzini
2015-08-05 15:23 ` [PATCH 6/9] KVM: x86: Split the APIC from the rest of IRQCHIP Paolo Bonzini
2015-08-05 15:23 ` [PATCH 7/9] KVM: x86: Add KVM exit for IOAPIC EOIs Paolo Bonzini
2015-08-05 15:23 ` [PATCH 8/9] KVM: x86: Add EOI exit bitmap inference Paolo Bonzini
2015-08-07  5:43   ` Wu, Feng
2015-08-07  7:32     ` Paolo Bonzini
2015-08-07  7:46   ` Wu, Feng
2015-08-07 10:16     ` Paolo Bonzini
2015-08-07 22:55       ` Wu, Feng
2015-08-05 15:23 ` [PATCH 9/9] KVM: x86: Add support for local interrupt requests from userspace Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438788228-34856-6-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    --cc=srutherford@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).