Re: [PATCH v2 18/23] KVM: selftests: Generalize nested mapping functions
From: Sean Christopherson
Date: Thu Nov 20 2025 - 19:10:54 EST
On Tue, Oct 21, 2025, Yosry Ahmed wrote:
> Instead of passing in a pointer to struct vmx_pages, pass in the GPA of
> the root of the EPTs, as that's the only member being used. Furthermore,
> only use ept_pte_masks for VMX, and use x86_pte_masks otherwise (which
> is what NPT uses).
>
> This is in preparation of supporting NPTs as well.
>
> No functional change intended.
>
> Signed-off-by: Yosry Ahmed <yosry.ahmed@xxxxxxxxx>
> ---
> tools/testing/selftests/kvm/include/x86/vmx.h | 6 +++---
> .../testing/selftests/kvm/lib/x86/memstress.c | 4 ++--
> tools/testing/selftests/kvm/lib/x86/vmx.c | 20 ++++++++++---------
> .../selftests/kvm/x86/vmx_dirty_log_test.c | 6 +++---
> 4 files changed, 19 insertions(+), 17 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/include/x86/vmx.h b/tools/testing/selftests/kvm/include/x86/vmx.h
> index 5aa14ceed050a..4429e83e1f52c 100644
> --- a/tools/testing/selftests/kvm/include/x86/vmx.h
> +++ b/tools/testing/selftests/kvm/include/x86/vmx.h
> @@ -561,11 +561,11 @@ bool load_vmcs(struct vmx_pages *vmx);
>
> bool ept_1g_pages_supported(void);
>
> -void nested_map(struct vmx_pages *vmx, struct kvm_vm *vm,
> +void nested_map(struct kvm_vm *vm, vm_paddr_t root_gpa,
> uint64_t nested_paddr, uint64_t paddr, uint64_t size);
> -void nested_map_memslot(struct vmx_pages *vmx, struct kvm_vm *vm,
> +void nested_map_memslot(struct kvm_vm *vm, vm_paddr_t root_gpa,
> uint32_t memslot);
> -void nested_identity_map_1g(struct vmx_pages *vmx, struct kvm_vm *vm,
> +void nested_identity_map_1g(struct kvm_vm *vm, vm_paddr_t root_gpa,
> uint64_t addr, uint64_t size);
Ugh, "nested" is a bad namespace. Running L2 doesn't strictly require nested
TDP, and the operations themselves are non-nested, in the sense that we're
modifying stage-2 / TDP page tables.
My vote would be to do a rename to either stage2_pg_map() or tdp_pg_map()