This series backports the upstream ARM64 KVM_PRE_FAULT_MEMORY feature (mainline v7.4-rc1) to the openEuler OLK-6.6 kernel. KVM_PRE_FAULT_MEMORY allows userspace to pre-populate stage-2 page tables for a given GPA range before the guest actually accesses it, reducing the latency of the first guest access. The upstream series is built on a newer arm64 KVM fault-handling infrastructure, so this backport includes the minimal prerequisite changes required by OLK-6.6. Differences from the upstream series: - Only the kvm_s2_fault_desc structure and the user_mem_abort() signature change are backported. The upstream struct kvm_s2_fault split and the gmem_abort()/guest_memfd path are omitted because OLK-6.6 does not have that infrastructure. - The OLK-6.6-specific arguments (struct kvm_s1_trans *result, fault_status, shadow_seq and walk_seq) are kept as separate parameters instead of being folded into kvm_s2_fault_desc. - The PVM shadow stage-1 path is preserved. Shared fault-handling code uses the new ESR-based helpers, while the PVM exec_fault semantics (esr_trap_is_iabt()) remain distinct from the ordinary path (esr_abt_is_exec_fault()). - Nested stage-2 and pKVM paths are not present or not supported in this backport. The pre-fault hook rejects pKVM, PVM and CCA realms that do not use the canonical stage-2 page tables targeted by this implementation. - The arm64 selftest is adapted to the OLK-6.6 selftest tree (pthread usage, u64 instead of gpa_t, TEST_ASSERT messages) and enabled for aarch64. - The synthetic ESR used by pre-fault is a read fault. Pre-faulting therefore establishes read-only mappings and leaves write/exec permission upgrades and COW to the first real guest fault. Validation: - Kernel build: 0 errors. - Booted 6.6.0+ on a 96-CPU arm64 EulerOS 2.0 SP16 machine. - pre_fault_memory_test passes on 10 guest modes with anonymous, THP, shmem, 2M/64K/32M hugetlb backings; 1G hugetlb passes with guest mode 14. - A 2U4G benchmark (2 vCPUs, 4G guest RAM) shows two concurrent 2G pre-faults take about 259 ms versus about 518 ms for a single 4G pre-fault. Jack Thomson (3): KVM: arm64: Pass walk flags to kvm_pgtable_get_leaf() KVM: selftests: Enable pre_fault_memory_test for arm64 KVM: selftests: Add option for different backing in pre-fault tests Lorenzo Stoakes (ARM) (10): KVM: Allow architectures to disallow pre-fault arm64: Add ESR fault helpers KVM: arm64: Use ESR helpers in guest abort handling KVM: arm64: Propagate and use esr in s2fd when handling guest aborts KVM: arm64: Propagate and use mmu in s2fd when handling guest aborts KVM: arm64: Propagate and use kvm_s2_fault_result on S2 fault KVM: arm64: Size the stage-2 memcache from the fault MMU KVM: arm64: Propagate EHWPOISON in kvm_s2_fault_pin_pfn() KVM: arm64: Implement KVM_PRE_FAULT_MEMORY Documentation: KVM: document arm64 KVM_PRE_FAULT_MEMORY Marc Zyngier (1): KVM: arm64: Move fault context to const structure Documentation/virt/kvm/api.rst | 22 +- arch/arm64/include/asm/esr.h | 37 ++ arch/arm64/include/asm/kvm_emulate.h | 61 ++-- arch/arm64/include/asm/kvm_pgtable.h | 5 +- arch/arm64/kvm/Kconfig | 1 + arch/arm64/kvm/arm.c | 3 + arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +- arch/arm64/kvm/hyp/pgtable.c | 5 +- arch/arm64/kvm/mmu.c | 243 +++++++++++-- arch/arm64/kvm/virtcca_cvm.c | 2 +- arch/x86/kvm/mmu/mmu.c | 11 +- include/linux/kvm_host.h | 1 + tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/pre_fault_memory_test.c | 324 ++++++++++++++++++ virt/kvm/kvm_main.c | 10 +- 15 files changed, 650 insertions(+), 78 deletions(-) create mode 100644 tools/testing/selftests/kvm/pre_fault_memory_test.c -- 2.43.0