From: Eric Auger <eric.auger@linaro.org>
To: eric.auger@st.com, christoffer.dall@linaro.org,
qemu-devel@nongnu.org, a.rigo@virtualopensystems.com,
marc.zyngier@arm.com, ard.biesheuvel@linaro.org, agraf@suse.de,
peter.maydell@linaro.org, pbonzini@redhat.com, afaerber@suse.de
Cc: a.motakis@virtualopensystems.com, alex.williamson@redhat.com,
patches@linaro.org, kvmarm@lists.cs.columbia.edu,
eric.auger@linaro.org
Subject: [Qemu-devel] [PATCH 2/2] hw/intc/arm_gic: Initialize the vgic on machine init done
Date: Tue, 2 Dec 2014 18:28:14 +0000 [thread overview]
Message-ID: <1417544894-2000-3-git-send-email-eric.auger@linaro.org> (raw)
In-Reply-To: <1417544894-2000-1-git-send-email-eric.auger@linaro.org>
With current implementation the vgic is instantiated very late,
when the VM is started, on the first VCPU run execution. This patch
forces its initialization in a machine init done notifier. This
latter is registered in the vgic realize function. The notifier uses
a new group/attribute that allows such operation. In practice, vgic
initialization can be done as soon as those dimensioning parameters
are known:
- the number of IRQs,
- the number of vcpus
- start address of dist and CPU interface (set in a memory listener).
This earlier initialization allows, for example, to setup VFIO
signaling after vgic initialization, on a reset notifier.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
hw/intc/arm_gic_kvm.c | 21 +++++++++++++++++++++
include/hw/intc/arm_gic_common.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
index 5038885..24fdf98 100644
--- a/hw/intc/arm_gic_kvm.c
+++ b/hw/intc/arm_gic_kvm.c
@@ -23,6 +23,7 @@
#include "sysemu/kvm.h"
#include "kvm_arm.h"
#include "gic_internal.h"
+#include "sysemu/sysemu.h"
//#define DEBUG_GIC_KVM
@@ -511,6 +512,17 @@ static void kvm_arm_gic_reset(DeviceState *dev)
kvm_arm_gic_put(s);
}
+static void kvm_arm_vgic_init_notify(Notifier *notifier, void *data)
+{
+ GICState *s = container_of(notifier, GICState, init_notifier);
+ struct kvm_device_attr attr = {
+ .group = KVM_DEV_ARM_VGIC_GRP_CTRL,
+ .attr = KVM_DEV_ARM_VGIC_CTRL_INIT};
+ if (s->dev_fd >= 0) {
+ kvm_device_ioctl(s->dev_fd, KVM_SET_DEVICE_ATTR, &attr);
+ }
+}
+
static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)
{
int i;
@@ -553,6 +565,15 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)
return;
}
+ /*
+ * Register a notifier that will request the VGIC initialization.
+ * It will be executed after the notifier registered by
+ * kvm_arm_register_device whose role is to set dist and cpu interface
+ * base address. Also IRQ and VCPU number is known.
+ */
+ s->init_notifier.notify = kvm_arm_vgic_init_notify;
+ qemu_add_machine_init_done_notifier(&s->init_notifier);
+
/* Distributor */
memory_region_init_reservation(&s->iomem, OBJECT(s),
"kvm-gic_dist", 0x1000);
diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h
index f6887ed..98653c9 100644
--- a/include/hw/intc/arm_gic_common.h
+++ b/include/hw/intc/arm_gic_common.h
@@ -105,6 +105,7 @@ typedef struct GICState {
uint32_t num_irq;
uint32_t revision;
int dev_fd; /* kvm device fd if backed by kvm vgic support */
+ Notifier init_notifier; /* notifier used to init the vgic */
} GICState;
#define TYPE_ARM_GIC_COMMON "arm_gic_common"
--
1.8.3.2
prev parent reply other threads:[~2014-12-02 18:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-02 18:28 [Qemu-devel] [PATCH 0/2] arm_gic: Initialize VGIC on machine init done Eric Auger
2014-12-02 18:28 ` [Qemu-devel] [PATCH 1/2] linux-headers: Update KVM headers from linux-next tag ToBeFilled Eric Auger
2014-12-03 10:49 ` Christoffer Dall
2014-12-03 10:53 ` Eric Auger
2014-12-03 11:03 ` Christoffer Dall
2014-12-03 11:03 ` Eric Auger
2014-12-02 18:28 ` Eric Auger [this message]
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=1417544894-2000-3-git-send-email-eric.auger@linaro.org \
--to=eric.auger@linaro.org \
--cc=a.motakis@virtualopensystems.com \
--cc=a.rigo@virtualopensystems.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=ard.biesheuvel@linaro.org \
--cc=christoffer.dall@linaro.org \
--cc=eric.auger@st.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.com \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.com \
--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 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).