Re: [PATCH 1/2] KVM: arm64: vgic-v3: Don't truncate the redistributor region index

From: Fuad Tabba

Date: Tue Dec 01 2026 - 12:31:30 EST


Hi Raffaele,

On Tue, 1 Dec 2026 at 08:30, Raffaele Tranfaglia via B4 Relay
<devnull+raffaele.tranfaglia.gmail.com@xxxxxxxxxx> wrote:
>
> 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>

Tested on QEMU, running vgic_init in VHE and nVHE.

Reviewed-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>
Tested-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>

Cheers,
/fuad