Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Net5f-0006Kw-PQ for qemu-devel@nongnu.org; Tue, 09 Feb 2010 11:37:31 -0500 Received: from [199.232.76.173] (port=50212 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Net5e-0006KV-S8 for qemu-devel@nongnu.org; Tue, 09 Feb 2010 11:37:30 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Net5Q-0007DT-9L for qemu-devel@nongnu.org; Tue, 09 Feb 2010 11:37:29 -0500 Received: from cantor.suse.de ([195.135.220.2]:52946 helo=mx1.suse.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Net5N-0007CK-K0 for qemu-devel@nongnu.org; Tue, 09 Feb 2010 11:37:14 -0500 From: Alexander Graf Date: Tue, 9 Feb 2010 17:37:10 +0100 Message-Id: <1265733430-9656-11-git-send-email-agraf@suse.de> In-Reply-To: <1265733430-9656-1-git-send-email-agraf@suse.de> References: <1265733430-9656-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH 10/10] PPC: Add timer when running KVM List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com, aurelien@aurel32.net, mst@redhat.com For some odd reason we sometimes hang inside KVM forever. I'd guess it's a race condition where we actually have a level triggered interrupt, but the infrastructure can't expose that yet, so the guest ACKs it, goes to sleep and never gets notified that there's still an interrupt pending. As a quick workaround, let's just wake up every 500 ms. That way we can assure that we're always reinjecting interrupts in time. Signed-off-by: Alexander Graf --- target-ppc/kvm.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index f889110..fafa6fb 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -37,6 +37,22 @@ do { } while (0) #endif +/* XXX For some odd reason we sometimes hang inside KVM forever. I'd guess it's + * a race condition where we actually have a level triggered interrupt, but + * the infrastructure can't expose that yet, so the guest ACKs it, goes to + * sleep and never gets notified that there's still an interrupt pending. + * + * As a quick workaround, let's just wake up every 500 ms. That way we can + * assure that we're always reinjecting interrupts in time. + */ +static QEMUTimer *idle_timer; + +static void do_nothing(void *opaque) +{ + qemu_mod_timer(idle_timer, qemu_get_clock(vm_clock) + + (get_ticks_per_sec() / 2)); +} + int kvm_arch_init(KVMState *s, int smp_cpus) { return 0; @@ -173,6 +189,12 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run) int r; unsigned irq; + if (!idle_timer) { + idle_timer = qemu_new_timer(vm_clock, do_nothing, NULL); + qemu_mod_timer(idle_timer, qemu_get_clock(vm_clock) + + (get_ticks_per_sec() / 2)); + } + /* PowerPC Qemu tracks the various core input pins (interrupt, critical * interrupt, reset, etc) in PPC-specific env->irq_input_state. */ if (run->ready_for_interrupt_injection && -- 1.6.0.2