Skip to content

RFC KVM: arm64: Use TTBR1_EL2 for hVHE runtime mappings

Aneesh Kumar K.V (Arm) kvmarm linux-arm-kernel lkml sashiko-reviews 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest5 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5KVM: arm64: Make hyp symbol address conversion explicitarch/arm64/include/asm/kvm_asm.h arch/arm64/include/asm/kvm_mmu.h arch/arm64/kvm/arm.c +1 more+53 -300 replies
2/5KVM: arm64: Split hyp mapping APIs by address typearch/arm64/include/asm/kvm_mmu.h arch/arm64/kvm/arm.c arch/arm64/kvm/hyp/include/nvhe/mm.h +5 more+122 -730 replies
3/5KVM: arm64: Split hyp VA-to-PA conversion by address typearch/arm64/include/asm/kvm_host.h arch/arm64/include/asm/kvm_mmu.h arch/arm64/kvm/arm.c +9 more+49 -350 replies
4/5KVM: arm64: Rename the hyp private VA allocation basearch/arm64/kvm/hyp/nvhe/mm.c+16 -150 replies
5/5KVM: arm64: Use TTBR1_EL2 for hVHE runtime mappingsarch/arm64/include/asm/kvm_asm.h arch/arm64/include/asm/kvm_hyp.h arch/arm64/include/asm/kvm_mmu.h +12 more+328 -501 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/5] KVM: arm64: Use TTBR1_EL2 for hVHE runtime mappings

hVHE currently disables TTBR1_EL2 and places both the identity mapping and the hyp runtime mappings in TTBR0_EL2. As a result, it continues to use the legacy nVHE virtual-address layout even though hVHE uses the EL2&0 translation regime and can retain canonical kernel-image addresses.

This series moves the hVHE runtime mappings to TTBR1_EL2 and reserves TTBR0_EL2 for the identity mapping used during MMU and page-table transitions. Conventional VHE is unaffected, and nVHE continues to use the existing TTBR0-only layout, including when protected mode is enabled.

The existing code does not consistently distinguish kernel-image symbols from linear-map addresses because both currently use the same EL2 address transformation. The first four patches make this distinction explicit by:

- adding helpers for kernel-image symbol addresses;
- splitting the hyp mapping APIs by address type;
- providing separate symbol and linear VA-to-PA conversions; and
- clarifying the private hyp VA allocation terminology.

The final patch implements the TTBR1 layout. Hyp symbols retain their linked kernel-image VAs, while pools, per-CPU regions, SVE state and shared memory continue to use linear-map addresses. A separate TTBR0 page table contains the idmap, and both roots are installed during initial EL2 setup and pKVM finalization.

The resulting layouts are:

nVHE:
TTBR0_EL2: idmap and runtime mappings
TTBR1_EL2: unused

hVHE:
TTBR0_EL2: idmap
TTBR1_EL2: runtime mappings

Cc Marc Zyngier <[email protected]>
Cc Oliver Upton <[email protected]>
Cc Joey Gouly <[email protected]>
Cc Steffen Eiden <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc Zenghui Yu <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>

Aneesh Kumar K.V (Arm) (5):
KVM: arm64: Make hyp symbol address conversion explicit
KVM: arm64: Split hyp mapping APIs by address type
KVM: arm64: Split hyp VA-to-PA conversion by address type
KVM: arm64: Rename the hyp private VA allocation base
KVM: arm64: Use TTBR1_EL2 for hVHE runtime mappings

 arch/arm64/include/asm/kvm_asm.h         |  13 +--
 arch/arm64/include/asm/kvm_host.h        |   2 +
 arch/arm64/include/asm/kvm_hyp.h         |   4 +-
 arch/arm64/include/asm/kvm_mmu.h         |  89 ++++++++++++++--
 arch/arm64/include/asm/kvm_pgtable.h     |  27 +++++
 arch/arm64/include/asm/kvm_pkvm.h        |   3 +
 arch/arm64/kernel/asm-offsets.c          |   5 +-
 arch/arm64/kvm/arm.c                     |  92 +++++++++-------
 arch/arm64/kvm/hyp/include/nvhe/memory.h |  13 +--
 arch/arm64/kvm/hyp/include/nvhe/mm.h     |   9 +-
 arch/arm64/kvm/hyp/nvhe/early_alloc.c    |   1 +
 arch/arm64/kvm/hyp/nvhe/events.c         |   2 +-
 arch/arm64/kvm/hyp/nvhe/host.S           |   4 +-
 arch/arm64/kvm/hyp/nvhe/hyp-init.S       |  29 ++++-
 arch/arm64/kvm/hyp/nvhe/mem_protect.c    |  30 +++---
 arch/arm64/kvm/hyp/nvhe/mm.c             | 110 +++++++++++++------
 arch/arm64/kvm/hyp/nvhe/psci-relay.c     |  12 +--
 arch/arm64/kvm/hyp/nvhe/setup.c          |  55 +++++++---
 arch/arm64/kvm/hyp/pgtable.c             |  62 ++++++++++-
 arch/arm64/kvm/hyp_trace.c               |   2 +-
 arch/arm64/kvm/mmu.c                     | 128 ++++++++++++++++-------
 arch/arm64/kvm/pkvm.c                    |   3 +
 arch/arm64/kvm/va_layout.c               |  32 +++++-
 23 files changed, 546 insertions(+), 181 deletions(-)

base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa

Signature · 1 line
2.43.0