qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/timer/grlib_gptimer: Avoid integer overflow
@ 2014-02-13  9:16 Sebastian Huber
  2014-02-13 11:44 ` Fabien Chouteau
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sebastian Huber @ 2014-02-13  9:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Sebastian Huber, Fabien 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.
---
 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);
 }
 
-- 
1.7.7

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

end of thread, other threads:[~2014-02-15 12:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-13  9:16 [Qemu-devel] [PATCH] hw/timer/grlib_gptimer: Avoid integer overflow Sebastian Huber
2014-02-13 11:44 ` Fabien Chouteau
2014-02-15 12:21 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-02-15 12:38 ` [Qemu-devel] " Peter Maydell

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