acrn-kernel/arch/arm64/kvm
Marc Zyngier 3d2d051be1 KVM: arm64: vgic-v4: Make the doorbell request robust w.r.t preemption
[ Upstream commit b321c31c9b ]

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: Sasha Levin <sashal@kernel.org>
2023-08-23 17:52:28 +02:00
..
hyp arm64: errata: Mitigate Ampere1 erratum AC03_CPU_38 at stage-2 2023-08-03 10:23:54 +02:00
vgic KVM: arm64: vgic-v4: Make the doorbell request robust w.r.t preemption 2023-08-23 17:52:28 +02:00
.gitignore
Kconfig
Makefile
arch_timer.c
arm.c KVM: arm64: vgic-v4: Make the doorbell request robust w.r.t preemption 2023-08-23 17:52:28 +02:00
debug.c
fpsimd.c
guest.c KVM: arm64: Use config_lock to protect data ordered against KVM_RUN 2023-05-11 23:03:03 +09:00
handle_exit.c
hypercalls.c KVM: arm64: Use config_lock to protect data ordered against KVM_RUN 2023-05-11 23:03:03 +09:00
inject_fault.c
irq.h
mmio.c
mmu.c KVM: arm64: Retry fault if vma_lookup() results become invalid 2023-05-01 08:26:27 +09:00
pkvm.c
pmu-emul.c KVM: arm64: Use config_lock to protect data ordered against KVM_RUN 2023-05-11 23:03:03 +09:00
pmu.c
psci.c KVM: arm64: Avoid vcpu->mutex v. kvm->lock inversion in CPU_ON 2023-05-11 23:03:03 +09:00
pvtime.c
reset.c KVM: arm64: Avoid lock inversion when setting the VM register width 2023-05-11 23:03:03 +09:00
stacktrace.c
sys_regs.c KVM: arm64: PMU: Restore the guest's EL0 event counting after migration 2023-04-20 12:35:07 +02:00
sys_regs.h
trace.h
trace_arm.h
trace_handle_exit.h
trng.c
va_layout.c
vgic-sys-reg-v3.c
vmid.c