Re: [PATCH] KVM: arm64: gic-v5: Reject an ID_BITS too large for a linear IST

From: Fuad Tabba

Date: Thu Nov 26 2026 - 07:40:41 EST


Hi Sascha,

On Thu, 26 Nov 2026 at 12:28, Sascha Bischoff <sascha.bischoff@xxxxxxx> wrote:
[...]
> > Reject an ID_BITS for which a linear IST would be larger than
> > KMALLOC_MAX_SIZE. This applies even for a Linux guest, which
> > configures a much smaller IST. Userspace writes to IRS_IDR2 are new
> > in this cycle, so no release has them.
>
> Thanks for catching and fixing this issue. I agree that we shouldn't
> allow this to happen, and what you have here is a defensive check.
> However, I was surprised that this was reachable in the first place, and
> now see the mistake I'd made.
>
> In general, we limit GICv5-based VMs to 16-bits of ID space in both the
> CPUIF (see vgic_v5_reset()) and in the emulated IRS (see
> kvm_vgic_v5_irs_init()). The userspace write path fails to enforce that
> limit, however, and only checks the hardware capabilities. I see no
> reason to allow a vIRS that supports more ID bits than the CPUIF.
>
> Maybe something along the lines of the following in
> vgic_v5_mmio_uaccess_write_irs()?
>
> /* We limit the CPU interface to 16 ID bits, so match that here. */
> if (FIELD_GET(GICV5_IRS_IDR2_ID_BITS, val) > 16)
> return -EINVAL;
>
> Are you happy to add this (or similar) to your patch, or would you
> prefer me to fix that up separately?

I think that this is the better fix. I'll respin with that.

Thanks!
/fuad