qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fabien Chouteau <chouteau@adacore.com>
To: Sebastian Huber <sebastian.huber@embedded-brains.de>,
	qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] hw/timer/grlib_gptimer: Avoid integer overflow
Date: Thu, 13 Feb 2014 12:44:56 +0100	[thread overview]
Message-ID: <52FCB038.3090500@adacore.com> (raw)
In-Reply-To: <1392282978-19368-1-git-send-email-sebastian.huber@embedded-brains.de>

On 02/13/2014 10:16 AM, Sebastian Huber wrote:
> The GPTIMER uses 32-bit registers.  Use a 64-bit operation to get the
> ptimer count, otherwise we end up with a count of 0 for GPTIMER counter
> values of 0xffffffff.

Looks good, thanks Sebastian.

Reviewed-by: Fabien Chouteau <chouteau@adacore.com>

> ---
>  hw/timer/grlib_gptimer.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c
> index d5687f6..343563c 100644
> --- a/hw/timer/grlib_gptimer.c
> +++ b/hw/timer/grlib_gptimer.c
> @@ -106,9 +106,9 @@ static void grlib_gptimer_enable(GPTimer *timer)
>      /* ptimer is triggered when the counter reach 0 but GPTimer is triggered at
>         underflow. Set count + 1 to simulate the GPTimer behavior. */
>  
> -    trace_grlib_gptimer_enable(timer->id, timer->counter + 1);
> +    trace_grlib_gptimer_enable(timer->id, timer->counter);
>  
> -    ptimer_set_count(timer->ptimer, timer->counter + 1);
> +    ptimer_set_count(timer->ptimer, (uint64_t)timer->counter + 1);
>      ptimer_run(timer->ptimer, 1);
>  }
>  
> 

  reply	other threads:[~2014-02-13 11:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13  9:16 [Qemu-devel] [PATCH] hw/timer/grlib_gptimer: Avoid integer overflow Sebastian Huber
2014-02-13 11:44 ` Fabien Chouteau [this message]
2014-02-15 12:21 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-02-15 12:38 ` [Qemu-devel] " Peter Maydell

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=52FCB038.3090500@adacore.com \
    --to=chouteau@adacore.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=sebastian.huber@embedded-brains.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).