[PATCH v1 09/13] KVM: selftests: Add va_start/end into uffd_desc

James Houghton
2024-12-04T19:14:24Z

This will be used for the self-test to look up which userfaultfd we
should be using when handling a KVM Userfault (in the event KVM
Userfault and userfaultfd are being used together).

Signed-off-by: James Houghton <jthoughton@google.com>
---
tools/testing/selftests/kvm/include/userfaultfd_util.h | 2 ++
tools/testing/selftests/kvm/lib/userfaultfd_util.c | 2 ++
2 files changed, 4 insertions(+)

diff --git a/tools/testing/selftests/kvm/include/userfaultfd_util.h b/tools/testing/selftests/kvm/include/userfaultfd_util.h
index 60f7f9d435dc..b62fecdfe745 100644
--- a/tools/testing/selftests/kvm/include/userfaultfd_util.h
+++ b/tools/testing/selftests/kvm/include/userfaultfd_util.h
@@ -30,6 +30,8 @@ struct uffd_desc {
int *pipefds;
pthread_t *readers;
struct uffd_reader_args *reader_args;
+ void *va_start;
+ void *va_end;
};

struct uffd_desc *uffd_setup_demand_paging(int uffd_mode, useconds_t delay,
diff --git a/tools/testing/selftests/kvm/lib/userfaultfd_util.c b/tools/testing/selftests/kvm/lib/userfaultfd_util.c
index 7c9de8414462..93004c85bcdc 100644
--- a/tools/testing/selftests/kvm/lib/userfaultfd_util.c
+++ b/tools/testing/selftests/kvm/lib/userfaultfd_util.c
@@ -152,6 +152,8 @@ struct uffd_desc *uffd_setup_demand_paging(int uffd_mode, useconds_t delay,
expected_ioctls, "missing userfaultfd ioctls");

uffd_desc->uffd = uffd;
+ uffd_desc->va_start = hva;
+ uffd_desc->va_end = (char *)hva + len;
for (i = 0; i < uffd_desc->num_readers; ++i) {
int pipes[2];

--
2.47.0.338.g60cca15819-goog