mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
hw/timer/grlib_gptimer: Avoid integer overflows
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> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
parent
39d16d29c8
commit
9d5614d582
1 changed files with 2 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue