From patchwork Mon Sep 3 15:34:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 181373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5A3422C0093 for ; Tue, 4 Sep 2012 01:34:58 +1000 (EST) Received: from localhost ([::1]:37879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8Yfw-0006zN-48 for incoming@patchwork.ozlabs.org; Mon, 03 Sep 2012 11:34:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8Yfk-0006wV-En for qemu-devel@nongnu.org; Mon, 03 Sep 2012 11:34:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8Yfj-0003rd-3i for qemu-devel@nongnu.org; Mon, 03 Sep 2012 11:34:44 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:40760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8Yfi-0003rR-Sp for qemu-devel@nongnu.org; Mon, 03 Sep 2012 11:34:43 -0400 Received: by dadn15 with SMTP id n15so3611306dad.4 for ; Mon, 03 Sep 2012 08:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=2g9ObzstDAk8ODrZxthsKTrapZONy1R4rR83FP9j5NE=; b=iFqyH7vEGUWgMJJUiCW7rbe5qWdJ2PP2fUbdtX867qIB74hdH5YLoy0NiC1HQsGejA Bizc9kkHuoXpcVHFS7X9CQYjoxfRU6bUEmtOWxIGQjpeYJGuwutC/8sJH0OWP17qRnBw GuUzF5oC/l7sUSZDQQW+VnUem63Dyo10u/u6Uph8YrZRc8OMzJY9WcPCQESx3eAy+DMn iiHWdKgHbtSSm2Gg5t8w3tpHGvNQfOtH86HNy7Ll1vxs9ejZO30OYcVUwxV6EoCafAzw BZrOvTFwLRqHMPpbENHCs4/OCCVtKAXRTiu2hd4cBsy3/mS5T3J9cCkXgaZg4fcA+nwL BsbA== Received: by 10.68.221.225 with SMTP id qh1mr39308594pbc.50.1346686481740; Mon, 03 Sep 2012 08:34:41 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id vd4sm10129341pbc.41.2012.09.03.08.34.37 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Sep 2012 08:34:40 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 3 Sep 2012 17:34:32 +0200 Message-Id: <1346686472-23999-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.11.2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Cc: aliguori@us.ibm.com, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH for 1.2] qemu-timer: properly arm alarm timer for timers set by device initialization X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org QEMU will hang when fed the following command-line qemu-system-mips -kernel vmlinux-2.6.32-5-4kc-malta -append "console=ttyS0" -nographic -net none The -net none is important otherwise it seems some events are generated causing the things to work. When it doesn't work, the guest hangs when measuring the CPU frequency, after the following line: [ 0.000000] NR_IRQS:256 Pressing a key on the serial port unblocks it, hinting that the problem is due to the recent elimination of the 1 second timeout in the main loop. The problem is that because init_timer_alarm sets the timer's pending flag to true, the alarm timer is never armed until after the first time through the main loop. Thus the bug started when QEMU started testing the pending flag in qemu_mod_timer (commit 1828be3, more alarm timer cleanup, 2010-03-10). But actually, it isn't true at all that a timer is pending when the alarm timer is created, and the real bug has been latent forever: the fix is to remove the bogus setting of pending flag. Reported-by: Aurelien Jarno Signed-off-by: Paolo Bonzini Reviewed-by: Jan Kiszka Tested-by: Aurelien Jarno Tested-By: Michael Tokarev --- qemu-timer.c | 3 --- 1 file modificato, 3 rimozioni(-) diff --git a/qemu-timer.c b/qemu-timer.c index 5aea94e..c7a1551 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -759,11 +759,8 @@ int init_timer_alarm(void) goto fail; } - /* first event is at time 0 */ atexit(quit_timers); - t->pending = true; alarm_timer = t; - return 0; fail: