The upstream version provides the same feature plus proper support for the PC speaker port while the in-kernel PIT is enabled. Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx> --- A cleanup patch will follow once the _kvm_arch_init_vcpu thing is resolved. Makefile.objs | 3 +- Makefile.target | 2 - configure | 11 ----- hw/hpet.c | 1 - hw/i8254-kvm.c | 114 ----------------------------------------------------- hw/i8254.c | 19 --------- hw/i8254.h | 6 --- hw/i8254_common.c | 2 +- hw/pc.c | 4 +- vl.c | 13 ++++++- 10 files changed, 16 insertions(+), 159 deletions(-) delete mode 100644 hw/i8254-kvm.c diff --git a/Makefile.objs b/Makefile.objs index e1509f1..a166112 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -227,8 +227,7 @@ hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o hw-obj-$(CONFIG_SERIAL) += serial.o hw-obj-$(CONFIG_PARALLEL) += parallel.o -# Moved back to Makefile.target due to #include qemu-kvm.h: -#hw-obj-$(CONFIG_I8254) += i8254_common.o i8254.o +hw-obj-$(CONFIG_I8254) += i8254_common.o i8254.o hw-obj-$(CONFIG_PCSPK) += pcspk.o hw-obj-$(CONFIG_PCKBD) += pckbd.o hw-obj-$(CONFIG_USB_UHCI) += usb/hcd-uhci.o diff --git a/Makefile.target b/Makefile.target index 5c74f88..7ed7535 100644 --- a/Makefile.target +++ b/Makefile.target @@ -253,7 +253,6 @@ obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o obj-i386-y += testdev.o obj-i386-y += acpi.o acpi_piix4.o -obj-i386-y += i8254_common.o i8254.o obj-i386-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o # shared objects @@ -310,7 +309,6 @@ obj-lm32-y += milkymist-vgafb.o obj-lm32-y += framebuffer.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o -obj-mips-y += i8254_common.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 diff --git a/configure b/configure index b1640f0..f69e08fd 100755 --- a/configure +++ b/configure @@ -188,7 +188,6 @@ bsd_user="no" guest_base="" uname_release="" mixemu="no" -kvm_cap_pit="yes" kvm_cap_device_assignment="yes" aix="no" blobs="yes" @@ -710,10 +709,6 @@ for opt do ;; --enable-tcg-interpreter) tcg_interpreter="yes" ;; - --disable-kvm-pit) kvm_cap_pit="no" - ;; - --enable-kvm-pit) kvm_cap_pit="yes" - ;; --disable-kvm-device-assignment) kvm_cap_device_assignment="no" ;; --enable-kvm-device-assignment) kvm_cap_device_assignment="yes" @@ -1078,8 +1073,6 @@ echo " --disable-slirp disable SLIRP userspace network connectivity" echo " --disable-kvm disable KVM acceleration support" echo " --enable-kvm enable KVM acceleration support" echo " --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)" -echo " --disable-kvm-pit disable KVM pit support" -echo " --enable-kvm-pit enable KVM pit support" echo " --disable-kvm-device-assignment disable KVM device assignment support" echo " --enable-kvm-device-assignment enable KVM device assignment support" echo " --disable-nptl disable usermode NPTL support" @@ -2959,7 +2952,6 @@ echo "ATTR/XATTR support $attr" echo "Install blobs $blobs" echo "KVM support $kvm" echo "TCG interpreter $tcg_interpreter" -echo "KVM PIT support $kvm_cap_pit" echo "KVM device assig. $kvm_cap_device_assignment" echo "fdt support $fdt" echo "preadv support $preadv" @@ -3677,9 +3669,6 @@ case "$target_arch2" in if test "$vhost_net" = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak fi - if test $kvm_cap_pit = "yes" ; then - echo "CONFIG_KVM_PIT=y" >> $config_target_mak - fi if test $kvm_cap_device_assignment = "yes" ; then echo "CONFIG_KVM_DEVICE_ASSIGNMENT=y" >> $config_target_mak fi diff --git a/hw/hpet.c b/hw/hpet.c index 51074b7..fd3ddca 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -239,7 +239,6 @@ static int hpet_post_load(void *opaque, int version_id) if (s->timer[0].config & HPET_TN_FSB_CAP) { s->flags |= 1 << HPET_MSI_SUPPORT; } - return 0; } diff --git a/hw/i8254-kvm.c b/hw/i8254-kvm.c deleted file mode 100644 index 9da1c8b..0000000 --- a/hw/i8254-kvm.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * QEMU 8253/8254 interval timer emulation - * - * Copyright (c) 2003-2004 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifdef CONFIG_KVM_PIT - -static void kvm_pit_pre_save(void *opaque) -{ - PITCommonState *s = (void *)opaque; - struct kvm_pit_state2 pit2; - struct kvm_pit_channel_state *c; - struct PITChannelState *sc; - int i; - - if (kvm_has_pit_state2()) { - kvm_get_pit2(kvm_state, &pit2); - s->channels[0].irq_disabled = pit2.flags; - } else { - /* pit2 is superset of pit struct so just cast it and use it */ - kvm_get_pit(kvm_state, (struct kvm_pit_state *)&pit2); - } - for (i = 0; i < 3; i++) { - c = &pit2.channels[i]; - sc = &s->channels[i]; - sc->count = c->count; - sc->latched_count = c->latched_count; - sc->count_latched = c->count_latched; - sc->status_latched = c->status_latched; - sc->status = c->status; - sc->read_state = c->read_state; - sc->write_state = c->write_state; - sc->write_latch = c->write_latch; - sc->rw_mode = c->rw_mode; - sc->mode = c->mode; - sc->bcd = c->bcd; - sc->gate = c->gate; - sc->count_load_time = c->count_load_time; - } -} - -static int kvm_pit_post_load(void *opaque, int version_id) -{ - PITCommonState *s = opaque; - struct kvm_pit_state2 pit2; - struct kvm_pit_channel_state *c; - struct PITChannelState *sc; - int i; - - pit2.flags = s->channels[0].irq_disabled; - for (i = 0; i < 3; i++) { - c = &pit2.channels[i]; - sc = &s->channels[i]; - c->count = sc->count; - c->latched_count = sc->latched_count; - c->count_latched = sc->count_latched; - c->status_latched = sc->status_latched; - c->status = sc->status; - c->read_state = sc->read_state; - c->write_state = sc->write_state; - c->write_latch = sc->write_latch; - c->rw_mode = sc->rw_mode; - c->mode = sc->mode; - c->bcd = sc->bcd; - c->gate = sc->gate; - c->count_load_time = sc->count_load_time; - } - - if (kvm_has_pit_state2()) { - kvm_set_pit2(kvm_state, &pit2); - } else { - kvm_set_pit(kvm_state, (struct kvm_pit_state *)&pit2); - } - return 0; -} - -static void dummy_timer(void *opaque) -{ -} - -static void qemu_kvm_pit_init(PITCommonState *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_common.pre_save = kvm_pit_pre_save; - vmstate_pit_common.post_load = kvm_pit_post_load; - return; -} - -#endif diff --git a/hw/i8254.c b/hw/i8254.c index 9604547..77bd5e8 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -25,7 +25,6 @@ #include "pc.h" #include "isa.h" #include "qemu-timer.h" -#include "kvm.h" #include "i8254.h" #include "i8254_internal.h" @@ -38,10 +37,6 @@ static void pit_irq_timer_update(PITChannelState *s, int64_t current_time); -#ifdef CONFIG_KVM_PIT -static void qemu_kvm_pit_init(PITCommonState *pit); -#endif - static int pit_get_count(PITChannelState *s) { uint64_t d; @@ -266,8 +261,6 @@ static void pit_irq_timer(void *opaque) pit_irq_timer_update(s, s->next_transition_time); } -extern VMStateDescription vmstate_pit_common; - static void pit_reset(DeviceState *dev) { PITCommonState *pit = DO_UPCAST(PITCommonState, dev.qdev, dev); @@ -279,9 +272,6 @@ static void pit_reset(DeviceState *dev) if (!s->irq_disabled) { qemu_mod_timer(s->irq_timer, s->next_transition_time); } - if (vmstate_pit_common.post_load) { - vmstate_pit_common.post_load(pit, 2); - } } /* When HPET is operating in legacy mode, suppress the ignored timer IRQ, @@ -325,13 +315,6 @@ static int pit_initfn(PITCommonState *pit) { PITChannelState *s; -#ifdef CONFIG_KVM_PIT - if (kvm_enabled() && kvm_irqchip_in_kernel()) { - qemu_kvm_pit_init(pit); - return 0; - } -#endif - s = &pit->channels[0]; /* the timer 0 is connected to an IRQ */ s->irq_timer = qemu_new_timer_ns(vm_clock, pit_irq_timer, s); @@ -375,5 +358,3 @@ static void pit_register_types(void) } type_init(pit_register_types) - -#include "i8254-kvm.c" diff --git a/hw/i8254.h b/hw/i8254.h index 933866d..ba6b598 100644 --- a/hw/i8254.h +++ b/hw/i8254.h @@ -27,7 +27,6 @@ #include "hw.h" #include "isa.h" -#include "kvm.h" #define PIT_FREQ 1193182 @@ -46,11 +45,6 @@ static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq, dev = isa_create(bus, "isa-pit"); qdev_prop_set_uint32(&dev->qdev, "iobase", base); qdev_init_nofail(&dev->qdev); - - if (kvm_enabled() && kvm_irqchip_in_kernel()) { - return dev; - } - qdev_connect_gpio_out(&dev->qdev, 0, isa_irq >= 0 ? isa_get_irq(dev, isa_irq) : alt_irq); diff --git a/hw/i8254_common.c b/hw/i8254_common.c index e2e11b5..b01ad70 100644 --- a/hw/i8254_common.c +++ b/hw/i8254_common.c @@ -266,7 +266,7 @@ static int pit_dispatch_post_load(void *opaque, int version_id) return 0; } -VMStateDescription vmstate_pit_common = { +static const VMStateDescription vmstate_pit_common = { .name = "i8254", .version_id = 3, .minimum_version_id = 2, diff --git a/hw/pc.c b/hw/pc.c index feb6ef3..edfeed1 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -907,7 +907,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id) apic_mapped = 1; } -#ifdef UNUSED_UPSTREAM_KVM +#ifdef UPSTREAM_KVM /* KVM does not support MSI yet. */ if (!kvm_irqchip_in_kernel()) { msi_supported = true; @@ -1127,7 +1127,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, } else { pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq); } - if (hpet && !(kvm_enabled() && kvm_irqchip_in_kernel())) { + if (hpet) { /* connect PIT to output control line of the HPET */ qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0)); } diff --git a/vl.c b/vl.c index fccf647..e857b68 100644 --- a/vl.c +++ b/vl.c @@ -2986,7 +2986,18 @@ int main(int argc, char **argv, char **envp) break; } case QEMU_OPTION_no_kvm_pit_reinjection: { - kvm_pit_reinject = 0; + static GlobalProperty kvm_pit_lost_tick_policy[] = { + { + .driver = "kvm-pit", + .property = "lost_tick_policy", + .value = "discard", + }, + { /* end of list */ } + }; + + fprintf(stderr, "Warning: option deprecated, use " + "lost_tick_policy property of kvm-pit instead.\n"); + qdev_prop_register_global_list(kvm_pit_lost_tick_policy); break; } #endif -- 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