Lines Matching +full:addr +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0
41 # define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
42 # define test_bit_le(nr, addr) \ argument
43 test_bit((nr) ^ BITOP_LE_SWIZZLE, addr)
44 # define set_bit_le(nr, addr) \ argument
45 set_bit((nr) ^ BITOP_LE_SWIZZLE, addr)
46 # define clear_bit_le(nr, addr) \ argument
47 clear_bit((nr) ^ BITOP_LE_SWIZZLE, addr)
48 # define test_and_set_bit_le(nr, addr) \ argument
49 test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, addr)
50 # define test_and_clear_bit_le(nr, addr) \ argument
51 test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, addr)
91 uint64_t addr; in guest_code() local
101 addr = guest_test_virt_mem + i * guest_page_size; in guest_code()
102 *(uint64_t *)addr = READ_ONCE(iteration); in guest_code()
107 addr = guest_test_virt_mem; in guest_code()
108 addr += (READ_ONCE(random_array[i]) % guest_num_pages) in guest_code()
110 addr &= ~(host_page_size - 1); in guest_code()
111 *(uint64_t *)addr = READ_ONCE(iteration); in guest_code()
144 /* Mode of logging to test. Default is to run all supported modes */
146 /* Logging mode for current run */
183 /* Return true if this mode is supported, otherwise false */
192 .name = "dirty-log",
196 .name = "clear-log",
224 struct log_mode *mode = &log_modes[host_log_mode]; in log_mode_supported() local
226 if (mode->supported) in log_mode_supported()
227 return mode->supported(); in log_mode_supported()
234 struct log_mode *mode = &log_modes[host_log_mode]; in log_mode_create_vm_done() local
236 if (mode->create_vm_done) in log_mode_create_vm_done()
237 mode->create_vm_done(vm); in log_mode_create_vm_done()
243 struct log_mode *mode = &log_modes[host_log_mode]; in log_mode_collect_dirty_pages() local
245 TEST_ASSERT(mode->collect_dirty_pages != NULL, in log_mode_collect_dirty_pages()
246 "collect_dirty_pages() is required for any log mode!"); in log_mode_collect_dirty_pages()
247 mode->collect_dirty_pages(vm, slot, bitmap, num_pages); in log_mode_collect_dirty_pages()
281 exit_reason_str(run->exit_reason)); in vcpu_worker()
290 static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap) in vm_dirty_log_verify() argument
292 uint64_t step = vm_num_host_pages(mode, 1); in vm_dirty_log_verify()
316 *value_ptr == iteration - 1, in vm_dirty_log_verify()
326 * (iteration-1) if that write can happen in vm_dirty_log_verify()
329 * (1) increase loop count to "iteration-1" in vm_dirty_log_verify()
331 * "iteration-1") in vm_dirty_log_verify()
332 * (3) get dirty log for "iteration-1"; we'll in vm_dirty_log_verify()
339 * value "iteration-1". in vm_dirty_log_verify()
357 static struct kvm_vm *create_vm(enum vm_guest_mode mode, uint32_t vcpuid, in create_vm() argument
363 pr_info("Testing guest mode: %s\n", vm_guest_mode_string(mode)); in create_vm()
365 vm = vm_create(mode, DEFAULT_GUEST_PHY_PAGES + extra_pg_pages, O_RDWR); in create_vm()
378 static void run_test(enum vm_guest_mode mode, unsigned long iterations, in run_test() argument
386 print_skip("Log mode '%s' not supported", in run_test()
399 vm = create_vm(mode, VCPU_ID, in run_test()
400 2ul << (DIRTY_MEM_BITS - PAGE_SHIFT_4K), in run_test()
408 guest_num_pages = (1ul << (DIRTY_MEM_BITS - in run_test()
410 guest_num_pages = vm_adjust_num_guest_pages(mode, guest_num_pages); in run_test()
413 host_num_pages = vm_num_host_pages(mode, guest_num_pages); in run_test()
416 guest_test_phys_mem = (vm_get_max_gfn(vm) - in run_test()
418 guest_test_phys_mem &= ~(host_page_size - 1); in run_test()
425 guest_test_phys_mem &= ~((1 << 20) - 1); in run_test()
472 vm_dirty_log_verify(mode, bmap); in run_test()
497 #define guest_mode_init(mode, supported, enabled) ({ \ argument
498 guest_modes[mode] = (struct guest_mode){ supported, enabled }; \
506 printf("usage: %s [-h] [-i iterations] [-I interval] " in help()
507 "[-p offset] [-m mode]\n", name); in help()
509 printf(" -i: specify iteration counts (default: %"PRIu64")\n", in help()
511 printf(" -I: specify interval in ms (default: %"PRIu64" ms)\n", in help()
513 printf(" -p: specify guest physical test memory offset\n" in help()
515 printf(" -M: specify the host logging mode " in help()
518 printf(" -m: specify the guest mode ID to test " in help()
521 " Guest mode IDs:\n"); in help()
536 unsigned int mode; in main() local
561 while ((opt = getopt(argc, argv, "hi:I:p:m:M:")) != -1) { in main()
578 mode = strtoul(optarg, NULL, 10); in main()
579 TEST_ASSERT(mode < NUM_VM_MODES, in main()
580 "Guest mode ID %d too big", mode); in main()
581 guest_modes[mode].enabled = true; in main()
590 pr_info("Setting log mode to: '%s'\n", in main()
597 printf("Log mode '%s' invalid. Please choose " in main()
622 "Guest mode ID %d (%s) not supported.", in main()
625 /* Run each log mode */ in main()
627 pr_info("Testing Log Mode '%s'\n", in main()