From: Colton Lewis <coltonlewis@google.com>
To: Wei-Lin Chang <weilin.chang@arm.com>
Cc: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>,
Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Fuad Tabba <fuad.tabba@linux.dev>,
Steffen Eiden <seiden@linux.ibm.com>,
kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: arm64: nv: Fix guest stage-2 mapping leak on sub-block unmap
Date: Fri, 20 Nov 2026 23:17:53 +0000 [thread overview]
Message-ID: <20261120231753.1170879-1-coltonlewis@google.com> (raw)
In-Reply-To: <iyfa5sagkdapb4plle575uhbxbmjdcxvbe35nnlxkqzfqnztqd@mmweqvqmil6x>
On Fri, 20 Nov 2026 06:35:12 +0000, Wei-Lin Chang <weilin.chang@arm.com> wrote:
> > result, every sub-block invalidation followed by a re-fault leaks a
>
> Doesn't the block tracking node get leaked regardless of whether a
> re-fault happens?
Yes, the stale entry is left behind on the first TLBI. Re-faulting is
just what lets L1 accumulate additional entries.
> For this third paragraph can you improve it by stating how the problem
> is fixed upfront? The first two paragraphs describe the problem, then
> you started to talk about stage2_unmap_walker all of a sudden (which I'm
> not sure how much it helps), and the fix itself is not emphasised. The
> combination makes it pretty difficult to get what the patch is doing.
Agreed, the commit message was unclear. In v2 I will drop the
kvm_remove_guest_s2_mappings() approach in favor of ignoring TLBI
IPAS2E1 when the guest-supplied TTL is smaller than the mapped granule
(as Marc suggested), and rewrite the commit messages to be shorter and
clearer.
> > In addition, suppress exact-match duplicate insertions in
> > kvm_record_guest_s2_mapping() when concurrent faults or -EAGAIN retries
> > record an identical (nested, canonical) range on the same shadow MMU.
>
> I believe this is better split into its own patch, it's doing another
> thing.
Makes sense. I will split it into a separate patch in v2.
> > Fixes: 5491980c1a41 ("KVM: arm64: nv: Track guest stage-2 mapping removal")
> > Fixes: c2778d14cd2f ("KVM: arm64: nv: Track guest stage-2 mapping creation")
>
> Since there isn't a real bug in the original implementation do we need
> these tags?
Good point. I will drop the Fixes tag on the duplicate-avoidance patch
and point the TTL patch at the commit that added FEAT_TTL handling
instead.
> > + scoped_guard(spinlock, &kvm->arch.guest_s2_tracking_lock) {
> > + if (!guest_s2_mapping_exists(mmu, mapping)) {
> > + interval_tree_insert(&mapping->nested,
> > + &mmu->guest_s2_mappings);
> > + interval_tree_insert(&mapping->canonical,
> > + &kvm->arch.mmu.guest_s2_mappings);
> > + mapping = NULL;
> > + }
> > + }
> > +
> > + kfree(mapping);
>
> In my understanding kfree() can be called while holding locks, so we
> don't need the extra level of indentation.
Yes, kfree() is safe under the spinlock. I will keep guard(spinlock)
and call kfree() directly there.
next prev parent reply other threads:[~2026-11-20 23:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 18:51 Colton Lewis
2026-11-20 6:35 ` Wei-Lin Chang
2026-11-20 23:17 ` Colton Lewis [this message]
2026-11-20 11:13 ` Marc Zyngier
2026-11-20 23:10 ` Colton Lewis
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=20261120231753.1170879-1-coltonlewis@google.com \
--to=coltonlewis@google.com \
--cc=fuad.tabba@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=weilin.chang@arm.com \
--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
all inboxes | Powered by JetHome®