All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Max Filippov <jcmvbkbc@gmail.com>
Cc: Blue Swirl <blauwirbel@gmail.com>,
	qemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH] hpet: fix infinite loop in qemu_run_timers with -icount enabled
Date: Wed, 09 Nov 2011 13:44:38 -0600	[thread overview]
Message-ID: <4EBAD826.1060400@codemonkey.ws> (raw)
In-Reply-To: <1320801489-18193-1-git-send-email-jcmvbkbc@gmail.com>

On 11/08/2011 07:18 PM, Max Filippov wrote:
> hpet_timer timer callback rearms itself based on difference between
> current HPET tick counter and comparator value. Difference calculated by
> the hpet_calculate_diff function is limited to non-negative values.
>
> cur_tick is calculated via hpet_get_ticks that uses qemu_get_clock_ns(vm_clock).
>
> With -icount enabled vm_clock doesn't advance during qemu_run_timers
> loop thus once difference is zero, qemu_run_timers loops forever
> handling hpet_timer.
>
> Limit hpet_calculate_diff results to positive only values to avoid that
> infinite loop.
>
> This fixes the following qemu-system-x86_64 hang when it reaches
> timer_irq_works() in the linux bootup:
>
> [    0.000000] Fast TSC calibration using PIT
> [    0.000000] Detected 1000.054 MHz processor.
> [    0.000031] Calibrating delay loop (skipped), value calculated using timer frequency.. 2000.10 BogoMIPS (lpj=10000540)
> [    0.000404] pid_max: default: 32768 minimum: 301
> [    0.001138] Mount-cache hash table entries: 256
> [    0.003883] Initializing cgroup subsys ns
> [    0.004035] Initializing cgroup subsys cpuacct
> [    0.004280] Initializing cgroup subsys freezer
> [    0.004790] Performance Events: AMD PMU driver.
> [    0.004985] ... version:                0
> [    0.005134] ... bit width:              48
> [    0.005285] ... generic registers:      4
> [    0.005437] ... value mask:             0000ffffffffffff
> [    0.005625] ... max period:             00007fffffffffff
> [    0.005807] ... fixed-purpose events:   0
> [    0.005957] ... event mask:             000000000000000f
> [    0.006275] SMP alternatives: switching to UP code
>
> Signed-off-by: Max Filippov<jcmvbkbc@gmail.com>

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   hw/hpet.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/hpet.c b/hw/hpet.c
> index 12bd64d..6e6ea52 100644
> --- a/hw/hpet.c
> +++ b/hw/hpet.c
> @@ -157,14 +157,14 @@ static inline uint64_t hpet_calculate_diff(HPETTimer *t, uint64_t current)
>
>           cmp = (uint32_t)t->cmp;
>           diff = cmp - (uint32_t)current;
> -        diff = (int32_t)diff>  0 ? diff : (uint32_t)0;
> +        diff = (int32_t)diff>  0 ? diff : (uint32_t)1;
>           return (uint64_t)diff;
>       } else {
>           uint64_t diff, cmp;
>
>           cmp = t->cmp;
>           diff = cmp - current;
> -        diff = (int64_t)diff>  0 ? diff : (uint64_t)0;
> +        diff = (int64_t)diff>  0 ? diff : (uint64_t)1;
>           return diff;
>       }
>   }

      reply	other threads:[~2011-11-09 19:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-09  1:18 [Qemu-devel] [PATCH] hpet: fix infinite loop in qemu_run_timers with -icount enabled Max Filippov
2011-11-09 19:44 ` Anthony Liguori [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EBAD826.1060400@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=agraf@suse.de \
    --cc=blauwirbel@gmail.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.