mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
04de6cb002
The nrf51_timer has a free-running counter which we implement using the pattern of using two fields (update_counter_ns, counter) to track the last point at which we calculated the counter value, and the counter value at that time. Then we can find the current counter value by converting the difference in wall-clock time between then and now to a tick count that we need to add to the counter value. Unfortunately the nrf51_timer's implementation of this has a bug which means it loses time every time update_counter() is called. After updating s->counter it always sets s->update_counter_ns to 'now', even though the actual point when s->counter hit the new value will be some point in the past (half a tick, say). In the worst case (guest code in a tight loop reading the counter, icount mode) the counter is continually queried less than a tick after it was last read, so s->counter never advances but s->update_counter_ns does, and the guest never makes forward progress. The fix for this is to only advance update_counter_ns to the timestamp of the last tick, not all the way to 'now'. (This is the pattern used in hw/misc/mps2-fpgaio.c's counter.) Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Joel Stanley <joel@jms.id.au> Message-id: 20230606134917.3782215-1-peter.maydell@linaro.org (cherry picked from commit d2f9a79a8cf6ab992e1d0f27ad05b3e582d2b18a) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> |
||
---|---|---|
.. | ||
a9gtimer.c | ||
allwinner-a10-pit.c | ||
altera_timer.c | ||
arm_mptimer.c | ||
arm_timer.c | ||
armv7m_systick.c | ||
aspeed_timer.c | ||
avr_timer16.c | ||
bcm2835_systmr.c | ||
cadence_ttc.c | ||
cmsdk-apb-dualtimer.c | ||
cmsdk-apb-timer.c | ||
digic-timer.c | ||
etraxfs_timer.c | ||
exynos4210_mct.c | ||
exynos4210_pwm.c | ||
grlib_gptimer.c | ||
hpet.c | ||
i8254_common.c | ||
i8254.c | ||
ibex_timer.c | ||
imx_epit.c | ||
imx_gpt.c | ||
Kconfig | ||
meson.build | ||
mips_gictimer.c | ||
mss-timer.c | ||
npcm7xx_timer.c | ||
nrf51_timer.c | ||
omap_gptimer.c | ||
omap_synctimer.c | ||
pxa2xx_timer.c | ||
renesas_cmt.c | ||
renesas_tmr.c | ||
sh_timer.c | ||
sifive_pwm.c | ||
slavio_timer.c | ||
sse-counter.c | ||
sse-timer.c | ||
stellaris-gptm.c | ||
stm32f2xx_timer.c | ||
trace-events | ||
trace.h | ||
xilinx_timer.c |