[LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD

Cyril Hrubis chrubis@suse.cz
Wed Apr 29 13:07:50 CEST 2026


Hi!
>  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");
> +		}

The tst_syscall() code has already branch that checks for ENOSYS and
calls tst_brk(TCONF, ...) which looks like:

#define TST_SYSCALL_BRK__(NR, SNR) ({ \
tst_brk(TCONF, \
        "syscall(%d) " SNR " not supported on your arch", NR); \
})

#define tst_syscall(NR, ...) ({ \
intptr_t tst_ret; \
if (NR == __LTP__NR_INVALID_SYSCALL) { \
        errno = ENOSYS; \
        tst_ret = -1; \
} else { \
        tst_ret = syscall(NR, ##__VA_ARGS__); \
} \
if (tst_ret == -1 && errno == ENOSYS) { \
        TST_SYSCALL_BRK__(NR, #NR); \
} \
tst_ret; \
})

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list