[PATCH RFC] icount: don't adjust virtual time backwards after warp

Nicholas Piggin posted 1 patch 10 months, 4 weeks ago
Failed in applying to current master (apply log)
There is a newer version of this series
softmmu/icount.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH RFC] icount: don't adjust virtual time backwards after warp
Posted by Nicholas Piggin 10 months, 4 weeks ago
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(+)

diff --git a/softmmu/icount.c b/softmmu/icount.c
index 7ae6544909..a6d605dfad 100644
--- a/softmmu/icount.c
+++ b/softmmu/icount.c
@@ -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,
-- 
2.40.1
Re: [PATCH RFC] icount: don't adjust virtual time backwards after warp
Posted by Paolo Bonzini 10 months, 3 weeks ago
Queued, thanks.

Paolo
Re: [PATCH RFC] icount: don't adjust virtual time backwards after warp
Posted by Paolo Bonzini 10 months, 3 weeks ago
On Mon, Jun 26, 2023 at 1:08 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
> Queued, thanks.

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

Thanks,

Paolo
Re: [PATCH RFC] icount: don't adjust virtual time backwards after warp
Posted by Nicholas Piggin 10 months, 3 weeks ago
On Mon Jun 26, 2023 at 9:09 PM AEST, Paolo Bonzini wrote:
> On Mon, Jun 26, 2023 at 1:08 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
> > 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