The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Colton Lewis <coltonlewis@google.com>
Cc: Oliver Upton <oupton@kernel.org>,
	Wei-Lin Chang <weilin.chang@arm.com>,
	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 11:13:09 +0000	[thread overview]
Message-ID: <87cxrz92nu.wl-maz@kernel.org> (raw)
In-Reply-To: <20261119185105.626343-1-coltonlewis@google.com>

On Thu, 19 Nov 2026 18:51:05 +0000,
Colton Lewis <coltonlewis@google.com> wrote:
> 
> When a shadow stage-2 block mapping (for example, 2M at PMD level) is
> partially invalidated by a smaller guest unmap such as a 4K TLBI
> IPAS2E1IS,

What does that mean? If we have a 2MB shadow mapping, then the guest
cannot have something smaller in its own PTs. And how do you get a "4K
TLBI IPAS2E1IS"? TTL == {4kB, L3}? If that's the case, we have every
right to *ignore* this TLBI, because it cannot possibly reflect the
original state of the PTs. If this is an unqualified address (no TTL),
then the whole block *must* go.

There is no such thing as "partial invalidation".

> kvm_pgtable_stage2_unmap() shatters and clears the entire
> block descriptor in mmu->pgt.

Shatters? Or clears the entire block? It cannot be "and" because the
two are polar opposites.

> However, kvm_remove_guest_s2_mappings()
> only removes a struct kvm_guest_s2_mapping node when its entire
> [nested_start, nested.last] span lies within the unmap range.

What do you call "the unmap range"? What we have removed from the
shadow S2? What the guest gives us as part of the TLBI instruction?
Something else?

> As a
> result, every sub-block invalidation followed by a re-fault leaks a
> stale block-sized tracking node in mmu->guest_s2_mappings and
> kvm->arch.mmu.guest_s2_mappings until the shadow MMU is destroyed,

Leaks? A leak is something that is still allocated, but not linked to
an existing data structure, and therefore not recoverable. This looks
to me like exact opposite of a leak...

> allowing an L1 guest to grow host kernel memory and degrade subsequent
> TLBI IPAS2E1IS walks to O(N) under write_lock(&kvm->mmu_lock).

Honestly, this wall of text is not an explanation. That's just a whole
lot of LLM gunk that you have generously copy pasted.

>
> Conversely, unconditionally removing any overlapping tracking node on a
> sub-block unmap would be unsafe when a shadow block mapping has been
> split into a child table (such as on a page-granule fault under dirty
> logging or a racing shared walk returning -EAGAIN), because sibling
> sub-page PTEs outside the unmapped range remain live in mmu->pgt and
> still rely on the block-sized tracking node for host MMU notifier
> unmaps.

-ENOPARSE. Sub-page PTEs sounds like a great idea.

I stopped reading here. Please come back with an actual description of
the problem that you will have produced yourself, or provide the
original LLM report (it cannot be much worse than the above).

	M.

-- 
Jazz isn't dead. It just smells funny.

      parent reply	other threads:[~2026-11-20 11:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 18:51 [PATCH] KVM: arm64: nv: Fix guest stage-2 mapping leak on sub-block unmap Colton Lewis
2026-11-20  6:35 ` Wei-Lin Chang
2026-11-20 11:13 ` 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=87cxrz92nu.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=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=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