public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: vgic: Annotate struct vgic_dist with __counted_by_ptr
@ 2026-03-19  1:54 Bill Wendling
  2026-03-20 19:08 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Bill Wendling @ 2026-03-19  1:54 UTC (permalink / raw)
  To: linux-kernel
  Cc: Bill Wendling, Marc Zyngier, Oliver Upton, Joey Gouly,
	Suzuki K Poulose, Zenghui Yu, Gogul Balakrishnan,
	Arman Hasanzadeh, Kees Cook, linux-arm-kernel, kvmarm,
	codemender-patching+linux

Add the __counted_by_ptr attribute to the spis pointer field in struct
vgic_dist. This pointer field points to an array of struct vgic_irq
elements, and the number of elements is tracked by the nr_spis field
within the same structure.

The nr_spis field is initialized in vgic_init() (or earlier via
userspace) before the spis array is allocated in kvm_vgic_dist_init().
The nr_spis value remains constant during the lifetime of the spis
allocation, making it a suitable counter for the array.

This patch was generated by CodeMender and reviewed by Bill Wendling.
Tested with the KVM selftests.

Signed-off-by: Bill Wendling <morbo@google.com>
---
Cc: Marc Zyngier <maz@kernel.org>
Cc: Oliver Upton <oupton@kernel.org>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Zenghui Yu <yuzenghui@huawei.com>
Cc: Gogul Balakrishnan <bgogul@google.com>
Cc: Arman Hasanzadeh <armanihm@google.com>
Cc: Kees Cook <kees@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: kvmarm@lists.linux.dev
Cc: linux-kernel@vger.kernel.org
Cc: codemender-patching+linux@google.com
---
 include/kvm/arm_vgic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index f2eafc65bbf4..1cca87623d92 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -284,7 +284,7 @@ struct vgic_dist {
 	/* Wants SGIs without active state */
 	bool			nassgireq;
 
-	struct vgic_irq		*spis;
+	struct vgic_irq		*spis __counted_by_ptr(nr_spis);
 
 	struct vgic_io_device	dist_iodev;
 	struct vgic_io_device	cpuif_iodev;
-- 
2.53.0.851.ga537e3e6e9-goog


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

end of thread, other threads:[~2026-03-20 19:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19  1:54 [PATCH] KVM: arm64: vgic: Annotate struct vgic_dist with __counted_by_ptr Bill Wendling
2026-03-20 19:08 ` Kees Cook

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