Re: [PATCH] irqchip/riscv-imsic: Fix vector lifetime during IRQ migration
From: Anup Patel
Date: Thu Dec 03 2026 - 00:58:19 EST
On Wed, Dec 2, 2026 at 5:19 PM Zhanpeng Zhang
<zhangzhanpeng.jasper@xxxxxxxxxxxxx> wrote:
>
> When fio runs in a guest with oversubscribed vCPUs and a VFIO
> passthrough device, the host can panic on a NULL pointer dereference in
> irq_can_move_in_process_context() due to a race between IRQ-domain
> teardown and IMSIC vector move completion.
>
> Teardown can free the IRQ descriptor and release the destination vector
> while the old CPU still has a move to complete. The old CPU can then
> look up an IRQ number with no descriptor or forward a pending MSI to a
> vector that another IRQ has already taken over.
>
> Save the temporary MSI ID when setting affinity so move completion can
> use it without looking up irq_data. During teardown, validate and
> cancel the move under the old CPU's lock. Clear the retiring vectors'
> enable and pending bits before returning their IDs to the matrix.
> Clear the temporary pending bit if no other IRQ or move uses that ID.
>
> Wait for the online vector owners before returning from the IRQ-domain
> free callback. This also lets any chained handler that has read the old
> IRQ number finish dispatching it before the IRQ core can reuse the
> number. Offline CPUs finish cleanup when they come online.
>
> During CPU offlining, complete the move on the outgoing CPU before
> clearing the reverse link so pending MSIs can reach the active vector.
Clearly based on the above commit description, multiple changes
are being done in a single patch without clear explanation about
exactly why each change is required.
The commit description also does not explain the failure scenario
in detail.
Break down this patch into small incremental patches without
breaking git bisectability where commit description of each
patch clearly explaining why the is change required. The
cover-letter should clearly explain the failure scenario that
you are trying to address.
Regards,
Anup