[PATCH v2 0/7] Move pKVM ownership state to hyp_vmemmap

Quentin Perret posted 7 patches 8 months, 1 week ago
arch/arm64/include/asm/kvm_host.h        |  12 +--
arch/arm64/kvm/hyp/include/nvhe/memory.h |  58 ++++++++++---
arch/arm64/kvm/hyp/nvhe/hyp-main.c       |   4 -
arch/arm64/kvm/hyp/nvhe/mem_protect.c    | 106 ++++++++++++-----------
arch/arm64/kvm/hyp/nvhe/pkvm.c           |  47 +++++++++-
arch/arm64/kvm/hyp/nvhe/setup.c          |  10 ++-
6 files changed, 158 insertions(+), 79 deletions(-)
[PATCH v2 0/7] Move pKVM ownership state to hyp_vmemmap
Posted by Quentin Perret 8 months, 1 week ago
Hi all,

This series moves the hypervisor's ownership state to the hyp_vmemmap,
as discussed in [1]. The two main benefits are:

 1. much cheaper hyp state lookups, since we can avoid the hyp stage-1
    page-table walk;

 2. de-correlates the hyp state from the presence of a mapping in the
    linear map range of the hypervisor; which enables a bunch of
    clean-ups in the existing code and will simplify the introduction of
    other features in the future (hyp tracing, ...)

Patch 01 is a self-sufficient cleanup that I found thanks to patch 06.
Patch 02 is another self-sufficient cleanup that came out from the
discussion with Marc at [2]. Patches 03-05 implement the aforementioned
migration of the hyp state to the vmemmap. Patches 06 and 07 are further
improvements enabled by that migration.

Changes since v1:
 - fixed page-tracking comments in nvhe/memory.h
 - rebased on 6.15-rc2
 - applied Marc's Reviewed-by

Thanks,
Quentin

[1] https://lore.kernel.org/kvmarm/Z79ZJVOHtNu6YsVt@google.com/
[2] https://lore.kernel.org/kvmarm/867c4pnspi.wl-maz@kernel.org/

Fuad Tabba (1):
  KVM: arm64: Track SVE state in the hypervisor vcpu structure

Quentin Perret (6):
  KVM: arm64: Fix pKVM page-tracking comments
  KVM: arm64: Use 0b11 for encoding PKVM_NOPAGE
  KVM: arm64: Introduce {get,set}_host_state() helpers
  KVM: arm64: Move hyp state to hyp_vmemmap
  KVM: arm64: Defer EL2 stage-1 mapping on share
  KVM: arm64: Unconditionally cross check hyp state

 arch/arm64/include/asm/kvm_host.h        |  12 +--
 arch/arm64/kvm/hyp/include/nvhe/memory.h |  58 ++++++++++---
 arch/arm64/kvm/hyp/nvhe/hyp-main.c       |   4 -
 arch/arm64/kvm/hyp/nvhe/mem_protect.c    | 106 ++++++++++++-----------
 arch/arm64/kvm/hyp/nvhe/pkvm.c           |  47 +++++++++-
 arch/arm64/kvm/hyp/nvhe/setup.c          |  10 ++-
 6 files changed, 158 insertions(+), 79 deletions(-)

-- 
2.49.0.604.gff1f9ca942-goog
Re: [PATCH v2 0/7] Move pKVM ownership state to hyp_vmemmap
Posted by Marc Zyngier 7 months, 3 weeks ago
On Wed, 16 Apr 2025 15:26:40 +0000, Quentin Perret wrote:
> This series moves the hypervisor's ownership state to the hyp_vmemmap,
> as discussed in [1]. The two main benefits are:
> 
>  1. much cheaper hyp state lookups, since we can avoid the hyp stage-1
>     page-table walk;
> 
>  2. de-correlates the hyp state from the presence of a mapping in the
>     linear map range of the hypervisor; which enables a bunch of
>     clean-ups in the existing code and will simplify the introduction of
>     other features in the future (hyp tracing, ...)
> 
> [...]

Applied to next, thanks!

[1/7] KVM: arm64: Track SVE state in the hypervisor vcpu structure
      commit: 5db1bef933427aa467ad89c7b695a84a6b4afe16
[2/7] KVM: arm64: Fix pKVM page-tracking comments
      commit: ba637018ca67224fa21dc2212cb4457b357a5455
[3/7] KVM: arm64: Use 0b11 for encoding PKVM_NOPAGE
      commit: cd4b039165a5e709d0d599e207709d73141a8bed
[4/7] KVM: arm64: Introduce {get,set}_host_state() helpers
      commit: ba5b2e5b9dff5ba14940e1525f6e3a595f012466
[5/7] KVM: arm64: Move hyp state to hyp_vmemmap
      commit: 3390b3cbb613bc0822854f5754437cd1d1b3d5d0
[6/7] KVM: arm64: Defer EL2 stage-1 mapping on share
      commit: 48d848882395a6a42ff1bb685082c79791d4e753
[7/7] KVM: arm64: Unconditionally cross check hyp state
      commit: 43c475504a39e98f10f5e6ec4d9d9ed60672a753

Cheers,

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