2 * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
3 * Copyright (c) 2015-2017 The strace developers.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "xlat/uffd_flags.h"
36 printflags(uffd_flags, tcp->u_arg[0], "UFFD_???");
38 return RVAL_DECODED | RVAL_FD;
41 #ifdef HAVE_LINUX_USERFAULTFD_H
42 # include <linux/ioctl.h>
43 # include <linux/userfaultfd.h>
45 # include "xlat/uffd_api_flags.h"
46 # include "xlat/uffd_copy_flags.h"
47 # include "xlat/uffd_register_ioctl_flags.h"
48 # include "xlat/uffd_register_mode_flags.h"
49 # include "xlat/uffd_zeropage_flags.h"
52 tprintf_uffdio_range(const struct uffdio_range *range)
54 tprintf("{start=%#" PRI__x64 ", len=%#" PRI__x64 "}",
55 range->start, range->len);
59 uffdio_ioctl(struct tcb *const tcp, const unsigned int code,
60 const kernel_ulong_t arg)
67 if (umove_or_printaddr(tcp, arg, &ua))
68 return RVAL_DECODED | 1;
69 /* Features is intended to contain some flags, but
70 * there aren't any defined yet.
72 tprintf("{api=%#" PRI__x64
73 ", features=%#" PRI__x64,
76 if (!syserror(tcp) && !umove(tcp, arg, &ua)) {
77 tprintf(", features.out=%#" PRI__x64
78 ", ioctls=", ua.features);
79 printflags64(uffd_api_flags, ua.ioctls,
88 struct uffdio_copy uc;
91 if (umove_or_printaddr(tcp, arg, &uc))
92 return RVAL_DECODED | 1;
93 tprintf("{dst=%#" PRI__x64 ", src=%#" PRI__x64
94 ", len=%#" PRI__x64 ", mode=",
95 uc.dst, uc.src, uc.len);
96 printflags64(uffd_copy_flags, uc.mode,
99 if (!syserror(tcp) && !umove(tcp, arg, &uc))
100 tprintf(", copy=%#" PRI__x64, uc.copy);
106 case UFFDIO_REGISTER: {
107 struct uffdio_register ur;
110 if (umove_or_printaddr(tcp, arg, &ur))
111 return RVAL_DECODED | 1;
113 tprintf_uffdio_range(&ur.range);
115 printflags64(uffd_register_mode_flags, ur.mode,
116 "UFFDIO_REGISTER_MODE_???");
118 if (!syserror(tcp) && !umove(tcp, arg, &ur)) {
119 tprints(", ioctls=");
120 printflags64(uffd_register_ioctl_flags,
121 ur.ioctls, "UFFDIO_???");
128 case UFFDIO_UNREGISTER:
130 struct uffdio_range ura;
132 if (!umove_or_printaddr(tcp, arg, &ura))
133 tprintf_uffdio_range(&ura);
134 return RVAL_DECODED | 1;
137 case UFFDIO_ZEROPAGE: {
138 struct uffdio_zeropage uz;
141 if (umove_or_printaddr(tcp, arg, &uz))
142 return RVAL_DECODED | 1;
144 tprintf_uffdio_range(&uz.range);
146 printflags64(uffd_zeropage_flags, uz.mode,
147 "UFFDIO_ZEROPAGE_???");
149 if (!syserror(tcp) && !umove(tcp, arg, &uz))
150 tprintf(", zeropage=%#" PRI__x64, uz.zeropage);
160 #endif /* HAVE_LINUX_USERFAULTFD_H */