explicit VGIC initialization in finalize function
v2 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.
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(+)
Signature · 1 line
1.8.3.2
RFC v2 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 headers found in
http://git.linaro.org/people/eric.auger/linux.git
branch irqfd_v6_integrated_official_release
--- 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
@@ -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
@@ -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
RFC v2 2/2 hw/intc/arm_gic: Initialize the vgic in the realize function
In reply to Eric AugerThis 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
@@ -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