diff --git a/cpus.c b/cpus.c index 8ae477728d65758c4efc290b53107f960b1e630b..cbeb1f6139ea35de86b7684b5a527ae72bf306d4 100644 --- a/cpus.c +++ b/cpus.c @@ -338,10 +338,18 @@ static int64_t qemu_icount_round(int64_t count) static void icount_warp_rt(void) { + unsigned seq; + int64_t warp_start; + /* The icount_warp_timer is rescheduled soon after vm_clock_warp_start * changes from -1 to another value, so the race here is okay. */ - if (atomic_read(&vm_clock_warp_start) == -1) { + do { + seq = seqlock_read_begin(&timers_state.vm_clock_seqlock); + warp_start = vm_clock_warp_start; + } while (seqlock_read_retry(&timers_state.vm_clock_seqlock, seq)); + + if (warp_start == -1) { return; }