The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 0/4] irqchip/gic-v4, KVM: arm64: Fix the vgic init error paths
@ 2026-08-24  7:42 Fuad Tabba
  2026-08-24  7:42 ` [PATCH v2 1/4] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them Fuad Tabba
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Fuad Tabba @ 2026-08-24  7:42 UTC (permalink / raw)
  To: Marc Zyngier, Oliver Upton
  Cc: Thomas Gleixner, Eric Auger, Joey Gouly, Steffen Eiden,
	Suzuki K Poulose, Zenghui Yu, Will Deacon, Sascha Bischoff,
	Sebastian Ene, Fuad Tabba, kvmarm, linux-arm-kernel, linux-kernel

Hi folks,

Changes since v1 [1]:
  - New patch 4: restore its_vm.nr_vpes in vgic_v4_teardown() so that
    its_free_vcpu_irqs() frees every vPE. (sashiko, Marc)
  - Patch 2: corrected the commit message. Skipping a vPE with no SGI
    domain avoids a wrong free, not a warning.
  - Patch 3: added a second Fixes: tag. The SPI-array leak arrived with
    the routing call, well before the vPE one.
  - No code changes to patches 1 to 3.

Four fixes on the paths that run when vgic init fails partway. Each one
needs an allocation failure to reach.

Sashiko reported the vgic_init() case [2] while reviewing the SPI-array
leak fix, and the two irq-gic-v4.c fixes came out of chasing the first
[3]. Then, just when I thought I'd squashed every bug Sashiko could
find, it turned up one more in its v1 review: the pre-existing nr_vpes
one, fixed in patch 4 as Marc suggested [4].

Patch 1 clears the irq domain and fwnode pointers at the four GICv4
sites that free them and leave them set. Patch 2 makes
its_alloc_vcpu_irqs() release what it allocated when the SGI loop
fails, which is both the SGI domains and the vPE irqs, wider than the
SGI-domain leak I described before posting v1 [3]. Patch 3 releases the
SPI array and the vPEs on vgic_init()'s later failure paths, so
KVM_DEV_ARM_VGIC_CTRL_INIT is all or nothing and a retry starts from
scratch. Patch 4 is Marc's suggested fix [4] for the nr_vpes overload.

These patches run across two subsystems, but ordering matters, which is
why this is one series. Patch 2 reuses its_free_sgi_irqs() from an
error path, which only works once patch 1 has cleared the pointers.
Patch 3 runs vgic_v4_teardown() on a path it never ran on before, which
adds a route into what patch 1 fixes. Patch 4 is only correct on top of
patch 3, which is what stops online_vcpus outgrowing the vPE array.

Based on kvmarm/next (aa8e5dc6a7a2a).

Cheers,
/fuad

[1] https://lore.kernel.org/all/20260820125053.2951078-1-fuad.tabba@linux.dev/
[2] https://lore.kernel.org/all/20260807105558.73D701F000E9@smtp.kernel.org/
[3] https://lore.kernel.org/all/CA+EHjTyDix+y6NTLTsXP5j9Sn2VLOZcsw94LntQxg_etRBJZuA@mail.gmail.com/
[4] https://lore.kernel.org/all/87ik51np8e.wl-maz@kernel.org/

Fuad Tabba (4):
  irqchip/gic-v4: Clear the domain and fwnode pointers after freeing
    them
  irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure
  KVM: arm64: vgic: Tear down what vgic_init() created when it fails
  KVM: arm64: vgic-v4: Restore nr_vpes before freeing the vPE resources

 arch/arm64/kvm/vgic/vgic-init.c | 11 +++++++++--
 arch/arm64/kvm/vgic/vgic-v4.c   |  3 +++
 drivers/irqchip/irq-gic-v4.c    | 34 +++++++++++++++++++++++++++------
 3 files changed, 40 insertions(+), 8 deletions(-)


base-commit: aa8e5dc6a7a2a1141ab40706a51010adcd0e57d2
-- 
2.39.5


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-08-25  9:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24  7:42 [PATCH v2 0/4] irqchip/gic-v4, KVM: arm64: Fix the vgic init error paths Fuad Tabba
2026-08-24  7:42 ` [PATCH v2 1/4] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them Fuad Tabba
2026-08-25  8:52   ` Yao Yuan
2026-08-24  7:42 ` [PATCH v2 2/4] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure Fuad Tabba
2026-08-25  9:10   ` Yao Yuan
2026-08-24  7:42 ` [PATCH v2 3/4] KVM: arm64: vgic: Tear down what vgic_init() created when it fails Fuad Tabba
2026-08-25  9:18   ` Yao Yuan
2026-08-25  9:47     ` Fuad Tabba
2026-08-24  7:42 ` [PATCH v2 4/4] KVM: arm64: vgic-v4: Restore nr_vpes before freeing the vPE resources Fuad Tabba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox