mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
hvm/hpet: Detect comparator values in the past
This statement only works using 64-bit arithmetic for the main
63
counter never changing by more then 2 . (Which is a boundary
case that should not happen in my life time.)
Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Tim Deegan <tim@xen.org>
This commit is contained in:
1 parent
62d514c2e7
commit
22d73d1fe0
1 file changed
+6
-4
@@ -98,10 +98,12 @@ static uint64_t hpet_get_comparator(HPETState *h, unsigned int tn,
|
||||
uint64_t period = h->hpet.period[tn];
|
||||
if (period)
|
||||
{
|
||||
elapsed = hpet_read_maincounter(h, guest_time) +
|
||||
period - comparator;
|
||||
comparator += (elapsed / period) * period;
|
||||
h->hpet.comparator64[tn] = comparator;
|
||||
elapsed = hpet_read_maincounter(h, guest_time) - comparator;
|
||||
if ( (int64_t)elapsed >= 0 )
|
||||
{
|
||||
comparator += ((elapsed + period) / period) * period;
|
||||
h->hpet.comparator64[tn] = comparator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||