Index: /trunk/src/VBox/Devices/PC/DevHPET.cpp
===================================================================
--- /trunk/src/VBox/Devices/PC/DevHPET.cpp	(revision 42560)
+++ /trunk/src/VBox/Devices/PC/DevHPET.cpp	(revision 42561)
@@ -266,14 +266,4 @@
 }
 
-DECLINLINE(uint32_t) hpetTimeAfter32(uint64_t a, uint64_t b)
-{
-    return ((int32_t)(b) - (int32_t)(a) <= 0);
-}
-
-DECLINLINE(uint32_t) hpetTimeAfter64(uint64_t a, uint64_t b)
-{
-    return ((int64_t)(b) - (int64_t)(a) <= 0);
-}
-
 DECLINLINE(uint64_t) hpetTicksToNs(HpetState *pThis, uint64_t value)
 {
@@ -347,20 +337,12 @@
 static void hpetAdjustComparator(HpetTimer *pHpetTimer, uint64_t u64Now)
 {
-  uint64_t u64Period = pHpetTimer->u64Period;
-  if (   (pHpetTimer->u64Config & HPET_TN_PERIODIC)
-      && u64Period != 0)
-  {
-      /* While loop is suboptimal */
-      if (hpet32bitTimer(pHpetTimer))
-      {
-          while (hpetTimeAfter32(u64Now, pHpetTimer->u64Cmp))
-              pHpetTimer->u64Cmp = (uint32_t)(pHpetTimer->u64Cmp + u64Period);
-      }
-      else
-      {
-          while (hpetTimeAfter64(u64Now, pHpetTimer->u64Cmp))
-              pHpetTimer->u64Cmp += u64Period;
-      }
-  }
+    uint64_t    u64Period = pHpetTimer->u64Period;
+
+    if ((pHpetTimer->u64Config & HPET_TN_PERIODIC) && u64Period)
+    {
+          uint64_t  cPeriods = (u64Now - pHpetTimer->u64Cmp) / u64Period;
+
+          pHpetTimer->u64Cmp += (cPeriods + 1) * u64Period;
+    }
 }
 
@@ -571,8 +553,5 @@
 
             if (pHpetTimer->u64Config & HPET_TN_PERIODIC)
-            {
-                u32NewValue &= hpetInvalidValue(pHpetTimer) >> 1; /** @todo check this in the docs and add a not why? */
                 pHpetTimer->u64Period = RT_MAKE_U64(u32NewValue, RT_HI_U32(pHpetTimer->u64Period));
-            }
             pHpetTimer->u64Cmp     = RT_MAKE_U64(u32NewValue, RT_HI_U32(pHpetTimer->u64Cmp));
             pHpetTimer->u64Config &= ~HPET_TN_SETVAL;
