@@ -985,6 +985,11 @@ void vm_mem_add(struct kvm_vm *vm, enum vm_mem_backing_src_type src_type,
" vm->max_gfn: 0x%lx vm->page_size: 0x%x",
guest_paddr, npages, vm->max_gfn, vm->page_size);
+ TEST_ASSERT(!(is_backing_src_hugetlb(src_type) &&
+ (mem_size & (backing_src_pagesz - 1))),
+ "mem_size 0x%lx is not aligned to backing src %s's page size 0x%lx",
+ mem_size, vm_mem_backing_src_alias(src_type)->name, backing_src_pagesz);
+
/*
* Confirm a mem region with an overlapping address doesn't
* already exist.