[PATCH v4 11/21] KVM: selftests: Stop passing VMX metadata to TDP mapping functions
Yosry Ahmed
yosry.ahmed at linux.dev
Fri Jan 2 09:12:32 PST 2026
On Tue, Dec 30, 2025 at 03:01:40PM -0800, Sean Christopherson wrote:
> From: Yosry Ahmed <yosry.ahmed at linux.dev>
>
> The root GPA can now be retrieved from the nested MMU, stop passing VMX
> metadata. This is in preparation for making these functions work for
> NPTs as well.
>
> Opportunistically drop tdp_pg_map() since it's unused.
>
> No functional change intended.
>
> Signed-off-by: Yosry Ahmed <yosry.ahmed at linux.dev>
> Signed-off-by: Sean Christopherson <seanjc at google.com>
> ---
> tools/testing/selftests/kvm/include/x86/vmx.h | 11 ++-----
> .../testing/selftests/kvm/lib/x86/memstress.c | 11 +++----
> tools/testing/selftests/kvm/lib/x86/vmx.c | 33 +++++++------------
> .../selftests/kvm/x86/vmx_dirty_log_test.c | 9 +++--
> 4 files changed, 24 insertions(+), 40 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/include/x86/vmx.h b/tools/testing/selftests/kvm/include/x86/vmx.h
> index 1fd83c23529a..4dd4c2094ee6 100644
> --- a/tools/testing/selftests/kvm/include/x86/vmx.h
> +++ b/tools/testing/selftests/kvm/include/x86/vmx.h
> @@ -557,14 +557,9 @@ bool load_vmcs(struct vmx_pages *vmx);
>
> bool ept_1g_pages_supported(void);
>
> -void tdp_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm, uint64_t nested_paddr,
> - uint64_t paddr);
> -void tdp_map(struct vmx_pages *vmx, struct kvm_vm *vm, uint64_t nested_paddr,
> - uint64_t paddr, uint64_t size);
> -void tdp_identity_map_default_memslots(struct vmx_pages *vmx,
> - struct kvm_vm *vm);
> -void tdp_identity_map_1g(struct vmx_pages *vmx, struct kvm_vm *vm,
> - uint64_t addr, uint64_t size);
> +void tdp_map(struct kvm_vm *vm, uint64_t nested_paddr, uint64_t paddr, uint64_t size);
> +void tdp_identity_map_default_memslots(struct kvm_vm *vm);
> +void tdp_identity_map_1g(struct kvm_vm *vm, uint64_t addr, uint64_t size);
> bool kvm_cpu_has_ept(void);
> void vm_enable_ept(struct kvm_vm *vm);
> void prepare_virtualize_apic_accesses(struct vmx_pages *vmx, struct kvm_vm *vm);
> diff --git a/tools/testing/selftests/kvm/lib/x86/memstress.c b/tools/testing/selftests/kvm/lib/x86/memstress.c
> index 00f7f11e5f0e..3319cb57a78d 100644
> --- a/tools/testing/selftests/kvm/lib/x86/memstress.c
> +++ b/tools/testing/selftests/kvm/lib/x86/memstress.c
> @@ -59,7 +59,7 @@ uint64_t memstress_nested_pages(int nr_vcpus)
> return 513 + 10 * nr_vcpus;
> }
>
> -static void memstress_setup_ept_mappings(struct vmx_pages *vmx, struct kvm_vm *vm)
> +static void memstress_setup_ept_mappings(struct kvm_vm *vm)
> {
> uint64_t start, end;
>
> @@ -68,16 +68,15 @@ static void memstress_setup_ept_mappings(struct vmx_pages *vmx, struct kvm_vm *v
> * KVM can shadow the EPT12 with the maximum huge page size supported
> * by the backing source.
> */
> - tdp_identity_map_1g(vmx, vm, 0, 0x100000000ULL);
> + tdp_identity_map_1g(vm, 0, 0x100000000ULL);
>
> start = align_down(memstress_args.gpa, PG_SIZE_1G);
> end = align_up(memstress_args.gpa + memstress_args.size, PG_SIZE_1G);
> - tdp_identity_map_1g(vmx, vm, start, end - start);
> + tdp_identity_map_1g(vm, start, end - start);
> }
>
> void memstress_setup_nested(struct kvm_vm *vm, int nr_vcpus, struct kvm_vcpu *vcpus[])
> {
> - struct vmx_pages *vmx;
> struct kvm_regs regs;
> vm_vaddr_t vmx_gva;
> int vcpu_id;
> @@ -87,11 +86,11 @@ void memstress_setup_nested(struct kvm_vm *vm, int nr_vcpus, struct kvm_vcpu *vc
>
> vm_enable_ept(vm);
> for (vcpu_id = 0; vcpu_id < nr_vcpus; vcpu_id++) {
> - vmx = vcpu_alloc_vmx(vm, &vmx_gva);
> + vcpu_alloc_vmx(vm, &vmx_gva);
>
> /* The EPTs are shared across vCPUs, setup the mappings once */
> if (vcpu_id == 0)
> - memstress_setup_ept_mappings(vmx, vm);
> + memstress_setup_ept_mappings(vm);
Oh and if you're feeling nitpicky while applying, I think this call can
actually be moved outside of the loop now, right after vm_enable_ept(),
dropping the whole vcpu_id == 0 special case.
>
> /*
> * Override the vCPU to run memstress_l1_guest_code() which will
More information about the linux-riscv
mailing list