]> www.infradead.org Git - users/hch/misc.git/commit
KVM: arm64: vgic: Hoist SGI/PPI alloc from vgic_init() to kvm_create_vgic()
authorMarc Zyngier <maz@kernel.org>
Wed, 12 Feb 2025 18:25:58 +0000 (18:25 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 13 Feb 2025 18:03:54 +0000 (18:03 +0000)
commitb3aa9283c0c505b5cfd25f7d6cfd720de2adc807
tree753ed87f4933a91d92ecf166c8cbd5b4c1be005b
parente6e3e0022ef8f1d584ee4d5b89dca02472c5eb1f
KVM: arm64: vgic: Hoist SGI/PPI alloc from vgic_init() to kvm_create_vgic()

If userspace creates vcpus, then a vgic, we end-up in a situation
where irqchip_in_kernel() will return true, but no private interrupt
has been allocated for these vcpus. This situation will continue
until userspace initialises the vgic, at which point we fix the
early vcpus. Should a vcpu run or be initialised in the interval,
bad things may happen.

An obvious solution is to move this fix-up phase to the point where
the vgic is created. This ensures that from that point onwards,
all vcpus have their private interrupts, as new vcpus will directly
allocate them.

With that, we have the invariant that when irqchip_in_kernel() is
true, all vcpus have their private interrupts.

Reported-by: Alexander Potapenko <glider@google.com>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20250212182558.2865232-3-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/vgic/vgic-init.c