Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v4 1/3] userfaultfd: Add helper for checking UFFD feature support
@ 2026-05-07 12:28 Ricardo Branco
  2026-05-07 12:28 ` [LTP] [PATCH v4 2/3] userfaultfd: Use two-step handshake to probe features Ricardo Branco
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Ricardo Branco @ 2026-05-07 12:28 UTC (permalink / raw)
  To: ltp

Add CHECK_UFFD_FEATURE() to perform the initial UFFDIO_API handshake
without requesting optional features and verify that the kernel reports
the requested feature bit.

Signed-off-by: Ricardo Branco <rbranco@suse.de>
---
 include/lapi/userfaultfd.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/lapi/userfaultfd.h b/include/lapi/userfaultfd.h
index aab3890b7..170dfadd4 100644
--- a/include/lapi/userfaultfd.h
+++ b/include/lapi/userfaultfd.h
@@ -277,4 +277,24 @@ retry:
 	return ret;
 }
 
+#define CHECK_UFFD_FEATURE(feature)	check_uffd_feature(feature, #feature)
+
+static inline void check_uffd_feature(uint64_t feature, const char *name)
+{
+	struct uffdio_api uffdio_api = {};
+	int uffd;
+
+	uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
+
+	uffdio_api.api = UFFD_API;
+	SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
+
+	if (!(uffdio_api.features & feature)) {
+		SAFE_CLOSE(uffd);
+		tst_brk(TCONF, "%s not supported", name);
+	}
+
+	SAFE_CLOSE(uffd);
+}
+
 #endif /* LAPI_USERFAULTFD_H__ */
-- 
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [LTP] [PATCH v3 1/2] userfaultfd: Add helper for checking UFFD feature support
@ 2026-05-07  8:31 Ricardo Branco
  2026-05-07  9:40 ` [LTP] " linuxtestproject.agent
  0 siblings, 1 reply; 12+ messages in thread
From: Ricardo Branco @ 2026-05-07  8:31 UTC (permalink / raw)
  To: ltp

Add CHECK_UFFD_FEATURE() to perform the initial UFFDIO_API handshake
without requesting optional features and verify that the kernel reports
the requested feature bit.

Signed-off-by: Ricardo Branco <rbranco@suse.de>
---
 include/lapi/userfaultfd.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/lapi/userfaultfd.h b/include/lapi/userfaultfd.h
index aab3890b7..170dfadd4 100644
--- a/include/lapi/userfaultfd.h
+++ b/include/lapi/userfaultfd.h
@@ -277,4 +277,24 @@ retry:
 	return ret;
 }
 
+#define CHECK_UFFD_FEATURE(feature)	check_uffd_feature(feature, #feature)
+
+static inline void check_uffd_feature(uint64_t feature, const char *name)
+{
+	struct uffdio_api uffdio_api = {};
+	int uffd;
+
+	uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
+
+	uffdio_api.api = UFFD_API;
+	SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
+
+	if (!(uffdio_api.features & feature)) {
+		SAFE_CLOSE(uffd);
+		tst_brk(TCONF, "%s not supported", name);
+	}
+
+	SAFE_CLOSE(uffd);
+}
+
 #endif /* LAPI_USERFAULTFD_H__ */
-- 
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-05-07 16:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 12:28 [LTP] [PATCH v4 1/3] userfaultfd: Add helper for checking UFFD feature support Ricardo Branco
2026-05-07 12:28 ` [LTP] [PATCH v4 2/3] userfaultfd: Use two-step handshake to probe features Ricardo Branco
2026-05-07 12:36   ` Andrea Cervesato via ltp
2026-05-07 12:28 ` [LTP] [PATCH v4 3/3] userfaultfd: Reset wp_fault_seen on each run() Ricardo Branco
2026-05-07 12:36   ` Andrea Cervesato via ltp
2026-05-07 12:40 ` [LTP] [PATCH v4 1/3] userfaultfd: Add helper for checking UFFD feature support Andrea Cervesato via ltp
2026-05-07 14:20 ` Cyril Hrubis
2026-05-07 14:22 ` [LTP] " linuxtestproject.agent
2026-05-07 14:40   ` Andrea Cervesato via ltp
2026-05-07 14:43     ` Cyril Hrubis
2026-05-07 16:57       ` Andrea Cervesato via ltp
  -- strict thread matches above, loose matches on Subject: below --
2026-05-07  8:31 [LTP] [PATCH v3 1/2] " Ricardo Branco
2026-05-07  9:40 ` [LTP] " linuxtestproject.agent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox