Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
@ 2026-04-29  6:40 Wake Liu via ltp
  2026-04-29  6:52 ` Andrea Cervesato via ltp
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Wake Liu via ltp @ 2026-04-29  6:40 UTC (permalink / raw)
  To: ltp; +Cc: Wake Liu, camann, rbranco

When CONFIG_USERFAULTFD is not enabled in the kernel, the userfaultfd
syscall returns ENOSYS. Currently, SAFE_USERFAULTFD calls tst_brk(TBROK)
for any error other than EPERM, causing tests to fail when they should
be skipped.

Add a check for ENOSYS to return TCONF, so that tests using
SAFE_USERFAULTFD are skipped appropriately on kernels without
userfaultfd support.

Signed-off-by: Wake Liu <wakel@google.com>
---
 include/lapi/userfaultfd.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/lapi/userfaultfd.h b/include/lapi/userfaultfd.h
index 0c9e34c84..09126d856 100644
--- a/include/lapi/userfaultfd.h
+++ b/include/lapi/userfaultfd.h
@@ -244,6 +244,10 @@ static inline int safe_userfaultfd(const char *file, const int lineno, int
 retry:
 	ret = tst_syscall(__NR_userfaultfd, flags);
 	if (ret == -1) {
+		if (errno == ENOSYS) {
+			tst_brk_(file, lineno, TCONF | TERRNO,
+				"userfaultfd() is not supported by this kernel");
+		}
 		if (errno == EPERM) {
 			if (retry && !(flags & UFFD_USER_MODE_ONLY)) {
 				flags |= UFFD_USER_MODE_ONLY;
-- 
2.54.0.545.g6539524ca2-goog


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

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

end of thread, other threads:[~2026-05-06 15:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29  6:40 [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD Wake Liu via ltp
2026-04-29  6:52 ` Andrea Cervesato via ltp
2026-04-29  8:51   ` Wake Liu via ltp
2026-04-29  9:22     ` Andrea Cervesato via ltp
2026-04-29  9:48       ` Wake Liu via ltp
2026-04-29 10:02         ` Andrea Cervesato via ltp
2026-04-29 10:12           ` [LTP] [PATCH] syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y Wake Liu via ltp
2026-04-29 12:22             ` [LTP] " linuxtestproject.agent
2026-05-06 15:52             ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-05-06 15:57             ` Andrea Cervesato via ltp
2026-04-29  7:31 ` [LTP] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD linuxtestproject.agent
2026-04-29  7:36   ` Andrea Cervesato via ltp
2026-04-29 11:07 ` [LTP] [PATCH] " Cyril Hrubis

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