From: Vincent Donnefort <vdonnefort@google.com>
To: Haseeb Ashraf <haseebashraf091@gmail.com>
Cc: maz@kernel.org, Oliver Upton <oupton@kernel.org>,
Haseeb Ashraf <haseeb.ashraf@siemens.com>,
Fuad Tabba <fuad.tabba@linux.dev>,
Wei-Lin Chang <weilin.chang@arm.com>,
Joey Gouly <joey.gouly@arm.com>,
fahad.arslan@siemens.com, Steffen Eiden <seiden@linux.ibm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Quentin Perret <qperret@google.com>,
Raghavendra Rao Ananta <rananta@google.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] KVM: arm64: Resume stage-2 range walks where they stopped
Date: Wed, 2 Dec 2026 16:59:47 +0000 [thread overview]
Message-ID: <axBOg_h8s1tuUeMs@google.com> (raw)
In-Reply-To: <20261118051648.74580-2-haseebashraf091@gmail.com>
On Wed, Nov 18, 2026 at 10:16:48AM +0500, Haseeb Ashraf wrote:
> From: Haseeb Ashraf <haseeb.ashraf@siemens.com>
>
> stage2_apply_range() walks a range one block-sized chunk at a time.
> The walker steps over an invalid entry in one go, but the next walk
> starts at the following chunk, so an invalid entry larger than a chunk
> is visited once for every chunk it covers. Unmapping the whole IPA
> space of a shadow stage-2, as emulating TLBI VMALLS12E1IS and TLBI
> ALLE1IS does, takes 2^18 walks with 4K pages and a 48-bit IPA space,
> however little it maps. Each walk also ends with a range TLBI when
> FEAT_TLBIRANGE and FWB are available.
>
> On an AmpereOne A192-32X (192 CPUs, Xen on KVM, 4K pages, 48-bit IPA),
> a full-range unmap of one shadow stage-2 took 0.84-0.94 s (mean 0.91 s
> over 226 unmaps) on 6.18.29. With v3 of this change and the mainline
> commits it builds on backported, it took 2.1-45 ms (mean 4.1 ms over 672
> unmaps), with 512 to 1023 walks instead of 262144. The slowest TLBI
> VMALLS12E1IS trap took 0.94 s before and 46 ms after.
>
> Have the walk report the address it reached, and have
> stage2_apply_range() resume from there. Unmap, write-protect and flush
> all go through it, so all three get this. kvm_pgtable_stage2_unmap(),
> kvm_pgtable_stage2_wrprotect() and kvm_pgtable_stage2_flush() now
> return the address, or a negative error code, and so do their pKVM
> counterparts, which do not walk page tables and return the end of the
> range. The other callers, in nested.c and at EL2, only looked for an
> error: they now check for a negative value, and those that pass the
> result on turn it back into 0. The walk handles every entry it steps
> over, including invalid entries that carry state, so nothing has to be
> looked up beforehand.
>
> The unmap of a shadow stage-2 also drops the guest stage-2 records of
> the whole span the walk covered: nothing is mapped in the part it
> stepped over, so any record there is stale. Each walk that remains
> ends with the same deferred TLB invalidation as before. The spans that
> were skipped have no valid entry, so there is nothing to invalidate.
>
> Suggested-by: Oliver Upton <oupton@kernel.org>
> Signed-off-by: Haseeb Ashraf <haseeb.ashraf@siemens.com>
Reviewed-by: Vincent Donnefort <vdonnefort@google.com>
> ---
> arch/arm64/include/asm/kvm_pgtable.h | 25 ++++++++----
> arch/arm64/include/asm/kvm_pkvm.h | 6 +--
> arch/arm64/kvm/hyp/nvhe/mem_protect.c | 22 +++++++----
> arch/arm64/kvm/hyp/pgtable.c | 55 +++++++++++++++++----------
> arch/arm64/kvm/mmu.c | 32 ++++++++++------
> arch/arm64/kvm/nested.c | 2 +-
> arch/arm64/kvm/pkvm.c | 14 +++----
> 7 files changed, 97 insertions(+), 59 deletions(-)
>
[...]
prev parent reply other threads:[~2026-12-02 16:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 5:16 [PATCH v4 0/1] KVM: arm64: Resume stage-2 range walks where they stopped Haseeb Ashraf
2026-11-18 5:16 ` [PATCH v4] " Haseeb Ashraf
2026-12-02 16:59 ` Vincent Donnefort [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=axBOg_h8s1tuUeMs@google.com \
--to=vdonnefort@google.com \
--cc=catalin.marinas@arm.com \
--cc=fahad.arslan@siemens.com \
--cc=fuad.tabba@linux.dev \
--cc=haseeb.ashraf@siemens.com \
--cc=haseebashraf091@gmail.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=qperret@google.com \
--cc=rananta@google.com \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=weilin.chang@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 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.