KVM: hlt emulation should take in-kernel APIC/PIT timers into account
authorMarcelo Tosatti <mtosatti@redhat.com>
Fri, 11 Apr 2008 17:53:26 +0000 (14:53 -0300)
committerAvi Kivity <avi@qumranet.com>
Sun, 27 Apr 2008 09:04:11 +0000 (12:04 +0300)
commit3d80840d96127401ba6aeadd813c3a15b84e70fe
treeb3e083c651f09fee362d88f0d1fc140194f2431d
parent3564990af1b9f77a63692c1079e9c41af229f066
KVM: hlt emulation should take in-kernel APIC/PIT timers into account

Timers that fire between guest hlt and vcpu_block's add_wait_queue() are
ignored, possibly resulting in hangs.

Also make sure that atomic_inc and waitqueue_active tests happen in the
specified order, otherwise the following race is open:

CPU0                                        CPU1
                                            if (waitqueue_active(wq))
add_wait_queue()
if (!atomic_read(pit_timer->pending))
    schedule()
                                            atomic_inc(pit_timer->pending)

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/ia64/kvm/kvm-ia64.c
arch/s390/kvm/interrupt.c
arch/x86/kvm/i8254.c
arch/x86/kvm/irq.c
arch/x86/kvm/irq.h
arch/x86/kvm/lapic.c
include/linux/kvm_host.h
virt/kvm/kvm_main.c