[PATCH v6 00/10] Stage-2 huge mappings for pKVM np-guests

Vincent Donnefort posted 10 patches 6 months, 3 weeks ago
arch/arm64/include/asm/kvm_pgtable.h          |   7 +-
arch/arm64/include/asm/kvm_pkvm.h             |   2 +
arch/arm64/kvm/hyp/include/nvhe/mem_protect.h |   8 +-
arch/arm64/kvm/hyp/include/nvhe/memory.h      |  16 +-
arch/arm64/kvm/hyp/include/nvhe/mm.h          |   4 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c            |  16 +-
arch/arm64/kvm/hyp/nvhe/mem_protect.c         | 264 +++++++++++-------
arch/arm64/kvm/hyp/nvhe/mm.c                  |  97 ++++++-
arch/arm64/kvm/hyp/nvhe/setup.c               |  15 +-
arch/arm64/kvm/hyp/pgtable.c                  |   6 -
arch/arm64/kvm/mmu.c                          |   6 +-
arch/arm64/kvm/pkvm.c                         | 129 ++++-----
12 files changed, 365 insertions(+), 205 deletions(-)
[PATCH v6 00/10] Stage-2 huge mappings for pKVM np-guests
Posted by Vincent Donnefort 6 months, 3 weeks ago
Hi all,

This series adds support for stage-2 huge mappings (PMD_SIZE) to pKVM
np-guests, that is installing PMD-level mappings in the stage-2,
whenever the stage-1 is backed by either Hugetlbfs or THPs.

The last patch of that series is an optimization for CMOs using a shared
PMD_SIZE fixmap.

Changes since v5 (https://lore.kernel.org/all/20250520085201.3059786-1-vdonnefort@google.com/)

  - Fix fixblock_map usage. It should only be used on PMD_SIZE aligned addresses. (Marc)

Changes since v4 (https://lore.kernel.org/all/20250509131706.2336138-1-vdonnefort@google.com/)

  - Make guest CMO functions working with any input (Marc)
  - Improve for_each_hyp_page() and fold struct hyp_page declaration
    (Marc)
  - in mem_protect.c "PMD_SIZE" replaced with kvm_granule_size(KVM_PGTABLE_LAST_LEVEL - 1)
    (Marc)
  - Remove useless guest pgtable callback force_pte (Marc)
  - Fixblock functions fallsback on fixmap on 64KiB pages systems.
    (Marc)

Changes since v3 (https://lore.kernel.org/all/20250407082706.1239603-1-vdonnefort@google.com/)

  - Rebase on kvmarm/next

Changes since v2 (https://lore.kernel.org/all/20250306110038.3733649-1-vdonnefort@google.com/)

  - Fix PUD_SIZE -> PMD_SIZE enforcement (Quentin)
  - Rework pkvm_host_share_guest() to remove one hyp_page walk (Quentin)
  - Remove one pgtable walk into __check_host_shared_guest() (Quentin)
  - Return EBUSY on host_share_guest_count overflow

Changes since v1 (https://lore.kernel.org/all/20250228102530.1229089-1-vdonnefort@google.com/)

  - WARN_ON() on !PAGE_ALIGNED size for guest CMOs (Quentin)
  - check_range_allowed_memory() before accessing the Vmemmap (Quentin)

Quentin Perret (2):
  KVM: arm64: Convert pkvm_mappings to interval tree
  KVM: arm64: Add a range to pkvm_mappings

Vincent Donnefort (8):
  KVM: arm64: Handle huge mappings for np-guest CMOs
  KVM: arm64: Introduce for_each_hyp_page
  KVM: arm64: Add a range to __pkvm_host_share_guest()
  KVM: arm64: Add a range to __pkvm_host_unshare_guest()
  KVM: arm64: Add a range to __pkvm_host_wrprotect_guest()
  KVM: arm64: Add a range to __pkvm_host_test_clear_young_guest()
  KVM: arm64: Stage-2 huge mappings for np-guests
  KVM: arm64: np-guest CMOs with PMD_SIZE fixmap

 arch/arm64/include/asm/kvm_pgtable.h          |   7 +-
 arch/arm64/include/asm/kvm_pkvm.h             |   2 +
 arch/arm64/kvm/hyp/include/nvhe/mem_protect.h |   8 +-
 arch/arm64/kvm/hyp/include/nvhe/memory.h      |  16 +-
 arch/arm64/kvm/hyp/include/nvhe/mm.h          |   4 +-
 arch/arm64/kvm/hyp/nvhe/hyp-main.c            |  16 +-
 arch/arm64/kvm/hyp/nvhe/mem_protect.c         | 264 +++++++++++-------
 arch/arm64/kvm/hyp/nvhe/mm.c                  |  97 ++++++-
 arch/arm64/kvm/hyp/nvhe/setup.c               |  15 +-
 arch/arm64/kvm/hyp/pgtable.c                  |   6 -
 arch/arm64/kvm/mmu.c                          |   6 +-
 arch/arm64/kvm/pkvm.c                         | 129 ++++-----
 12 files changed, 365 insertions(+), 205 deletions(-)


base-commit: 52a62c117afb9ec3484a4d2fd6d0c4caff754c5b
-- 
2.49.0.1112.g889b7c5bd8-goog
Re: [PATCH v6 00/10] Stage-2 huge mappings for pKVM np-guests
Posted by Marc Zyngier 6 months, 3 weeks ago
On Wed, 21 May 2025 13:48:24 +0100, Vincent Donnefort wrote:
> This series adds support for stage-2 huge mappings (PMD_SIZE) to pKVM
> np-guests, that is installing PMD-level mappings in the stage-2,
> whenever the stage-1 is backed by either Hugetlbfs or THPs.
> 
> The last patch of that series is an optimization for CMOs using a shared
> PMD_SIZE fixmap.
> 
> [...]

Applied to next, thanks!

[01/10] KVM: arm64: Handle huge mappings for np-guest CMOs
        commit: 944a1ed8cc3ea6c5b16b6aca11475ced0daf68a9
[02/10] KVM: arm64: Introduce for_each_hyp_page
        commit: 3db771fa23ed6aecdf28ce4b806309198eea84e2
[03/10] KVM: arm64: Add a range to __pkvm_host_share_guest()
        commit: 4274385ebf090461b46b9bddb0f7c526182ba3c0
[04/10] KVM: arm64: Add a range to __pkvm_host_unshare_guest()
        commit: f28f1d02f4eaac05c2ad6bf7264a8696dc21d011
[05/10] KVM: arm64: Add a range to __pkvm_host_wrprotect_guest()
        commit: 0eb802b3b4ecfb10046bc325f47e7fd741c72ffe
[06/10] KVM: arm64: Add a range to __pkvm_host_test_clear_young_guest()
        commit: c4d99a833d34d8041a568f0c076379ae53c47896
[07/10] KVM: arm64: Convert pkvm_mappings to interval tree
        commit: b38c9775f73941ee59aebc0a489aa5c22e632def
[08/10] KVM: arm64: Add a range to pkvm_mappings
        commit: 3669ddd8fa8b5a46d96b9c54a6fa519a17e4a4fa
[09/10] KVM: arm64: Stage-2 huge mappings for np-guests
        commit: db14091d8f75852d960b18834c7bdb1b7c2bb74f
[10/10] KVM: arm64: np-guest CMOs with PMD_SIZE fixmap
        commit: c353fde17d8f7e710884532da50393cd22ddbfbe

Cheers,

	M.
-- 
Without deviation from the norm, progress is not possible.