qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC v2 0/2] explicit VGIC initialization in finalize function
@ 2015-01-15 13:05 Eric Auger
  2015-01-15 13:05 ` [Qemu-devel] [RFC v2 1/2] linux-headers: update KVM headers from KVM_DEV_ARM_VGIC_GRP_CTRL Eric Auger
  2015-01-15 13:05 ` [Qemu-devel] [RFC v2 2/2] hw/intc/arm_gic: Initialize the vgic in the realize function Eric Auger
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Auger @ 2015-01-15 13:05 UTC (permalink / raw)
  To: eric.auger, christoffer.dall, qemu-devel, marc.zyngier,
	peter.maydell, pbonzini, afaerber
  Cc: patches, kvmarm, eric.auger

With current implementation the vgic is initialized implicitly,
on-demand. This patch forces the init in the vgic finalize function.
At that point all the dimensioning parameters are known.

A new group/attribute in VGIC KVM device is used for that:
KVM_DEV_ARM_VGIC_GRP_CTRL/KVM_DEV_ARM_VGIC_CTRL_INIT.

Among other things, this earlier VGIC initialization allows to
have a simpler handling of VFIO. VFIO platform signaling can be
setup on reset handler, making sure the VGIC is ready, at that time,
to accept injected virtual IRQs.

Depends on the following kernel patch:
[PATCH v3 0/2] VGIC early initialization initiated by user-space

Tested on Calxeda Miday with VFIO platform use case

Can be found on
http://git.linaro.org/people/eric.auger/qemu.git,
branch vfio_integ_v9

v1 -> v2:
- The init is not mandated to be done in a machine init done notifier
  anymore since only the number of vcpus and number of IRQs must be known
  at init time.

Eric Auger (2):
  linux-headers: update KVM headers from KVM_DEV_ARM_VGIC_GRP_CTRL
  hw/intc/arm_gic: Initialize the vgic in the realize function

 hw/intc/arm_gic_kvm.c         | 6 ++++++
 linux-headers/asm-arm/kvm.h   | 5 +++++
 linux-headers/asm-arm64/kvm.h | 5 +++++
 3 files changed, 16 insertions(+)

-- 
1.8.3.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [RFC v2 1/2] linux-headers: update KVM headers from KVM_DEV_ARM_VGIC_GRP_CTRL
  2015-01-15 13:05 [Qemu-devel] [RFC v2 0/2] explicit VGIC initialization in finalize function Eric Auger
@ 2015-01-15 13:05 ` Eric Auger
  2015-01-15 13:05 ` [Qemu-devel] [RFC v2 2/2] hw/intc/arm_gic: Initialize the vgic in the realize function Eric Auger
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Auger @ 2015-01-15 13:05 UTC (permalink / raw)
  To: eric.auger, christoffer.dall, qemu-devel, marc.zyngier,
	peter.maydell, pbonzini, afaerber
  Cc: patches, kvmarm, eric.auger

Add a new group/attribute in VGIC KVM device enabling to force
vgic init: KVM_DEV_ARM_VGIC_GRP_CTRL/KVM_DEV_ARM_VGIC_CTRL_INIT

Update according to headers found in
http://git.linaro.org/people/eric.auger/linux.git
branch irqfd_v6_integrated_official_release

Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
 linux-headers/asm-arm/kvm.h   | 5 +++++
 linux-headers/asm-arm64/kvm.h | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/linux-headers/asm-arm/kvm.h b/linux-headers/asm-arm/kvm.h
index 09ee408..2499867 100644
--- a/linux-headers/asm-arm/kvm.h
+++ b/linux-headers/asm-arm/kvm.h
@@ -175,6 +175,8 @@ struct kvm_arch_memory_slot {
 #define   KVM_DEV_ARM_VGIC_OFFSET_SHIFT	0
 #define   KVM_DEV_ARM_VGIC_OFFSET_MASK	(0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT)
 #define KVM_DEV_ARM_VGIC_GRP_NR_IRQS	3
+#define KVM_DEV_ARM_VGIC_GRP_CTRL       4
+#define   KVM_DEV_ARM_VGIC_CTRL_INIT    0
 
 /* KVM_IRQ_LINE irq field index values */
 #define KVM_ARM_IRQ_TYPE_SHIFT		24
@@ -196,6 +198,9 @@ struct kvm_arch_memory_slot {
 /* Highest supported SPI, from VGIC_NR_IRQS */
 #define KVM_ARM_IRQ_GIC_MAX		127
 
+/* One single KVM irqchip, ie. the VGIC */
+#define KVM_NR_IRQCHIPS          1
+
 /* PSCI interface */
 #define KVM_PSCI_FN_BASE		0x95c1ba5e
 #define KVM_PSCI_FN(n)			(KVM_PSCI_FN_BASE + (n))
diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
index 8e38878..b35c95a 100644
--- a/linux-headers/asm-arm64/kvm.h
+++ b/linux-headers/asm-arm64/kvm.h
@@ -161,6 +161,8 @@ struct kvm_arch_memory_slot {
 #define   KVM_DEV_ARM_VGIC_OFFSET_SHIFT	0
 #define   KVM_DEV_ARM_VGIC_OFFSET_MASK	(0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT)
 #define KVM_DEV_ARM_VGIC_GRP_NR_IRQS	3
+#define KVM_DEV_ARM_VGIC_GRP_CTRL	4
+#define   KVM_DEV_ARM_VGIC_CTRL_INIT	0
 
 /* KVM_IRQ_LINE irq field index values */
 #define KVM_ARM_IRQ_TYPE_SHIFT		24
@@ -182,6 +184,9 @@ struct kvm_arch_memory_slot {
 /* Highest supported SPI, from VGIC_NR_IRQS */
 #define KVM_ARM_IRQ_GIC_MAX		127
 
+/* One single KVM irqchip, ie. the VGIC */
+#define KVM_NR_IRQCHIPS          1
+
 /* PSCI interface */
 #define KVM_PSCI_FN_BASE		0x95c1ba5e
 #define KVM_PSCI_FN(n)			(KVM_PSCI_FN_BASE + (n))
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] [RFC v2 2/2] hw/intc/arm_gic: Initialize the vgic in the realize function
  2015-01-15 13:05 [Qemu-devel] [RFC v2 0/2] explicit VGIC initialization in finalize function Eric Auger
  2015-01-15 13:05 ` [Qemu-devel] [RFC v2 1/2] linux-headers: update KVM headers from KVM_DEV_ARM_VGIC_GRP_CTRL Eric Auger
@ 2015-01-15 13:05 ` Eric Auger
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Auger @ 2015-01-15 13:05 UTC (permalink / raw)
  To: eric.auger, christoffer.dall, qemu-devel, marc.zyngier,
	peter.maydell, pbonzini, afaerber
  Cc: patches, kvmarm, eric.auger

This patch forces vgic initialization in the vgic realize function.
It uses a new group/attribute that allows such operation.

This earlier initialization allows, for example, to setup VFIO
signaling and irqfd after vgic initialization, on a reset notifier.

Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
 hw/intc/arm_gic_kvm.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
index 1ad3eb0..1395c9e 100644
--- a/hw/intc/arm_gic_kvm.c
+++ b/hw/intc/arm_gic_kvm.c
@@ -573,6 +573,12 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)
         kvm_gic_access(s, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0, 0, &numirqs, 1);
     }
 
+    if (kvm_gic_supports_attr(s, KVM_DEV_ARM_VGIC_GRP_CTRL,
+                              KVM_DEV_ARM_VGIC_CTRL_INIT)) {
+        kvm_gic_access(s, KVM_DEV_ARM_VGIC_GRP_CTRL,
+                          KVM_DEV_ARM_VGIC_CTRL_INIT, 0, 0, 1);
+    }
+
     /* Distributor */
     memory_region_init_reservation(&s->iomem, OBJECT(s),
                                    "kvm-gic_dist", 0x1000);
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-15 13:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-15 13:05 [Qemu-devel] [RFC v2 0/2] explicit VGIC initialization in finalize function Eric Auger
2015-01-15 13:05 ` [Qemu-devel] [RFC v2 1/2] linux-headers: update KVM headers from KVM_DEV_ARM_VGIC_GRP_CTRL Eric Auger
2015-01-15 13:05 ` [Qemu-devel] [RFC v2 2/2] hw/intc/arm_gic: Initialize the vgic in the realize function Eric Auger

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).