Lines Matching refs:vm
102 static void create_main_memslot(struct kvm_vm *vm) in create_main_memslot() argument
106 vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, 0, 0, MAIN_PAGE_COUNT, 0); in create_main_memslot()
109 vm->memslots[i] = 0; in create_main_memslot()
112 static void create_test_memslot(struct kvm_vm *vm) in create_test_memslot() argument
114 vm_userspace_mem_region_add(vm, in create_test_memslot()
116 TEST_DATA_START_GFN << vm->page_shift, in create_test_memslot()
121 vm->memslots[MEM_REGION_TEST_DATA] = TEST_DATA_MEMSLOT; in create_test_memslot()
124 static void create_memslots(struct kvm_vm *vm) in create_memslots() argument
140 create_main_memslot(vm); in create_memslots()
141 create_test_memslot(vm); in create_memslots()
144 static void finish_vm_setup(struct kvm_vm *vm) in finish_vm_setup() argument
148 kvm_vm_elf_load(vm, program_invocation_name); in finish_vm_setup()
150 slot0 = memslot2region(vm, 0); in finish_vm_setup()
151 ucall_init(vm, slot0->region.guest_phys_addr + slot0->region.memory_size); in finish_vm_setup()
153 kvm_arch_vm_post_create(vm); in finish_vm_setup()
158 struct kvm_vm *vm; in create_vm_two_memslots() local
160 vm = create_vm(); in create_vm_two_memslots()
162 create_memslots(vm); in create_vm_two_memslots()
164 finish_vm_setup(vm); in create_vm_two_memslots()
166 return vm; in create_vm_two_memslots()
169 static void enable_cmma(struct kvm_vm *vm) in enable_cmma() argument
173 r = __kvm_device_attr_set(vm->fd, KVM_S390_VM_MEM_CTRL, KVM_S390_VM_MEM_ENABLE_CMMA, NULL); in enable_cmma()
177 static void enable_dirty_tracking(struct kvm_vm *vm) in enable_dirty_tracking() argument
179 vm_mem_region_set_flags(vm, 0, KVM_MEM_LOG_DIRTY_PAGES); in enable_dirty_tracking()
180 vm_mem_region_set_flags(vm, TEST_DATA_MEMSLOT, KVM_MEM_LOG_DIRTY_PAGES); in enable_dirty_tracking()
183 static int __enable_migration_mode(struct kvm_vm *vm) in __enable_migration_mode() argument
185 return __kvm_device_attr_set(vm->fd, in __enable_migration_mode()
192 static void enable_migration_mode(struct kvm_vm *vm) in enable_migration_mode() argument
194 int r = __enable_migration_mode(vm); in enable_migration_mode()
199 static bool is_migration_mode_on(struct kvm_vm *vm) in is_migration_mode_on() argument
204 r = __kvm_device_attr_get(vm->fd, in is_migration_mode_on()
213 static int vm_get_cmma_bits(struct kvm_vm *vm, u64 flags, int *errno_out) in vm_get_cmma_bits() argument
226 rc = __vm_ioctl(vm, KVM_S390_GET_CMMA_BITS, &args); in vm_get_cmma_bits()
234 struct kvm_vm *vm = create_vm_two_memslots(); in test_get_cmma_basic() local
239 rc = vm_get_cmma_bits(vm, 0, &errno_out); in test_get_cmma_basic()
243 enable_cmma(vm); in test_get_cmma_basic()
244 vcpu = vm_vcpu_add(vm, 1, guest_do_one_essa); in test_get_cmma_basic()
249 rc = vm_get_cmma_bits(vm, 0, &errno_out); in test_get_cmma_basic()
254 rc = vm_get_cmma_bits(vm, KVM_S390_CMMA_PEEK, &errno_out); in test_get_cmma_basic()
258 enable_dirty_tracking(vm); in test_get_cmma_basic()
259 enable_migration_mode(vm); in test_get_cmma_basic()
262 rc = vm_get_cmma_bits(vm, 0xfeedc0fe, &errno_out); in test_get_cmma_basic()
266 kvm_vm_free(vm); in test_get_cmma_basic()
279 struct kvm_vm *vm = create_vm(); in test_migration_mode() local
285 rc = __enable_migration_mode(vm); in test_migration_mode()
288 TEST_ASSERT(!is_migration_mode_on(vm), "migration mode should still be off"); in test_migration_mode()
291 create_memslots(vm); in test_migration_mode()
292 finish_vm_setup(vm); in test_migration_mode()
294 enable_cmma(vm); in test_migration_mode()
295 vcpu = vm_vcpu_add(vm, 1, guest_do_one_essa); in test_migration_mode()
306 rc = __enable_migration_mode(vm); in test_migration_mode()
309 TEST_ASSERT(!is_migration_mode_on(vm), "migration mode should still be off"); in test_migration_mode()
313 enable_dirty_tracking(vm); in test_migration_mode()
316 rc = __enable_migration_mode(vm); in test_migration_mode()
318 TEST_ASSERT(is_migration_mode_on(vm), "migration mode should be on"); in test_migration_mode()
330 TEST_ASSERT(is_migration_mode_on(vm), "migration mode should be on"); in test_migration_mode()
331 vm_userspace_mem_region_add(vm, in test_migration_mode()
333 TEST_DATA_TWO_START_GFN << vm->page_shift, in test_migration_mode()
338 TEST_ASSERT(!is_migration_mode_on(vm), in test_migration_mode()
351 vm_mem_region_set_flags(vm, TEST_DATA_TWO_MEMSLOT, KVM_MEM_LOG_DIRTY_PAGES); in test_migration_mode()
352 rc = __enable_migration_mode(vm); in test_migration_mode()
354 TEST_ASSERT(is_migration_mode_on(vm), "migration mode should be on"); in test_migration_mode()
361 TEST_ASSERT(is_migration_mode_on(vm), "migration mode should be on"); in test_migration_mode()
362 vm_mem_region_set_flags(vm, TEST_DATA_TWO_MEMSLOT, 0); in test_migration_mode()
363 TEST_ASSERT(!is_migration_mode_on(vm), in test_migration_mode()
372 kvm_vm_free(vm); in test_migration_mode()
381 static void assert_all_slots_cmma_dirty(struct kvm_vm *vm) in assert_all_slots_cmma_dirty() argument
396 vm_ioctl(vm, KVM_S390_GET_CMMA_BITS, &args); in assert_all_slots_cmma_dirty()
409 vm_ioctl(vm, KVM_S390_GET_CMMA_BITS, &args); in assert_all_slots_cmma_dirty()
422 vm_ioctl(vm, KVM_S390_GET_CMMA_BITS, &args); in assert_all_slots_cmma_dirty()
431 static void assert_no_pages_cmma_dirty(struct kvm_vm *vm) in assert_no_pages_cmma_dirty() argument
443 vm_ioctl(vm, KVM_S390_GET_CMMA_BITS, &args); in assert_no_pages_cmma_dirty()
454 struct kvm_vm *vm = create_vm_two_memslots(); in test_get_inital_dirty() local
457 enable_cmma(vm); in test_get_inital_dirty()
458 vcpu = vm_vcpu_add(vm, 1, guest_do_one_essa); in test_get_inital_dirty()
467 enable_dirty_tracking(vm); in test_get_inital_dirty()
468 enable_migration_mode(vm); in test_get_inital_dirty()
470 assert_all_slots_cmma_dirty(vm); in test_get_inital_dirty()
473 assert_no_pages_cmma_dirty(vm); in test_get_inital_dirty()
475 kvm_vm_free(vm); in test_get_inital_dirty()
478 static void query_cmma_range(struct kvm_vm *vm, in query_cmma_range() argument
489 vm_ioctl(vm, KVM_S390_GET_CMMA_BITS, res_out); in query_cmma_range()
511 struct kvm_vm *vm = create_vm_two_memslots(); in test_get_skip_holes() local
516 enable_cmma(vm); in test_get_skip_holes()
517 vcpu = vm_vcpu_add(vm, 1, guest_dirty_test_data); in test_get_skip_holes()
528 enable_dirty_tracking(vm); in test_get_skip_holes()
529 enable_migration_mode(vm); in test_get_skip_holes()
532 assert_all_slots_cmma_dirty(vm); in test_get_skip_holes()
547 query_cmma_range(vm, 0, 1, &log); in test_get_skip_holes()
559 query_cmma_range(vm, TEST_DATA_START_GFN + TEST_DATA_PAGE_COUNT, 0x20, &log); in test_get_skip_holes()
574 query_cmma_range(vm, gfn_offset, 0x20, &log); in test_get_skip_holes()
587 query_cmma_range(vm, TEST_DATA_START_GFN, 1, &log); in test_get_skip_holes()
603 query_cmma_range(vm, gfn_offset, 15, &log); in test_get_skip_holes()
616 query_cmma_range(vm, gfn_offset, 17, &log); in test_get_skip_holes()
630 query_cmma_range(vm, gfn_offset, 25, &log); in test_get_skip_holes()
640 query_cmma_range(vm, gfn_offset, 0x40 - 0x33, &log); in test_get_skip_holes()
647 query_cmma_range(vm, gfn_offset, TEST_DATA_PAGE_COUNT - 0x61, &log); in test_get_skip_holes()
650 assert_no_pages_cmma_dirty(vm); in test_get_skip_holes()
673 struct kvm_vm *vm = create_vm(); in machine_has_cmma() local
676 r = !__kvm_has_device_attr(vm->fd, KVM_S390_VM_MEM_CTRL, KVM_S390_VM_MEM_ENABLE_CMMA); in machine_has_cmma()
677 kvm_vm_free(vm); in machine_has_cmma()