Lines Matching +full:full +full:- +full:bit
1 // SPDX-License-Identifier: GPL-2.0
47 # define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
147 * is the only place that we'll guarantee both "dirty bit" and "dirty data"
149 * after setting dirty bit but before the data is written.
154 * ring-full event. It should only be read until a sem_wait() of
160 * tricky case when the ring just got full, kvm will do userspace exit due to
161 * ring full. When that happens, the very last PFN is set but actually the
163 * we found that the dirty ring is full, refused to continue the vcpu, and
167 * bit, because it's a redundant bit, and when the write happens later the bit
212 while (ret == -1 && errno == EINTR); in sem_wait_until()
235 kvm_vm_get_dirty_log(vcpu->vm, slot, bitmap); in dirty_log_collect_dirty_pages()
242 kvm_vm_get_dirty_log(vcpu->vm, slot, bitmap); in clear_log_collect_dirty_pages()
243 kvm_vm_clear_dirty_log(vcpu->vm, slot, bitmap, 0, num_pages); in clear_log_collect_dirty_pages()
259 struct kvm_run *run = vcpu->run; in default_after_vcpu_run()
261 TEST_ASSERT(ret == 0 || (ret == -1 && err == EINTR), in default_after_vcpu_run()
266 exit_reason_str(run->exit_reason)); in default_after_vcpu_run()
283 * We rely on vcpu exit due to full dirty ring state. Adjust in dirty_ring_create_vm_done()
285 * full dirty ring state. in dirty_ring_create_vm_done()
287 pages = (1ul << (DIRTY_MEM_BITS - vm->page_shift)) + 3; in dirty_ring_create_vm_done()
288 pages = vm_adjust_num_guest_pages(vm->mode, pages); in dirty_ring_create_vm_done()
289 if (vm->page_size < getpagesize()) in dirty_ring_create_vm_done()
290 pages = vm_num_host_pages(vm->mode, pages); in dirty_ring_create_vm_done()
292 limit = 1 << (31 - __builtin_clz(pages)); in dirty_ring_create_vm_done()
293 test_dirty_ring_count = 1 << (31 - __builtin_clz(test_dirty_ring_count)); in dirty_ring_create_vm_done()
307 return smp_load_acquire(&gfn->flags) == KVM_DIRTY_GFN_F_DIRTY; in dirty_gfn_is_dirtied()
312 smp_store_release(&gfn->flags, KVM_DIRTY_GFN_F_RESET); in dirty_gfn_set_collected()
326 TEST_ASSERT(cur->slot == slot, "Slot number didn't match: " in dirty_ring_collect_one()
327 "%u != %u", cur->slot, slot); in dirty_ring_collect_one()
328 TEST_ASSERT(cur->offset < num_pages, "Offset overflow: " in dirty_ring_collect_one()
329 "0x%llx >= 0x%x", cur->offset, num_pages); in dirty_ring_collect_one()
330 //pr_info("fetch 0x%x page %llu\n", *fetch_index, cur->offset); in dirty_ring_collect_one()
331 __set_bit_le(cur->offset, bitmap); in dirty_ring_collect_one()
332 dirty_ring_last_page = cur->offset; in dirty_ring_collect_one()
365 * This is not a ring-full event, it's safe to allow in dirty_ring_collect_dirty_pages()
377 cleared = kvm_vm_reset_dirty_ring(vcpu->vm); in dirty_ring_collect_dirty_pages()
388 "Didn't continue vcpu even without ring full"); in dirty_ring_collect_dirty_pages()
397 struct kvm_run *run = vcpu->run; in dirty_ring_after_vcpu_run()
399 /* A ucall-sync or ring-full event is allowed */ in dirty_ring_after_vcpu_run()
403 } else if (run->exit_reason == KVM_EXIT_DIRTY_RING_FULL || in dirty_ring_after_vcpu_run()
404 (ret == -1 && err == EINTR)) { in dirty_ring_after_vcpu_run()
407 run->exit_reason == KVM_EXIT_DIRTY_RING_FULL); in dirty_ring_after_vcpu_run()
411 "dirty ring is full" : "vcpu is kicked out"); in dirty_ring_after_vcpu_run()
417 exit_reason_str(run->exit_reason)); in dirty_ring_after_vcpu_run()
435 .name = "dirty-log",
440 .name = "clear-log",
447 .name = "dirty-ring",
457 * bit set in the _next_ iteration. For example, if we detected the
459 * page bit is cleared in the latest bitmap, then the system must
478 if (mode->supported) in log_mode_supported()
479 return mode->supported(); in log_mode_supported()
488 if (mode->create_vm_done) in log_mode_create_vm_done()
489 mode->create_vm_done(vm); in log_mode_create_vm_done()
498 TEST_ASSERT(mode->collect_dirty_pages != NULL, in log_mode_collect_dirty_pages()
500 mode->collect_dirty_pages(vcpu, slot, bitmap, num_pages, ring_buf_idx); in log_mode_collect_dirty_pages()
507 if (mode->after_vcpu_run) in log_mode_after_vcpu_run()
508 mode->after_vcpu_run(vcpu, ret, err); in log_mode_after_vcpu_run()
523 struct kvm_vm *vm = vcpu->vm; in vcpu_worker()
528 sigset_t *sigset = (sigset_t *) &sigmask->sigset; in vcpu_worker()
532 * ioctl to return with -EINTR, but it is still pending and we need in vcpu_worker()
535 sigmask->len = 8; in vcpu_worker()
551 if (ret == -1 && errno == EINTR) { in vcpu_worker()
552 int sig = -1; in vcpu_worker()
578 "Page %"PRIu64" should have its dirty bit " in vm_dirty_log_verify()
589 * If the bit is set, the value written onto in vm_dirty_log_verify()
594 *value_ptr == iteration - 1); in vm_dirty_log_verify()
597 if (*value_ptr == iteration - 2 && min_iter <= iteration - 2) { in vm_dirty_log_verify()
602 * dirty ring full in iteration N-2. in vm_dirty_log_verify()
608 * -------- -------- in vm_dirty_log_verify()
610 * write 1 to page 0~(R-1) in vm_dirty_log_verify()
611 * full, vmexit in vm_dirty_log_verify()
612 * collect 0~(R-1) in vm_dirty_log_verify()
614 * write 1 to (R-1)~(2R-2) in vm_dirty_log_verify()
615 * full, vmexit in vm_dirty_log_verify()
617 * collect (R-1)~(2R-2) in vm_dirty_log_verify()
619 * write 1 to (2R-2) in vm_dirty_log_verify()
621 * write 2 to (2R-1)~(3R-3) in vm_dirty_log_verify()
622 * full, vmexit in vm_dirty_log_verify()
624 * collect (2R-2)~(3R-3) in vm_dirty_log_verify()
626 * "2R-2" is 1, while iter=3!!!) in vm_dirty_log_verify()
630 min_iter = iteration - 1; in vm_dirty_log_verify()
651 * (iteration-1) if that write can happen in vm_dirty_log_verify()
654 * (1) increase loop count to "iteration-1" in vm_dirty_log_verify()
656 * "iteration-1") in vm_dirty_log_verify()
657 * (3) get dirty log for "iteration-1"; we'll in vm_dirty_log_verify()
658 * see that page P bit is set (dirtied), in vm_dirty_log_verify()
659 * and not set the bit in host_bmap_track in vm_dirty_log_verify()
664 * value "iteration-1". in vm_dirty_log_verify()
726 2ul << (DIRTY_MEM_BITS - PAGE_SHIFT_4K), guest_code); in run_test()
728 guest_page_size = vm->page_size; in run_test()
733 guest_num_pages = (1ul << (DIRTY_MEM_BITS - vm->page_shift)) + 3; in run_test()
739 if (!p->phys_offset) { in run_test()
740 guest_test_phys_mem = (vm->max_gfn - guest_num_pages) * in run_test()
744 guest_test_phys_mem = p->phys_offset; in run_test()
797 while (iteration < p->iterations) { in run_test()
799 usleep(p->interval * 1000); in run_test()
812 * GUEST_SYNC but instead we stopped because ring is full; in run_test()
813 * that's okay too because ring full means we're only missing in run_test()
828 if (++iteration == p->iterations) in run_test()
849 printf("usage: %s [-h] [-i iterations] [-I interval] " in help()
850 "[-p offset] [-m mode]\n", name); in help()
852 printf(" -c: hint to dirty ring size, in number of entries\n"); in help()
853 printf(" (only useful for dirty-ring test; default: %"PRIu32")\n", in help()
855 printf(" -i: specify iteration counts (default: %"PRIu64")\n", in help()
857 printf(" -I: specify interval in ms (default: %"PRIu64" ms)\n", in help()
859 printf(" -p: specify guest physical test memory offset\n" in help()
861 printf(" -M: specify the host logging mode " in help()
883 while ((opt = getopt(argc, argv, "c:hi:I:p:m:M:")) != -1) { in main()