@@ -209,7 +209,7 @@ __weak void vm_vaddr_populate_bitmap(struct kvm_vm *vm)
209209 (1ULL << (vm -> va_bits - 1 )) >> vm -> page_shift );
210210}
211211
212- struct kvm_vm * ____vm_create (enum vm_guest_mode mode )
212+ struct kvm_vm * ____vm_create (struct vm_shape shape )
213213{
214214 struct kvm_vm * vm ;
215215
@@ -221,13 +221,13 @@ struct kvm_vm *____vm_create(enum vm_guest_mode mode)
221221 vm -> regions .hva_tree = RB_ROOT ;
222222 hash_init (vm -> regions .slot_hash );
223223
224- vm -> mode = mode ;
225- vm -> type = 0 ;
224+ vm -> mode = shape . mode ;
225+ vm -> type = shape . type ;
226226
227- vm -> pa_bits = vm_guest_mode_params [mode ].pa_bits ;
228- vm -> va_bits = vm_guest_mode_params [mode ].va_bits ;
229- vm -> page_size = vm_guest_mode_params [mode ].page_size ;
230- vm -> page_shift = vm_guest_mode_params [mode ].page_shift ;
227+ vm -> pa_bits = vm_guest_mode_params [vm -> mode ].pa_bits ;
228+ vm -> va_bits = vm_guest_mode_params [vm -> mode ].va_bits ;
229+ vm -> page_size = vm_guest_mode_params [vm -> mode ].page_size ;
230+ vm -> page_shift = vm_guest_mode_params [vm -> mode ].page_shift ;
231231
232232 /* Setup mode specific traits. */
233233 switch (vm -> mode ) {
@@ -265,7 +265,7 @@ struct kvm_vm *____vm_create(enum vm_guest_mode mode)
265265 /*
266266 * Ignore KVM support for 5-level paging (vm->va_bits == 57),
267267 * it doesn't take effect unless a CR4.LA57 is set, which it
268- * isn't for this VM_MODE .
268+ * isn't for this mode (48-bit virtual address space) .
269269 */
270270 TEST_ASSERT (vm -> va_bits == 48 || vm -> va_bits == 57 ,
271271 "Linear address width (%d bits) not supported" ,
@@ -285,10 +285,11 @@ struct kvm_vm *____vm_create(enum vm_guest_mode mode)
285285 vm -> pgtable_levels = 5 ;
286286 break ;
287287 default :
288- TEST_FAIL ("Unknown guest mode, mode : 0x%x" , mode );
288+ TEST_FAIL ("Unknown guest mode: 0x%x" , vm -> mode );
289289 }
290290
291291#ifdef __aarch64__
292+ TEST_ASSERT (!vm -> type , "ARM doesn't support test-provided types" );
292293 if (vm -> pa_bits != 40 )
293294 vm -> type = KVM_VM_TYPE_ARM_IPA_SIZE (vm -> pa_bits );
294295#endif
@@ -347,19 +348,19 @@ static uint64_t vm_nr_pages_required(enum vm_guest_mode mode,
347348 return vm_adjust_num_guest_pages (mode , nr_pages );
348349}
349350
350- struct kvm_vm * __vm_create (enum vm_guest_mode mode , uint32_t nr_runnable_vcpus ,
351+ struct kvm_vm * __vm_create (struct vm_shape shape , uint32_t nr_runnable_vcpus ,
351352 uint64_t nr_extra_pages )
352353{
353- uint64_t nr_pages = vm_nr_pages_required (mode , nr_runnable_vcpus ,
354+ uint64_t nr_pages = vm_nr_pages_required (shape . mode , nr_runnable_vcpus ,
354355 nr_extra_pages );
355356 struct userspace_mem_region * slot0 ;
356357 struct kvm_vm * vm ;
357358 int i ;
358359
359- pr_debug ("%s: mode='%s' pages='%ld'\n" , __func__ ,
360- vm_guest_mode_string (mode ), nr_pages );
360+ pr_debug ("%s: mode='%s' type='%d', pages='%ld'\n" , __func__ ,
361+ vm_guest_mode_string (shape . mode ), shape . type , nr_pages );
361362
362- vm = ____vm_create (mode );
363+ vm = ____vm_create (shape );
363364
364365 vm_userspace_mem_region_add (vm , VM_MEM_SRC_ANONYMOUS , 0 , 0 , nr_pages , 0 );
365366 for (i = 0 ; i < NR_MEM_REGIONS ; i ++ )
@@ -400,7 +401,7 @@ struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint32_t nr_runnable_vcpus,
400401 * extra_mem_pages is only used to calculate the maximum page table size,
401402 * no real memory allocation for non-slot0 memory in this function.
402403 */
403- struct kvm_vm * __vm_create_with_vcpus (enum vm_guest_mode mode , uint32_t nr_vcpus ,
404+ struct kvm_vm * __vm_create_with_vcpus (struct vm_shape shape , uint32_t nr_vcpus ,
404405 uint64_t extra_mem_pages ,
405406 void * guest_code , struct kvm_vcpu * vcpus [])
406407{
@@ -409,23 +410,23 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus
409410
410411 TEST_ASSERT (!nr_vcpus || vcpus , "Must provide vCPU array" );
411412
412- vm = __vm_create (mode , nr_vcpus , extra_mem_pages );
413+ vm = __vm_create (shape , nr_vcpus , extra_mem_pages );
413414
414415 for (i = 0 ; i < nr_vcpus ; ++ i )
415416 vcpus [i ] = vm_vcpu_add (vm , i , guest_code );
416417
417418 return vm ;
418419}
419420
420- struct kvm_vm * __vm_create_with_one_vcpu (struct kvm_vcpu * * vcpu ,
421- uint64_t extra_mem_pages ,
422- void * guest_code )
421+ struct kvm_vm * __vm_create_shape_with_one_vcpu (struct vm_shape shape ,
422+ struct kvm_vcpu * * vcpu ,
423+ uint64_t extra_mem_pages ,
424+ void * guest_code )
423425{
424426 struct kvm_vcpu * vcpus [1 ];
425427 struct kvm_vm * vm ;
426428
427- vm = __vm_create_with_vcpus (VM_MODE_DEFAULT , 1 , extra_mem_pages ,
428- guest_code , vcpus );
429+ vm = __vm_create_with_vcpus (shape , 1 , extra_mem_pages , guest_code , vcpus );
429430
430431 * vcpu = vcpus [0 ];
431432 return vm ;
0 commit comments