All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: Ben-Ami Yassour <benami@il.ibm.com>
Cc: Amit Shah <amit.shah@qumranet.com>,
	kvm@vger.kernel.org, Muli Ben-Yehuda <muli@il.ibm.com>,
	allen.m.kay@intel.com, chrisw@redhat.com, weidong.han@intel.com,
	virtualization@lists.osdl.org
Subject: Re: [PATCH 1/4] KVM: Introduce kvm_set_irq to inject interrupts in guests
Date: Sun, 06 Jul 2008 16:59:35 +0300	[thread overview]
Message-ID: <4870CFC7.8060804@qumranet.com> (raw)
In-Reply-To: <1215352251.31546.73.camel@cluwyn.haifa.ibm.com>

Ben-Ami Yassour wrote:
> On Sat, 2008-07-05 at 14:05 +0300, Avi Kivity wrote:
>   
>> Amit Shah wrote:
>>     
>>> This function injects an interrupt into the guest given the kvm struct,
>>> the (guest) irq number and the interrupt level.
>>>
>>> Signed-off-by: Amit Shah <amit.shah@qumranet.com>
>>> ---
>>>  arch/x86/kvm/irq.c |   11 +++++++++++
>>>  arch/x86/kvm/irq.h |    2 ++
>>>  2 files changed, 13 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
>>> index 76d736b..0d9e552 100644
>>> --- a/arch/x86/kvm/irq.c
>>> +++ b/arch/x86/kvm/irq.c
>>> @@ -100,3 +100,14 @@ void __kvm_migrate_timers(struct kvm_vcpu *vcpu)
>>>  	__kvm_migrate_apic_timer(vcpu);
>>>  	__kvm_migrate_pit_timer(vcpu);
>>>  }
>>> +
>>> +/* This should be called with the kvm->lock mutex held */
>>> +void kvm_set_irq(struct kvm *kvm, int irq, int level)
>>> +{
>>> +	/* Not possible to detect if the guest uses the PIC or the
>>> +	 * IOAPIC.  So set the bit in both. The guest will ignore
>>> +	 * writes to the unused one.
>>> +	 */
>>> +	kvm_ioapic_set_irq(kvm->arch.vioapic, irq, level);
>>> +	kvm_pic_set_irq(pic_irqchip(kvm), irq, level);
>>> +}
>>>   
>>>       
>> pic supports only irqs 0-15.
>>
>> I guess instead of adding the check here, better move it into i8259.c 
>> and ioapic.c.
>>
>>
>>     
>
> Do you mean something like the patch below?
> ( in the ioapic code there is already a check for the irq: if (irq >= 0 && irq < IOAPIC_NUM_PINS) )
>
> Thanks,
> Ben
>
> diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
> index 3ba5e5c..c2c4884 100644
> --- a/arch/x86/kvm/i8259.c
> +++ b/arch/x86/kvm/i8259.c
> @@ -130,8 +130,10 @@ void kvm_pic_set_irq(void *opaque, int irq, int level)
>  {
>  	struct kvm_pic *s = opaque;
>  
> -	pic_set_irq1(&s->pics[irq >> 3], irq & 7, level);
> -	pic_update_irq(s);
> +	if (irq >= 0 && irq < PIC_NUM_PINS) {
> +		pic_set_irq1(&s->pics[irq >> 3], irq & 7, level);
> +		pic_update_irq(s);
> +	}
>  }
>  
>  /*
> diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
> index bef9127..e9c7b3f 100644
> --- a/arch/x86/kvm/irq.h
> +++ b/arch/x86/kvm/irq.h
> @@ -30,6 +30,8 @@
>  #include "ioapic.h"
>  #include "lapic.h"
>  
> +#define PIC_NUM_PINS 15
> +
>   

16

Also, needs signoff and changelog entry.


-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2008-07-06 13:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-27 12:55 PCI device assignment to guests Amit Shah
2008-06-27 12:55 ` [PATCH 1/4] KVM: Introduce kvm_set_irq to inject interrupts in guests Amit Shah
2008-06-27 12:55   ` [PATCH 2/4] KVM: Introduce a callback routine for IOAPIC ack handling Amit Shah
2008-06-27 12:55     ` [PATCH 3/4] KVM: Introduce a callback routine for PIC " Amit Shah
2008-06-27 12:55       ` [PATCH 4/4] KVM: Handle device assignment to guests Amit Shah
2008-07-02 10:25         ` Amit Shah
2008-07-07 10:08     ` [PATCH 2/4] KVM: Introduce a callback routine for IOAPIC ack handling Avi Kivity
2008-07-08 10:34       ` Ben-Ami Yassour
2008-07-08 10:34         ` Ben-Ami Yassour
2008-07-10 13:57         ` Avi Kivity
2008-07-17 16:56           ` Ben-Ami Yassour
2008-07-17 17:16             ` Avi Kivity
2008-07-17 17:25               ` Avi Kivity
2008-07-17 17:25                 ` Avi Kivity
2008-07-05 11:05   ` [PATCH 1/4] KVM: Introduce kvm_set_irq to inject interrupts in guests Avi Kivity
2008-07-06 13:50     ` Ben-Ami Yassour
2008-07-06 13:59       ` Avi Kivity [this message]
2008-07-06 14:15         ` check injected pic irq Ben-Ami Yassour
2008-07-06 14:15           ` [PATCH] KVM: " Ben-Ami Yassour

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=4870CFC7.8060804@qumranet.com \
    --to=avi@qumranet.com \
    --cc=allen.m.kay@intel.com \
    --cc=amit.shah@qumranet.com \
    --cc=benami@il.ibm.com \
    --cc=chrisw@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=muli@il.ibm.com \
    --cc=virtualization@lists.osdl.org \
    --cc=weidong.han@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.