linux/arch/arm64/kvm/vgic
Marc Zyngier 4368f59a29 KVM: arm64: vgic-v4: Make the doorbell request robust w.r.t preemption
commit b321c31c9b upstream.

Xiang reports that VMs occasionally fail to boot on GICv4.1 systems when
running a preemptible kernel, as it is possible that a vCPU is blocked
without requesting a doorbell interrupt.

The issue is that any preemption that occurs between vgic_v4_put() and
schedule() on the block path will mark the vPE as nonresident and *not*
request a doorbell irq. This occurs because when the vcpu thread is
resumed on its way to block, vcpu_load() will make the vPE resident
again. Once the vcpu actually blocks, we don't request a doorbell
anymore, and the vcpu won't be woken up on interrupt delivery.

Fix it by tracking that we're entering WFI, and key the doorbell
request on that flag. This allows us not to make the vPE resident
when going through a preempt/schedule cycle, meaning we don't lose
any state.

Cc: stable@vger.kernel.org
Fixes: 8e01d9a396 ("KVM: arm64: vgic-v4: Move the GICv4 residency flow to be driven by vcpu_load/put")
Reported-by: Xiang Chen <chenxiang66@hisilicon.com>
Suggested-by: Zenghui Yu <yuzenghui@huawei.com>
Tested-by: Xiang Chen <chenxiang66@hisilicon.com>
Co-developed-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: Zenghui Yu <yuzenghui@huawei.com>
Link: https://lore.kernel.org/r/20230713070657.3873244-1-maz@kernel.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-07-27 08:56:43 +02:00
..
trace.h KVM: arm64: Move virt/kvm/arm to arch/arm64 2020-05-16 15:03:59 +01:00
vgic-debug.c KVM: arm64: Use config_lock to protect vgic state 2023-03-29 14:08:31 +01:00
vgic-init.c KVM: arm64: Restore GICv2-on-GICv3 functionality 2023-06-07 16:38:25 +01:00
vgic-irqfd.c KVM: arm64: vgic: Add memcg accounting to vgic allocations 2021-10-17 11:25:55 +01:00
vgic-its.c KVM: arm64: vgic: Wrap vgic_its_create() with config_lock 2023-05-19 10:20:00 +01:00
vgic-kvm-device.c KVM: arm64: vgic: Fix a circular locking issue 2023-05-19 10:20:00 +01:00
vgic-mmio-v2.c KVM: arm64: Don't read a HW interrupt pending state in user context 2022-06-07 16:28:19 +01:00
vgic-mmio-v3.c KVM: arm64: vgic: Fix a circular locking issue 2023-05-19 10:20:00 +01:00
vgic-mmio.c KVM: arm64: vgic: Fix a circular locking issue 2023-05-19 10:20:00 +01:00
vgic-mmio.h KVM: arm64: vgic-v3: Use u32 to manage the line level from userspace 2022-07-17 11:55:33 +01:00
vgic-v2.c KVM: arm64: vgic: Fix a circular locking issue 2023-05-19 10:20:00 +01:00
vgic-v3.c KVM: arm64: vgic-v4: Make the doorbell request robust w.r.t preemption 2023-07-27 08:56:43 +02:00
vgic-v4.c KVM: arm64: vgic-v4: Make the doorbell request robust w.r.t preemption 2023-07-27 08:56:43 +02:00
vgic.c Merge branch kvm-arm64/timer-vm-offsets into kvmarm-master/next 2023-04-21 09:36:40 +01:00
vgic.h KVM: arm64: Expose {un,}lock_all_vcpus() to the rest of KVM 2023-03-30 19:01:09 +01:00