@@ -712,16 +712,13 @@ void kvm_vm_release(struct kvm_vm *vmp)
712712}
713713
714714static void __vm_mem_region_delete (struct kvm_vm * vm ,
715- struct userspace_mem_region * region ,
716- bool unlink )
715+ struct userspace_mem_region * region )
717716{
718717 int ret ;
719718
720- if (unlink ) {
721- rb_erase (& region -> gpa_node , & vm -> regions .gpa_tree );
722- rb_erase (& region -> hva_node , & vm -> regions .hva_tree );
723- hash_del (& region -> slot_node );
724- }
719+ rb_erase (& region -> gpa_node , & vm -> regions .gpa_tree );
720+ rb_erase (& region -> hva_node , & vm -> regions .hva_tree );
721+ hash_del (& region -> slot_node );
725722
726723 region -> region .memory_size = 0 ;
727724 vm_ioctl (vm , KVM_SET_USER_MEMORY_REGION2 , & region -> region );
@@ -762,7 +759,7 @@ void kvm_vm_free(struct kvm_vm *vmp)
762759
763760 /* Free userspace_mem_regions. */
764761 hash_for_each_safe (vmp -> regions .slot_hash , ctr , node , region , slot_node )
765- __vm_mem_region_delete (vmp , region , false );
762+ __vm_mem_region_delete (vmp , region );
766763
767764 /* Free sparsebit arrays. */
768765 sparsebit_free (& vmp -> vpages_valid );
@@ -794,76 +791,6 @@ int kvm_memfd_alloc(size_t size, bool hugepages)
794791 return fd ;
795792}
796793
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-
867794static void vm_userspace_mem_region_gpa_insert (struct rb_root * gpa_tree ,
868795 struct userspace_mem_region * region )
869796{
@@ -1270,7 +1197,7 @@ void vm_mem_region_move(struct kvm_vm *vm, uint32_t slot, uint64_t new_gpa)
12701197 */
12711198void vm_mem_region_delete (struct kvm_vm * vm , uint32_t slot )
12721199{
1273- __vm_mem_region_delete (vm , memslot2region (vm , slot ), true );
1200+ __vm_mem_region_delete (vm , memslot2region (vm , slot ));
12741201}
12751202
12761203void vm_guest_mem_fallocate (struct kvm_vm * vm , uint64_t base , uint64_t size ,
0 commit comments