KVM: selftests: Verify KVM correctly handles mprotect(PROT_READ)
authorSean Christopherson <seanjc@google.com>
Thu, 28 Nov 2024 00:55:44 +0000 (16:55 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 18 Dec 2024 22:15:02 +0000 (14:15 -0800)
commitb6c304aec6483f6cd254df690eda35b225cd856c
tree388c6e01da5e51b48d4ef3702c60ee647ef56e05
parent80b7859a3a43ff8bb924947a03b144626aeb1d0c
KVM: selftests: Verify KVM correctly handles mprotect(PROT_READ)

Add two phases to mmu_stress_test to verify that KVM correctly handles
guest memory that was writable, and then made read-only in the primary MMU,
and then made writable again.

Add bonus coverage for x86 and arm64 to verify that all of guest memory was
marked read-only.  Making forward progress (without making memory writable)
requires arch specific code to skip over the faulting instruction, but the
test can at least verify each vCPU's starting page was made read-only for
other architectures.

Link: https://lore.kernel.org/r/20241128005547.4077116-14-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/mmu_stress_test.c