Re: [PATCH] RISC-V: KVM: Use a raw lock for IMSIC wakeup state
From: Andrew Jones
Date: Fri Oct 09 2026 - 09:50:37 EST
Hi Anup,
On Fri, Oct 09, 2026 at 01:45:20PM +0200, Anup Patel wrote:
> On Fri, Sep 25, 2026 at 5:51 PM Andrew Jones
> <andrew.jones@xxxxxxxxxxxxxxxx> wrote:
> >
> > kvm_riscv_vcpu_aia_imsic_put() can run from the scheduler preemption
> > notifier while the raw runqueue lock is held. Taking vsfile_lock, an
> > rwlock_t, there violates the lockdep wait-context rules.
> >
> > Protect the CPU/HGEI pair with a separate raw spinlock. All updates to
> > that pair retain vsfile_lock and take the new lock, while scheduler-out
> > uses only the new lock around the HGEIE update. This keeps the wakeup
> > setup serialized with VS-file publication and release without bringing
> > wider IMSIC operations into a raw critical section.
>
> Instead of introducing another lock, why not replace
> read_lock_irqsave(&imsic->vsfile_lock, flags) with
> write_lock_irqsave(&imsic->vsfile_lock, flags) in
> kvm_riscv_vcpu_aia_imsic_put() ??
Unfortunately, write_lock_irqsave() has the same PREEMPT_RT issue, since
rwlock_t is sleepable on RT in both modes.
Thanks,
drew