]> granicus.if.org Git - strace/commitdiff
Implement userfaultfd syscall decoding
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 15 Nov 2015 02:22:44 +0000 (02:22 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 17 Nov 2015 00:40:22 +0000 (00:40 +0000)
* userfaultfd.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/uffd_flags.in: New file.
* linux/dummy.h (userfaultfd): Remove.
* tests/userfaultfd.c: New file.
* tests/userfaultfd.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add userfaultfd.
(TESTS): Add userfaultfd.test.
* tests/.gitignore: Add userfaultfd.

Makefile.am
linux/dummy.h
tests/.gitignore
tests/Makefile.am
tests/userfaultfd.c [new file with mode: 0644]
tests/userfaultfd.test [new file with mode: 0755]
userfaultfd.c [new file with mode: 0644]
xlat/uffd_flags.in [new file with mode: 0644]

index 8070ba3e3ad7a33764e05c0d036328831e0c4d1c..82cd7ca8f1416c4e8829d397215c2632662b35fa 100644 (file)
@@ -154,6 +154,7 @@ strace_SOURCES =    \
        umask.c         \
        umount.c        \
        uname.c         \
+       userfaultfd.c   \
        util.c          \
        utime.c         \
        utimes.c        \
index 3a333ac34d57d2f7b073904a87178c02e3eef209..6c8d1452a563989b6e3ba97edd3f5e0d5ef7ae35 100644 (file)
@@ -42,7 +42,6 @@
 #define        sys_name_to_handle_at   printargs
 #define        sys_open_by_handle_at   printargs
 #define        sys_sysfs               printargs
-#define        sys_userfaultfd         printargs
 #define        sys_vm86                printargs
 #define        sys_vm86old             printargs
 
index 62574686f4cf1c2db7f7d2dc0ceba3f1312a045a..c886eb92af98d0adc60c704cf5eb58a335420098 100644 (file)
@@ -65,6 +65,7 @@ uio
 umovestr
 umovestr2
 unix-pair-send-recv
+userfaultfd
 utime
 utimensat
 wait
index c52f27601f0d1e5c40cb6a93e53c89574a4d8463..e0e352f411c278e74d36e14355340d9ab843ef4b 100644 (file)
@@ -78,6 +78,7 @@ check_PROGRAMS = \
        umovestr \
        umovestr2 \
        unix-pair-send-recv \
+       userfaultfd \
        utime \
        utimensat \
        wait \
@@ -170,6 +171,7 @@ TESTS = \
        uid16.test \
        uid32.test \
        uio.test \
+       userfaultfd.test \
        utime.test \
        utimensat.test \
        wait.test \
diff --git a/tests/userfaultfd.c b/tests/userfaultfd.c
new file mode 100644 (file)
index 0000000..2dcf31c
--- /dev/null
@@ -0,0 +1,26 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+int
+main(void)
+{
+#if defined __NR_userfaultfd && defined O_CLOEXEC
+       if (syscall(__NR_userfaultfd, 1 | O_NONBLOCK | O_CLOEXEC) != -1)
+               return 77;
+       printf("userfaultfd(O_NONBLOCK|O_CLOEXEC|0x1) = -1 %s\n",
+              errno == ENOSYS ?
+                       "ENOSYS (Function not implemented)" :
+                       "EINVAL (Invalid argument)");
+       puts("+++ exited with 0 +++");
+       return 0;
+#else
+        return 77;
+#endif
+}
diff --git a/tests/userfaultfd.test b/tests/userfaultfd.test
new file mode 100755 (executable)
index 0000000..b9c8368
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Check userfaultfd syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -a38 -euserfaultfd $args > "$OUT"
+match_diff "$OUT" "$LOG"
+rm -f "$OUT"
+
+exit 0
diff --git a/userfaultfd.c b/userfaultfd.c
new file mode 100644 (file)
index 0000000..7f8e3e4
--- /dev/null
@@ -0,0 +1,11 @@
+#include "defs.h"
+#include <fcntl.h>
+
+#include "xlat/uffd_flags.h"
+
+SYS_FUNC(userfaultfd)
+{
+       printflags(uffd_flags, tcp->u_arg[0], "UFFD_???");
+
+       return RVAL_DECODED | RVAL_FD;
+}
diff --git a/xlat/uffd_flags.in b/xlat/uffd_flags.in
new file mode 100644 (file)
index 0000000..fb0338b
--- /dev/null
@@ -0,0 +1,2 @@
+O_NONBLOCK
+O_CLOEXEC