Re: [PATCH v4 19/48] KVM: arm64: gic-v5: Add KVM_VGIC_V5_ADDR_TYPE_IRS to UAPI

Sascha Bischoff <[email protected]> Fri, 31 Jul 2026 10:22:40 +0000
Newsgroups dev.linux.lists.sashiko-reviews,dev.linux.lists.kvmarm,org.kernel.vger.kvm
Message-ID <[email protected]>
On Fri, 2026-07-24 at 11:30 +0000, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider:
> - [High] The patch defines a new UAPI constant for configuring the
> GICv5 IRS address but provides no kernel implementation to handle it.
> - [Low] UAPI macro KVM_VGIC_V5_IRS_SIZE uses the kernel-internal
> SZ_64K macro, causing compilation errors in userspace.
> --
> 
> --- Patch [19]: [PATCH v4 19/48] KVM: arm64: gic-v5: Add
> KVM_VGIC_V5_ADDR_TYPE_IRS to UAPI ---
> commit 58ea54e3d864bdb3fe8fc046f0912b0e710377f8
> Author: Sascha Bischoff <[email protected]>
> 
> KVM: arm64: gic-v5: Add KVM_VGIC_V5_ADDR_TYPE_IRS to UAPI
> 
> Define the UAPI address type used by userspace to describe the
> location of the emulated IRS in guest physical address space,
> together
> with the size reserved for that region.
> 
> As per the GICv5 specification, the IRS has one CONFIG_FRAME and
> optionally one SETLPI_FRAME per interrupt domain. Within a KVM VM we
> are only concerned with one interrupt domain. Each of these frames is
> 64kB in size, so reserve 2x64kB of contiguous memory in the GPA space
> for a GICv5 IRS.
> 
> > diff --git a/arch/arm64/include/uapi/asm/kvm.h
> > b/arch/arm64/include/uapi/asm/kvm.h
> > index 1c13bfa2d38aa..d1b2ca317f586 100644
> > --- a/arch/arm64/include/uapi/asm/kvm.h
> > +++ b/arch/arm64/include/uapi/asm/kvm.h
> > @@ -97,6 +97,11 @@ struct kvm_regs {
> >  #define KVM_VGIC_V3_REDIST_SIZE		(2 * SZ_64K)
> >  #define KVM_VGIC_V3_ITS_SIZE		(2 * SZ_64K)
> >  
> > +/* Supported VGICv5 address types  */
> > +#define KVM_VGIC_V5_ADDR_TYPE_IRS	6
> 
> [Severity: High]
> Is this new UAPI attribute handled by the kernel?
> 
> Looking at vgic_v5_set_attr() in arch/arm64/kvm/vgic/vgic-kvm-
> device.c,
> it currently returns -ENXIO for the KVM_DEV_ARM_VGIC_GRP_ADDR group:
> 
> arch/arm64/kvm/vgic/vgic-kvm-device.c:vgic_v5_set_attr() {
>     ...
>     case KVM_DEV_ARM_VGIC_GRP_ADDR:
>     case KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS:
>     case KVM_DEV_ARM_VGIC_GRP_NR_IRQS:
>         return -ENXIO;
>     ...
> }
> 
> Will userspace callers attempting to configure the IRS address via
> this
> constant fail because the KVM_SET_DEVICE_ATTR ioctl path is
> unimplemented?

With just this commit, yes. The actual plumbing for this is added in a
subsequent commit.

> 
> > +
> > +#define KVM_VGIC_V5_IRS_SIZE		(2 * SZ_64K)
> 
> [Severity: Low]
> Does this break userspace compilation?
> 
> The SZ_64K macro is a kernel-internal definition. If a userspace
> application includes <asm/kvm.h> and references KVM_VGIC_V5_IRS_SIZE,
> will it fail to compile due to an undeclared identifier?

This is an existing construct, not something I've gone and added. Yes,
userspace needs to support this, but it has not been an issue so far.
Won't fix.

> 
> [ ... ]
> 

Thanks,
Sascha