Skip to contentSkip to conversation

explicit VGIC initialization in finalize function

PATCH Superseded Eric Auger 2 participants 5 messages Feb 13, 2015

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

v3 cover explicit VGIC initialization in finalize function

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.

Tested on Calxeda Midway with VFIO platform use case

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

v2 -> v3: changed to a patch since the kernel dependency was integrated in 3.19

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(+)
Signature · 1 line
1.8.3.2
author
#1 lore raw

PATCH v3 1/2 linux-headers: update KVM headers from KVM_DEV_ARM_VGIC_GRP_CTRL

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 3.19 headers.

---
 linux-headers/asm-arm/kvm.h   | 5 +++++
 linux-headers/asm-arm64/kvm.h | 5 +++++
 2 files changed, 10 insertions(+)
linux-headers/asm-arm/kvm.h +5 -0
index 09ee408..2499867 100644
@@ -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))
linux-headers/asm-arm64/kvm.h +5 -0
index 8e38878..b35c95a 100644
@@ -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))
Signature · 1 line
1.8.3.2
#2 lore raw

Re: [Qemu-devel] [PATCH v3 1/2] linux-headers: update KVM headers from KVM_DEV_ARM_VGIC_GRP_CTRL

Quoted 4 lines · 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 3.19 headers.

Is this really a full header sync? I'd have expected it to have non-ARM changes in it too...

-- PMM

author
#3 lore raw

Re: [Qemu-devel] [PATCH v3 1/2] linux-headers: update KVM headers from KVM_DEV_ARM_VGIC_GRP_CTRL

Quoted 8 lines · Peter Maydell
Quoted 4 lines · 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 3.19 headers.

Is this really a full header sync? I'd have expected it to have non-ARM changes in it too...

Hi Peter,

This is indeed a partial update. I will resend doing the full update.

Thanks for the hint

-Eric

Quoted 3 lines

-- PMM

author
#4 lore raw

PATCH v3 2/2 hw/intc/arm_gic: Initialize the vgic in the realize function

In reply to 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.

---
 hw/intc/arm_gic_kvm.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/intc/arm_gic_kvm.c +6 -0
index 1ad3eb0..1395c9e 100644
@@ -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);
Signature · 1 line
1.8.3.2