From: Marc Zyngier <maz@kernel.org>
To: Karl Mehltretter <kmehltretter@gmail.com>
Cc: Oliver Upton <oupton@kernel.org>,
Fuad Tabba <fuad.tabba@linux.dev>,
Joey Gouly <joey.gouly@arm.com>,
Steffen Eiden <seiden@linux.ibm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] KVM: arm64: GICv2: Bound the INTID in vgic_v2_deactivate()
Date: Sat, 25 Jul 2026 18:12:31 +0100 [thread overview]
Message-ID: <87wlujouww.wl-maz@kernel.org> (raw)
In-Reply-To: <20260725154020.37305-1-kmehltretter@gmail.com>
On Sat, 25 Jul 2026 16:40:20 +0100,
Karl Mehltretter <kmehltretter@gmail.com> wrote:
>
> vgic_v2_deactivate() passes the INTID from a trapped GICV_DIR write to
> vgic_get_vcpu_irq() without checking it against the number of
> implemented interrupts. An out-of-range INTID makes the lookup return
> NULL and triggers WARN_ON_ONCE(!irq).
>
> A guest using EOImode=1 can therefore raise a host warning, or panic a
> host with panic_on_warn=1.
>
> The GICv3 counterpart rejects INTIDs outside the configured SGI, PPI and
> SPI range before performing the lookup. Add the same check to the GICv2
> path.
>
> Fixes: 255de897e7fb ("KVM: arm64: GICv2: Handle deactivation via GICV_DIR traps")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
> ---
> arch/arm64/kvm/vgic/vgic-v2.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kvm/vgic/vgic-v2.c b/arch/arm64/kvm/vgic/vgic-v2.c
> index cafa3cb32bda..42430c0fee07 100644
> --- a/arch/arm64/kvm/vgic/vgic-v2.c
> +++ b/arch/arm64/kvm/vgic/vgic-v2.c
> @@ -163,8 +163,12 @@ void vgic_v2_deactivate(struct kvm_vcpu *vcpu, u32 val)
> cpuid = FIELD_GET(GENMASK_ULL(12, 10), val);
> val &= ~GENMASK_ULL(12, 10);
>
> - /* We only deal with DIR when EOIMode==1 */
> - if (!(cpuif->vgic_vmcr & GICH_VMCR_EOI_MODE_MASK))
> + /*
> + * We only deal with DIR when EOIMode==1, and only for SGI,
> + * PPI or SPI.
> + */
> + if (!(cpuif->vgic_vmcr & GICH_VMCR_EOI_MODE_MASK) ||
> + val >= vcpu->kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS)
> return;
This duplicates the existing check, as GICv2 has no LPIs. I'd rather
drop the WARN_ON() altogether.
Thanks,
M.
--
Jazz isn't dead. It just smells funny.
prev parent reply other threads:[~2026-07-25 17:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 15:40 [PATCH] KVM: arm64: GICv2: Bound the INTID in vgic_v2_deactivate() Karl Mehltretter
2026-07-25 17:12 ` Marc Zyngier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wlujouww.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=fuad.tabba@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kmehltretter@gmail.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oupton@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox