Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Itaru Kitayama <itaru.kitayama@fujitsu.com>
To: Wei-Lin Chang <weilin.chang@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linux-kernel@vger.kernel.org, Marc Zyngier <maz@kernel.org>,
	Oliver Upton <oupton@kernel.org>, Fuad Tabba <tabba@google.com>,
	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>,
	Sebastian Ene <sebastianene@google.com>
Subject: Re: [PATCH v4 0/6] KVM: arm64: nv: Implement nested stage-2 reverse map
Date: Tue, 28 Jul 2026 07:24:39 +0900	[thread overview]
Message-ID: <amfap0e5dhQgo4eW@sm-arm-grace07> (raw)
In-Reply-To: <20260714115926.2044757-1-weilin.chang@arm.com>

On Tue, Jul 14, 2026 at 12:59:19PM +0100, Wei-Lin Chang wrote:
> Hi,
> 
> This is v4 of optimizing the shadow s2 mmu unmapping during MMU
> notifiers. The general theme stays the same, but various
> improvements/fixes are added. Thanks for all the feedback. Please see
> below for the changes.
> 
> * Changes from v3 [1]:
> 
>   - Rebased on to the latest kvmarm/fixes.
> 
>   - Removed commit "KVM: arm64: Move shadow_pt_debugfs_dentry to reduce
>     holes in kvm_s2_mmu" because the current shadow ptdump code is found
>     to be buggy and the proposed fix removes shadow_pt_debugfs_dentry [2].
> 
>   - Rename some variables to improve readability e.g. ipa ->
>     canonical_ipa, fault_ipa -> nested_ipa.
> 
>   - Skip reverse map optimization when !mmu->nested_stage2_enabled,
>     and just unmap the canonical IPA range during MMU notifiers.
> 
>   - Change comment above the code that checks whether an identical
>     reverse map already exists in kvm_record_nested_revmap() from saying
>     it could be a permission update to saying another parallel stage-2
>     fault could have inserted an identical reverse map. This is because
>     permission update won't trigger kvm_record_nested_revmap().
> 
>   - Add helpers for checking maple tree entry flags VALID_ENTRY and
>     UNKNOWN_IPA, also warn if both are set at the same time.
> 
>   - Test canonical IPA alignment with the mapping size during reverse
>     map insertion.
> 
>   - Move clean up of kvm_unmap_gfn_range() to its own patch.
> 
>   - Avoid naming variables with "*dir*", as it can be misunderstood to
>     be related to directories.
> 
>   - Use mas_find() instead of mas_find_range() as mas_find_range()
>     returns every range including empty/NULL ranges, for our use case
>     we only want to iterate over non-NULL ranges.
> 
>   - Added a trace point to track when the reverse map maple tree becomes
>     "broken" i.e. maple tree insertion failure.
> 
> Thanks!
> 
> [1]: https://lore.kernel.org/kvmarm/20260510145338.322962-1-weilin.chang@arm.com/
> [2]: https://lore.kernel.org/kvmarm/20260630121005.1130996-1-weilin.chang@arm.com/

Thanks for the update. I know this series is sitll being discussed, but I
went ahead testing the kernel with your proposed hello_nested seltest on a Grace
CPU. 

Before this series applied:
real    0m2.869s
user    0m0.003s
sys     0m2.862s

After this series applied:
real    0m0.027s
user    0m0.001s
sys     0m0.005s

It reduces the time needed for the VM tear-down paths. I will test this series again 
when v5 comes out, since I've git this a try;

Tested-by: Itaru Kitayama <itaru.kitayama@fujitsu.com>

Thanks,
Itaru.

> 
> Wei-Lin Chang (6):
>   KVM: arm64: Use a variable for the canonical GPA in kvm_s2_fault_map()
>   KVM: arm64: nv: Avoid full shadow s2 unmap
>   KVM: arm64: nv: Add nested revmap broken tracepoint
>   KVM: arm64: Refactor kvm_unmap_gfn_range() with common variables
>   KVM: arm64: nv: Remove reverse map entries during TLBI handling
>   KVM: arm64: nv: Create nested IPA direct map to speed up reverse map
>     removal
> 
>  arch/arm64/include/asm/kvm_host.h   |   9 +
>  arch/arm64/include/asm/kvm_nested.h |   6 +
>  arch/arm64/kvm/mmu.c                |  42 +++--
>  arch/arm64/kvm/nested.c             | 280 +++++++++++++++++++++++++++-
>  arch/arm64/kvm/sys_regs.c           |   3 +
>  arch/arm64/kvm/trace_arm.h          |  27 +++
>  6 files changed, 349 insertions(+), 18 deletions(-)
> 
> -- 
> 2.43.0
> 

      parent reply	other threads:[~2026-07-27 22:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 11:59 [PATCH v4 0/6] KVM: arm64: nv: Implement nested stage-2 reverse map Wei-Lin Chang
2026-07-14 11:59 ` [PATCH v4 1/6] KVM: arm64: Use a variable for the canonical GPA in kvm_s2_fault_map() Wei-Lin Chang
2026-07-14 11:59 ` [PATCH v4 2/6] KVM: arm64: nv: Avoid full shadow s2 unmap Wei-Lin Chang
2026-07-16  7:05   ` Oliver Upton
2026-07-16 16:14     ` Wei-Lin Chang
2026-07-16 17:16       ` Oliver Upton
2026-07-22 13:09         ` Wei-Lin Chang
2026-07-14 11:59 ` [PATCH v4 3/6] KVM: arm64: nv: Add nested revmap broken tracepoint Wei-Lin Chang
2026-07-16  6:45   ` Oliver Upton
2026-07-16  8:56     ` Marc Zyngier
2026-07-16 16:25       ` Wei-Lin Chang
2026-07-14 11:59 ` [PATCH v4 4/6] KVM: arm64: Refactor kvm_unmap_gfn_range() with common variables Wei-Lin Chang
2026-07-14 11:59 ` [PATCH v4 5/6] KVM: arm64: nv: Remove reverse map entries during TLBI handling Wei-Lin Chang
2026-07-14 11:59 ` [PATCH v4 6/6] KVM: arm64: nv: Create nested IPA direct map to speed up reverse map removal Wei-Lin Chang
2026-07-27 22:24 ` Itaru Kitayama [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=amfap0e5dhQgo4eW@sm-arm-grace07 \
    --to=itaru.kitayama@fujitsu.com \
    --cc=catalin.marinas@arm.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=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sebastianene@google.com \
    --cc=seiden@linux.ibm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tabba@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox