Re: [PATCH] KVM: selftests: Fix nx_huge_pages_test on TDP-disabled hosts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/27/22 00:20, Sean Christopherson wrote:
void __virt_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr,
		uint64_t nr_bytes, size_t page_size)
{
	uint64_t nr_pages = DIV_ROUND_UP(nr_bytes, page_size);

	TEST_ASSERT(vaddr + size > vaddr, "Vaddr overflow");
	TEST_ASSERT(paddr + size > paddr, "Paddr overflow");

	while (npages--) {
		virt_pg_map(vm, vaddr, paddr);
		vaddr += page_size;
		paddr += page_size;
	}
}

void virt_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr,
	      uint64_t nr_bytes)
{
	__virt_map(vm, vaddr, paddr, nr_bytes, vm->page_size);
}

I would just keep nr_pages in virt_map to begin with, for the sake of this patch. Changing virt_map can be done later (and should be separate anyway).

-	virt_map(vm, HPAGE_GVA, HPAGE_GPA, HPAGE_SLOT_NPAGES);
+	/*
+	 * Use 2MiB virtual mappings so that KVM can map the region with huge
+	 * pages even if TDP is disabled.
+	 */
+	virt_map_2m(vm, HPAGE_GVA, HPAGE_GPA, HPAGE_SLOT_2MB_PAGES);

Hmm, what about probing TDP support and deliberately using 4KiB pages when TDP is
enabled?  That would give a bit of bonus coverage by verifying that KVM creates
huge pages irrespective of guest mapping level.

Nice idea indeed.

Paolo




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux