KVM: selftests: Add coverage of EPT-disabled to vmx_dirty_log_test
authorDavid Matlack <dmatlack@google.com>
Fri, 15 Mar 2024 23:05:41 +0000 (16:05 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 11 Apr 2024 19:58:52 +0000 (12:58 -0700)
commit40e0ee6338f0c042c0dabe1f17eb76eac37b5425
tree3132398df788b7dc17fbed26b937ec43ddf45dd4
parentb1a8d2b02b69c7d7685f2e19f32034065310dbae
KVM: selftests: Add coverage of EPT-disabled to vmx_dirty_log_test

Extend vmx_dirty_log_test to include accesses made by L2 when EPT is
disabled.

This commit adds explicit coverage of a bug caught by syzkaller, where
the TDP MMU would clear D-bits instead of write-protecting SPTEs being
used to map an L2, which only happens when L1 does not enable EPT,
causing writes made by L2 to not be reflected in the dirty log when PML
is enabled:

  $ ./vmx_dirty_log_test
  Nested EPT: disabled
  ==== Test Assertion Failure ====
    x86_64/vmx_dirty_log_test.c:151: test_bit(0, bmap)
    pid=72052 tid=72052 errno=4 - Interrupted system call
    (stack trace empty)
    Page 0 incorrectly reported clean

Opportunistically replace the volatile casts with {READ,WRITE}_ONCE().

Link: https://lore.kernel.org/kvm/000000000000c6526f06137f18cc@google.com/
Signed-off-by: David Matlack <dmatlack@google.com>
Link: https://lore.kernel.org/r/20240315230541.1635322-5-dmatlack@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c