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:
Don Slutz authored and Tim Deegan committed 2014-05-08 12:03:53 +01:00
1 parent 62d514c2e7
commit 22d73d1fe0
1 file changed
+6 -4
+6 -4
View File
@@ -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;
}
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.