From: Sean Christopherson Date: Sat, 11 Jan 2025 00:29:59 +0000 (-0800) Subject: KVM: sefltests: Verify value of dirty_log_test last page isn't bogus X-Git-Tag: v6.15-rc1~195^2~8^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=485e27ed208f0d9667608c0e3fa9440654e01399;p=thirdparty%2Fkernel%2Flinux.git KVM: sefltests: Verify value of dirty_log_test last page isn't bogus Add a sanity check that a completely garbage value wasn't written to the last dirty page in the ring, e.g. that it doesn't contain the *next* iteration's value. Reviewed-by: Maxim Levitsky Link: https://lore.kernel.org/r/20250111003004.1235645-16-seanjc@google.com Signed-off-by: Sean Christopherson --- diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c index 3a4e411353d7d..500257b712e3f 100644 --- a/tools/testing/selftests/kvm/dirty_log_test.c +++ b/tools/testing/selftests/kvm/dirty_log_test.c @@ -514,8 +514,9 @@ static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long **bmap) * last page's iteration), as the value to be * written may be cached in a CPU register. */ - if (page == dirty_ring_last_page || - page == dirty_ring_prev_iteration_last_page) + if ((page == dirty_ring_last_page || + page == dirty_ring_prev_iteration_last_page) && + val < iteration) continue; } else if (!val && iteration == 1 && bmap0_dirty) { /*