From: Glauber Costa <glommer@redhat.com>
To: Juan Quintela <quintela@trasno.org>
Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 1/6] provide in-kernel ioapic
Date: Mon, 28 Sep 2009 19:24:03 -0300 [thread overview]
Message-ID: <20090928222403.GQ29735@mothafucka.localdomain> (raw)
In-Reply-To: <m3my4eagcp.fsf@neno.mitica>
On Mon, Sep 28, 2009 at 11:50:46PM +0200, Juan Quintela wrote:
> Glauber Costa <glommer@redhat.com> wrote:
> > This patch provides kvm with an in-kernel ioapic. 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>
>
>
> base_address IOAPICState field missing.
>
> > +#if defined(KVM_CAP_IRQCHIP) && defined(TARGET_I386)
> > +static void kvm_kernel_ioapic_load_from_user(IOAPICState *s)
> > +{
> > + struct kvm_irqchip chip;
> > + struct kvm_ioapic_state *kioapic;
> > + int i;
> > +
>
> if (!kvm_enabled() || !kvm_irqchip_in_kernel()) {
> return;
No need. if this function is ever called and this is not true, this is a bug.
>
> > + chip.chip_id = KVM_IRQCHIP_IOAPIC;
> > + kioapic = &chip.chip.ioapic;
> > +
> > + kioapic->id = s->id;
> > + kioapic->ioregsel = s->ioregsel;
> > + kioapic->base_address = IOAPIC_DEFAULT_BASE_ADDRESS;
> > + kioapic->irr = s->irr;
> > + for (i = 0; i < IOAPIC_NUM_PINS; i++) {
> > + kioapic->redirtbl[i].bits = s->ioredtbl[i];
> > + }
> > +
> > + kvm_set_irqchip(&chip);
> > +}
> > +
> > +static void kvm_kernel_ioapic_save_to_user(IOAPICState *s)
> > +{
> > + struct kvm_irqchip chip;
> > + struct kvm_ioapic_state *kioapic;
> > + int i;
>
> if (!kvm_enabled() || !kvm_irqchip_in_kernel()) {
> return;
ditto.
>
> > + chip.chip_id = KVM_IRQCHIP_IOAPIC;
> > + kvm_get_irqchip(&chip);
> > + kioapic = &chip.chip.ioapic;
> > +
> > + s->id = kioapic->id;
> > + s->ioregsel = kioapic->ioregsel;
> > + s->irr = kioapic->irr;
> > + for (i = 0; i < IOAPIC_NUM_PINS; i++) {
> > + s->ioredtbl[i] = kioapic->redirtbl[i].bits;
> > + }
> > +}
> > +#endif
> > +
> > +static void ioapic_pre_save(const void *opaque)
> > +{
> > +#if defined(KVM_CAP_IRQCHIP) && defined(TARGET_I386)
> > + IOAPICState *s = (void *)opaque;
> > +
> > + if (kvm_enabled() && kvm_irqchip_in_kernel()) {
>
> Can we put this test inside the functions? Yes, I know that qemu-kvm
> uses always this syntax, but it just makes the API simpler to use.
I am not sure if we are aiming for a simpler api here. Those functions should never
be called if we're not using in-kernel irqchip, and it is probably better to have
callers to enforce it.
>
> > + kvm_kernel_ioapic_save_to_user(s);
> > + }
> > +#endif
> > +}
> > +
> > +static int ioapic_pre_load(void *opaque)
> > +{
> > + IOAPICState *s = opaque;
> > +
> > + /* in case we are doing version 1, we just set these to sane
> > values */
>
> You forgot to update vmstate_ioapic to version 2.
ok.
>
> > + s->irr = 0;
> > + return 0;
> > +}
> > +
> > +static int ioapic_post_load(void *opaque)
> > +{
> > +#if defined(KVM_CAP_IRQCHIP) && defined(TARGET_I386)
> > + IOAPICState *s = opaque;
> > +
> > + if (kvm_enabled() && kvm_irqchip_in_kernel()) {
> > + kvm_kernel_ioapic_load_from_user(s);
> > + }
> > +#endif
> > + return 0;
> > +}
> > +
> > +
> > static const VMStateDescription vmstate_ioapic = {
> > .name = "ioapic",
> > .version_id = 1,
> > @@ -201,7 +276,10 @@ static const VMStateDescription vmstate_ioapic = {
> > VMSTATE_UINT8(ioregsel, IOAPICState),
> > VMSTATE_UINT64_ARRAY(ioredtbl, IOAPICState, IOAPIC_NUM_PINS),
> > VMSTATE_END_OF_LIST()
> > - }
> > + },
> > + .pre_load = ioapic_pre_load,
> > + .post_load = ioapic_post_load,
> > + .pre_save = ioapic_pre_save,
> > };
>
next prev parent reply other threads:[~2009-09-28 22:24 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
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 ` Glauber Costa [this message]
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=20090928222403.GQ29735@mothafucka.localdomain \
--to=glommer@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@trasno.org \
/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).