[PATCH v3 06/10] qemu-kvm: Use upstream kvm-i8259

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Drop the qemu-kvm version in favor of the equivalent upstream
implementation. This allows to move the i8259 back into the hwlib.

Note that this also drops the testdev hack and restores proper
isa_get_irq. If testdev scripts exist that inject > IRQ15, they need
fixing. Testing for these interrupts on the PIIX3 makes no practical
sense anyway as those lines are unused.

Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
 Makefile.objs   |    2 +-
 Makefile.target |    8 ++--
 hw/i8259.c      |  108 -------------------------------------------------------
 hw/isa-bus.c    |    2 +-
 hw/pc_piix.c    |    5 +--
 5 files changed, 7 insertions(+), 118 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index e4e7e95..c33c0f2 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -229,7 +229,7 @@ hw-obj-$(CONFIG_APPLESMC) += applesmc.o
 hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o
 hw-obj-$(CONFIG_SMARTCARD_NSS) += ccid-card-emulated.o
 hw-obj-$(CONFIG_USB_REDIR) += usb-redir.o
-# hw-obj-$(CONFIG_I8259) += i8259_common.o i8259.o
+hw-obj-$(CONFIG_I8259) += i8259_common.o i8259.o
 
 # PPC devices
 hw-obj-$(CONFIG_PREP_PCI) += prep_pci.o
diff --git a/Makefile.target b/Makefile.target
index 7eb07fa..a57411b 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -240,7 +240,7 @@ obj-$(CONFIG_IVSHMEM) += ivshmem.o
 obj-y += device-hotplug.o
 
 # Hardware support
-obj-i386-y += mc146818rtc.o pc.o i8259_common.o i8259.o
+obj-i386-y += mc146818rtc.o pc.o
 obj-i386-y += sga.o apic_common.o apic.o ioapic_common.o ioapic.o piix_pci.o
 obj-i386-y += vmport.o
 obj-i386-y += pci-hotplug.o smbios.o wdt_ib700.o
@@ -259,7 +259,7 @@ obj-i386-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o
 # shared objects
 obj-ppc-y = ppc.o ppc_booke.o
 # PREP target
-obj-ppc-y += mc146818rtc.o i8259_common.o i8259.o
+obj-ppc-y += mc146818rtc.o
 obj-ppc-y += ppc_prep.o
 # OldWorld PowerMac
 obj-ppc-y += ppc_oldworld.o
@@ -313,7 +313,7 @@ obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
 obj-mips-y += pcspk.o i8254.o
 obj-mips-y += acpi.o acpi_piix4.o
 obj-mips-y += mips_addr.o mips_timer.o mips_int.o
-obj-mips-y += gt64xxx.o mc146818rtc.o i8259_common.o i8259.o
+obj-mips-y += gt64xxx.o mc146818rtc.o
 obj-mips-$(CONFIG_FULONG) += bonito.o vt82c686.o mips_fulong2e.o
 
 obj-microblaze-y = petalogix_s3adsp1800_mmu.o
@@ -395,7 +395,7 @@ obj-m68k-y += m68k-semi.o dummy_m68k.o
 
 obj-s390x-y = s390-virtio-bus.o s390-virtio.o
 
-obj-alpha-y = mc146818rtc.o i8259_common.o i8259.o
+obj-alpha-y = mc146818rtc.o
 obj-alpha-y += alpha_pci.o alpha_dp264.o alpha_typhoon.o
 
 obj-xtensa-y += xtensa_pic.o
diff --git a/hw/i8259.c b/hw/i8259.c
index 6bf9fe3..53daf78 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -28,11 +28,6 @@
 #include "qemu-timer.h"
 #include "i8259_internal.h"
 
-#include "kvm.h"
-#include "apic_internal.h"
-
-static void kvm_i8259_set_irq(void *opaque, int irq, int level);
-
 /* debug PIC */
 //#define DEBUG_PIC
 
@@ -226,17 +221,9 @@ int pic_read_irq(DeviceState *d)
     return intno;
 }
 
-static int kvm_kernel_pic_load_from_user(PICCommonState *s);
-
 static void pic_init_reset(PICCommonState *s)
 {
     pic_reset_common(s);
-
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_kernel_pic_load_from_user(s);
-        return;
-    }
-
     pic_update_irq(s);
 }
 
@@ -393,22 +380,6 @@ static uint64_t elcr_ioport_read(void *opaque, target_phys_addr_t addr,
     return s->elcr;
 }
 
-static void kvm_kernel_pic_save_to_user(PICCommonState *s);
-
-static void kvm_pic_pre_save(PICCommonState *s)
-{
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_kernel_pic_save_to_user(s);
-    }
-}
-
-static void kvm_pic_post_load(PICCommonState *s)
-{
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_kernel_pic_load_from_user(s);
-    }
-}
-
 static const MemoryRegionOps pic_base_ioport_ops = {
     .read = pic_ioport_read,
     .write = pic_ioport_write,
@@ -498,10 +469,6 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq)
 
     slave_pic = DO_UPCAST(PICCommonState, dev, dev);
 
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        irq_set = qemu_allocate_irqs(kvm_i8259_set_irq, NULL, 24);
-    }
-
     return irq_set;
 }
 
@@ -511,8 +478,6 @@ static void i8259_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = pic_init;
-    k->pre_save  = kvm_pic_pre_save;
-    k->post_load = kvm_pic_post_load;
     dc->reset = pic_reset;
 }
 
@@ -528,77 +493,4 @@ static void pic_register_types(void)
     type_register_static(&i8259_info);
 }
 
-static void kvm_kernel_pic_save_to_user(PICCommonState *s)
-{
-#ifdef KVM_CAP_IRQCHIP
-    struct kvm_irqchip chip;
-    struct kvm_pic_state *kpic;
-
-    chip.chip_id = s->master ?
-                   KVM_IRQCHIP_PIC_MASTER :
-                   KVM_IRQCHIP_PIC_SLAVE;
-    kvm_get_irqchip(kvm_state, &chip);
-    kpic = &chip.chip.pic;
-
-    s->last_irr = kpic->last_irr;
-    s->irr = kpic->irr;
-    s->imr = kpic->imr;
-    s->isr = kpic->isr;
-    s->priority_add = kpic->priority_add;
-    s->irq_base = kpic->irq_base;
-    s->read_reg_select = kpic->read_reg_select;
-    s->poll = kpic->poll;
-    s->special_mask = kpic->special_mask;
-    s->init_state = kpic->init_state;
-    s->auto_eoi = kpic->auto_eoi;
-    s->rotate_on_auto_eoi = kpic->rotate_on_auto_eoi;
-    s->special_fully_nested_mode = kpic->special_fully_nested_mode;
-    s->init4 = kpic->init4;
-    s->elcr = kpic->elcr;
-    s->elcr_mask = kpic->elcr_mask;
-#endif
-}
-
-static int kvm_kernel_pic_load_from_user(PICCommonState *s)
-{
-#ifdef KVM_CAP_IRQCHIP
-    struct kvm_irqchip chip;
-    struct kvm_pic_state *kpic;
-
-    chip.chip_id = s->master ?
-                   KVM_IRQCHIP_PIC_MASTER :
-                   KVM_IRQCHIP_PIC_SLAVE;
-    kpic = &chip.chip.pic;
-
-    kpic->last_irr = s->last_irr;
-    kpic->irr = s->irr;
-    kpic->imr = s->imr;
-    kpic->isr = s->isr;
-    kpic->priority_add = s->priority_add;
-    kpic->irq_base = s->irq_base;
-    kpic->read_reg_select = s->read_reg_select;
-    kpic->poll = s->poll;
-    kpic->special_mask = s->special_mask;
-    kpic->init_state = s->init_state;
-    kpic->auto_eoi = s->auto_eoi;
-    kpic->rotate_on_auto_eoi = s->rotate_on_auto_eoi;
-    kpic->special_fully_nested_mode = s->special_fully_nested_mode;
-    kpic->init4 = s->init4;
-    kpic->elcr = s->elcr;
-    kpic->elcr_mask = s->elcr_mask;
-
-    kvm_set_irqchip(kvm_state, &chip);
-#endif
-    return 0;
-}
-
-static void kvm_i8259_set_irq(void *opaque, int irq, int level)
-{
-    int pic_ret;
-    if (kvm_set_irq(irq, level, &pic_ret)) {
-        apic_report_irq_delivered(pic_ret);
-        return;
-    }
-}
-
 type_init(pic_register_types)
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 070c4ab..5a43f03 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -68,7 +68,7 @@ void isa_bus_irqs(ISABus *bus, qemu_irq *irqs)
 qemu_irq isa_get_irq(ISADevice *dev, int isairq)
 {
     assert(!dev || DO_UPCAST(ISABus, qbus, dev->qdev.parent_bus) == isabus);
-    if (isairq < 0 || isairq > 23) {
+    if (isairq < 0 || isairq > 15) {
         hw_error("isa irq %d invalid", isairq);
     }
     return isabus->irqs[isairq];
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 32acdb2..3f3984c 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -212,12 +212,9 @@ static void pc_init1(MemoryRegion *system_memory,
     }
     isa_bus_irqs(isa_bus, gsi);
 
-#ifdef UNUSED_UPSTREAM_KVM
     if (kvm_irqchip_in_kernel()) {
         i8259 = kvm_i8259_init(isa_bus);
-    } else
-#endif
-    if (xen_enabled()) {
+    } else if (xen_enabled()) {
         i8259 = xen_interrupt_controller_init();
     } else {
         cpu_irq = pc_allocate_cpu_irq();
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux