]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: vgic-v4: Plug race between non-residency and v4.1 doorbell
authorMarc Zyngier <maz@kernel.org>
Tue, 23 Jun 2020 09:44:08 +0000 (10:44 +0100)
committerMarc Zyngier <maz@kernel.org>
Tue, 23 Jun 2020 10:24:39 +0000 (11:24 +0100)
commit0408073ebb3f4d1568496efb99bcc28313389080
tree68dcd6b06a1483b31561abdb41630e6a1cdb63c6
parent8dfdb227da048cf7d10b3f7c067da1af3bfdb015
KVM: arm64: vgic-v4: Plug race between non-residency and v4.1 doorbell

When making a vPE non-resident because it has hit a blocking WFI,
the doorbell can fire at any time after the write to the RD.
Crucially, it can fire right between the write to GICR_VPENDBASER
and the write to the pending_last field in the its_vpe structure.

This means that we would overwrite pending_last with stale data,
and potentially not wakeup until some unrelated event (such as
a timer interrupt) puts the vPE back on the CPU.

GICv4 isn't affected by this as we actively mask the doorbell on
entering the guest, while GICv4.1 automatically manages doorbell
delivery without any hypervisor-driven masking.

Use the vpe_lock to synchronize such update, which solves the
problem altogether.

Fixes: b860010fcdc0a ("irqchip/gic-v4.1: Move doorbell management to the GICv4 abstraction layer")
Reported-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/vgic/vgic-v4.c
drivers/irqchip/irq-gic-v3-its.c