All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 4/6] provide in-kernel i8259 chip
Date: Mon, 28 Sep 2009 19:25:15 -0300	[thread overview]
Message-ID: <20090928222515.GR29735@mothafucka.localdomain> (raw)
In-Reply-To: <m3fxa6afp5.fsf@neno.mitica>

On Tue, Sep 29, 2009 at 12:04:54AM +0200, Juan Quintela wrote:
> Glauber Costa <glommer@redhat.com> wrote:
> > This patch provides kvm with an in-kernel i8259 chip. We are currently not enabling it.
> > The code is heavily based on what's in qemu-kvm.git.
> >
> > Signed-off-by: Glauber Costa <glommer@redhat.com>
> > ---
> >  hw/i8259.c |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  hw/pc.h    |    1 +
> >  kvm-all.c  |   24 ++++++++++++++
> >  kvm.h      |    2 +
> >  4 files changed, 130 insertions(+), 0 deletions(-)
> >
> > diff --git a/hw/i8259.c b/hw/i8259.c
> > index 3de22e3..31524f5 100644
> > --- a/hw/i8259.c
> > +++ b/hw/i8259.c
> > @@ -26,6 +26,7 @@
> >  #include "isa.h"
> >  #include "monitor.h"
> >  #include "qemu-timer.h"
> > +#include "kvm.h"
> >  
> >  /* debug PIC */
> >  //#define DEBUG_PIC
> > @@ -446,9 +447,77 @@ static uint32_t elcr_ioport_read(void *opaque, uint32_t addr1)
> >      return s->elcr;
> >  }
> >  
> > +static int kvm_kernel_pic_load_from_user(void *opaque)
> > +{
> > +#if defined(TARGET_I386)
> > +    PicState *s = (void *)opaque;
> > +    struct kvm_irqchip chip;
> > +    struct kvm_pic_state *kpic;
> 
> It miss:
>    if (!kvm_enabled() && !kvm_irqchip_enabled()) {
>       return 0;
>    }
> 
> Or similar logic, otherwise kvm_set_irqchip() is called when kvm_irqchip
> is not enabled.  Same for save_to_user.
> 
> > +    chip.chip_id = (&s->pics_state->pics[0] == s) ?
> > +                   KVM_IRQCHIP_PIC_MASTER :
> > +                   KVM_IRQCHIP_PIC_SLAVE;
> > +    kpic = &chip.chip.pic;
> > +
> > +    kpic->last_irr = s->last_irr;
> > +    kpic->irr = s->irr;
> > +    kpic->imr = s->imr;
> > +    kpic->isr = s->isr;
> > +    kpic->priority_add = s->priority_add;
> > +    kpic->irq_base = s->irq_base;
> > +    kpic->read_reg_select = s->read_reg_select;
> > +    kpic->poll = s->poll;
> > +    kpic->special_mask = s->special_mask;
> > +    kpic->init_state = s->init_state;
> > +    kpic->auto_eoi = s->auto_eoi;
> > +    kpic->rotate_on_auto_eoi = s->rotate_on_auto_eoi;
> > +    kpic->special_fully_nested_mode = s->special_fully_nested_mode;
> > +    kpic->init4 = s->init4;
> > +    kpic->elcr = s->elcr;
> > +    kpic->elcr_mask = s->elcr_mask;
> > +
> > +    kvm_set_irqchip(&chip);
> > +#endif
> > +    return 0;
> > +}
> ....
> >  static const VMStateDescription vmstate_pic = {
> >      .name = "i8259",
> >      .version_id = 1,
> > +    .pre_save = kvm_kernel_pic_save_to_user,
> > +    .post_load = kvm_kernel_pic_load_from_user,
> 
> Let the three version_id fields together, please.
> 
> 
> > +#if defined(KVM_CAP_IRQCHIP) && defined(TARGET_I386)
> > +static void kvm_i8259_set_irq(void *opaque, int irq, int level)
> > +{
> > +    int pic_ret;
> > +    if (kvm_set_irq(irq, level, &pic_ret)) {
> > +        if (pic_ret != 0)
> > +            apic_set_irq_delivered();
> > +        return;
> > +    }
> > +}
> > +
> > +static void kvm_pic_init1(int io_addr, PicState *s)
> > +{
> > +    vmstate_register(io_addr, &vmstate_pic, s);
> > +    qemu_register_reset(pic_reset, s);
> > +}
> > +
> > +qemu_irq *kvm_i8259_init(qemu_irq parent_irq)
> > +{
> > +    PicState2 *s;
> > +
> > +    s = qemu_mallocz(sizeof(PicState2));
> > +
> > +    kvm_pic_init1(0x20, &s->pics[0]);
> > +    kvm_pic_init1(0xa0, &s->pics[1]);
> > +    s->parent_irq = parent_irq;
> > +    s->pics[0].pics_state = s;
> > +    s->pics[1].pics_state = s;
> > +    isa_pic = s;
> > +    return qemu_allocate_irqs(kvm_i8259_set_irq, s, 24);
> > +}
> > +#endif
> 
> I think everything would be nicer if this three functions where merged
> with the _non_ kvm ones with a kvm_enable() test.  They only differ in
> 2-3 lines.
I disagree. I think it is a better solution long term to provide irqchips
that are completely free of kvm code.

  reply	other threads:[~2009-09-28 22:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-28 21:15 [Qemu-devel] [PATCH 0/6] in kernel irqchip support Glauber Costa
2009-09-28 21:15 ` [Qemu-devel] [PATCH 1/6] provide in-kernel ioapic Glauber Costa
2009-09-28 21:15   ` [Qemu-devel] [PATCH 2/6] provide in-kernel apic Glauber Costa
2009-09-28 21:15     ` [Qemu-devel] [PATCH 3/6] provide apic_set_irq_delivered Glauber Costa
2009-09-28 21:15       ` [Qemu-devel] [PATCH 4/6] provide in-kernel i8259 chip Glauber Costa
2009-09-28 21:15         ` [Qemu-devel] [PATCH 5/6] initialize " Glauber Costa
2009-09-28 21:15           ` [Qemu-devel] [PATCH 6/6] Initialize in-kernel irqchip Glauber Costa
2009-10-02 20:33             ` [Qemu-devel] " Jan Kiszka
2009-10-02 21:59               ` Jamie Lokier
2009-10-02 22:22                 ` Glauber Costa
2009-09-28 22:04         ` [Qemu-devel] Re: [PATCH 4/6] provide in-kernel i8259 chip Juan Quintela
2009-09-28 22:25           ` Glauber Costa [this message]
2009-09-28 22:39             ` Juan Quintela
2009-10-02 20:33               ` Jan Kiszka
     [not found]   ` <m3my4eagcp.fsf@neno.mitica>
2009-09-28 22:24     ` [Qemu-devel] Re: [PATCH 1/6] provide in-kernel ioapic Glauber Costa
2009-09-29  0:39 ` [Qemu-devel] [PATCH 0/6] in kernel irqchip support Jamie Lokier
2009-09-29  1:06   ` Glauber Costa
2009-09-29  8:15 ` Avi Kivity
2009-09-30 20:01 ` Anthony Liguori

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=20090928222515.GR29735@mothafucka.localdomain \
    --to=glommer@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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.