From patchwork Tue Mar 2 05:06:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Li X-Patchwork-Id: 46623 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9D913B7D05 for ; Tue, 2 Mar 2010 16:12:33 +1100 (EST) Received: from localhost ([127.0.0.1]:39007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmKLH-00085G-8F for incoming@patchwork.ozlabs.org; Tue, 02 Mar 2010 00:08:23 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NmKK3-000850-S0 for qemu-devel@nongnu.org; Tue, 02 Mar 2010 00:07:07 -0500 Received: from [199.232.76.173] (port=57321 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmKK2-00084m-Oe for qemu-devel@nongnu.org; Tue, 02 Mar 2010 00:07:06 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NmKK1-0002av-Vg for qemu-devel@nongnu.org; Tue, 02 Mar 2010 00:07:06 -0500 Received: from cowpens.ceas.rochester.edu ([128.151.162.25]:57703) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NmKK1-0002aZ-OO for qemu-devel@nongnu.org; Tue, 02 Mar 2010 00:07:05 -0500 Received: from [128.151.137.62] (urwireless-dhcp-128-151-137-62.wireless.rochester.edu [128.151.137.62]) by cowpens.ceas.rochester.edu (8.13.6/8.13.6) with ESMTP id o22574AF017916 for ; Tue, 2 Mar 2010 00:07:04 -0500 (EST) Message-ID: <4B8C9CF3.8000700@rochester.edu> Date: Tue, 02 Mar 2010 00:06:59 -0500 From: Xin Li User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.7) Gecko/20100120 Fedora/3.0.1-1.fc11 Thunderbird/3.0.1 MIME-Version: 1.0 To: qemu-devel@nongnu.org X-detected-operating-system: by monty-python.gnu.org: Solaris 9 Subject: [Qemu-devel] Bug: hpet timer hangs QEMU using icount X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hpet hangs QEMU when icount is present. I don't know if this is a universal problem. The cause is that for periodical timers, hpet_timer function tries to insert the timer back to the active timers queue, using an updated expire time. However, before the update, if the expire time is equal to the current time, this updating will be skipped. As a result, this timer will be inserted as is and goes off again and again, basically traps itself in a infinite loop, preventing any new instructions from being executed. The patch tries to update the timer even when the current time equals the old expire time. Thanks. -Xin --- hw/hpet.c 2010-03-01 23:58:08.815931235 -0500 +++ hw/new_hpet.c 2010-03-01 23:55:07.316704119 -0500 @@ -220,10 +220,10 @@ if (timer_is_periodic(t) && period != 0) { if (t->config & HPET_TN_32BIT) { - while (hpet_time_after(cur_tick, t->cmp)) + while (!hpet_time_after(t->cmp, cur_tick)) t->cmp = (uint32_t)(t->cmp + t->period); } else - while (hpet_time_after64(cur_tick, t->cmp)) + while (!hpet_time_after64(t->cmp, cur_tick)) t->cmp += period; diff = hpet_calculate_diff(t, cur_tick);