Skip to content

Commit ce3b90b

Browse files
committed
KVM: selftests: Remove unused kvm_memcmp_hva_gva()
Remove sefltests' kvm_memcmp_hva_gva(), which has literally never had a single user since it was introduced by commit 783e9e5 ("kvm: selftests: add API testing infrastructure"). Link: https://lore.kernel.org/r/20240802200853.336512-1-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent d841406 commit ce3b90b

File tree

2 files changed

+0
-72
lines changed

2 files changed

+0
-72
lines changed

tools/testing/selftests/kvm/include/kvm_util.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,6 @@ const char *vm_guest_mode_string(uint32_t i);
428428
void kvm_vm_free(struct kvm_vm *vmp);
429429
void kvm_vm_restart(struct kvm_vm *vmp);
430430
void kvm_vm_release(struct kvm_vm *vmp);
431-
int kvm_memcmp_hva_gva(void *hva, struct kvm_vm *vm, const vm_vaddr_t gva,
432-
size_t len);
433431
void kvm_vm_elf_load(struct kvm_vm *vm, const char *filename);
434432
int kvm_memfd_alloc(size_t size, bool hugepages);
435433

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -794,76 +794,6 @@ int kvm_memfd_alloc(size_t size, bool hugepages)
794794
return fd;
795795
}
796796

797-
/*
798-
* Memory Compare, host virtual to guest virtual
799-
*
800-
* Input Args:
801-
* hva - Starting host virtual address
802-
* vm - Virtual Machine
803-
* gva - Starting guest virtual address
804-
* len - number of bytes to compare
805-
*
806-
* Output Args: None
807-
*
808-
* Input/Output Args: None
809-
*
810-
* Return:
811-
* Returns 0 if the bytes starting at hva for a length of len
812-
* are equal the guest virtual bytes starting at gva. Returns
813-
* a value < 0, if bytes at hva are less than those at gva.
814-
* Otherwise a value > 0 is returned.
815-
*
816-
* Compares the bytes starting at the host virtual address hva, for
817-
* a length of len, to the guest bytes starting at the guest virtual
818-
* address given by gva.
819-
*/
820-
int kvm_memcmp_hva_gva(void *hva, struct kvm_vm *vm, vm_vaddr_t gva, size_t len)
821-
{
822-
size_t amt;
823-
824-
/*
825-
* Compare a batch of bytes until either a match is found
826-
* or all the bytes have been compared.
827-
*/
828-
for (uintptr_t offset = 0; offset < len; offset += amt) {
829-
uintptr_t ptr1 = (uintptr_t)hva + offset;
830-
831-
/*
832-
* Determine host address for guest virtual address
833-
* at offset.
834-
*/
835-
uintptr_t ptr2 = (uintptr_t)addr_gva2hva(vm, gva + offset);
836-
837-
/*
838-
* Determine amount to compare on this pass.
839-
* Don't allow the comparsion to cross a page boundary.
840-
*/
841-
amt = len - offset;
842-
if ((ptr1 >> vm->page_shift) != ((ptr1 + amt) >> vm->page_shift))
843-
amt = vm->page_size - (ptr1 % vm->page_size);
844-
if ((ptr2 >> vm->page_shift) != ((ptr2 + amt) >> vm->page_shift))
845-
amt = vm->page_size - (ptr2 % vm->page_size);
846-
847-
assert((ptr1 >> vm->page_shift) == ((ptr1 + amt - 1) >> vm->page_shift));
848-
assert((ptr2 >> vm->page_shift) == ((ptr2 + amt - 1) >> vm->page_shift));
849-
850-
/*
851-
* Perform the comparison. If there is a difference
852-
* return that result to the caller, otherwise need
853-
* to continue on looking for a mismatch.
854-
*/
855-
int ret = memcmp((void *)ptr1, (void *)ptr2, amt);
856-
if (ret != 0)
857-
return ret;
858-
}
859-
860-
/*
861-
* No mismatch found. Let the caller know the two memory
862-
* areas are equal.
863-
*/
864-
return 0;
865-
}
866-
867797
static void vm_userspace_mem_region_gpa_insert(struct rb_root *gpa_tree,
868798
struct userspace_mem_region *region)
869799
{

0 commit comments

Comments
 (0)