Skip to content

Commit 60de423

Browse files
yosrym93sean-jc
authored andcommitted
KVM: selftests: Rename nested TDP mapping functions
Rename the functions from nested_* to tdp_* to make their purpose clearer. No functional change intended. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev> Link: https://patch.msgid.link/20251230230150.4150236-4-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 97dfbdf commit 60de423

4 files changed

Lines changed: 37 additions & 39 deletions

File tree

tools/testing/selftests/kvm/include/x86/vmx.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -559,14 +559,14 @@ bool load_vmcs(struct vmx_pages *vmx);
559559

560560
bool ept_1g_pages_supported(void);
561561

562-
void nested_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm,
563-
uint64_t nested_paddr, uint64_t paddr);
564-
void nested_map(struct vmx_pages *vmx, struct kvm_vm *vm,
565-
uint64_t nested_paddr, uint64_t paddr, uint64_t size);
566-
void nested_identity_map_default_memslots(struct vmx_pages *vmx,
567-
struct kvm_vm *vm);
568-
void nested_identity_map_1g(struct vmx_pages *vmx, struct kvm_vm *vm,
569-
uint64_t addr, uint64_t size);
562+
void tdp_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm, uint64_t nested_paddr,
563+
uint64_t paddr);
564+
void tdp_map(struct vmx_pages *vmx, struct kvm_vm *vm, uint64_t nested_paddr,
565+
uint64_t paddr, uint64_t size);
566+
void tdp_identity_map_default_memslots(struct vmx_pages *vmx,
567+
struct kvm_vm *vm);
568+
void tdp_identity_map_1g(struct vmx_pages *vmx, struct kvm_vm *vm,
569+
uint64_t addr, uint64_t size);
570570
bool kvm_cpu_has_ept(void);
571571
void prepare_eptp(struct vmx_pages *vmx, struct kvm_vm *vm);
572572
void prepare_virtualize_apic_accesses(struct vmx_pages *vmx, struct kvm_vm *vm);

tools/testing/selftests/kvm/lib/x86/memstress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ void memstress_setup_ept(struct vmx_pages *vmx, struct kvm_vm *vm)
7070
* KVM can shadow the EPT12 with the maximum huge page size supported
7171
* by the backing source.
7272
*/
73-
nested_identity_map_1g(vmx, vm, 0, 0x100000000ULL);
73+
tdp_identity_map_1g(vmx, vm, 0, 0x100000000ULL);
7474

7575
start = align_down(memstress_args.gpa, PG_SIZE_1G);
7676
end = align_up(memstress_args.gpa + memstress_args.size, PG_SIZE_1G);
77-
nested_identity_map_1g(vmx, vm, start, end - start);
77+
tdp_identity_map_1g(vmx, vm, start, end - start);
7878
}
7979

8080
void memstress_setup_nested(struct kvm_vm *vm, int nr_vcpus, struct kvm_vcpu *vcpus[])

tools/testing/selftests/kvm/lib/x86/vmx.c

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,12 @@ void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip, void *guest_rsp)
362362
init_vmcs_guest_state(guest_rip, guest_rsp);
363363
}
364364

365-
static void nested_create_pte(struct kvm_vm *vm,
366-
struct eptPageTableEntry *pte,
367-
uint64_t nested_paddr,
368-
uint64_t paddr,
369-
int current_level,
370-
int target_level)
365+
static void tdp_create_pte(struct kvm_vm *vm,
366+
struct eptPageTableEntry *pte,
367+
uint64_t nested_paddr,
368+
uint64_t paddr,
369+
int current_level,
370+
int target_level)
371371
{
372372
if (!pte->readable) {
373373
pte->writable = true;
@@ -394,8 +394,8 @@ static void nested_create_pte(struct kvm_vm *vm,
394394
}
395395

396396

397-
void __nested_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm,
398-
uint64_t nested_paddr, uint64_t paddr, int target_level)
397+
void __tdp_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm,
398+
uint64_t nested_paddr, uint64_t paddr, int target_level)
399399
{
400400
const uint64_t page_size = PG_LEVEL_SIZE(target_level);
401401
struct eptPageTableEntry *pt = vmx->eptp_hva, *pte;
@@ -428,7 +428,7 @@ void __nested_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm,
428428
index = (nested_paddr >> PG_LEVEL_SHIFT(level)) & 0x1ffu;
429429
pte = &pt[index];
430430

431-
nested_create_pte(vm, pte, nested_paddr, paddr, level, target_level);
431+
tdp_create_pte(vm, pte, nested_paddr, paddr, level, target_level);
432432

433433
if (pte->page_size)
434434
break;
@@ -445,10 +445,10 @@ void __nested_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm,
445445

446446
}
447447

448-
void nested_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm,
449-
uint64_t nested_paddr, uint64_t paddr)
448+
void tdp_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm,
449+
uint64_t nested_paddr, uint64_t paddr)
450450
{
451-
__nested_pg_map(vmx, vm, nested_paddr, paddr, PG_LEVEL_4K);
451+
__tdp_pg_map(vmx, vm, nested_paddr, paddr, PG_LEVEL_4K);
452452
}
453453

454454
/*
@@ -468,8 +468,8 @@ void nested_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm,
468468
* Within the VM given by vm, creates a nested guest translation for the
469469
* page range starting at nested_paddr to the page range starting at paddr.
470470
*/
471-
void __nested_map(struct vmx_pages *vmx, struct kvm_vm *vm,
472-
uint64_t nested_paddr, uint64_t paddr, uint64_t size,
471+
void __tdp_map(struct vmx_pages *vmx, struct kvm_vm *vm,
472+
uint64_t nested_paddr, uint64_t paddr, uint64_t size,
473473
int level)
474474
{
475475
size_t page_size = PG_LEVEL_SIZE(level);
@@ -479,23 +479,23 @@ void __nested_map(struct vmx_pages *vmx, struct kvm_vm *vm,
479479
TEST_ASSERT(paddr + size > paddr, "Paddr overflow");
480480

481481
while (npages--) {
482-
__nested_pg_map(vmx, vm, nested_paddr, paddr, level);
482+
__tdp_pg_map(vmx, vm, nested_paddr, paddr, level);
483483
nested_paddr += page_size;
484484
paddr += page_size;
485485
}
486486
}
487487

488-
void nested_map(struct vmx_pages *vmx, struct kvm_vm *vm,
489-
uint64_t nested_paddr, uint64_t paddr, uint64_t size)
488+
void tdp_map(struct vmx_pages *vmx, struct kvm_vm *vm,
489+
uint64_t nested_paddr, uint64_t paddr, uint64_t size)
490490
{
491-
__nested_map(vmx, vm, nested_paddr, paddr, size, PG_LEVEL_4K);
491+
__tdp_map(vmx, vm, nested_paddr, paddr, size, PG_LEVEL_4K);
492492
}
493493

494494
/* Prepare an identity extended page table that maps all the
495495
* physical pages in VM.
496496
*/
497-
void nested_identity_map_default_memslots(struct vmx_pages *vmx,
498-
struct kvm_vm *vm)
497+
void tdp_identity_map_default_memslots(struct vmx_pages *vmx,
498+
struct kvm_vm *vm)
499499
{
500500
uint32_t s, memslot = 0;
501501
sparsebit_idx_t i, last;
@@ -512,18 +512,16 @@ void nested_identity_map_default_memslots(struct vmx_pages *vmx,
512512
if (i > last)
513513
break;
514514

515-
nested_map(vmx, vm,
516-
(uint64_t)i << vm->page_shift,
517-
(uint64_t)i << vm->page_shift,
518-
1 << vm->page_shift);
515+
tdp_map(vmx, vm, (uint64_t)i << vm->page_shift,
516+
(uint64_t)i << vm->page_shift, 1 << vm->page_shift);
519517
}
520518
}
521519

522520
/* Identity map a region with 1GiB Pages. */
523-
void nested_identity_map_1g(struct vmx_pages *vmx, struct kvm_vm *vm,
521+
void tdp_identity_map_1g(struct vmx_pages *vmx, struct kvm_vm *vm,
524522
uint64_t addr, uint64_t size)
525523
{
526-
__nested_map(vmx, vm, addr, addr, size, PG_LEVEL_1G);
524+
__tdp_map(vmx, vm, addr, addr, size, PG_LEVEL_1G);
527525
}
528526

529527
bool kvm_cpu_has_ept(void)

tools/testing/selftests/kvm/x86/vmx_dirty_log_test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ static void test_vmx_dirty_log(bool enable_ept)
121121
*/
122122
if (enable_ept) {
123123
prepare_eptp(vmx, vm);
124-
nested_identity_map_default_memslots(vmx, vm);
125-
nested_map(vmx, vm, NESTED_TEST_MEM1, GUEST_TEST_MEM, PAGE_SIZE);
126-
nested_map(vmx, vm, NESTED_TEST_MEM2, GUEST_TEST_MEM, PAGE_SIZE);
124+
tdp_identity_map_default_memslots(vmx, vm);
125+
tdp_map(vmx, vm, NESTED_TEST_MEM1, GUEST_TEST_MEM, PAGE_SIZE);
126+
tdp_map(vmx, vm, NESTED_TEST_MEM2, GUEST_TEST_MEM, PAGE_SIZE);
127127
}
128128

129129
bmap = bitmap_zalloc(TEST_MEM_PAGES);

0 commit comments

Comments
 (0)