@@ -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-
867797static void vm_userspace_mem_region_gpa_insert (struct rb_root * gpa_tree ,
868798 struct userspace_mem_region * region )
869799{
0 commit comments