From: "Andreas Färber" <afaerber@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, kvmarm@lists.cs.columbia.edu,
kvm@vger.kernel.org, patches@linaro.org
Subject: Re: [Qemu-devel] [RFC v2 4/6] hw/kvm/arm_gic: Implement support for KVM in-kernel ARM GIC
Date: Wed, 10 Oct 2012 19:23:53 +0200 [thread overview]
Message-ID: <5075AF29.30509@suse.de> (raw)
In-Reply-To: <1349881659-8403-5-git-send-email-peter.maydell@linaro.org>
Am 10.10.2012 17:07, schrieb Peter Maydell:
> Implement support for using the KVM in-kernel GIC for ARM.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/a15mpcore.c | 8 ++-
> hw/arm/Makefile.objs | 1 +
> hw/kvm/arm_gic.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 170 insertions(+), 1 deletion(-)
> create mode 100644 hw/kvm/arm_gic.c
>
> diff --git a/hw/a15mpcore.c b/hw/a15mpcore.c
> index fc0a02a..a37fc61 100644
> --- a/hw/a15mpcore.c
> +++ b/hw/a15mpcore.c
> @@ -19,6 +19,7 @@
> */
>
> #include "sysbus.h"
> +#include "kvm.h"
>
> /* A15MP private memory region. */
>
> @@ -41,7 +42,12 @@ static int a15mp_priv_init(SysBusDevice *dev)
> A15MPPrivState *s = FROM_SYSBUS(A15MPPrivState, dev);
> SysBusDevice *busdev;
>
> - s->gic = qdev_create(NULL, "arm_gic");
> + if (kvm_irqchip_in_kernel()) {
> + s->gic = qdev_create(NULL, "kvm-arm_gic");
> + } else {
> + s->gic = qdev_create(NULL, "arm_gic");
> + }
You could follow x86 more closely by just selecting apic_type. (Then if
we drop/change qdev_create() at some point it's one change less.)
> +
> qdev_prop_set_uint32(s->gic, "num-cpu", s->num_cpu);
> qdev_prop_set_uint32(s->gic, "num-irq", s->num_irq);
> qdev_prop_set_uint32(s->gic, "revision", 2);
[...]
> diff --git a/hw/kvm/arm_gic.c b/hw/kvm/arm_gic.c
> new file mode 100644
> index 0000000..3ec538d
> --- /dev/null
> +++ b/hw/kvm/arm_gic.c
> @@ -0,0 +1,162 @@
> +/*
> + * ARM Generic Interrupt Controller using KVM in-kernel support
> + *
> + * Copyright (c) 2012 Linaro Limited
> + * Written by Peter Maydell
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "hw/sysbus.h"
> +#include "kvm.h"
> +#include "hw/arm_gic_internal.h"
> +
> +#define TYPE_KVM_ARM_GIC "kvm-arm_gic"
"kvm-arm-gic"?
> +#define KVM_ARM_GIC(obj) \
> + OBJECT_CHECK(gic_state, (obj), TYPE_KVM_ARM_GIC)
> +#define KVM_ARM_GIC_CLASS(klass) \
> + OBJECT_CLASS_CHECK(KVMARMGICClass, (klass), TYPE_KVM_ARM_GIC)
> +#define KVM_ARM_GIC_GET_CLASS(obj) \
> + OBJECT_GET_CLASS(KVMARMGICClass, (obj), TYPE_KVM_ARM_GIC)
> +
> +typedef struct KVMARMGICClass {
> + ARMGICCommonClass parent_class;
> + int (*parent_init)(SysBusDevice *dev);
> + void (*parent_reset)(DeviceState *dev);
> +} KVMARMGICClass;
> +
> +static void kvm_arm_gic_set_irq(void *opaque, int irq, int level)
> +{
> + /* Meaning of the 'irq' parameter:
> + * [0..N-1] : external interrupts
> + * [N..N+31] : PPI (internal) interrupts for CPU 0
> + * [N+32..N+63] : PPI (internal interrupts for CPU 1
> + * ...
> + * Convert this to the kernel's desired encoding, which
> + * has separate fields in the irq number for type,
> + * CPU number and interrupt number.
> + */
> + gic_state *s = (gic_state *)opaque;
You don't happen to have time to clean up gic_state -> GICState before
spreading its use? ;)
[...]
> +static TypeInfo arm_gic_info = {
static const
> + .name = TYPE_KVM_ARM_GIC,
> + .parent = TYPE_ARM_GIC_COMMON,
> + .instance_size = sizeof(gic_state),
> + .class_init = kvm_arm_gic_class_init,
> + .class_size = sizeof(KVMARMGICClass),
> +};
> +
> +static void arm_gic_register_types(void)
kvm_arm_gic_register_types?
> +{
> + type_register_static(&arm_gic_info);
> +}
> +
> +type_init(arm_gic_register_types)
>
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
WARNING: multiple messages have this Message-ID (diff)
From: "Andreas Färber" <afaerber@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: patches@linaro.org, qemu-devel@nongnu.org, kvm@vger.kernel.org,
kvmarm@lists.cs.columbia.edu
Subject: Re: [Qemu-devel] [RFC v2 4/6] hw/kvm/arm_gic: Implement support for KVM in-kernel ARM GIC
Date: Wed, 10 Oct 2012 19:23:53 +0200 [thread overview]
Message-ID: <5075AF29.30509@suse.de> (raw)
In-Reply-To: <1349881659-8403-5-git-send-email-peter.maydell@linaro.org>
Am 10.10.2012 17:07, schrieb Peter Maydell:
> Implement support for using the KVM in-kernel GIC for ARM.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/a15mpcore.c | 8 ++-
> hw/arm/Makefile.objs | 1 +
> hw/kvm/arm_gic.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 170 insertions(+), 1 deletion(-)
> create mode 100644 hw/kvm/arm_gic.c
>
> diff --git a/hw/a15mpcore.c b/hw/a15mpcore.c
> index fc0a02a..a37fc61 100644
> --- a/hw/a15mpcore.c
> +++ b/hw/a15mpcore.c
> @@ -19,6 +19,7 @@
> */
>
> #include "sysbus.h"
> +#include "kvm.h"
>
> /* A15MP private memory region. */
>
> @@ -41,7 +42,12 @@ static int a15mp_priv_init(SysBusDevice *dev)
> A15MPPrivState *s = FROM_SYSBUS(A15MPPrivState, dev);
> SysBusDevice *busdev;
>
> - s->gic = qdev_create(NULL, "arm_gic");
> + if (kvm_irqchip_in_kernel()) {
> + s->gic = qdev_create(NULL, "kvm-arm_gic");
> + } else {
> + s->gic = qdev_create(NULL, "arm_gic");
> + }
You could follow x86 more closely by just selecting apic_type. (Then if
we drop/change qdev_create() at some point it's one change less.)
> +
> qdev_prop_set_uint32(s->gic, "num-cpu", s->num_cpu);
> qdev_prop_set_uint32(s->gic, "num-irq", s->num_irq);
> qdev_prop_set_uint32(s->gic, "revision", 2);
[...]
> diff --git a/hw/kvm/arm_gic.c b/hw/kvm/arm_gic.c
> new file mode 100644
> index 0000000..3ec538d
> --- /dev/null
> +++ b/hw/kvm/arm_gic.c
> @@ -0,0 +1,162 @@
> +/*
> + * ARM Generic Interrupt Controller using KVM in-kernel support
> + *
> + * Copyright (c) 2012 Linaro Limited
> + * Written by Peter Maydell
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "hw/sysbus.h"
> +#include "kvm.h"
> +#include "hw/arm_gic_internal.h"
> +
> +#define TYPE_KVM_ARM_GIC "kvm-arm_gic"
"kvm-arm-gic"?
> +#define KVM_ARM_GIC(obj) \
> + OBJECT_CHECK(gic_state, (obj), TYPE_KVM_ARM_GIC)
> +#define KVM_ARM_GIC_CLASS(klass) \
> + OBJECT_CLASS_CHECK(KVMARMGICClass, (klass), TYPE_KVM_ARM_GIC)
> +#define KVM_ARM_GIC_GET_CLASS(obj) \
> + OBJECT_GET_CLASS(KVMARMGICClass, (obj), TYPE_KVM_ARM_GIC)
> +
> +typedef struct KVMARMGICClass {
> + ARMGICCommonClass parent_class;
> + int (*parent_init)(SysBusDevice *dev);
> + void (*parent_reset)(DeviceState *dev);
> +} KVMARMGICClass;
> +
> +static void kvm_arm_gic_set_irq(void *opaque, int irq, int level)
> +{
> + /* Meaning of the 'irq' parameter:
> + * [0..N-1] : external interrupts
> + * [N..N+31] : PPI (internal) interrupts for CPU 0
> + * [N+32..N+63] : PPI (internal interrupts for CPU 1
> + * ...
> + * Convert this to the kernel's desired encoding, which
> + * has separate fields in the irq number for type,
> + * CPU number and interrupt number.
> + */
> + gic_state *s = (gic_state *)opaque;
You don't happen to have time to clean up gic_state -> GICState before
spreading its use? ;)
[...]
> +static TypeInfo arm_gic_info = {
static const
> + .name = TYPE_KVM_ARM_GIC,
> + .parent = TYPE_ARM_GIC_COMMON,
> + .instance_size = sizeof(gic_state),
> + .class_init = kvm_arm_gic_class_init,
> + .class_size = sizeof(KVMARMGICClass),
> +};
> +
> +static void arm_gic_register_types(void)
kvm_arm_gic_register_types?
> +{
> + type_register_static(&arm_gic_info);
> +}
> +
> +type_init(arm_gic_register_types)
>
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2012-10-10 17:23 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-10 15:07 [RFC v2 0/6] QEMU: Support KVM on ARM Peter Maydell
2012-10-10 15:07 ` [Qemu-devel] " Peter Maydell
2012-10-10 15:07 ` [RFC v2 1/6] linux-headers: Add ARM KVM headers (not for upstream) Peter Maydell
2012-10-10 15:07 ` [Qemu-devel] " Peter Maydell
2012-10-10 15:07 ` [RFC v2 2/6] ARM: KVM: Add support for KVM on ARM architecture Peter Maydell
2012-10-10 15:07 ` [Qemu-devel] " Peter Maydell
2012-10-13 9:09 ` Blue Swirl
2012-10-13 9:09 ` Blue Swirl
2012-10-13 19:19 ` Peter Maydell
2012-10-13 19:19 ` Peter Maydell
2012-10-18 12:37 ` Peter Maydell
2012-10-18 12:37 ` Peter Maydell
2012-10-18 17:41 ` Jan Kiszka
2012-10-18 17:41 ` [Qemu-devel] " Jan Kiszka
2012-10-18 17:53 ` Peter Maydell
2012-10-18 17:53 ` [Qemu-devel] " Peter Maydell
2012-10-10 15:07 ` [RFC v2 3/6] hw/arm_gic: Add presave/postload hooks Peter Maydell
2012-10-10 15:07 ` [Qemu-devel] " Peter Maydell
2012-10-10 17:29 ` Andreas Färber
2012-10-10 17:29 ` Andreas Färber
2012-10-10 15:07 ` [RFC v2 4/6] hw/kvm/arm_gic: Implement support for KVM in-kernel ARM GIC Peter Maydell
2012-10-10 15:07 ` [Qemu-devel] " Peter Maydell
2012-10-10 17:23 ` Andreas Färber [this message]
2012-10-10 17:23 ` Andreas Färber
2012-10-10 17:35 ` Peter Maydell
2012-10-10 17:35 ` Peter Maydell
2012-10-10 15:07 ` [RFC v2 5/6] ARM KVM: save and load VFP registers from kernel Peter Maydell
2012-10-10 15:07 ` [Qemu-devel] " Peter Maydell
2012-10-10 15:07 ` [RFC v2 6/6] configure: Enable KVM on ARM Peter Maydell
2012-10-10 15:07 ` [Qemu-devel] " Peter Maydell
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=5075AF29.30509@suse.de \
--to=afaerber@suse.de \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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 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.