public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Sheng Yang <sheng@linux.intel.com>
Cc: kvm@vger.kernel.org, avi@redhat.com
Subject: Re: [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too.
Date: Tue, 7 Apr 2009 13:07:08 +0300	[thread overview]
Message-ID: <20090407100708.GA25543@redhat.com> (raw)
In-Reply-To: <200904071756.13864.sheng@linux.intel.com>

> >   * check if there are pending timer events
> > @@ -48,14 +49,17 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
> >  {
> >  	struct kvm_pic *s;
> >
> > -	if (kvm_apic_has_interrupt(v) == -1) {	/* LAPIC */
> > -		if (kvm_apic_accept_pic_intr(v)) {
> > -			s = pic_irqchip(v->kvm);	/* PIC */
> > -			return s->output;
> > -		} else
> > -			return 0;
> > +	if (irqchip_in_kernel(v->kvm)) {
> > +		if (kvm_apic_has_interrupt(v) == -1) {	/* LAPIC */
> > +			if (kvm_apic_accept_pic_intr(v)) {
> > +				s = pic_irqchip(v->kvm);	/* PIC */
> > +				return s->output;
> > +			} else
> > +				return 0;
> > +		}
> > +		return 1;
> >  	}
> > -	return 1;
> > +	return v->arch.irq_summary;
> >  }
> 
> Use if (!irqchip_in_kernel(v->kvm)) for userspace seems more simple(rather 
> than a series of indention...).
> 
As long as lines are smaller then 80 chars I don't care much :) If new
version of the patch will be needed I'll change this.

> >
> > @@ -2976,8 +2975,9 @@ static int handle_interrupt_window(struct kvm_vcpu
> > *vcpu, * If the user space waits to inject interrupts, exit as soon as *
> > possible
> >  	 */
> > -	if (kvm_run->request_interrupt_window &&
> > -	    !vcpu->arch.irq_summary) {
> > +	if (!irqchip_in_kernel(vcpu->kvm) &&
> > +	    kvm_run->request_interrupt_window &&
> 
> I think kvm_run->request_interrupt_window can indicate it's userspace irqchip?
> 
You are correct, but this value is directly controlled by userspase, so
I added irqchip_in_kernel() check to protect from buggy userspace.
 
--
			Gleb.

  reply	other threads:[~2009-04-07 10:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-07  9:08 [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too Gleb Natapov
2009-04-07  9:08 ` [PATCH 2/3] Consolidate userspace and kernel interrupt injection for VMX Gleb Natapov
2009-04-11 11:29   ` Avi Kivity
2009-04-11 19:53     ` Gleb Natapov
2009-04-07  9:08 ` [PATCH 3/3] Cleanup vmx_intr_assist() Gleb Natapov
2009-04-11 11:30   ` Avi Kivity
2009-04-11 19:52     ` Gleb Natapov
2009-04-07  9:56 ` [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too Sheng Yang
2009-04-07 10:07   ` Gleb Natapov [this message]
2009-04-11 11:24     ` Avi Kivity

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=20090407100708.GA25543@redhat.com \
    --to=gleb@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=sheng@linux.intel.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