add support for KVM_CAP_SPLIT_IRQCHIP
PATCH 2/2 add support for KVM_CAP_SPLIT_IRQCHIP
This patch adds support for split IRQ chip mode. When KVM_CAP_SPLIT_IRQCHIP is enabled:
1.) The PIC, PIT, and IOAPIC are implemented in userspace while the LAPIC is implemented by KVM.
2.) The software IOAPIC delivers interrupts to the KVM LAPIC via kvm_set_irq. Interrupt delivery is configured via the MSI routing table, for which routes are reserved in target-i386/kvm.c then configured in hw/intc/ioapic.c
3.) KVM delivers IOAPIC EOIs via a new exit KVM_EXIT_IOAPIC_EOI, which is handled in target-i386/kvm.c and relayed to the software IOAPIC via ioapic_eoi_broadcast.
--- hw/i386/pc.c | 7 ++++-- hw/i386/pc_piix.c | 4 ++-- hw/intc/ioapic.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++-- include/sysemu/kvm.h | 5 ++++- kvm-all.c | 10 +++++++-- stubs/kvm.c | 2 +- target-arm/kvm.c | 2 +- target-i386/cpu.c | 3 ++- target-i386/kvm.c | 43 +++++++++++++++++++++++++++++++++-- 9 files changed, 125 insertions(+), 14 deletions(-)
hw/i386/pc.c +5 -2
@@ -65,6 +65,7 @@#include "hw/mem/pc-dimm.h" #include "qapi/visitor.h" #include "qapi-visit.h" +#include "qom/cpu.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ
@@ -1517,10 +1518,11 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,qemu_register_boot_set (pc_boot_set, *rtc_state);if (!xen_enabled ()) { -if (kvm_irqchip_in_kernel ()) { +if (kvm_pit_in_kernel ()) { pit =kvm_pit_init (isa_bus,0x40 ); }else { pit =pit_init (isa_bus,0x40 , pit_isa_irq, pit_alt_irq); +DPRINTF ("Created software PIT.\n" ); }if (hpet) {/* connect PIT to output control line of the HPET */
@@ -1592,10 +1594,11 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)SysBusDevice *d;unsigned int i; -if (kvm_irqchip_in_kernel ()) { +if (kvm_ioapic_in_kernel ()) { dev =qdev_create (NULL ,"kvm-ioapic" ); }else { dev =qdev_create (NULL ,"ioapic" ); +DPRINTF ("Created software ioapic.\n" ); }if (parent_name) { object_property_add_child(object_resolve_path(parent_name, NULL),
hw/i386/pc_piix.c +2 -2
@@ -181,7 +181,7 @@ static void pc_init1(MachineState *machine, } gsi_state =g_malloc0 (sizeof (*gsi_state)); -if (kvm_irqchip_in_kernel ()) { +if (kvm_ioapic_in_kernel ()) {kvm_pc_setup_irq_routing (pci_enabled); gsi =qemu_allocate_irqs (kvm_pc_gsi_handler, gsi_state,GSI_NUM_PINS );
@@ -205,7 +205,7 @@ static void pc_init1(MachineState *machine, }isa_bus_irqs (isa_bus, gsi); -if (kvm_irqchip_in_kernel ()) { +if (kvm_pic_in_kernel ()) { i8259 =kvm_i8259_init (isa_bus); }else if (xen_enabled ()) { i8259 =xen_interrupt_controller_init ();
hw/intc/ioapic.c +61 -2
105 lines not on this page · raw message
include/sysemu/kvm.h +4 -1
@@ -309,6 +309,8 @@ MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run);int kvm_arch_handle_exit (CPUState *cpu,struct kvm_run *run); +int kvm_arch_handle_ioapic_eoi (CPUState *cpu,struct kvm_run *run); +int kvm_arch_process_async_events (CPUState *cpu);int kvm_arch_get_registers (CPUState *cpu);
@@ -475,6 +477,7 @@ void kvm_init_irq_routing(KVMState *s);/** * kvm_arch_irqchip_create: * @KVMState: The KVMState pointer +* @MachineState: The MachineState pointer * * Allow architectures to create an in-kernel irq chip themselves. *
@@ -482,7 +485,7 @@ void kvm_init_irq_routing(KVMState *s);* 0: irq chip was not created * > 0: irq chip was created */ -int kvm_arch_irqchip_create (KVMState *s); +int kvm_arch_irqchip_create (MachineState *ms,KVMState *s);/** * kvm_set_one_reg - set a register value in KVM via KVM_SET_ONE_REG ioctl
kvm-all.c +8 -2
@@ -97,6 +97,7 @@ struct KVMStateKVMState *kvm_state;bool kvm_kernel_irqchip; +bool kvm_split_irqchip;bool kvm_async_interrupts_allowed;bool kvm_halt_in_kernel_allowed;bool kvm_eventfds_allowed;
@@ -1394,9 +1395,14 @@ static void kvm_irqchip_create(MachineState *machine, KVMState *s)/* 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); + ret =kvm_arch_irqchip_create (machine, s);if (ret ==0 ) { - ret =kvm_vm_ioctl (s,KVM_CREATE_IRQCHIP ); +if (machine_kernel_irqchip_split (machine)) { +perror ("Split IRQ chip mode not supported." ); +exit (1 ); + }else { + ret =kvm_vm_ioctl (s,KVM_CREATE_IRQCHIP ); + } }if (ret <0 ) {fprintf (stderr,"Create kernel irqchip failed: %s\n" ,strerror (-ret));
stubs/kvm.c +1 -1
@@ -1,7 +1,7 @@#include "qemu-common.h" #include "sysemu/kvm.h" -int kvm_arch_irqchip_create (KVMState *s) +int kvm_arch_irqchip_create (MachineState *ms,KVMState *s) {return 0 ; }
target-arm/kvm.c +1 -1
@@ -583,7 +583,7 @@ void kvm_arch_init_irq_routing(KVMState *s) { } -int kvm_arch_irqchip_create (KVMState *s) +int kvm_arch_irqchip_create (MachineState *ms,KVMState *s) {/* If we can create the VGIC using the newer device control API, we * let the device do this when it initializes itself, otherwise we
target-i386/cpu.c +2 -1
@@ -22,6 +22,7 @@#include <inttypes.h> #include "cpu.h" +#include "hw/i386/pc.h" #include "sysemu/kvm.h" #include "sysemu/cpus.h" #include "kvm_i386.h"
@@ -2739,7 +2740,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)APICCommonState *apic;const char *apic_type ="apic" ; -if (kvm_irqchip_in_kernel ()) { +if (kvm_apic_in_kernel ()) { apic_type ="kvm-apic" ; }else if (xen_enabled ()) { apic_type ="xen-apic" ;
target-i386/kvm.c +41 -2
73 lines not on this page · raw message
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
hw/intc/ioapic.c line 42
Quoted 4 lines · Matt Gingell
hw/intc/ioapic.c +4
-0+#define APIC_DELIVERY_MODE_SHIFT 8; +#define APIC_POLARITY_SHIFT 14; +#define APIC_TRIG_MODE_SHIFT 15; +
Stray semicolons, fixed and queued for QEMU 2.6.
Paolo