Skip to contentSkip to conversation

qemu-kvm: Switch to upstream irqchip services

PATCH Superseded Jan Kiszka 1 participant 10 messages Feb 13, 2012

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

v2 cover qemu-kvm: Switch to upstream irqchip services

Now that upstream has basic irqchip support, we can make use of it for qemu-kvm as well, removing another 700 lines of code here.

This series depends on

apic: Fix legacy vmstate loading for KVM

which is currently awaiting upstream merge via uq/master.

Jan Kiszka (9):
qemu-kvm: Move kvm_create_pit out of arch init code
qemu-kvm: Use machine options to configure qemu-kvm defaults
qemu-kvm: Use upstream irq routing services
qemu-kvm: Use upstream kvm_irqchip_create
qemu-kvm: Use upstream kvm-ioapic
qemu-kvm: Use upstream kvm-i8259
qemu-kvm: Drop unused kvm_get/set_irqchip
qemu-kvm: Use upstream kvm_irqchip_set_irq instead of kvm_set_irq
qemu-kvm: Use upstream kvm-apic

 Makefile.objs          |    2 +-
 Makefile.target        |    8 +-
 hw/apic.c              |  151 +-----------------------------------
 hw/device-assignment.c |   10 +-
 hw/i8254-kvm.c         |    3 +
 hw/i8259.c             |  108 -------------------------
 hw/ioapic.c            |   75 +-----------------
 hw/isa-bus.c           |    2 +-
 hw/msi.c               |    6 +-
 hw/msix.c              |   10 +-
 hw/pc.c                |    7 +-
 hw/pc_piix.c           |   23 ++----
 kvm-all.c              |   17 +----
 kvm-stub.c             |    6 +-
 kvm.h                  |    9 +-
 qemu-kvm-x86.c         |   85 +-------------------
 qemu-kvm.c             |  204 +-----------------------------------------------
 qemu-kvm.h             |   72 +----------------
 target-i386/kvm.c      |   17 ----
 vl.c                   |   10 +--
 20 files changed, 58 insertions(+), 767 deletions(-)
Signature · 1 line
1.7.3.4
author
#1 lore raw

PATCH v2 1/9 qemu-kvm: Move kvm_create_pit out of arch init code

This belongs where the PIT is created and allows us to drop another kvm_irqchip reference.

---
 hw/i8254-kvm.c    |    3 +++
 qemu-kvm-x86.c    |    4 ++--
 qemu-kvm.h        |    2 ++
 target-i386/kvm.c |    7 -------
 4 files changed, 7 insertions(+), 9 deletions(-)
hw/i8254-kvm.c +3 -0
index 8b494d0..f0c7ac8 100644
@@ -107,6 +107,9 @@ void kvm_pit_init(PITState *pit)
 {
     PITChannelState *s;
 
+    if (kvm_create_pit(kvm_state) < 0) {
+        hw_error("KVM PIT creation failed\n");
+    }
     s = &pit->channels[0];
     s->irq_timer = qemu_new_timer_ns(vm_clock, dummy_timer, s);
     vmstate_pit.pre_save = kvm_pit_pre_save;
qemu-kvm-x86.c +2 -2
index a0bfc23..6fe48a4 100644
@@ -23,11 +23,11 @@
 #include "kvm.h"
 #include "hw/apic.h"
 
-static int kvm_create_pit(KVMState *s)
+int kvm_create_pit(KVMState *s)
 {
     int r;
 
-    if (kvm_irqchip) {
+    if (kvm_irqchip_in_kernel()) {
         r = kvm_vm_ioctl(s, KVM_CREATE_PIT);
         if (r < 0) {
             fprintf(stderr, "Create kernel PIC irqchip failed\n");
qemu-kvm.h +2 -0
index 975b6fa..653370e 100644
@@ -256,6 +256,8 @@ int kvm_update_ioport_access(CPUState *env);
 int kvm_arch_set_ioport_access(unsigned long start, unsigned long size,
                                bool enable);
 
+int kvm_create_pit(KVMState *s);
+
 extern int kvm_irqchip;
 extern int kvm_pit_reinject;
 extern unsigned int kvm_shadow_memory;
target-i386/kvm.c +0 -7
index 7079e87..ee2d3f8 100644
@@ -661,8 +661,6 @@ static int kvm_get_supported_msrs(KVMState *s)
     return ret;
 }
 
-static int kvm_create_pit(KVMState *s);
-
 int kvm_arch_init(KVMState *s)
 {
     uint64_t identity_base = 0xfffbc000;
@@ -712,11 +710,6 @@ int kvm_arch_init(KVMState *s)
     }
     qemu_register_reset(kvm_unpoison_all, NULL);
 
-    ret = kvm_create_pit(s);
-    if (ret < 0) {
-        return ret;
-    }
-
     if (kvm_shadow_memory) {
         ret = kvm_vm_ioctl(s, KVM_SET_NR_MMU_PAGES, kvm_shadow_memory);
         if (ret < 0) {
Signature · 1 line
1.7.3.4
author
#2 lore raw

PATCH v2 2/9 qemu-kvm: Use machine options to configure qemu-kvm defaults

In reply to Jan Kiszka

Upstream is moving towards this mechanism, so start using it in qemu-kvm already to configure the specific defaults: kvm enabled on, just like in-kernel irqchips.

---
 hw/pc_piix.c |    7 +++++++
 kvm-all.c    |    8 ++++++++
 vl.c         |    9 +++------
 3 files changed, 18 insertions(+), 6 deletions(-)
hw/pc_piix.c +7 -0
index c9c580c..156fcc8 100644
@@ -394,6 +394,7 @@ static QEMUMachine pc_machine_v1_0 = {
     .init = pc_init_pci,
     .max_cpus = 255,
     .is_default = 1,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
 };
 
 static QEMUMachine pc_machine_v0_15 = {
@@ -409,6 +410,7 @@ static QEMUMachine pc_machine_v0_14 = {
     .desc = "Standard PC",
     .init = pc_init_pci,
     .max_cpus = 255,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "qxl",
@@ -444,6 +446,7 @@ static QEMUMachine pc_machine_v0_13 = {
     .desc = "Standard PC",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "virtio-9p-pci",
@@ -491,6 +494,7 @@ static QEMUMachine pc_machine_v0_12 = {
     .desc = "Standard PC",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "virtio-serial-pci",
@@ -542,6 +546,7 @@ static QEMUMachine pc_machine_v0_11 = {
     .desc = "Standard PC, qemu 0.11",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "virtio-blk-pci",
@@ -601,6 +606,7 @@ static QEMUMachine pc_machine_v0_10 = {
     .desc = "Standard PC, qemu 0.10",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "virtio-blk-pci",
@@ -672,6 +678,7 @@ static QEMUMachine isapc_machine = {
     .desc = "ISA-only PC",
     .init = pc_init_isa,
     .max_cpus = 1,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
 };
 
 #ifdef CONFIG_XEN
kvm-all.c +8 -0
index ae89389..515ba6e 100644
@@ -887,6 +887,7 @@ int kvm_init(void)
     const KVMCapabilityInfo *missing_cap;
     int ret;
     int i;
+    QemuOptsList *list;
 
     s = g_malloc0(sizeof(KVMState));
 
@@ -973,6 +974,13 @@ int kvm_init(void)
     s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
 #endif
 
+    list = qemu_find_opts("machine");
+    if (!QTAILQ_EMPTY(&list->head) &&
+        !qemu_opt_get_bool(QTAILQ_FIRST(&list->head),
+                           "kernel_irqchip", false)) {
+        kvm_irqchip = 0;
+    }
+
     ret = kvm_arch_init(s);
     if (ret < 0) {
         goto err;
vl.c +3 -6
index c5994ee..c3b4037 100644
@@ -2040,13 +2040,8 @@ static int configure_accelerator(void)
     }
 
     if (p == NULL) {
-#ifdef CONFIG_KVM_OPTIONS
-        /* Use the default "accelerator", kvm */
-        p = "kvm";
-#else
         /* Use the default "accelerator", tcg */
         p = "tcg";
-#endif
     }
 
     while (!accel_initalised && *p != '\0') {
@@ -2908,7 +2903,9 @@ int main(int argc, char **argv, char **envp)
                 break;
 #ifdef CONFIG_KVM_OPTIONS
 	    case QEMU_OPTION_no_kvm_irqchip: {
-		kvm_irqchip = 0;
+                olist = qemu_find_opts("machine");
+                qemu_opts_reset(olist);
+                qemu_opts_parse(olist, "accel=kvm,kernel_irqchip=off", 0);
 		break;
 	    }
 	    case QEMU_OPTION_no_kvm_pit: {
Signature · 1 line
1.7.3.4
author
#3 lore raw

PATCH v2 3/9 qemu-kvm: Use upstream irq routing services

In reply to Jan Kiszka

Replace qemu-kvm's versions of kvm_add_irq_route, kvm_add_routing_entry, kvm_init_irq_routing, kvm_arch_init_irq_routing, and kvm_commit_irq_routes with the corresponding upstream services. Until the MSI API is refactored, we only need to export kvm_add_routing_entry for this.

---
 hw/device-assignment.c |   10 ++--
 hw/msi.c               |    4 +-
 hw/msix.c              |    8 ++--
 hw/pc.c                |    2 +-
 hw/pc_piix.c           |    4 --
 kvm-all.c              |   10 +---
 kvm-stub.c             |    4 +-
 kvm.h                  |    6 +-
 qemu-kvm-x86.c         |   50 --------------------
 qemu-kvm.c             |  117 +----------------------------------------------
 qemu-kvm.h             |   19 +-------
 target-i386/kvm.c      |    2 -
 12 files changed, 25 insertions(+), 211 deletions(-)
hw/device-assignment.c +5 -5
index 584cbb9..d8019fe 100644
@@ -943,8 +943,8 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev)
         }
         assigned_dev->entry->gsi = r;
 
-        kvm_add_routing_entry(assigned_dev->entry);
-        if (kvm_commit_irq_routes() < 0) {
+        kvm_add_routing_entry(kvm_state, assigned_dev->entry);
+        if (kvm_irqchip_commit_routes(kvm_state) < 0) {
             perror("assigned_dev_update_msi: kvm_commit_irq_routes");
             assigned_dev->cap.state &= ~ASSIGNED_DEVICE_MSI_ENABLED;
             return;
@@ -1028,7 +1028,7 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
         DEBUG("MSI-X vector %d, gsi %d, addr %08x_%08x, data %08x\n", i,
               r, entry->addr_hi, entry->addr_lo, entry->data);
 
-        kvm_add_routing_entry(&adev->entry[i]);
+        kvm_add_routing_entry(kvm_state, &adev->entry[i]);
 
         msix_entry.gsi = adev->entry[i].gsi;
         msix_entry.entry = i;
@@ -1039,7 +1039,7 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
         }
     }
 
-    if (r == 0 && kvm_commit_irq_routes() < 0) {
+    if (r == 0 && kvm_irqchip_commit_routes(kvm_state) < 0) {
 	    perror("assigned_dev_update_msix_mmio: kvm_commit_irq_routes");
 	    return -EINVAL;
     }
@@ -1504,7 +1504,7 @@ static void msix_mmio_write(void *opaque, target_phys_addr_t addr,
                     return;
                 }
 
-                ret = kvm_commit_irq_routes();
+                ret = kvm_irqchip_commit_routes(kvm_state);
                 if (ret) {
                     fprintf(stderr,
                             "Error committing irq routes (%d)\n", ret);
hw/msi.c +2 -2
index 5c179c2..3e623c2 100644
@@ -178,7 +178,7 @@ static void kvm_msi_update(PCIDevice *dev)
     }
     dev->msi_entries_nr = nr_vectors;
     if (changed) {
-        r = kvm_commit_irq_routes();
+        r = kvm_irqchip_commit_routes(kvm_state);
         if (r) {
             fprintf(stderr, "%s: kvm_commit_irq_routes failed: %s\n", __func__,
                     strerror(-r));
@@ -196,7 +196,7 @@ static void kvm_msi_free(PCIDevice *dev)
         kvm_msi_message_del(&dev->msi_irq_entries[vector]);
     }
     if (dev->msi_entries_nr > 0) {
-        kvm_commit_irq_routes();
+        kvm_irqchip_commit_routes(kvm_state);
     }
     dev->msi_entries_nr = 0;
 }
hw/msix.c +4 -4
index 6e40957..55ddbf4 100644
@@ -49,7 +49,7 @@ static void kvm_msix_free(PCIDevice *dev)
         }
     }
     if (changed) {
-        kvm_commit_irq_routes();
+        kvm_irqchip_commit_routes(kvm_state);
     }
 }
 
@@ -89,7 +89,7 @@ static void kvm_msix_update(PCIDevice *dev, int vector,
     }
     if (r > 0) {
         *entry = new_entry;
-        r = kvm_commit_irq_routes();
+        r = kvm_irqchip_commit_routes(kvm_state);
         if (r) {
             fprintf(stderr, "%s: kvm_commit_irq_routes failed: %s\n", __func__,
 		    strerror(-r));
@@ -110,7 +110,7 @@ static int kvm_msix_vector_add(PCIDevice *dev, unsigned vector)
         return r;
     }
 
-    r = kvm_commit_irq_routes();
+    r = kvm_irqchip_commit_routes(kvm_state);
     if (r < 0) {
         fprintf(stderr, "%s: kvm_commit_irq_routes failed: %s\n", __func__, strerror(-r));
         return r;
@@ -121,7 +121,7 @@ static int kvm_msix_vector_add(PCIDevice *dev, unsigned vector)
 static void kvm_msix_vector_del(PCIDevice *dev, unsigned vector)
 {
     kvm_msi_message_del(&dev->msix_irq_entries[vector]);
-    kvm_commit_irq_routes();
+    kvm_irqchip_commit_routes(kvm_state);
 }
 
 /* Add MSI-X capability to the config space for the device. */
hw/pc.c +1 -1
index 70abb6c..e38a63d 100644
@@ -1158,7 +1158,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
 
     register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
 
-    if (!no_hpet) {
+    if (!no_hpet && (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) {
         DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL);
 
         if (hpet) {
hw/pc_piix.c +0 -4
index 156fcc8..ef0202a 100644
@@ -57,7 +57,6 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
 
 const char *global_cpu_model; /* cpu hotadd */
 
-#ifdef UNUSED_UPSTREAM_KVM
 static void kvm_piix3_setup_irq_routing(bool pci_enabled)
 {
 #ifdef CONFIG_KVM
@@ -90,7 +89,6 @@ static void kvm_piix3_setup_irq_routing(bool pci_enabled)
     }
 #endif /* CONFIG_KVM */
 }
-#endif
 
 static void kvm_piix3_gsi_handler(void *opaque, int n, int level)
 {
@@ -195,9 +193,7 @@ static void pc_init1(MemoryRegion *system_memory,
 
     gsi_state = g_malloc0(sizeof(*gsi_state));
     if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-#ifdef UNUSED_UPSTREAM_KVM
         kvm_piix3_setup_irq_routing(pci_enabled);
-#endif
         gsi = qemu_allocate_irqs(kvm_piix3_gsi_handler, gsi_state,
                                  GSI_NUM_PINS);
     } else {
kvm-all.c +2 -8
index 515ba6e..afcad44 100644
@@ -83,13 +83,9 @@ struct KVMState
 #ifdef KVM_CAP_IRQ_ROUTING
     struct kvm_irq_routing *irq_routes;
     int nr_allocated_irq_routes;
-#ifdef UNUSED_UPSTREAM_KVM
     uint32_t *used_gsi_bitmap;
     unsigned int max_gsi;
 #endif
-#endif
-    void *used_gsi_bitmap;
-    int max_gsi;
 };
 
 KVMState *kvm_state;
@@ -760,7 +756,6 @@ int kvm_irqchip_set_irq(KVMState *s, int irq, int level)
     return (s->irqchip_inject_ioctl == KVM_IRQ_LINE) ? 1 : event.status;
 }
 
-#ifdef UNUSED_UPSTREAM_KVM
 #ifdef KVM_CAP_IRQ_ROUTING
 static void set_gsi(KVMState *s, unsigned int gsi)
 {
@@ -794,8 +789,8 @@ static void kvm_init_irq_routing(KVMState *s)
     kvm_arch_init_irq_routing(s);
 }
 
-static void kvm_add_routing_entry(KVMState *s,
-                                  struct kvm_irq_routing_entry *entry)
+void kvm_add_routing_entry(KVMState *s,
+                           struct kvm_irq_routing_entry *entry)
 {
     struct kvm_irq_routing_entry *new;
     int n, size;
@@ -845,7 +840,6 @@ static void kvm_init_irq_routing(KVMState *s)
 {
 }
 #endif /* !KVM_CAP_IRQ_ROUTING */
-#endif
 
 static int kvm_irqchip_create(KVMState *s)
 {
kvm-stub.c +3 -1
index c98170e..266dc4a 100644
@@ -16,6 +16,8 @@
 #include "gdbstub.h"
 #include "kvm.h"
 
+KVMState *kvm_state;
+
 int kvm_irqchip_in_kernel(void)
 {
     return 0;
@@ -155,7 +157,7 @@ int kvm_msi_message_update(KVMMsiMessage *old, KVMMsiMessage *new)
     return -ENOSYS;
 }
 
-int kvm_commit_irq_routes(void)
+int kvm_irqchip_commit_routes(KVMState *s)
 {
     return -ENOSYS;
 }
kvm.h +3 -3
index c7c9d79..b84aa40 100644
@@ -130,9 +130,7 @@ void kvm_arch_reset_vcpu(CPUState *env);
 int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr);
 int kvm_arch_on_sigbus(int code, void *addr);
 
-#ifdef UNUSED_UPSTREAM_KVM
 void kvm_arch_init_irq_routing(KVMState *s);
-#endif
 
 int kvm_irqchip_set_irq(KVMState *s, int irq, int level);
 
@@ -229,7 +227,9 @@ int kvm_msi_message_add(KVMMsiMessage *msg);
 int kvm_msi_message_del(KVMMsiMessage *msg);
 int kvm_msi_message_update(KVMMsiMessage *old, KVMMsiMessage *new);
 
-int kvm_commit_irq_routes(void);
+#ifndef NEED_CPU_H
+int kvm_irqchip_commit_routes(KVMState *s);
+#endif
 
 int kvm_irqchip_in_kernel(void);
 
qemu-kvm-x86.c +0 -50

53 lines not on this page · raw message

qemu-kvm.c +3 -114

153 lines not on this page · raw message

qemu-kvm.h +2 -17
index 653370e..6235800 100644
@@ -183,14 +183,6 @@ int kvm_deassign_pci_device(KVMState *s,
 int kvm_clear_gsi_routes(void);
 
 /*!
- * \brief Adds an irq route to the temporary irq routing table
- *
- * Adds an irq route to the temporary irq routing table.  Nothing is
- * committed to the running VM.
- */
-int kvm_add_irq_route(int gsi, int irqchip, int pin);
-
-/*!
  * \brief Removes an irq route from the temporary irq routing table
  *
  * Adds an irq route to the temporary irq routing table.  Nothing is
@@ -199,13 +191,8 @@ int kvm_add_irq_route(int gsi, int irqchip, int pin);
 int kvm_del_irq_route(int gsi, int irqchip, int pin);
 
 struct kvm_irq_routing_entry;
-/*!
- * \brief Adds a routing entry to the temporary irq routing table
- *
- * Adds a filled routing entry to the temporary irq routing table. Nothing is
- * committed to the running VM.
- */
-int kvm_add_routing_entry(struct kvm_irq_routing_entry *entry);
+
+void kvm_add_routing_entry(KVMState *s, struct kvm_irq_routing_entry *entry);
 
 /*!
  * \brief Removes a routing from the temporary irq routing table
@@ -245,8 +232,6 @@ void kvm_hpet_disable_kpit(void);
 
 void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write);
 
-int kvm_arch_init_irq_routing(void);
-
 int kvm_add_ioport_region(unsigned long start, unsigned long size,
                           bool is_hot_plug);
 int kvm_remove_ioport_region(unsigned long start, unsigned long size,
target-i386/kvm.c +0 -2
index ee2d3f8..7096752 100644
@@ -2017,7 +2017,6 @@ bool kvm_arch_stop_on_emulation_error(CPUState *env)
            ((env->segs[R_CS].selector  & 3) != 3);
 }
 
-#ifdef UNUSED_UPSTREAM_KVM
 void kvm_arch_init_irq_routing(KVMState *s)
 {
     if (!kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) {
@@ -2028,6 +2027,5 @@ void kvm_arch_init_irq_routing(KVMState *s)
         no_hpet = 1;
     }
 }
-#endif
 
 #include "qemu-kvm-x86.c"
Signature · 1 line
1.7.3.4
author
#4 lore raw

PATCH v2 4/9 qemu-kvm: Use upstream kvm_irqchip_create

In reply to Jan Kiszka

Drop kvm_create_irqchip in favor of the equivalent upstream version. This also allows to drop the kvm_irqchip global variable.

---
 kvm-all.c  |   15 ---------------
 qemu-kvm.c |   29 -----------------------------
 qemu-kvm.h |    3 ---
 vl.c       |    1 -
 4 files changed, 0 insertions(+), 48 deletions(-)
kvm-all.c +0 -15
index afcad44..606bd02 100644
@@ -843,7 +843,6 @@ static void kvm_init_irq_routing(KVMState *s)
 
 static int kvm_irqchip_create(KVMState *s)
 {
-#ifdef UNUSED_UPSTREAM_KVM
     QemuOptsList *list = qemu_find_opts("machine");
     int ret;
 
@@ -867,7 +866,6 @@ static int kvm_irqchip_create(KVMState *s)
     s->irqchip_in_kernel = 1;
 
     kvm_init_irq_routing(s);
-#endif
 
     return 0;
 }
@@ -881,7 +879,6 @@ int kvm_init(void)
     const KVMCapabilityInfo *missing_cap;
     int ret;
     int i;
-    QemuOptsList *list;
 
     s = g_malloc0(sizeof(KVMState));
 
@@ -968,13 +965,6 @@ int kvm_init(void)
     s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
 #endif
 
-    list = qemu_find_opts("machine");
-    if (!QTAILQ_EMPTY(&list->head) &&
-        !qemu_opt_get_bool(QTAILQ_FIRST(&list->head),
-                           "kernel_irqchip", false)) {
-        kvm_irqchip = 0;
-    }
-
     ret = kvm_arch_init(s);
     if (ret < 0) {
         goto err;
@@ -990,11 +980,6 @@ int kvm_init(void)
 
     s->many_ioeventfds = kvm_check_many_ioeventfds();
 
-    ret = kvm_create_irqchip(s);
-    if (ret < 0) {
-        return ret;
-    }
-
     cpu_interrupt_handler = kvm_handle_interrupt;
 
     return 0;
qemu-kvm.c +0 -29
index 37af80f..8f1b760 100644
@@ -41,35 +41,6 @@ static inline void clear_gsi(KVMState *s, unsigned int gsi)
     }
 }
 
-int kvm_create_irqchip(KVMState *s)
-{
-#ifdef KVM_CAP_IRQCHIP
-    int r;
-
-    if (!kvm_irqchip || !kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
-        return 0;
-    }
-
-    r = kvm_vm_ioctl(s, KVM_CREATE_IRQCHIP);
-    if (r < 0) {
-        fprintf(stderr, "Create kernel PIC irqchip failed\n");
-        return r;
-    }
-
-    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
-#if defined(KVM_CAP_IRQ_INJECT_STATUS) && defined(KVM_IRQ_LINE_STATUS)
-    if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
-        s->irqchip_inject_ioctl = KVM_IRQ_LINE_STATUS;
-    }
-#endif
-    s->irqchip_in_kernel = 1;
-
-    kvm_init_irq_routing(s);
-#endif
-
-    return 0;
-}
-
 #ifdef KVM_CAP_IRQCHIP
 
 int kvm_set_irq(int irq, int level, int *status)
qemu-kvm.h +0 -3
index 6235800..cd5e3cc 100644
@@ -32,8 +32,6 @@
 
 #include "kvm.h"
 
-int kvm_create_irqchip(KVMState *s);
-
 /*!
  * \brief Dump in kernel IRQCHIP contents
  *
@@ -243,7 +241,6 @@ int kvm_arch_set_ioport_access(unsigned long start, unsigned long size,
 
 int kvm_create_pit(KVMState *s);
 
-extern int kvm_irqchip;
 extern int kvm_pit_reinject;
 extern unsigned int kvm_shadow_memory;
 
vl.c +0 -1
index c3b4037..98d29ce 100644
@@ -2173,7 +2173,6 @@ static void free_and_trace(gpointer mem)
 }
 
 #ifdef CONFIG_KVM_OPTIONS
-int kvm_irqchip = 1;
 int kvm_pit_reinject = 1;
 #endif
 
Signature · 1 line
1.7.3.4
author
#5 lore raw

PATCH v2 5/9 qemu-kvm: Use upstream kvm-ioapic

In reply to Jan Kiszka

Drop the qemu-kvm version in favor of the equivalent upstream implementation.

---
 hw/ioapic.c  |   75 +---------------------------------------------------------
 hw/pc_piix.c |    7 +----
 2 files changed, 2 insertions(+), 80 deletions(-)
hw/ioapic.c +1 -74
index 3f86eff..79549f8 100644
@@ -26,8 +26,6 @@
 #include "ioapic.h"
 #include "ioapic_internal.h"
 
-#include "kvm.h"
-
 //#define DEBUG_IOAPIC
 
 #ifdef DEBUG_IOAPIC
@@ -222,75 +220,6 @@ ioapic_mem_write(void *opaque, target_phys_addr_t addr, uint64_t val,
     }
 }
 
-static void kvm_kernel_ioapic_save_to_user(IOAPICCommonState *s)
-{
-#if defined(KVM_CAP_IRQCHIP) && defined(TARGET_I386)
-    struct kvm_irqchip chip;
-    struct kvm_ioapic_state *kioapic;
-    int i;
-
-    chip.chip_id = KVM_IRQCHIP_IOAPIC;
-    kvm_get_irqchip(kvm_state, &chip);
-    kioapic = &chip.chip.ioapic;
-
-    s->id = kioapic->id;
-    s->ioregsel = kioapic->ioregsel;
-    s->irr = kioapic->irr;
-    for (i = 0; i < IOAPIC_NUM_PINS; i++) {
-        s->ioredtbl[i] = kioapic->redirtbl[i].bits;
-    }
-#endif
-}
-
-static void kvm_kernel_ioapic_load_from_user(IOAPICCommonState *s)
-{
-#if defined(KVM_CAP_IRQCHIP) && defined(TARGET_I386)
-    struct kvm_irqchip chip;
-    struct kvm_ioapic_state *kioapic;
-    int i;
-
-    chip.chip_id = KVM_IRQCHIP_IOAPIC;
-    kioapic = &chip.chip.ioapic;
-
-    kioapic->id = s->id;
-    kioapic->ioregsel = s->ioregsel;
-    kioapic->base_address = s->busdev.mmio[0].addr;
-    kioapic->irr = s->irr;
-    for (i = 0; i < IOAPIC_NUM_PINS; i++) {
-        kioapic->redirtbl[i].bits = s->ioredtbl[i];
-    }
-
-    kvm_set_irqchip(kvm_state, &chip);
-#endif
-}
-
-static void kvm_ioapic_pre_save(IOAPICCommonState *s)
-{
-
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_kernel_ioapic_save_to_user(s);
-    }
-}
-
-static void kvm_ioapic_post_load(IOAPICCommonState *s)
-{
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_kernel_ioapic_load_from_user(s);
-    }
-}
-
-static void ioapic_reset(DeviceState *d)
-{
-    IOAPICCommonState *s = DO_UPCAST(IOAPICCommonState, busdev.qdev, d);
-
-    ioapic_reset_common(d);
-#ifdef KVM_CAP_IRQCHIP
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_kernel_ioapic_load_from_user(s);
-    }
-#endif
-}
-
 static const MemoryRegionOps ioapic_io_ops = {
     .read = ioapic_mem_read,
     .write = ioapic_mem_write,
@@ -312,9 +241,7 @@ static void ioapic_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = ioapic_init;
-    k->pre_save = kvm_ioapic_pre_save;
-    k->post_load = kvm_ioapic_post_load;
-    dc->reset = ioapic_reset;
+    dc->reset = ioapic_reset_common;
 }
 
 static TypeInfo ioapic_info = {
hw/pc_piix.c +1 -6
index ef0202a..58bec18 100644
@@ -47,8 +47,6 @@
 #  include <xen/hvm/hvm_info_table.h>
 #endif
 
-qemu_irq *ioapic_irq_hack;
-
 #define MAX_IDE_BUS 2
 
 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
@@ -108,12 +106,9 @@ static void ioapic_init(GSIState *gsi_state)
     SysBusDevice *d;
     unsigned int i;
 
-#ifdef UNUSED_UPSTREAM_KVM
     if (kvm_enabled() && kvm_irqchip_in_kernel()) {
         dev = qdev_create(NULL, "kvm-ioapic");
-    } else
-#endif
-    {
+    } else {
         dev = qdev_create(NULL, "ioapic");
     }
     qdev_init_nofail(dev);
Signature · 1 line
1.7.3.4
author
#6 lore raw

PATCH v2 6/9 qemu-kvm: Use upstream kvm-i8259

In reply to Jan Kiszka

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.

---
 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(-)
Makefile.objs +1 -1
index ee6b15d..2f70b84 100644
@@ -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
Makefile.target +4 -4
index f644762..b0ff38e 100644
@@ -239,7 +239,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
@@ -257,7 +257,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
@@ -312,7 +312,7 @@ 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 += jazz_led.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
@@ -391,7 +391,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
hw/i8259.c +0 -108

145 lines not on this page · raw message

hw/isa-bus.c +1 -1
index fd2bc60..d03f828 100644
@@ -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];
hw/pc_piix.c +1 -4
index 58bec18..2ee115c 100644
@@ -213,12 +213,9 @@ static void pc_init1(MemoryRegion *system_memory,
     }
     isa_bus_irqs(isa_bus, gsi);
 
-#ifdef UNUSED_UPSTREAM_KVM
     if (kvm_enabled() && 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();
Signature · 1 line
1.7.3.4
author
#7 lore raw

PATCH v2 7/9 qemu-kvm: Drop unused kvm_get/set_irqchip

In reply to Jan Kiszka

No users remaining.

---
 qemu-kvm.c |   28 ----------------------------
 qemu-kvm.h |   23 -----------------------
 2 files changed, 0 insertions(+), 51 deletions(-)
qemu-kvm.c +0 -28
index 8f1b760..10a313d 100644
@@ -71,34 +71,6 @@ int kvm_set_irq(int irq, int level, int *status)
     return 1;
 }
 
-int kvm_get_irqchip(KVMState *s, struct kvm_irqchip *chip)
-{
-    int r;
-
-    if (!s->irqchip_in_kernel) {
-        return 0;
-    }
-    r = kvm_vm_ioctl(s, KVM_GET_IRQCHIP, chip);
-    if (r < 0) {
-        perror("kvm_get_irqchip\n");
-    }
-    return r;
-}
-
-int kvm_set_irqchip(KVMState *s, struct kvm_irqchip *chip)
-{
-    int r;
-
-    if (!s->irqchip_in_kernel) {
-        return 0;
-    }
-    r = kvm_vm_ioctl(s, KVM_SET_IRQCHIP, chip);
-    if (r < 0) {
-        perror("kvm_set_irqchip\n");
-    }
-    return r;
-}
-
 #endif
 
 #ifdef KVM_CAP_DEVICE_ASSIGNMENT
qemu-kvm.h +0 -23
index cd5e3cc..433e2fe 100644
@@ -32,29 +32,6 @@
 
 #include "kvm.h"
 
-/*!
- * \brief Dump in kernel IRQCHIP contents
- *
- * Dump one of the in kernel irq chip devices, including PIC (master/slave)
- * and IOAPIC into a kvm_irqchip structure
- *
- * \param kvm Pointer to the current kvm_context
- * \param chip The irq chip device to be dumped
- */
-int kvm_get_irqchip(KVMState *s, struct kvm_irqchip *chip);
-
-/*!
- * \brief Set in kernel IRQCHIP contents
- *
- * Write one of the in kernel irq chip devices, including PIC (master/slave)
- * and IOAPIC
- *
- *
- * \param kvm Pointer to the current kvm_context
- * \param chip THe irq chip device to be written
- */
-int kvm_set_irqchip(KVMState *s, struct kvm_irqchip *chip);
-
 #if defined(__i386__) || defined(__x86_64__)
 /*!
  * \brief Get in kernel local APIC for vcpu
Signature · 1 line
1.7.3.4
author
#8 lore raw

PATCH v2 8/9 qemu-kvm: Use upstream kvm_irqchip_set_irq instead of kvm_set_irq

In reply to Jan Kiszka

Functions are equivalent, let's switch.

---
 hw/msi.c   |    2 +-
 hw/msix.c  |    2 +-
 kvm-stub.c |    2 +-
 kvm.h      |    3 +--
 qemu-kvm.c |   32 --------------------------------
 5 files changed, 4 insertions(+), 37 deletions(-)
hw/msi.c +1 -1
index 3e623c2..7bb3e2f 100644
@@ -350,7 +350,7 @@ void msi_notify(PCIDevice *dev, unsigned int vector)
     }
 
     if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_set_irq(dev->msi_irq_entries[vector].gsi, 1, NULL);
+        kvm_irqchip_set_irq(kvm_state, dev->msi_irq_entries[vector].gsi, 1);
         return;
     }
 
hw/msix.c +1 -1
index 55ddbf4..7955221 100644
@@ -494,7 +494,7 @@ void msix_notify(PCIDevice *dev, unsigned vector)
     }
 
     if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_set_irq(dev->msix_irq_entries[vector].gsi, 1, NULL);
+        kvm_irqchip_set_irq(kvm_state, dev->msix_irq_entries[vector].gsi, 1);
         return;
     }
 
kvm-stub.c +1 -1
index 266dc4a..d22fcad 100644
@@ -162,7 +162,7 @@ int kvm_irqchip_commit_routes(KVMState *s)
     return -ENOSYS;
 }
 
-int kvm_set_irq(int irq, int level, int *status)
+int kvm_irqchip_set_irq(KVMState *s, int irq, int level)
 {
     assert(0);
     return -ENOSYS;
kvm.h +1 -2
index b84aa40..3c3a510 100644
@@ -228,13 +228,12 @@ int kvm_msi_message_del(KVMMsiMessage *msg);
 int kvm_msi_message_update(KVMMsiMessage *old, KVMMsiMessage *new);
 
 #ifndef NEED_CPU_H
+int kvm_irqchip_set_irq(KVMState *s, int irq, int level);
 int kvm_irqchip_commit_routes(KVMState *s);
 #endif
 
 int kvm_irqchip_in_kernel(void);
 
-int kvm_set_irq(int irq, int level, int *status);
-
 #ifdef NEED_CPU_H
 #include "qemu-kvm.h"
 #endif
qemu-kvm.c +0 -32
index 10a313d..09a35f0 100644
@@ -41,38 +41,6 @@ static inline void clear_gsi(KVMState *s, unsigned int gsi)
     }
 }
 
-#ifdef KVM_CAP_IRQCHIP
-
-int kvm_set_irq(int irq, int level, int *status)
-{
-    struct kvm_irq_level event;
-    int r;
-
-    if (!kvm_state->irqchip_in_kernel) {
-        return 0;
-    }
-    event.level = level;
-    event.irq = irq;
-    r = kvm_vm_ioctl(kvm_state, kvm_state->irqchip_inject_ioctl,
-                     &event);
-    if (r < 0) {
-        perror("kvm_set_irq");
-    }
-
-    if (status) {
-#ifdef KVM_CAP_IRQ_INJECT_STATUS
-        *status = (kvm_state->irqchip_inject_ioctl == KVM_IRQ_LINE) ?
-            1 : event.status;
-#else
-        *status = 1;
-#endif
-    }
-
-    return 1;
-}
-
-#endif
-
 #ifdef KVM_CAP_DEVICE_ASSIGNMENT
 int kvm_assign_pci_device(KVMState *s,
                           struct kvm_assigned_pci_dev *assigned_dev)
Signature · 1 line
1.7.3.4
author
#9 lore raw

PATCH v2 9/9 qemu-kvm: Use upstream kvm-apic

In reply to Jan Kiszka

Drop the qemu-kvm version in favor of the equivalent upstream implementation.

---
 hw/apic.c         |  151 +---------------------------------------------------
 hw/pc.c           |    5 +--
 qemu-kvm-x86.c    |   31 -----------
 qemu-kvm.h        |   25 ---------
 target-i386/kvm.c |    8 ---
 5 files changed, 4 insertions(+), 216 deletions(-)
hw/apic.c +3 -148
index b767b87..086c544 100644
@@ -22,7 +22,6 @@
 #include "host-utils.h"
 #include "trace.h"
 #include "pc.h"
-#include "kvm.h"
 
 #define MAX_APIC_WORDS 8
 
@@ -133,35 +132,9 @@ void apic_deliver_pic_intr(DeviceState *d, int level)
     }
 }
 
-static inline uint32_t kapic_reg(struct kvm_lapic_state *kapic, int reg_id);
-
-static void kvm_irqchip_deliver_nmi(void *p)
-{
-    APICCommonState *s = p;
-    struct kvm_lapic_state klapic;
-    uint32_t lvt;
-
-    kvm_get_lapic(s->cpu_env, &klapic);
-    lvt = kapic_reg(&klapic, 0x32 + APIC_LVT_LINT1);
-
-    if (lvt & APIC_LVT_MASKED) {
-        return;
-    }
-
-    if (((lvt >> 8) & 7) != APIC_DM_NMI) {
-        return;
-    }
-
-    kvm_vcpu_ioctl(s->cpu_env, KVM_NMI);
-}
-
 static void apic_external_nmi(APICCommonState *s)
 {
-    if (kvm_irqchip_in_kernel()) {
-        run_on_cpu(s->cpu_env, kvm_irqchip_deliver_nmi, s);
-    } else {
-        apic_local_deliver(s, APIC_LVT_LINT1);
-    }
+    apic_local_deliver(s, APIC_LVT_LINT1);
 }
 
 #define foreach_apic(apic, deliver_bitmask, code) \
@@ -254,11 +227,8 @@ void apic_deliver_irq(uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode,
 
 static void apic_set_base(APICCommonState *s, uint64_t val)
 {
-    if (kvm_enabled() && kvm_irqchip_in_kernel())
-        s->apicbase = val;
-    else
-        s->apicbase = (val & 0xfffff000) |
-            (s->apicbase & (MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE));
+    s->apicbase = (val & 0xfffff000) |
+        (s->apicbase & (MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE));
     /* if disabled, cannot be enabled again */
     if (!(val & MSR_IA32_APICBASE_ENABLE)) {
         s->apicbase &= ~MSR_IA32_APICBASE_ENABLE;
@@ -270,9 +240,6 @@ static void apic_set_base(APICCommonState *s, uint64_t val)
 static void apic_set_tpr(APICCommonState *s, uint8_t val)
 {
     s->tpr = (val & 0x0f) << 4;
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        return;
-    }
     apic_update_irq(s);
 }
 
@@ -770,120 +737,8 @@ static void apic_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
     }
 }
 
-#ifdef KVM_CAP_IRQCHIP
-
-static inline uint32_t kapic_reg(struct kvm_lapic_state *kapic, int reg_id)
-{
-    return *((uint32_t *) (kapic->regs + (reg_id << 4)));
-}
-
-static inline void kapic_set_reg(struct kvm_lapic_state *kapic,
-                                 int reg_id, uint32_t val)
-{
-    *((uint32_t *) (kapic->regs + (reg_id << 4))) = val;
-}
-
-static void kvm_kernel_lapic_save_to_user(APICCommonState *s)
-{
-    struct kvm_lapic_state apic;
-    struct kvm_lapic_state *kapic = &apic;
-    int i, v;
-
-    kvm_get_lapic(s->cpu_env, kapic);
-
-    s->id = kapic_reg(kapic, 0x2) >> 24;
-    s->tpr = kapic_reg(kapic, 0x8);
-    s->arb_id = kapic_reg(kapic, 0x9);
-    s->log_dest = kapic_reg(kapic, 0xd) >> 24;
-    s->dest_mode = kapic_reg(kapic, 0xe) >> 28;
-    s->spurious_vec = kapic_reg(kapic, 0xf);
-    for (i = 0; i < 8; i++) {
-        s->isr[i] = kapic_reg(kapic, 0x10 + i);
-        s->tmr[i] = kapic_reg(kapic, 0x18 + i);
-        s->irr[i] = kapic_reg(kapic, 0x20 + i);
-    }
-    s->esr = kapic_reg(kapic, 0x28);
-    s->icr[0] = kapic_reg(kapic, 0x30);
-    s->icr[1] = kapic_reg(kapic, 0x31);
-    for (i = 0; i < APIC_LVT_NB; i++)
-	s->lvt[i] = kapic_reg(kapic, 0x32 + i);
-    s->initial_count = kapic_reg(kapic, 0x38);
-    s->divide_conf = kapic_reg(kapic, 0x3e);
-
-    v = (s->divide_conf & 3) | ((s->divide_conf >> 1) & 4);
-    s->count_shift = (v + 1) & 7;
-
-    s->initial_count_load_time = qemu_get_clock_ns(vm_clock);
-    apic_next_timer(s, s->initial_count_load_time);
-}
-
-static void kvm_kernel_lapic_load_from_user(APICCommonState *s)
-{
-    struct kvm_lapic_state apic;
-    struct kvm_lapic_state *klapic = &apic;
-    int i;
-
-    memset(klapic, 0, sizeof apic);
-    kapic_set_reg(klapic, 0x2, s->id << 24);
-    kapic_set_reg(klapic, 0x8, s->tpr);
-    kapic_set_reg(klapic, 0xd, s->log_dest << 24);
-    kapic_set_reg(klapic, 0xe, s->dest_mode << 28 | 0x0fffffff);
-    kapic_set_reg(klapic, 0xf, s->spurious_vec);
-    for (i = 0; i < 8; i++) {
-        kapic_set_reg(klapic, 0x10 + i, s->isr[i]);
-        kapic_set_reg(klapic, 0x18 + i, s->tmr[i]);
-        kapic_set_reg(klapic, 0x20 + i, s->irr[i]);
-    }
-    kapic_set_reg(klapic, 0x28, s->esr);
-    kapic_set_reg(klapic, 0x30, s->icr[0]);
-    kapic_set_reg(klapic, 0x31, s->icr[1]);
-    for (i = 0; i < APIC_LVT_NB; i++)
-        kapic_set_reg(klapic, 0x32 + i, s->lvt[i]);
-    kapic_set_reg(klapic, 0x38, s->initial_count);
-    kapic_set_reg(klapic, 0x3e, s->divide_conf);
-
-    kvm_set_lapic(s->cpu_env, klapic);
-}
-
-#endif
-
-void kvm_load_lapic(CPUState *env)
-{
-#ifdef KVM_CAP_IRQCHIP
-    APICCommonState *s =
-        DO_UPCAST(APICCommonState, busdev.qdev, env->apic_state);
-
-    if (!s) {
-        return;
-    }
-
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_kernel_lapic_load_from_user(s);
-    }
-#endif
-}
-
-void kvm_save_lapic(CPUState *env)
-{
-#ifdef KVM_CAP_IRQCHIP
-    APICCommonState *s =
-        DO_UPCAST(APICCommonState, busdev.qdev, env->apic_state);
-
-    if (!s) {
-        return;
-    }
-
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_kernel_lapic_save_to_user(s);
-    }
-#endif
-}
-
 static void apic_post_load(APICCommonState *s)
 {
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        return;
-    }
     if (s->timer_expiry != -1) {
         qemu_mod_timer(s->timer, s->timer_expiry);
     } else {
hw/pc.c +1 -4
index e38a63d..26623f7 100644
@@ -890,12 +890,9 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
     DeviceState *dev;
     static int apic_mapped;
 
-#ifdef UNUSED_UPSTREAM_KVM
     if (kvm_enabled() && kvm_irqchip_in_kernel()) {
         dev = qdev_create(NULL, "kvm-apic");
-    } else
-#endif
-    {
+    } else {
         dev = qdev_create(NULL, "apic");
     }
     qdev_prop_set_uint8(dev, "id", apic_id);
qemu-kvm-x86.c +0 -31
index e5b94b0..2dad5af 100644
@@ -64,37 +64,6 @@ int kvm_enable_vapic(CPUState *env, uint64_t vapic)
     return kvm_vcpu_ioctl(env, KVM_SET_VAPIC_ADDR, &va);
 }
 
-int kvm_get_lapic(CPUState *env, struct kvm_lapic_state *s)
-{
-    int r = 0;
-
-    if (!kvm_irqchip_in_kernel()) {
-        return r;
-    }
-
-    r = kvm_vcpu_ioctl(env, KVM_GET_LAPIC, s);
-    if (r < 0) {
-        fprintf(stderr, "KVM_GET_LAPIC failed\n");
-    }
-    return r;
-}
-
-int kvm_set_lapic(CPUState *env, struct kvm_lapic_state *s)
-{
-    int r = 0;
-
-    if (!kvm_irqchip_in_kernel()) {
-        return 0;
-    }
-
-    r = kvm_vcpu_ioctl(env, KVM_SET_LAPIC, s);
-
-    if (r < 0) {
-        fprintf(stderr, "KVM_SET_LAPIC failed\n");
-    }
-    return r;
-}
-
 int kvm_get_pit(KVMState *s, struct kvm_pit_state *pit_state)
 {
     if (!kvm_irqchip_in_kernel()) {
qemu-kvm.h +0 -25
index 433e2fe..3c4f023 100644
@@ -34,28 +34,6 @@
 
 #if defined(__i386__) || defined(__x86_64__)
 /*!
- * \brief Get in kernel local APIC for vcpu
- *
- * Save the local apic state including the timer of a virtual CPU
- *
- * \param kvm Pointer to the current kvm_context
- * \param vcpu Which virtual CPU should be accessed
- * \param s Local apic state of the specific virtual CPU
- */
-int kvm_get_lapic(CPUState *env, struct kvm_lapic_state *s);
-
-/*!
- * \brief Set in kernel local APIC for vcpu
- *
- * Restore the local apic state including the timer of a virtual CPU
- *
- * \param kvm Pointer to the current kvm_context
- * \param vcpu Which virtual CPU should be accessed
- * \param s Local apic state of the specific virtual CPU
- */
-int kvm_set_lapic(CPUState *env, struct kvm_lapic_state *s);
-
-/*!
  * \brief Get in kernel PIT of the virtual domain
  *
  * Save the PIT state.
@@ -199,9 +177,6 @@ struct kvm_pit_state {
 
 #endif                          /* !CONFIG_KVM */
 
-void kvm_save_lapic(CPUState *env);
-void kvm_load_lapic(CPUState *env);
-
 void kvm_hpet_enable_kpit(void);
 void kvm_hpet_disable_kpit(void);
 
target-i386/kvm.c +0 -8
index 7096752..be45fc0 100644
@@ -1364,7 +1364,6 @@ static int kvm_get_mp_state(CPUState *env)
 
 static int kvm_get_apic(CPUState *env)
 {
-#ifdef UNUSED_UPSTREAM_KVM
     DeviceState *apic = env->apic_state;
     struct kvm_lapic_state kapic;
     int ret;
@@ -1377,15 +1376,11 @@ static int kvm_get_apic(CPUState *env)
 
         kvm_get_apic_state(apic, &kapic);
     }
-#else
-    kvm_save_lapic(env);
-#endif
     return 0;
 }
 
 static int kvm_put_apic(CPUState *env)
 {
-#ifdef UNUSED_UPSTREAM_KVM
     DeviceState *apic = env->apic_state;
     struct kvm_lapic_state kapic;
 
@@ -1394,9 +1389,6 @@ static int kvm_put_apic(CPUState *env)
 
         return kvm_vcpu_ioctl(env, KVM_SET_LAPIC, &kapic);
     }
-#else
-    kvm_load_lapic(env);
-#endif
     return 0;
 }
 
Signature · 1 line
1.7.3.4