On Wed, 2 Jul 2025 at 17:31, Eric Auger <eric.au...@redhat.com> wrote:
>
> From: Haibo Xu <haibo...@linaro.org>
>
> Allow virt arm machine to set the interrupt ID for the KVM
> GIC maintenance interrupt.
>
> This setting must be done before the KVM_DEV_ARM_VGIC_CTRL_INIT
> hence the choice to perform the setting in the GICv3 realize
> instead of proceeding the same way as kvm_arm_pmu_set_irq().
>
> Signed-off-by: Haibo Xu <haibo...@linaro.org>
> Signed-off-by: Miguel Luis <miguel.l...@oracle.com>
> Signed-off-by: Eric Auger <eric.au...@redhat.com>

> @@ -231,6 +231,7 @@ struct GICv3State {
>      uint32_t num_cpu;
>      uint32_t num_irq;
>      uint32_t revision;
> +    uint32_t maint_irq;
>      bool lpi_enable;
>      bool nmi_support;
>      bool security_extn;

> +    if (s->maint_irq) {
> +        int ret;
> +
> +        ret = kvm_device_check_attr(s->dev_fd,
> +                                    KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ, 0);
> +        if (!ret) {
> +            error_setg_errno(errp, errno,
> +                             "VGICv3 setting maintenance IRQ is not "
> +                             "supported by this host kernel");
> +            return;
> +        }
> +
> +        ret = kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ, 0,
> +                                &s->maint_irq, true, errp);

This doesn't seem to line up with what the kernel documents
for KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ:

https://www.kernel.org/doc/Documentation/virt/kvm/devices/arm-vgic-v3.rst
says

# KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ
# Attributes:
#
#    The attr field of kvm_device_attr encodes the following values:
#
#      bits:     | 31   ....    5 | 4  ....  0 |
#      values:   |      RES0      |   vINTID   |
#
#    The vINTID specifies which interrupt is generated when the vGIC
#    must generate a maintenance interrupt. This must be a PPI.

but this code sets kvmattr.addr to 0 and kvmaddr.addr to
the address of a uint32_t with the vINTID in it.

Looking at the kernel code in vgic_v3_attr_regs_access() it
looks like maybe the kernel docs are wrong, but I'm not sure.

thanks
-- PMM

Reply via email to