Module Name: src Committed By: thorpej Date: Mon Sep 20 00:09:02 UTC 2021
Modified Files: src/sys/compat/linux/arch/alpha: syscalls.master src/sys/compat/linux/arch/amd64: syscalls.master src/sys/compat/linux/arch/arm: syscalls.master src/sys/compat/linux/arch/i386: syscalls.master src/sys/compat/linux/arch/m68k: syscalls.master src/sys/compat/linux/arch/mips: syscalls.master src/sys/compat/linux/arch/powerpc: syscalls.master src/sys/compat/linux/common: linux_misc.c src/sys/compat/linux32/arch/amd64: syscalls.master src/sys/compat/linux32/common: linux32_misc.c Log Message: Add the eventfd system calls to COMPAT_LINUX and COMPAT_LINUX32. To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/sys/compat/linux/arch/alpha/syscalls.master cvs rdiff -u -r1.64 -r1.65 src/sys/compat/linux/arch/amd64/syscalls.master cvs rdiff -u -r1.71 -r1.72 src/sys/compat/linux/arch/arm/syscalls.master cvs rdiff -u -r1.126 -r1.127 src/sys/compat/linux/arch/i386/syscalls.master cvs rdiff -u -r1.97 -r1.98 src/sys/compat/linux/arch/m68k/syscalls.master cvs rdiff -u -r1.70 -r1.71 src/sys/compat/linux/arch/mips/syscalls.master cvs rdiff -u -r1.76 -r1.77 src/sys/compat/linux/arch/powerpc/syscalls.master cvs rdiff -u -r1.252 -r1.253 src/sys/compat/linux/common/linux_misc.c cvs rdiff -u -r1.73 -r1.74 src/sys/compat/linux32/arch/amd64/syscalls.master cvs rdiff -u -r1.31 -r1.32 src/sys/compat/linux32/common/linux32_misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/linux/arch/alpha/syscalls.master diff -u src/sys/compat/linux/arch/alpha/syscalls.master:1.99 src/sys/compat/linux/arch/alpha/syscalls.master:1.100 --- src/sys/compat/linux/arch/alpha/syscalls.master:1.99 Sun Sep 19 23:51:36 2021 +++ src/sys/compat/linux/arch/alpha/syscalls.master Mon Sep 20 00:09:01 2021 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.99 2021/09/19 23:51:36 thorpej Exp $ + $NetBSD: syscalls.master,v 1.100 2021/09/20 00:09:01 thorpej Exp $ ; ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -764,7 +764,7 @@ struct linux_timespec *times, int flag); } 476 UNIMPL signalfd 477 UNIMPL timerfd -478 UNIMPL eventfd +478 STD { int|linux_sys||eventfd(unsigned int initval); } 479 STD { int|linux_sys||recvmmsg(int s, \ struct linux_mmsghdr *msgvec, unsigned int vlen, \ unsigned int flags, struct timespec *timeout); } @@ -778,7 +778,8 @@ 483 STD { int|linux_sys||timerfd_gettime(int fd, \ struct linux_itimerspec *tim); } 484 UNIMPL signalfd4 -485 UNIMPL eventfd2 +485 STD { int|linux_sys||eventfd2(unsigned int initval, \ + int flags); } 486 UNIMPL epoll_create1 487 STD { int|linux_sys||dup3(int from, int to, int flags); } 488 STD { int|linux_sys||pipe2(int *pfds, int flags); } Index: src/sys/compat/linux/arch/amd64/syscalls.master diff -u src/sys/compat/linux/arch/amd64/syscalls.master:1.64 src/sys/compat/linux/arch/amd64/syscalls.master:1.65 --- src/sys/compat/linux/arch/amd64/syscalls.master:1.64 Sun Sep 19 23:51:36 2021 +++ src/sys/compat/linux/arch/amd64/syscalls.master Mon Sep 20 00:09:01 2021 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.64 2021/09/19 23:51:36 thorpej Exp $ + $NetBSD: syscalls.master,v 1.65 2021/09/20 00:09:01 thorpej Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -521,7 +521,7 @@ 282 UNIMPL signalfd 283 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ int flags); } -284 UNIMPL eventfd +284 STD { int|linux_sys||eventfd(unsigned int initval); } 285 STD { int|linux_sys||fallocate(int fd, int mode, \ off_t offset, off_t len); } 286 STD { int|linux_sys||timerfd_settime(int fd, int flags, \ @@ -533,7 +533,8 @@ struct osockaddr *name, \ int *anamelen, int flags); } 289 UNIMPL signalfd4 -290 UNIMPL eventfd2 +290 STD { int|linux_sys||eventfd2(unsigned int initval, \ + int flags); } 291 UNIMPL epoll_create1 292 STD { int|linux_sys||dup3(int from, int to, int flags); } 293 STD { int|linux_sys||pipe2(int *pfds, int flags); } Index: src/sys/compat/linux/arch/arm/syscalls.master diff -u src/sys/compat/linux/arch/arm/syscalls.master:1.71 src/sys/compat/linux/arch/arm/syscalls.master:1.72 --- src/sys/compat/linux/arch/arm/syscalls.master:1.71 Sun Sep 19 23:51:36 2021 +++ src/sys/compat/linux/arch/arm/syscalls.master Mon Sep 20 00:09:01 2021 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.71 2021/09/19 23:51:36 thorpej Exp $ + $NetBSD: syscalls.master,v 1.72 2021/09/20 00:09:01 thorpej Exp $ ; Derived from sys/compat/linux/arch/*/syscalls.master ; and from Linux 2.4.12 arch/arm/kernel/calls.S @@ -564,7 +564,7 @@ 349 UNIMPL signalfd 350 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ int flags); } -351 UNIMPL eventfd +351 STD { int|linux_sys||eventfd(unsigned int initval); } 352 STD { int|linux_sys||fallocate(int fd, int mode, \ off_t offset, off_t len); } 353 STD { int|linux_sys||timerfd_settime(int fd, int flags, \ @@ -573,7 +573,8 @@ 354 STD { int|linux_sys||timerfd_gettime(int fd, \ struct linux_itimerspec *tim); } 355 UNIMPL signalfd4 -356 UNIMPL eventfd2 +356 STD { int|linux_sys||eventfd2(unsigned int initval, \ + int flags); } 357 UNIMPL epoll_create1 358 STD { int|linux_sys||dup3(int from, int to, int flags); } 359 STD { int|linux_sys||pipe2(int *pfds, int flags); } Index: src/sys/compat/linux/arch/i386/syscalls.master diff -u src/sys/compat/linux/arch/i386/syscalls.master:1.126 src/sys/compat/linux/arch/i386/syscalls.master:1.127 --- src/sys/compat/linux/arch/i386/syscalls.master:1.126 Sun Sep 19 23:51:36 2021 +++ src/sys/compat/linux/arch/i386/syscalls.master Mon Sep 20 00:09:01 2021 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.126 2021/09/19 23:51:36 thorpej Exp $ + $NetBSD: syscalls.master,v 1.127 2021/09/20 00:09:01 thorpej Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -531,7 +531,7 @@ 321 UNIMPL signalfd 322 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ int flags); } -323 UNIMPL eventfd +323 STD { int|linux_sys||eventfd(unsigned int initval); } 324 STD { int|linux_sys||fallocate(int fd, int mode, \ off_t offset, off_t len); } 325 STD { int|linux_sys||timerfd_settime(int fd, int flags, \ @@ -540,7 +540,8 @@ 326 STD { int|linux_sys||timerfd_gettime(int fd, \ struct linux_itimerspec *tim); } 327 UNIMPL signalfd4 -328 UNIMPL eventfd2 +328 STD { int|linux_sys||eventfd2(unsigned int initval, \ + int flags); } 329 UNIMPL epoll_create1 330 STD { int|linux_sys||dup3(int from, int to, int flags); } 331 STD { int|linux_sys||pipe2( int *pfds, int flags); } Index: src/sys/compat/linux/arch/m68k/syscalls.master diff -u src/sys/compat/linux/arch/m68k/syscalls.master:1.97 src/sys/compat/linux/arch/m68k/syscalls.master:1.98 --- src/sys/compat/linux/arch/m68k/syscalls.master:1.97 Sun Sep 19 23:51:36 2021 +++ src/sys/compat/linux/arch/m68k/syscalls.master Mon Sep 20 00:09:01 2021 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.97 2021/09/19 23:51:36 thorpej Exp $ + $NetBSD: syscalls.master,v 1.98 2021/09/20 00:09:01 thorpej Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -549,7 +549,7 @@ 317 UNIMPL signalfd 318 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ int flags); } -319 UNIMPL eventfd +319 STD { int|linux_sys||eventfd(unsigned int initval); } 320 STD { int|linux_sys||fallocate(int fd, int mode, \ off_t offset, off_t len); } 321 STD { int|linux_sys||timerfd_settime(int fd, int flags, \ @@ -558,7 +558,8 @@ 322 STD { int|linux_sys||timerfd_gettime(int fd, \ struct linux_itimerspec *tim); } 323 UNIMPL signalfd4 -324 UNIMPL eventfd2 +324 STD { int|linux_sys||eventfd2(unsigned int initval, \ + int flags); } 325 UNIMPL epoll_create1 326 STD { int|linux_sys||dup3(int from, int to, int flags); } 327 STD { int|linux_sys||pipe2(int *pfds, int flags); } Index: src/sys/compat/linux/arch/mips/syscalls.master diff -u src/sys/compat/linux/arch/mips/syscalls.master:1.70 src/sys/compat/linux/arch/mips/syscalls.master:1.71 --- src/sys/compat/linux/arch/mips/syscalls.master:1.70 Sun Sep 19 23:51:37 2021 +++ src/sys/compat/linux/arch/mips/syscalls.master Mon Sep 20 00:09:01 2021 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.70 2021/09/19 23:51:37 thorpej Exp $ + $NetBSD: syscalls.master,v 1.71 2021/09/20 00:09:01 thorpej Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -536,7 +536,7 @@ struct linux_timespec *times, int flag); } 317 UNIMPL signalfd 318 UNIMPL timerfd -319 UNIMPL eventfd +319 STD { int|linux_sys||eventfd(unsigned int initval); } 320 STD { int|linux_sys||fallocate(int fd, int mode, \ off_t offset, off_t len); } 321 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ @@ -547,7 +547,8 @@ const struct linux_itimerspec *tim, \ struct linux_itimerspec *otim); } 324 UNIMPL signalfd4 -325 UNIMPL eventfd2 +325 STD { int|linux_sys||eventfd2(unsigned int initval, \ + int flags); } 326 UNIMPL epoll_create1 327 STD { int|linux_sys||dup3(int from, int to, int flags); } 328 STD { int|linux_sys||pipe2(int *pfds, int flags); } Index: src/sys/compat/linux/arch/powerpc/syscalls.master diff -u src/sys/compat/linux/arch/powerpc/syscalls.master:1.76 src/sys/compat/linux/arch/powerpc/syscalls.master:1.77 --- src/sys/compat/linux/arch/powerpc/syscalls.master:1.76 Sun Sep 19 23:51:37 2021 +++ src/sys/compat/linux/arch/powerpc/syscalls.master Mon Sep 20 00:09:01 2021 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.76 2021/09/19 23:51:37 thorpej Exp $ + $NetBSD: syscalls.master,v 1.77 2021/09/20 00:09:01 thorpej Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -535,7 +535,7 @@ 305 UNIMPL signalfd 306 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ int flags); } -307 UNIMPL eventfd +307 STD { int|linux_sys||eventfd(unsigned int initval); } 308 UNIMPL sync_file_range2 309 STD { int|linux_sys||fallocate(int fd, int mode, \ off_t offset, off_t len); } @@ -546,7 +546,8 @@ 312 STD { int|linux_sys||timerfd_gettime(int fd, \ struct linux_itimerspec *tim); } 313 UNIMPL signalfd4 -314 UNIMPL eventfd2 +314 STD { int|linux_sys||eventfd2(unsigned int initval, \ + int flags); } 315 UNIMPL epoll_create1 316 STD { int|linux_sys||dup3(int from, int to, int flags); } 317 STD { int|linux_sys||pipe2(int *pfds, int flags); } Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.252 src/sys/compat/linux/common/linux_misc.c:1.253 --- src/sys/compat/linux/common/linux_misc.c:1.252 Tue Sep 7 11:43:04 2021 +++ src/sys/compat/linux/common/linux_misc.c Mon Sep 20 00:09:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.252 2021/09/07 11:43:04 riastradh Exp $ */ +/* $NetBSD: linux_misc.c,v 1.253 2021/09/20 00:09:02 thorpej Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,13 +57,14 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.252 2021/09/07 11:43:04 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.253 2021/09/20 00:09:02 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/namei.h> #include <sys/proc.h> #include <sys/dirent.h> +#include <sys/eventfd.h> #include <sys/file.h> #include <sys/stat.h> #include <sys/filedesc.h> @@ -1583,3 +1584,54 @@ linux_do_futex(int *uaddr, int op, int v return do_futex(uaddr, op & ~FUTEX_PRIVATE_FLAG, val, timeout, uaddr2, val2, val3, retval); } + +#define LINUX_EFD_SEMAPHORE 0x0001 +#define LINUX_EFD_CLOEXEC LINUX_O_CLOEXEC +#define LINUX_EFD_NONBLOCK LINUX_O_NONBLOCK + +static int +linux_do_eventfd2(struct lwp *l, unsigned int initval, int flags, + register_t *retval) +{ + int nflags = 0; + + if (flags & ~(LINUX_EFD_SEMAPHORE | LINUX_EFD_CLOEXEC | + LINUX_EFD_NONBLOCK)) { + return EINVAL; + } + if (flags & LINUX_EFD_SEMAPHORE) { + nflags |= EFD_SEMAPHORE; + } + if (flags & LINUX_EFD_CLOEXEC) { + nflags |= EFD_CLOEXEC; + } + if (flags & LINUX_EFD_NONBLOCK) { + nflags |= EFD_NONBLOCK; + } + + return do_eventfd(l, initval, nflags, retval); +} + +int +linux_sys_eventfd(struct lwp *l, const struct linux_sys_eventfd_args *uap, + register_t *retval) +{ + /* { + syscallarg(unsigned int) initval; + } */ + + return linux_do_eventfd2(l, SCARG(uap, initval), 0, retval); +} + +int +linux_sys_eventfd2(struct lwp *l, const struct linux_sys_eventfd2_args *uap, + register_t *retval) +{ + /* { + syscallarg(unsigned int) initval; + syscallarg(int) flags; + } */ + + return linux_do_eventfd2(l, SCARG(uap, initval), SCARG(uap, flags), + retval); +} Index: src/sys/compat/linux32/arch/amd64/syscalls.master diff -u src/sys/compat/linux32/arch/amd64/syscalls.master:1.73 src/sys/compat/linux32/arch/amd64/syscalls.master:1.74 --- src/sys/compat/linux32/arch/amd64/syscalls.master:1.73 Sun Sep 19 23:51:37 2021 +++ src/sys/compat/linux32/arch/amd64/syscalls.master Mon Sep 20 00:09:02 2021 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.73 2021/09/19 23:51:37 thorpej Exp $ + $NetBSD: syscalls.master,v 1.74 2021/09/20 00:09:02 thorpej Exp $ ; NetBSD i386 COMPAT_LINUX32 system call name/number "master" file. ; (See syscalls.conf to see what it is processed into.) @@ -552,7 +552,7 @@ 321 UNIMPL signalfd 322 NOARGS { int|linux_sys||timerfd_create(clockid_t clock_id, \ int flags); } -323 UNIMPL eventfd +323 STD { int|linux32_sys||eventfd(unsigned int initval); } 324 STD { int|linux32_sys||fallocate(int fd, int mode, \ off_t offset, off_t len); } 325 STD { int|linux32_sys||timerfd_settime(int fd, int flags, \ @@ -561,7 +561,8 @@ 326 STD { int|linux32_sys||timerfd_gettime(int fd, \ struct linux32_itimerspec *tim); } 327 UNIMPL signalfd4 -328 UNIMPL eventfd2 +328 STD { int|linux32_sys||eventfd2(unsigned int initval, \ + int flags); } 329 UNIMPL epoll_create1 330 STD { int|linux32_sys||dup3(int from, int to, int flags); } 331 STD { int|linux32_sys||pipe2(netbsd32_intp fd, int flags); } Index: src/sys/compat/linux32/common/linux32_misc.c diff -u src/sys/compat/linux32/common/linux32_misc.c:1.31 src/sys/compat/linux32/common/linux32_misc.c:1.32 --- src/sys/compat/linux32/common/linux32_misc.c:1.31 Sun Sep 19 22:32:45 2021 +++ src/sys/compat/linux32/common/linux32_misc.c Mon Sep 20 00:09:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_misc.c,v 1.31 2021/09/19 22:32:45 thorpej Exp $ */ +/* $NetBSD: linux32_misc.c,v 1.32 2021/09/20 00:09:02 thorpej Exp $ */ /*- * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.31 2021/09/19 22:32:45 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.32 2021/09/20 00:09:02 thorpej Exp $"); #include <sys/param.h> #include <sys/proc.h> @@ -350,3 +350,33 @@ linux32_sys_ppoll(struct lwp *l, const s return pollcommon(retval, SCARG_P32(uap, fds), SCARG(uap, nfds), ts, sigmask); } + +int +linux32_sys_eventfd(struct lwp *l, const struct linux32_sys_eventfd_args *uap, + register_t *retval) +{ + /* { + syscallarg(unsigned int) initval; + } */ + struct linux_sys_eventfd_args ua; + + NETBSD32TO64_UAP(initval); + + return linux_sys_eventfd(l, &ua, retval); +} + +int +linux32_sys_eventfd2(struct lwp *l, const struct linux32_sys_eventfd2_args *uap, + register_t *retval) +{ + /* { + syscallarg(unsigned int) initval; + syscallarg(int) flags; + } */ + struct linux_sys_eventfd2_args ua; + + NETBSD32TO64_UAP(initval); + NETBSD32TO64_UAP(flags); + + return linux_sys_eventfd2(l, &ua, retval); +}