KVM: selftests: aarch64: Relax userfaultfd read vs. write checks
authorRicardo Koller <ricarkol@google.com>
Fri, 27 Jan 2023 21:43:50 +0000 (21:43 +0000)
committerMarc Zyngier <maz@kernel.org>
Sun, 29 Jan 2023 18:49:08 +0000 (18:49 +0000)
commit0dd8d22a887a473f6f11abf556c4f7944ab5ef1d
treede06a588fc4094e0d841fb96fe6dbbff83e0a1b1
parent6028acbe3a5f2119a2a6ddd3e06453c87c09cae0
KVM: selftests: aarch64: Relax userfaultfd read vs. write checks

Only Stage1 Page table walks (S1PTW) writing a PTE on an unmapped page
should result in a userfaultfd write. However, the userfaultfd tests in
page_fault_test wrongly assert that any S1PTW is a PTE write.

Fix this by relaxing the read vs. write checks in all userfaultfd
handlers.  Note that this is also an attempt to focus less on KVM (and
userfaultfd) behavior, and more on architectural behavior. Also note
that after commit 406504c7b040 ("KVM: arm64: Fix S1PTW handling on RO
memslots"), the userfaultfd fault (S1PTW with AF on an unmaped PTE
page) is actually a read: the translation fault that comes before the
permission fault.

Signed-off-by: Ricardo Koller <ricarkol@google.com>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230127214353.245671-2-ricarkol@google.com
tools/testing/selftests/kvm/aarch64/page_fault_test.c