KVM: selftests: Add a userfaultfd library
authorRicardo Koller <ricarkol@google.com>
Mon, 17 Oct 2022 19:58:21 +0000 (19:58 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 10 Nov 2022 19:10:27 +0000 (19:10 +0000)
commita93871d0ea9fd59fb5eb783619334183d7f07f51
tree1d0a4d9bec147f734f25a1c090c5b2bd57925b42
parent30a0b95b1335e12efef89dd78518ed3e4a71a763
KVM: selftests: Add a userfaultfd library

Move the generic userfaultfd code out of demand_paging_test.c into a
common library, userfaultfd_util. This library consists of a setup and a
stop function. The setup function starts a thread for handling page
faults using the handler callback function. This setup returns a
uffd_desc object which is then used in the stop function (to wait and
destroy the threads).

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Reviewed-by: Ben Gardon <bgardon@google.com>
Signed-off-by: Ricardo Koller <ricarkol@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221017195834.2295901-2-ricarkol@google.com
tools/testing/selftests/kvm/Makefile
tools/testing/selftests/kvm/demand_paging_test.c
tools/testing/selftests/kvm/include/userfaultfd_util.h [new file with mode: 0644]
tools/testing/selftests/kvm/lib/userfaultfd_util.c [new file with mode: 0644]