qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Fix ptimer_get_count overflow.


From: Vladimir Prus
Subject: [Qemu-devel] Fix ptimer_get_count overflow.
Date: Thu, 12 Feb 2009 17:33:43 +0300
User-agent: KMail/1.9.10

At present, ptimers have a slight inaccuracy that can lead to
overflow. The period is stored as 64.32 fixed point number.
ptimer_reload uses both integer and fractional part of the perion
when computing when the next event should happen. ptimer_get_count,
however, uses only integer part of the period. Therefore, when
ptimer_get_count is called very soon after ptimer_reload the value
returned may be greater than the value ptimer_reload has set.
And if the counter was 0xFFFFFFFF, this may result in overflow.

This was observed in SH4A emulation as "time jumps", where system
time gets magically increased by 10 minutes sometimes.

This patch fixes this. The math is not the most accurate possible,
but it's relatively fast and fixes the problems.

- Volodya

Attachment: primer_overflow.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]