]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: arm64: Reimplement vgic-debug XArray iteration
authorFuad Tabba <tabba@google.com>
Mon, 2 Feb 2026 08:57:20 +0000 (08:57 +0000)
committerMarc Zyngier <maz@kernel.org>
Mon, 2 Feb 2026 10:59:25 +0000 (10:59 +0000)
commit5ab24969705a9adadbc1d3cff4c1c15df174eafb
tree5ec38d9960f079ba7386c4f06985ff91e56401a4
parentdcd79ed450934421158d81600f1be4c2e2af20bf
KVM: arm64: Reimplement vgic-debug XArray iteration

The vgic-debug interface implementation uses XArray marks
(`LPI_XA_MARK_DEBUG_ITER`) to "snapshot" LPIs at the start of iteration.
This modifies global state for a read-only operation and complicates
reference counting, leading to leaks if iteration is aborted or fails.

Reimplement the iterator to use dynamic iteration logic:

- Remove `lpi_idx` from `struct vgic_state_iter`.
- Replace the XArray marking mechanism with dynamic iteration using
  `xa_find_after(..., XA_PRESENT)`.
- Wrap XArray traversals in `rcu_read_lock()`/`rcu_read_unlock()` to
  ensure safety against concurrent modifications (e.g., LPI unmapping).
- Handle potential races where an LPI is removed during iteration by
  gracefully skipping it in `show()`, rather than warning.
- Remove the unused `LPI_XA_MARK_DEBUG_ITER` definition.

This simplifies the lifecycle management of the iterator and prevents
resource leaks associated with the marking mechanism, and paves the way
for using a standard seq_file iterator.

Signed-off-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260202085721.3954942-3-tabba@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/vgic/vgic-debug.c
include/kvm/arm_vgic.h