Skip to content
Commit 468ef153 authored by Marc Zyngier's avatar Marc Zyngier Committed by Greg Kroah-Hartman
Browse files

KVM: arm64: vgic-v4: Make the doorbell request robust w.r.t preemption



commit b321c31c 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: 8e01d9a3 ("KVM: arm64: vgic-v4: Move the GICv4 residency flow to be driven by vcpu_load/put")
Reported-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
Suggested-by: default avatarZenghui Yu <yuzenghui@huawei.com>
Tested-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
Co-developed-by: default avatarOliver Upton <oliver.upton@linux.dev>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Acked-by: default avatarZenghui Yu <yuzenghui@huawei.com>
Link: https://lore.kernel.org/r/20230713070657.3873244-1-maz@kernel.org


Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
[ modified to wrangle the vCPU flags directly instead of going through
  the flag helper macros as they have not yet been introduced. Also doing
  the flag wranging in the kvm_arch_vcpu_{un}blocking() hooks as the
  introduction of kvm_vcpu_wfi has not yet happened. See:
  6109c5a6 ("KVM: arm64: Move vGIC v4 handling for WFI out arch callback hook") ]
Signed-off-by: default avatarJames Gowans <jgowans@amazon.com>
Acked-by: default avatarMarc Zyngier <maz@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent da38b55c
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment