linux-stable/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 KVM: arm64: Generate hyp_constants.h for the host 2021-12-06 08:37:03 +00:00
arch_timer.c Merge branch kvm-arm64/burn-the-flags into kvmarm-master/next 2022-06-29 10:30:10 +01:00
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 Merge branch kvm-arm64/single-step-async-exception into kvmarm-master/next 2022-09-19 10:59:29 +01:00
fpsimd.c KVM: arm64: Move the handling of !FP outside of the fast path 2022-06-29 10:23:56 +01:00
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 KVM: arm64: Clear PSTATE.SS when the Software Step state was Active-pending 2022-09-19 10:48:53 +01:00
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 KVM: arm64: Move vcpu PC/Exception flags to the input flag set 2022-06-10 09:54:34 +01:00
irq.h
Kconfig KVM: arm64: Move PROTECTED_NVHE_STACKTRACE around 2022-07-27 18:18:03 +01:00
Makefile KVM: arm64: Move nVHE stacktrace unwinding into its own compilation unit 2022-07-27 18:18:03 +01:00
mmio.c KVM: arm64: Generalise VM features into a set of flags 2022-03-18 14:02:33 +00:00
mmu.c KVM: arm64: Retry fault if vma_lookup() results become invalid 2023-05-01 08:26:27 +09:00
pkvm.c KVM: arm64: Move host EL1 code out of hyp/ directory 2021-12-06 08:37:03 +00:00
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 KVM: arm64: Pass pmu events to hyp via vcpu 2022-05-15 11:26:41 +01:00
psci.c KVM: arm64: Avoid vcpu->mutex v. kvm->lock inversion in CPU_ON 2023-05-11 23:03:03 +09:00
pvtime.c KVM: arm64: Use kvm_write_guest_lock when init stolen time 2020-12-03 19:02:18 +00:00
reset.c KVM: arm64: Avoid lock inversion when setting the VM register width 2023-05-11 23:03:03 +09:00
stacktrace.c arm64: stacktrace: track hyp stacks in unwinder's address space 2022-09-09 12:30:08 +01:00
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 KVM: arm64: Add a visibility bit to ignore user writes 2022-09-14 11:36:16 +01:00
trace.h
trace_arm.h KVM: Move arm64's MMU notifier trace events to generic code 2021-04-17 08:30:56 -04:00
trace_handle_exit.h KVM: arm64: Upgrade trace_kvm_arm_set_dreg32() to 64bit 2021-08-20 11:12:18 +01:00
trng.c KVM: arm64: Implement the TRNG hypervisor call 2021-01-25 22:19:31 +00:00
va_layout.c arm64: alternatives: kvm: prepare for cap changes 2022-09-16 17:15:02 +01:00
vgic-sys-reg-v3.c KVM: arm64: vgic-v3: Convert userspace accessors over to FIELD_GET/FIELD_PREP 2022-07-17 11:55:33 +01:00
vmid.c KVM: arm64: Fix inconsistent indenting 2022-06-07 15:27:05 +01:00