Introduce kvm_arch_irqchip_create an arch-specific hook in preparation for architecture-specific use of the device control API to create IRQ chips.
Following patches will implement the ARM irqchip create method to prefer the device control API over the older KVM_CREATE_IRQCHIP API.
Signed-off-by: Christoffer Dall christoffer.dall@linaro.org --- include/sysemu/kvm.h | 4 ++++ kvm-all.c | 11 +++++++++-- target-arm/kvm.c | 5 +++++ target-i386/kvm.c | 5 +++++ target-ppc/kvm.c | 5 +++++ target-s390x/kvm.c | 5 +++++ 6 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index de74411..1e5847e 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -224,6 +224,10 @@ void kvm_arch_reset_vcpu(CPUState *cpu); int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); int kvm_arch_on_sigbus(int code, void *addr);
+/* return negative error on error, 0 if irq chip was not created, and positive + * number if it was created */ +int kvm_arch_irqchip_create(KVMState *s); + void kvm_arch_init_irq_routing(KVMState *s);
int kvm_set_irq(KVMState *s, int irq, int level); diff --git a/kvm-all.c b/kvm-all.c index 716860f..fe64f3b 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1295,10 +1295,17 @@ static int kvm_irqchip_create(KVMState *s) return 0; }
- ret = kvm_vm_ioctl(s, KVM_CREATE_IRQCHIP); + /* First probe and see if there's a arch-specific hook to create the + * in-kernel irqchip for us */ + ret = kvm_arch_irqchip_create(s); if (ret < 0) { - fprintf(stderr, "Create kernel irqchip failed\n"); return ret; + } else if (ret == 0) { + ret = kvm_vm_ioctl(s, KVM_CREATE_IRQCHIP); + if (ret < 0) { + fprintf(stderr, "Create kernel irqchip failed\n"); + return ret; + } }
kvm_kernel_irqchip = true; diff --git a/target-arm/kvm.c b/target-arm/kvm.c index b92e00d..2484d90 100644 --- a/target-arm/kvm.c +++ b/target-arm/kvm.c @@ -647,3 +647,8 @@ void kvm_arch_remove_all_hw_breakpoints(void) void kvm_arch_init_irq_routing(KVMState *s) { } + +int kvm_arch_irqchip_create(KVMState *s) +{ + return 0; +} diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 376fc70..8a62161 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -2188,6 +2188,11 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cs) ((env->segs[R_CS].selector & 3) != 3); }
+int kvm_arch_irqchip_create(KVMState *s) +{ + return 0; +} + void kvm_arch_init_irq_routing(KVMState *s) { if (!kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) { diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 30a870e..15c92e8 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -1875,3 +1875,8 @@ int kvm_arch_on_sigbus(int code, void *addr) void kvm_arch_init_irq_routing(KVMState *s) { } + +int kvm_arch_irqchip_create(KVMState *s) +{ + return 0; +} diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 26d18e3..7f4dae9 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -893,6 +893,11 @@ void kvm_arch_init_irq_routing(KVMState *s) { }
+int kvm_arch_irqchip_create(KVMState *s) +{ + return 0; +} + int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, int vq, bool assign) {