Skip to content

Commit 2020d3b

Browse files
committed
KVM: selftests: Tighten checks around prev iter's last dirty page in ring
Now that each iteration collects all dirty entries and ensures the guest *completes* at least one write, tighten the exemptions for the last dirty page of the previous iteration. Specifically, the only legal value (other than the current iteration) is N-1. Unlike the last page for the current iteration, the in-progress write from the previous iteration is guaranteed to have completed, otherwise the test would have hung. Reviewed-by: Maxim Levitsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 73eaa2a commit 2020d3b

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

tools/testing/selftests/kvm/dirty_log_test.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,14 +517,22 @@ static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long **bmap)
517517

518518
if (host_log_mode == LOG_MODE_DIRTY_RING) {
519519
/*
520-
* The last page in the ring from this iteration
521-
* or the previous can be written with the value
522-
* from the previous iteration (relative to the
523-
* last page's iteration), as the value to be
524-
* written may be cached in a CPU register.
520+
* The last page in the ring from previous
521+
* iteration can be written with the value
522+
* from the previous iteration, as the value to
523+
* be written may be cached in a CPU register.
525524
*/
526-
if ((page == dirty_ring_last_page ||
527-
page == dirty_ring_prev_iteration_last_page) &&
525+
if (page == dirty_ring_prev_iteration_last_page &&
526+
val == iteration - 1)
527+
continue;
528+
529+
/*
530+
* Any value from a previous iteration is legal
531+
* for the last entry, as the write may not yet
532+
* have retired, i.e. the page may hold whatever
533+
* it had before this iteration started.
534+
*/
535+
if (page == dirty_ring_last_page &&
528536
val < iteration)
529537
continue;
530538
} else if (!val && iteration == 1 && bmap0_dirty) {

0 commit comments

Comments
 (0)