Skip to contentSkip to conversation

icount: don't adjust virtual time backwards after warp

RFC PATCH Applied Nicholas Piggin 2 participants 4 messages Jun 25, 2023 – Jun 27, 2023

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 icount: don't adjust virtual time backwards after warp

With icount shift=auto, the QEMU_CLOCK_VIRTUAL can be adjusted backwards after a warp, resulting in the machine observing time going backwards. Linux on powerpc can't handle this, and it results in lockup due to a time delta underflowing.

This patch seems to solve it, no more backwards time observed. Is it a reasonable way to address it?

Thanks,
Nick

---
 softmmu/icount.c | 3 +++
 1 file changed, 3 insertions(+)
softmmu/icount.c +3 -0
index 7ae6544909..a6d605dfad 100644
@@ -273,6 +273,9 @@ static void icount_warp_rt(void)
              */
             int64_t cur_icount = icount_get_locked();
             int64_t delta = clock - cur_icount;
+            if (delta < 0) {
+                warp_delta = 0;
+            }
             warp_delta = MIN(warp_delta, delta);
         }
         qatomic_set_i64(&timers_state.qemu_icount_bias,
Signature · 1 line
2.40.1
#2 lore raw
Quoted 1 line · Paolo Bonzini

Queued, thanks.

Hmm, almost, can you provide the Signed-off-by?

Thanks,

Paolo

#3 lore raw
Quoted 4 lines · Paolo Bonzini
Quoted 1 line · Paolo Bonzini

Queued, thanks.

Hmm, almost, can you provide the Signed-off-by?

Sure, give me a bit and I'll make up a better changelog and patch.

Thanks,
Nick