From: Ricardo Branco <rbranco@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 1/3] userfaultfd: Add helper for checking UFFD feature support
Date: Thu, 7 May 2026 14:28:53 +0200 [thread overview]
Message-ID: <20260507122858.19670-1-rbranco@suse.de> (raw)
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
next reply other threads:[~2026-05-07 12:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 12:28 Ricardo Branco [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260507122858.19670-1-rbranco@suse.de \
--to=rbranco@suse.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox