]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: selftests: Sync dirty_log_test iteration to guest *before* resuming
authorSean Christopherson <seanjc@google.com>
Sat, 11 Jan 2025 00:29:46 +0000 (16:29 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 12 Feb 2025 17:00:54 +0000 (09:00 -0800)
commit67428ee7b7460146db98365c4e87664f91e122ad
treef3ed7bd6d44ed1bdbea01c880c2f704969bda5f7
parentfe49f80052578cfe79411b6b47bb9ea278acbea8
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/20250111003004.1235645-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/dirty_log_test.c