[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJHc60xPKgVn96azWhP1NbfKioEZj68APQPf=zKRMuHB7-goqA@mail.gmail.com>
Date: Tue, 29 Jul 2025 09:56:12 -0700
From: Raghavendra Rao Ananta <rananta@...gle.com>
To: Oliver Upton <oliver.upton@...ux.dev>
Cc: Marc Zyngier <maz@...nel.org>, linux-arm-kernel@...ts.infradead.org,
kvmarm@...ts.linux.dev, linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Subject: Re: [PATCH] KVM: arm64: Set/unset vGIC v4 forwarding if direct IRQs
are supported
On Tue, Jul 29, 2025 at 7:37 AM Oliver Upton <oliver.upton@...ux.dev> wrote:
>
> Hi Raghu,
>
> Thanks for reporting this so quickly :)
>
> On Mon, Jul 28, 2025 at 10:37:10PM +0000, Raghavendra Rao Ananta wrote:
> > diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c
> > index e7e284d47a77..873a190bcff7 100644
> > --- a/arch/arm64/kvm/vgic/vgic-v4.c
> > +++ b/arch/arm64/kvm/vgic/vgic-v4.c
> > @@ -433,7 +433,7 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
> > unsigned long flags;
> > int ret = 0;
> >
> > - if (!vgic_supports_direct_msis(kvm))
> > + if (!vgic_supports_direct_irqs(kvm))
> > return 0;
> >
> > /*
> > @@ -533,7 +533,7 @@ int kvm_vgic_v4_unset_forwarding(struct kvm *kvm, int host_irq)
> > unsigned long flags;
> > int ret = 0;
> >
> > - if (!vgic_supports_direct_msis(kvm))
> > + if (!vgic_supports_direct_irqs(kvm))
> > return 0;
>
> I'm not sure this is what we want, since a precondition of actually
> doing vLPI injection is the guest having an ITS. Could you try the
> following?
>
> Thanks,
> Oliver
>
> diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> index a3ef185209e9..70d50c77e5dc 100644
> --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> @@ -50,6 +50,14 @@ bool vgic_has_its(struct kvm *kvm)
>
> bool vgic_supports_direct_msis(struct kvm *kvm)
> {
> + /*
> + * Deliberately conflate vLPI and vSGI support on GICv4.1 hardware,
> + * indirectly allowing userspace to control whether or not vPEs are
> + * allocated for the VM.
> + */
> + if (system_supports_direct_sgis() && !vgic_supports_direct_sgis(kvm))
> + return false;
> +
> return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm);
> }
>
> diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h
> index 1384a04c0784..de1c1d3261c3 100644
> --- a/arch/arm64/kvm/vgic/vgic.h
> +++ b/arch/arm64/kvm/vgic/vgic.h
> @@ -396,15 +396,7 @@ bool vgic_supports_direct_sgis(struct kvm *kvm);
>
> static inline bool vgic_supports_direct_irqs(struct kvm *kvm)
> {
> - /*
> - * Deliberately conflate vLPI and vSGI support on GICv4.1 hardware,
> - * indirectly allowing userspace to control whether or not vPEs are
> - * allocated for the VM.
> - */
> - if (system_supports_direct_sgis())
> - return vgic_supports_direct_sgis(kvm);
> -
> - return vgic_supports_direct_msis(kvm);
> + return vgic_supports_direct_msis(kvm) || vgic_supports_direct_sgis(kvm);
> }
>
> int vgic_v4_init(struct kvm *kvm);
Yes, the diff seems fine (tested as well). Would you be pushing a v2
or do you want me to (on your behalf)?
Thank you.
Raghavendra
Powered by blists - more mailing lists