[PATCH 1/2] KVM: arm64: vgic-v3: Don't truncate the redistributor region index
From: Raffaele Tranfaglia via B4 Relay
Date: Tue Dec 01 2026 - 03:30:27 EST
From: Raffaele Tranfaglia <raffaele.tranfaglia@xxxxxxxxx>
Keep the index of a KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION attribute in a
u32 instead of a u8.
The index field of the attribute is 12 bits wide, and the redistributor
region helpers take a u32 index, but kvm_vgic_addr() stores it in a u8.
Indices from 256 upwards therefore alias indices 0 to 255:
- reading the characteristics of region 256 returns those of region 0
instead of failing with -ENOENT;
- the first region can be registered with index 256, and is then
recorded as region 0, although the first region must use index 0;
- region 256 can never be registered, as its index is checked as 0.
This was found by an AI coding assistant during a review of the
KVM/arm64 ioctl paths.
Fixes: 04c110932225 ("KVM: arm/arm64: Implement KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION")
Signed-off-by: Raffaele Tranfaglia <raffaele.tranfaglia@xxxxxxxxx>
---
arch/arm64/kvm/vgic/vgic-kvm-device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kvm/vgic/vgic-kvm-device.c b/arch/arm64/kvm/vgic/vgic-kvm-device.c
index 1c205cb1361f..8bb9508b7a64 100644
--- a/arch/arm64/kvm/vgic/vgic-kvm-device.c
+++ b/arch/arm64/kvm/vgic/vgic-kvm-device.c
@@ -149,7 +149,7 @@ static int kvm_vgic_addr(struct kvm *kvm, struct kvm_device_attr *attr, bool wri
case KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION:
{
struct vgic_redist_region *rdreg;
- u8 index;
+ u32 index;
r = vgic_check_type(kvm, KVM_DEV_TYPE_ARM_VGIC_V3);
if (r)
--
2.56.0