All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Carlos López" <clopez@suse.de>
Cc: "Marc Zyngier" <maz@kernel.org>,
	"Oliver Upton" <oupton@kernel.org>,
	kvmarm@lists.linux.dev
Subject: Re: [PATCH v3 2/2] KVM: arm64: vgic: Mitigate potential LPI registration failure
Date: Fri, 03 Jul 2026 11:18:49 +0000	[thread overview]
Message-ID: <20260703111850.20CA41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703110130.2609872-4-clopez@suse.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Fallback XArray node allocation bypasses memcg accounting
--

commit bdc0b53cd314d49c8e7e70017bf5fb300a832c2b
Author: Carlos López <clopez@suse.de>
KVM: arm64: vgic: Mitigate potential LPI registration failure

This commit mitigates a race condition in vgic_add_lpi() where an LPI might
be discarded and re-mapped concurrently. It allows __xa_store() to allocate
a new node under the lock if the previously reserved entry was freed.

> diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c
> index 577286069368d..ace3e59fff971 100644
> --- a/arch/arm64/kvm/vgic/vgic-its.c
> +++ b/arch/arm64/kvm/vgic/vgic-its.c
[ ... ]
> @@ -121,7 +121,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
>  		 * from the deferred release path, pending cleanup by
>  		 * vgic_release_deleted_lpis(). Evict and free it if present.
>  		 */
> -		oldirq = __xa_store(&dist->lpi_xa, intid, irq, 0);
> +		oldirq = __xa_store(&dist->lpi_xa, intid, irq, GFP_NOWAIT);

[Severity: Low]
Does this __xa_store() fallback allocation bypass memcg accounting?

The initial allocation in vgic_add_lpi() via xa_reserve_irq() correctly uses
GFP_KERNEL_ACCOUNT. However, the GFP_NOWAIT flag here does not include
__GFP_ACCOUNT.

If a guest races a DISCARD and MAPTI command such that the LPI is released
after xa_reserve_irq() but before xa_lock_irqsave(), this __xa_store()
will allocate a new node. Should this use GFP_NOWAIT | __GFP_ACCOUNT to
ensure this allocation is still charged to the guest's memory cgroup?

>  		ret = xa_err(oldirq);
>  		if (!ret && oldirq)
>  			kfree_rcu(oldirq, rcu);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260703110130.2609872-2-clopez@suse.de?part=2

      reply	other threads:[~2026-07-03 11:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 11:01 [PATCH v3 0/2] KVM: arm64: vgic: Fix racy LPI release and re-registration handling Carlos López
2026-07-03 11:01 ` [PATCH v3 1/2] KVM: arm64: vgic: Fix race between LPI release and re-registration Carlos López
2026-07-03 11:01 ` [PATCH v3 2/2] KVM: arm64: vgic: Mitigate potential LPI registration failure Carlos López
2026-07-03 11:18   ` sashiko-bot [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=20260703111850.20CA41F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=clopez@suse.de \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.