Skip to content

KVM: arm64: nv: Implement nested stage-2 reverse map

Wei-Lin Chang kvmarm linux-arm-kernel lkml 5 versions – Applied

Status from this message: Applied to next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest7 patches 14 repliesApplied
  2. v56 patches 25 repliesSuperseded
  3. v46 patches 8 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v35 patches9 repliesSuperseded
v11 patch7 repliesSuperseded

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/7KVM: arm64: Use a variable for the canonical IPA in kvm_s2_fault_map()arch/arm64/kvm/mmu.c+6 -50 replies
2/7KVM: arm64: nv: Introduce guest stage-2 tracking structuresarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/mmu.c arch/arm64/kvm/nested.c+42 -00 replies
3/7KVM: arm64: nv: Track guest stage-2 mapping creationarch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/mmu.c arch/arm64/kvm/nested.c+67 -00 replies
4/7KVM: arm64: nv: Track guest stage-2 mapping removalarch/arm64/include/asm/kvm_host.h arch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/mmu.c +1 more+61 -30 replies
5/7KVM: arm64: nv: Avoid full shadow stage-2 unmaparch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/mmu.c arch/arm64/kvm/nested.c+53 -60 replies
6/7KVM: arm64: nv: Drop kvm_s2_mmu pointer from kvm_guest_s2_mappingarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/nested.c+54 -190 replies
7/7KVM: arm64: Refactor kvm_unmap_gfn_range() with common variablesarch/arm64/kvm/mmu.c+7 -60 replies

Reviews trailers per patch

None of the 7 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchOliver UptonItaru KitayamaShuai Xue
SeriesR-b T-b T-b
1/7
2/7
3/7
4/7
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v6 thread

Cover letter [PATCH v6 0/7] KVM: arm64: nv: Implement nested stage-2 reverse map

Hi,

This is v6 of optimizing the shadow s2 mmu unmapping during MMU notifiers.

This version fixes a few issues, and adds Marc's space optimization for kvm_guest_s2_mapping [1]. Please see the changelog for the details.

Tested by booting L3, and running in-kernel targetted tests described in [2]. v5 got some tested-by's from Itaru and Wang (thanks), I didn't carry them over since some bugs fixed in v6 are non-obvious. Some retest would be much appreciated!

Series based on v7.3-rc3 + Marc's nested mmu lifecycle fixes [3].

* Changes from v5 [4]:

- Align the addresses down to the mapping size when recording the

    guest s2 mappings. s2fd->fault_ipa isn't necessarily PAGE_SIZE aligned.

- Record guest s2 mappings even when page table maps return -EAGAIN. kvm_pgtable_stage2_map() can create mappings while returning -EAGAIN. For example, a 2M block map (A) could race with a 4K page map (B):
1. (A) maps the 2M block in kvm_pgtable_visitor_cb()
2. (B) breaks that block into a table and maps 4K
3. (A) reloads and finds the table after kvm_pgtable_visitor_cb(), then descends into it.
4. (A) maps some 4K, but before it finishes reads entry mapped by (B).
5. (A) returns -EAGAIN although it had mapped a few pages.
In this case, we don't know what subrange is mapped, just track the whole requested mapping range.

- Don't remove tracked mappings from the interval trees if they only partially overlap the removal range. Because of the previous bullet point we can have a 4K shadow mapping tracked as a 2M range in the interval trees. It would be wrong to remove the 2M range when a guest TLBI doesn't touch the 4K mapped.

- Check mmu->pgt during mmu unmap notifier, as it could race against MMU teardown.

- Make guest_s2_tracking_destroy() canonical mmu only. We simply don't need to detach the nodes from the nested mmus' trees. Freeing them during canonical mmu's teardown is enough.

Thanks!

[1]: https://lore.kernel.org/kvmarm/[email protected]/
[2]: https://lore.kernel.org/kvmarm/gerjpm62a2gszzggc6vuai22bf3prfquvfsp7ueumps7vz2ev3@odlmovaklg2b/
[3]: https://lore.kernel.org/kvmarm/[email protected]/
[4]: https://lore.kernel.org/kvmarm/[email protected]/

Marc Zyngier (1):
KVM: arm64: nv: Drop kvm_s2_mmu pointer from kvm_guest_s2_mapping

Wei-Lin Chang (6):
KVM: arm64: Use a variable for the canonical IPA in kvm_s2_fault_map()
KVM: arm64: nv: Introduce guest stage-2 tracking structures
KVM: arm64: nv: Track guest stage-2 mapping creation
KVM: arm64: nv: Track guest stage-2 mapping removal
KVM: arm64: nv: Avoid full shadow stage-2 unmap
KVM: arm64: Refactor kvm_unmap_gfn_range() with common variables

 arch/arm64/include/asm/kvm_host.h   |  31 +++++-
 arch/arm64/include/asm/kvm_nested.h |   7 ++
 arch/arm64/kvm/mmu.c                | 109 +++++++++++++++++++---
 arch/arm64/kvm/nested.c             | 140 +++++++++++++++++++++++++++-
 4 files changed, 269 insertions(+), 18 deletions(-)
Signature · 1 line
2.43.0