Skip to content

KVM: arm64: nv: VNCR page mapping fixes

Jia He kvm kvmarm linux-arm-kernel linux-kselftest lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 0 repliesNew
  2. v34 patches 6 repliesSuperseded

Changes in v4 from the cover letter

- Rebase onto v7.4-rc4.
- Patch 1: use the cached HPA in __compute_hcr(), align the address passed to __set_fixmap(), and clarify the granule requirements (Marc).
- Patch 3: document the 16K and 64K test results and that the test runs with nested stage-2 disabled (Marc).
- Patch 4: shorten the cacheability helper comment (Marc), move the test descriptions to the cover letter (Marc), and defer the SEA injection for PFN fault-in errors and non-cacheable results until after the existing mmu_invalidate_retry() check under mmu_lock.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4KVM: arm64: nv: Locate the VNCR page in the host page from its PAarch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/hyp/vhe/switch.c arch/arm64/kvm/nested.c+28 -230 replies
2/4KVM: arm64: nv: Inject an SEA when the VNCR walk cannot set the AFarch/arm64/kvm/nested.c+1 -00 replies
3/4KVM: arm64: selftests: Add a test for VNCR_EL2 translation faultstools/testing/selftests/kvm/Makefile.kvm tools/testing/selftests/kvm/arm64/nv_vncr_abort.c+222 -00 replies
4/4KVM: arm64: nv: Allow the L1 VNCR page in cacheable PFNMAP memoryarch/arm64/include/asm/kvm_mmu.h arch/arm64/kvm/mmu.c arch/arm64/kvm/nested.c+45 -160 replies

Reviews trailers per patch

1 of 4 patches has a Reviewed-by or Acked-by.

PatchYuan Yao
1/4
2/4R-b
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/4] KVM: arm64: nv: VNCR page mapping fixes

Fix the VNCR fixmap offset on hosts with 16K or 64K pages and inject the fault recorded by the stage-1 walker when an AF update fails. Add a selftest for both fixes. The last patch allows cacheable PFNMAP memory to back the VNCR page.

Testing for patch 4:

On an FGT-capable host with L1's RAM backed by cacheable PFNMAP, the L2 hypervisor repeatedly took an SEA before the patch and booted with it.

On Neoverse-N2, an NV2 VTTBR_EL2 read from a cacheable PFNMAP VNCR page in a read-only memslot took an SEA with gfn_to_hva_memslot() and read the expected value with gfn_to_hva_memslot_prot().

On a Neoverse-N2 host with 4K pages, both writable and read-only memslots passed the cacheable PFNMAP read, non-cacheable PFNMAP and PROT_NONE rejection, and concurrent PFNMAP/shmem replacement tests. Both 5-second remap runs completed without a spurious SEA or bad read; an instrumented run confirmed that both the fault-in error and cacheability failure paths hit concurrent invalidations and retried. nv_vncr_abort passed 3/3.

Changes since v3:
- Rebase onto v7.4-rc4.
- Patch 1: use the cached HPA in __compute_hcr(), align the address passed to __set_fixmap(), and clarify the granule requirements (Marc).
- Patch 3: document the 16K and 64K test results and that the test runs with nested stage-2 disabled (Marc).
- Patch 4: shorten the cacheability helper comment (Marc), move the test descriptions to the cover letter (Marc), and defer the SEA injection for PFN fault-in errors and non-cacheable results until after the existing mmu_invalidate_retry() check under mmu_lock.

Changes since v2:
- New patch 1 (Sashiko).
- Patch 3: size the read-only memslot to whole host pages, and map the VNCR page at a VA whose bits [15:12] differ from those of its PA (Sashiko).

Changes since v1:
- New patches 2 and 3 (Sashiko).
- Patch 4: get the HVA with gfn_to_hva_memslot_prot() so that a VNCR page in a read-only memslot is not rejected (Sashiko).
- Patch 4: limit the stage-2 comparison in the commit message to VM_PFNMAP and VM_MIXEDMAP VMAs.

v3: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]
v1: https://lore.kernel.org/r/[email protected]

Jia He (4):
KVM: arm64: nv: Locate the VNCR page in the host page from its PA
KVM: arm64: nv: Inject an SEA when the VNCR walk cannot set the AF
KVM: arm64: selftests: Add a test for VNCR_EL2 translation faults
KVM: arm64: nv: Allow the L1 VNCR page in cacheable PFNMAP memory

 arch/arm64/include/asm/kvm_mmu.h              |   2 +
 arch/arm64/include/asm/kvm_nested.h           |  20 ++
 arch/arm64/kvm/hyp/vhe/switch.c               |   7 +-
 arch/arm64/kvm/mmu.c                          |   2 +-
 arch/arm64/kvm/nested.c                       |  82 ++++---
 tools/testing/selftests/kvm/Makefile.kvm      |   1 +
 .../selftests/kvm/arm64/nv_vncr_abort.c       | 221 ++++++++++++++++++
 7 files changed, 296 insertions(+), 39 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/arm64/nv_vncr_abort.c

base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f

Signature · 1 line
2.34.1