]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: arm64: Use standard seq_file iterator for idregs debugfs
authorFuad Tabba <tabba@google.com>
Mon, 2 Feb 2026 08:57:19 +0000 (08:57 +0000)
committerMarc Zyngier <maz@kernel.org>
Mon, 2 Feb 2026 10:59:25 +0000 (10:59 +0000)
commitdcd79ed450934421158d81600f1be4c2e2af20bf
treed4bf067bea4f8104bafe07e7b3076b10c981037e
parent9ace4753a5202b02191d54e9fdf7f9e3d02b85eb
KVM: arm64: Use standard seq_file iterator for idregs debugfs

The current implementation uses `idreg_debugfs_iter` in `struct
kvm_arch` to track the sequence position. This effectively makes the
iterator shared across all open file descriptors for the VM.

This approach has significant drawbacks:
- It enforces mutual exclusion, preventing concurrent reads of the
  debugfs file (returning -EBUSY).
- It relies on storing transient iterator state in the long-lived VM
  structure (`kvm_arch`).
- The use of `u8` for the iterator index imposes an implicit limit of
  255 registers. While not currently exceeded, this is fragile against
  future architectural growth. Switching to `loff_t` eliminates this
  overflow risk.

Refactor the implementation to use the standard `seq_file` iterator.
Instead of storing state in `kvm_arch`, rely on the `pos` argument
passed to the `start` and `next` callbacks, which tracks the logical
index specific to the file descriptor.

This change enables concurrent access and eliminates the
`idreg_debugfs_iter` field from `struct kvm_arch`.

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