KVM: selftests: Add tests in xen_shinfo_test to detect lock races
authorMichal Luczaj <mhal@rbox.co>
Thu, 13 Oct 2022 21:12:33 +0000 (21:12 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 28 Oct 2022 10:10:27 +0000 (06:10 -0400)
commita51abbbf25317c07cb00b40ae7d04a209d2a3d54
tree9c7c70859b3392cfa472e6a3ab023a429fec1100
parentecbcf030b45666ad11bc98565e71dfbcb7be4393
KVM: selftests: Add tests in xen_shinfo_test to detect lock races

Tests for races between shinfo_cache (de)activation and hypercall+ioctl()
processing.  KVM has had bugs where activating the shared info cache
multiple times and/or with concurrent users results in lock corruption,
NULL pointer dereferences, and other fun.

For the timer injection testcase (#22), re-arm the timer until the IRQ
is successfully injected.  If the timer expires while the shared info
is deactivated (invalid), KVM will drop the event.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
Co-developed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20221013211234.1318131-16-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c