kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Steve Rutherford <srutherford@google.com>,
	KVM list <kvm@vger.kernel.org>
Subject: Re: [PATCH v7 4/4] KVM: x86: Add support for local interrupt requests from userspace
Date: Thu, 30 Jul 2015 11:33:47 +0200	[thread overview]
Message-ID: <55B9EF7B.9080806@redhat.com> (raw)
In-Reply-To: <1438237303-19124-4-git-send-email-srutherford@google.com>

On 30/07/2015 08:21, Steve Rutherford wrote:
>   */
>  int kvm_cpu_has_injectable_intr(struct kvm_vcpu *v)
>  {
> -	if (!irqchip_in_kernel(v->kvm))
> +	if (!pic_in_kernel(v->kvm))
>  		return v->arch.interrupt.pending;
>  
>  	if (kvm_cpu_has_extint(v))
> @@ -75,7 +88,7 @@ int kvm_cpu_has_injectable_intr(struct kvm_vcpu *v)
>   */
>  int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
>  {
> -	if (!irqchip_in_kernel(v->kvm))
> +	if (!pic_in_kernel(v->kvm))
>  		return v->arch.interrupt.pending;
>  
>  	if (kvm_cpu_has_extint(v))
> @@ -103,7 +123,7 @@ int kvm_cpu_get_interrupt(struct kvm_vcpu *v)
>  {
>  	int vector;
>  
> -	if (!irqchip_in_kernel(v->kvm))
> +	if (!pic_in_kernel(v->kvm) && v->arch.interrupt.pending)
>  		return v->arch.interrupt.nr;
>  
>  	vector = kvm_cpu_get_extint(v);

I have one more doubt about these three hunks.

v->arch.interrupt should not be used at all with split irqchip.  In 
particular:

- kvm_cpu_has_injectable_intr should go through kvm_cpu_has_extint and 
query pending_userspace_extint

- same for kvm_cpu_has_interrupt

- kvm_cpu_get_interrupt should go through kvm_cpu_get_extint and 
return/clear v->arch.pending_external_vector.

So I think !irqchip_in_kernel(v->kvm) is the right test.  In 
particular, with pic_in_kernel, kvm_cpu_has_extint's irqchip_split case 
is dead.  I am then not sure how you reach this code in x86.c:

	/* kvm_cpu_has_injectable_intr doesn't take extints into account? */
        } else if (kvm_cpu_has_injectable_intr(vcpu)) {
                /*
                 * Because interrupts can be injected asynchronously, we are
                 * calling check_nested_events again here to avoid a race condition.
                 * See https://lkml.org/lkml/2014/7/2/60 for discussion about this
                 * proposal and current concerns.  Perhaps we should be setting
                 * KVM_REQ_EVENT only on certain events and not unconditionally?
                 */
                if (is_guest_mode(vcpu) && kvm_x86_ops->check_nested_events) {
                        r = kvm_x86_ops->check_nested_events(vcpu, req_int_win);
                        if (r != 0)
                                return r;
                }
                if (kvm_x86_ops->interrupt_allowed(vcpu)) {
			/*
			 * kvm_cpu_get_interrupt does take extints into account
			 * because of the " && v->arch.interrupt.pending", but
			 * you won't get here unless you have an APIC interrupt
			 * pending!
			 */
                        kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu),
                                            false);
                        kvm_x86_ops->set_irq(vcpu);
                }
        }

Paolo

  parent reply	other threads:[~2015-07-30  9:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-30  6:21 [PATCH v7 1/4] KVM: x86: Split the APIC from the rest of IRQCHIP Steve Rutherford
2015-07-30  6:21 ` [PATCH v7 2/4] KVM: x86: Add KVM exit for IOAPIC EOIs Steve Rutherford
2015-07-30  6:21 ` [PATCH v7 3/4] KVM: x86: Add EOI exit bitmap inference Steve Rutherford
2015-07-30  6:21 ` [PATCH v7 4/4] KVM: x86: Add support for local interrupt requests from userspace Steve Rutherford
2015-07-30  8:21   ` Paolo Bonzini
2015-07-30  9:33   ` Paolo Bonzini [this message]
2015-07-30  8:21 ` [PATCH v7 1/4] KVM: x86: Split the APIC from the rest of IRQCHIP Paolo Bonzini
2015-07-30  8:37   ` Steve Rutherford
2015-07-30  9:38     ` Paolo Bonzini
2015-07-30 21:19       ` Steve Rutherford
2015-07-31  8:32         ` Jan Kiszka

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=55B9EF7B.9080806@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --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).