[PATCH v3 36/36] KVM: arm64: gic-v5: Communicate userspace-driveable PPIs via a UAPI
Jonathan Cameron
jonathan.cameron at huawei.com
Mon Jan 12 08:42:19 PST 2026
On Fri, 9 Jan 2026 17:04:50 +0000
Sascha Bischoff <Sascha.Bischoff at arm.com> wrote:
> GICv5 systems will likely not support the full set of PPIs. The
> presence of any virtual PPI is tied to the presence of the physical
> PPI. Therefore, the available PPIs will be limited by the physical
> host. Userspace cannot drive any PPIs that are not implemented.
>
> Moreover, it is not desirable to expose all PPIs to the guest in the
> first place, even if they are supported in hardware. Some devices,
> such as the arch timer, are implemented in KVM, and hence those PPIs
> shouldn't be driven by userspace, either.
>
> Provided a new UAPI:
> KVM_DEV_ARM_VGIC_GRP_CTRL => KVM_DEV_ARM_VGIC_USERPSPACE_PPIs
>
> This allows userspace to query which PPIs it is able to drive via
> KVM_IRQ_LINE.
>
> Additionally, introduce a check in kvm_vm_ioctl_irq_line() to reject
> any PPIs not in the userspace mask.
>
> Signed-off-by: Sascha Bischoff <sascha.bischoff at arm.com>
>
> FOLD: Limit KVM_IRQ_LINE PPIs
Looks like you did a squash rather than a fixup merge and failed to drop this.
Otherwise, just one trivial thing below.
Thanks,
Jonathan
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index 1cfd1e53b060e..e15c97395f50f 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -1437,6 +1437,14 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,
> if (irq_num >= VGIC_V5_NR_PRIVATE_IRQS)
> return -EINVAL;
>
> + /*
> + * Only allow PPIs that are explicitly exposed to
> + * usespace to be driven via KVM_IRQ_LINE
> + */
> + u64 mask = kvm->arch.vgic.gicv5_vm.userspace_ppis[irq_num / 64];
Inline declarations are still normally limited to when we need to have
them, e.g for cleanup.h stuff. So declare mask at top of appropriate
scope.
> + if (!(mask & BIT_ULL(irq_num % 64)))
> + return -EINVAL;
> +
> /* Build a GICv5-style IntID here */
> irq_num |= FIELD_PREP(GICV5_HWIRQ_TYPE, GICV5_HWIRQ_TYPE_PPI);
> } else if (irq_num < VGIC_NR_SGIS ||
More information about the linux-arm-kernel
mailing list