Skip to content

Commit 67428ee

Browse files
committed
KVM: selftests: Sync dirty_log_test iteration to guest *before* resuming
Sync the new iteration to the guest prior to restarting the vCPU, otherwise it's possible for the vCPU to dirty memory for the next iteration using the current iteration's value. Note, because the guest can be interrupted between the vCPU's load of the iteration and its write to memory, it's still possible for the guest to store the previous iteration to memory as the previous iteration may be cached in a CPU register (which the test accounts for). Note #2, the test's current approach of collecting dirty entries *before* stopping the vCPU also results dirty memory having the previous iteration. E.g. if page is dirtied in the previous iteration, but not the current iteration, the verification phase will observe the previous iteration's value in memory. That wart will be remedied in the near future, at which point synchronizing the iteration before restarting the vCPU will guarantee the only way for verification to observe stale iterations is due to the CPU register caching case, or due to a dirty entry being collected before the store retires. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent fe49f80 commit 67428ee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/kvm/dirty_log_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,9 +859,9 @@ static void run_test(enum vm_guest_mode mode, void *arg)
859859
*/
860860
if (++iteration == p->iterations)
861861
WRITE_ONCE(host_quit, true);
862+
sync_global_to_guest(vm, iteration);
862863

863864
sem_post(&sem_vcpu_cont);
864-
sync_global_to_guest(vm, iteration);
865865
}
866866

867867
pthread_join(vcpu_thread, NULL);

0 commit comments

Comments
 (0)