[PATCH] riscv: vector: preserve state when scheduling at nonzero depth

Karl Mehltretter kmehltretter at gmail.com
Mon Aug 10 23:59:30 PDT 2026


On Tue, Aug 11, 2026 at 01:15:05PM +0100, Andy Chiu wrote:
> 
> Since the problem only appears in the v4 series of the kvm fix,
> triggering this bug on the current upstream may indicate that there are
> some unclosed path that leads to the error. So it would be valuable if
> you could provide the exact reproducer and base for us to investagate.

Hi Andy,

I first saw the warning during a syzkaller run while testing my KCOV
series [1]. The exact test branch is:

  https://github.com/kmehltretter82/linux/tree/kcov-pause-v2

The following branch is based on clean v7.2-rc6. It has the stress source,
syzkaller config/log, and warning report:

  https://github.com/kmehltretter82/linux/tree/riscv-vector-warning-repro

The warning also happens on clean v7.2-rc6, so KCOV is not needed. I don't
know if KCOV changes how often it happens.

The syzkaller job had reproduce=false, so it did not save a minimized
program or C reproducer. It got the warning after about 110k executions
(116236 at the end of that cycle), with QEMU 2 CPUs and procs=4.

On clean v7.2-rc6 (b9b3e33b70b7), the standalone stress test got 18
warnings with -smp 1 -icount shift=7. At normal TCG timing it got none. I
did not see data corruption; all byte tests completed without mismatches.

Your v5 patch 1 looks better for the switch-out change. Please consider my
posted patch withdrawn. I am testing v5 with the same stress and syzkaller
setups now.

I also tried this possible switch-in guard. It got zero warnings in two
stress runs, I am still testing it:

@@ -392,6 +392,7 @@ static inline void __switch_to_vector(struct task_struct *prev,
			next->thread.riscv_v_flags &= ~RISCV_PREEMPT_V_IN_SCHEDULE;
			riscv_v_enable();
		} else {
+			riscv_v_disable();
			riscv_preempt_v_set_restore(next);
		}
	} else {


[1] The KCOV pause series is five patches on v7.2-rc5:
    https://lore.kernel.org/r/20260724192122.73080-1-kmehltretter@gmail.com/

Thanks,
Karl



More information about the linux-riscv mailing list