qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] hw/timer/grlib_gptimer: Avoid integer overflows
@ 2014-02-16 11:12 Sebastian Huber
  2014-02-26  7:53 ` Sebastian Huber
  2014-03-14 16:13 ` Michael Tokarev
  0 siblings, 2 replies; 6+ messages in thread
From: Sebastian Huber @ 2014-02-16 11:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, chouteau

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.

Use the GPTIMER counter value for tracing to avoid an overflow of the
32-bit value passed to trace_grlib_gptimer_enable().

Reviewed-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 hw/timer/grlib_gptimer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c
index 74c16d6..7672d3a 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);
 }
 
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] hw/timer/grlib_gptimer: Avoid integer overflows
  2014-02-16 11:12 [Qemu-devel] [PATCH v2] hw/timer/grlib_gptimer: Avoid integer overflows Sebastian Huber
@ 2014-02-26  7:53 ` Sebastian Huber
  2014-03-02 13:17   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
  2014-03-14 16:13 ` Michael Tokarev
  1 sibling, 1 reply; 6+ messages in thread
From: Sebastian Huber @ 2014-02-26  7:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial

Ping.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] hw/timer/grlib_gptimer: Avoid integer overflows
  2014-02-26  7:53 ` Sebastian Huber
@ 2014-03-02 13:17   ` Michael Tokarev
  2014-03-02 15:56     ` Sebastian Huber
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Tokarev @ 2014-03-02 13:17 UTC (permalink / raw)
  To: Sebastian Huber; +Cc: qemu-trivial, qemu-devel

26.02.2014 11:53, Sebastian Huber wrote:
> Ping.

There was another comment on this, about the first hunk,
see https://lists.gnu.org/archive/html/qemu-trivial/2014-02/msg00067.html

Note that the comment below this line mentions the +1 which is
being removed.

Thanks,

/mjt

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] hw/timer/grlib_gptimer: Avoid integer overflows
  2014-03-02 13:17   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
@ 2014-03-02 15:56     ` Sebastian Huber
  2014-03-12  9:48       ` Sebastian Huber
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Huber @ 2014-03-02 15:56 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: qemu-trivial, qemu-devel

On 03/02/2014 02:17 PM, Michael Tokarev wrote:
> 26.02.2014 11:53, Sebastian Huber wrote:
>> Ping.
> There was another comment on this, about the first hunk,
> see https://lists.gnu.org/archive/html/qemu-trivial/2014-02/msg00067.html
>
> Note that the comment below this line mentions the +1 which is
> being removed.

I think I addressed this issue with the following sentence in the commit 
message of v2:

"Use the GPTIMER counter value for tracing to avoid an overflow of the 
32-bit value passed to trace_grlib_gptimer_enable()."

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] hw/timer/grlib_gptimer: Avoid integer overflows
  2014-03-02 15:56     ` Sebastian Huber
@ 2014-03-12  9:48       ` Sebastian Huber
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Huber @ 2014-03-12  9:48 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: qemu-trivial, qemu-devel

Hello,

On 2014-03-02 16:56, Sebastian Huber wrote:
> On 03/02/2014 02:17 PM, Michael Tokarev wrote:
>> 26.02.2014 11:53, Sebastian Huber wrote:
>>> Ping.
>> There was another comment on this, about the first hunk,
>> see https://lists.gnu.org/archive/html/qemu-trivial/2014-02/msg00067.html
>>
>> Note that the comment below this line mentions the +1 which is
>> being removed.
>
> I think I addressed this issue with the following sentence in the commit
> message of v2:
>
> "Use the GPTIMER counter value for tracing to avoid an overflow of the 32-bit
> value passed to trace_grlib_gptimer_enable()."
>

should I better split the patch into two parts?

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] hw/timer/grlib_gptimer: Avoid integer overflows
  2014-02-16 11:12 [Qemu-devel] [PATCH v2] hw/timer/grlib_gptimer: Avoid integer overflows Sebastian Huber
  2014-02-26  7:53 ` Sebastian Huber
@ 2014-03-14 16:13 ` Michael Tokarev
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Tokarev @ 2014-03-14 16:13 UTC (permalink / raw)
  To: Sebastian Huber; +Cc: qemu-trivial, qemu-devel

16.02.2014 15:12, 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.
> 
> Use the GPTIMER counter value for tracing to avoid an overflow of the
> 32-bit value passed to trace_grlib_gptimer_enable().

Thanks, applied to the trivial patches queue.

Somehow this was quite a bit difficult for me to understand what's going
on.  Once I did, things are really trivial indeed.

/mjt

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-14 16:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-16 11:12 [Qemu-devel] [PATCH v2] hw/timer/grlib_gptimer: Avoid integer overflows Sebastian Huber
2014-02-26  7:53 ` Sebastian Huber
2014-03-02 13:17   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-03-02 15:56     ` Sebastian Huber
2014-03-12  9:48       ` Sebastian Huber
2014-03-14 16:13 ` Michael Tokarev

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).