Software shouldn't see counter eq to "0" before timer IRQ trigger happened,
as it could be wrong behaviour for some of the emulated platforms. In order
to maintain deterministic behaviour, change returned counter value to "1"
for the expired timer.

Signed-off-by: Dmitry Osipenko <dig...@gmail.com>
---
 hw/core/ptimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
index 30829ee..9dc2bb0 100644
--- a/hw/core/ptimer.c
+++ b/hw/core/ptimer.c
@@ -96,7 +96,7 @@ uint64_t ptimer_get_count(ptimer_state *s)
         if (expired) {
             /* Prevent timer underflowing if it should already have
                triggered.  */
-            counter = 0;
+            counter = 1;
         } else {
             uint64_t rem;
             uint64_t div;
-- 
2.9.2


Reply via email to