From owner-dev-commits-src-main@freebsd.org Thu Jun 10 12:19:36 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E480064A7FD; Thu, 10 Jun 2021 12:19:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G132068Fqz4bZ5; Thu, 10 Jun 2021 12:19:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B787A71E6; Thu, 10 Jun 2021 12:19:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15ACJaNV047097; Thu, 10 Jun 2021 12:19:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15ACJadH047096; Thu, 10 Jun 2021 12:19:36 GMT (envelope-from git) Date: Thu, 10 Jun 2021 12:19:36 GMT Message-Id: <202106101219.15ACJadH047096@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: ed61e0ce1d29 - main - linux(4): Implement ppoll_time64 system call. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ed61e0ce1d293d659b86e382def05a31ac337e03 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2021 12:19:37 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=ed61e0ce1d293d659b86e382def05a31ac337e03 commit ed61e0ce1d293d659b86e382def05a31ac337e03 Author: Dmitry Chagin AuthorDate: 2021-06-10 12:18:46 +0000 Commit: Dmitry Chagin CommitDate: 2021-06-10 12:18:46 +0000 linux(4): Implement ppoll_time64 system call. MFC after: 2 weeks --- sys/amd64/linux32/linux32_dummy_machdep.c | 1 - sys/amd64/linux32/syscalls.master | 8 ++- sys/compat/linux/linux_misc.c | 98 +++++++++++++++++++++++-------- sys/i386/linux/linux_dummy_machdep.c | 1 - sys/i386/linux/syscalls.master | 8 ++- 5 files changed, 87 insertions(+), 29 deletions(-) diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c index 81e0ed51ae31..fb7c88629af7 100644 --- a/sys/amd64/linux32/linux32_dummy_machdep.c +++ b/sys/amd64/linux32/linux32_dummy_machdep.c @@ -72,7 +72,6 @@ DUMMY(timer_gettime64); DUMMY(timer_settime64); DUMMY(timerfd_gettime64); DUMMY(timerfd_settime64); -DUMMY(ppoll_time64); DUMMY(io_pgetevents_time64); DUMMY(recvmmsg_time64); DUMMY(mq_timedsend_time64); diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index ef89e331b429..0ca919182998 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -2400,7 +2400,13 @@ ); } 414 AUE_NULL STD { - int linux_ppoll_time64(void); + int linux_ppoll_time64( + struct pollfd *fds, + uint32_t nfds, + struct l_timespec *tsp, + l_sigset_t *sset, + l_size_t ssize + ); } 415 AUE_NULL UNIMPL nosys 416 AUE_NULL STD { diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 78dc37d9a19f..53dd27dc23db 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -141,6 +141,9 @@ static int linux_common_utimensat(struct thread *, int, static int linux_common_pselect6(struct thread *, l_int, l_fd_set *, l_fd_set *, l_fd_set *, struct timespec *, l_uintptr_t *); +static int linux_common_ppoll(struct thread *, struct pollfd *, + uint32_t, struct timespec *, l_sigset_t *, + l_size_t); int linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args) @@ -2484,24 +2487,10 @@ linux_pselect6_time64(struct thread *td, int linux_ppoll(struct thread *td, struct linux_ppoll_args *args) { - struct timespec ts0, ts1; - struct l_timespec lts; struct timespec uts, *tsp; - l_sigset_t l_ss; - sigset_t *ssp; - sigset_t ss; + struct l_timespec lts; int error; - if (args->sset != NULL) { - if (args->ssize != sizeof(l_ss)) - return (EINVAL); - error = copyin(args->sset, &l_ss, sizeof(l_ss)); - if (error) - return (error); - linux_to_bsd_sigset(&l_ss, &ss); - ssp = &ss; - } else - ssp = NULL; if (args->tsp != NULL) { error = copyin(args->tsp, <s, sizeof(lts)); if (error) @@ -2509,31 +2498,90 @@ linux_ppoll(struct thread *td, struct linux_ppoll_args *args) error = linux_to_native_timespec(&uts, <s); if (error != 0) return (error); - - nanotime(&ts0); tsp = &uts; } else tsp = NULL; - error = kern_poll(td, args->fds, args->nfds, tsp, ssp); + error = linux_common_ppoll(td, args->fds, args->nfds, tsp, + args->sset, args->ssize); + if (error != 0) + return (error); + if (tsp != NULL) { + error = native_to_linux_timespec(<s, tsp); + if (error == 0) + error = copyout(<s, args->tsp, sizeof(lts)); + } + return (error); +} + +static int +linux_common_ppoll(struct thread *td, struct pollfd *fds, uint32_t nfds, + struct timespec *tsp, l_sigset_t *sset, l_size_t ssize) +{ + struct timespec ts0, ts1; + l_sigset_t l_ss; + sigset_t *ssp; + sigset_t ss; + int error; - if (error == 0 && args->tsp != NULL) { + if (sset != NULL) { + if (ssize != sizeof(l_ss)) + return (EINVAL); + error = copyin(sset, &l_ss, sizeof(l_ss)); + if (error) + return (error); + linux_to_bsd_sigset(&l_ss, &ss); + ssp = &ss; + } else + ssp = NULL; + if (tsp != NULL) + nanotime(&ts0); + + error = kern_poll(td, fds, nfds, tsp, ssp); + + if (error == 0 && tsp != NULL) { if (td->td_retval[0]) { nanotime(&ts1); timespecsub(&ts1, &ts0, &ts1); - timespecsub(&uts, &ts1, &uts); - if (uts.tv_sec < 0) - timespecclear(&uts); + timespecsub(tsp, &ts1, tsp); + if (tsp->tv_sec < 0) + timespecclear(tsp); } else - timespecclear(&uts); + timespecclear(tsp); + } + return (error); +} - error = native_to_linux_timespec(<s, &uts); +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int +linux_ppoll_time64(struct thread *td, struct linux_ppoll_time64_args *args) +{ + struct timespec uts, *tsp; + struct l_timespec64 lts; + int error; + + if (args->tsp != NULL) { + error = copyin(args->tsp, <s, sizeof(lts)); + if (error != 0) + return (error); + error = linux_to_native_timespec64(&uts, <s); + if (error != 0) + return (error); + tsp = &uts; + } else + tsp = NULL; + error = linux_common_ppoll(td, args->fds, args->nfds, tsp, + args->sset, args->ssize); + if (error != 0) + return (error); + if (tsp != NULL) { + error = native_to_linux_timespec64(<s, tsp); if (error == 0) error = copyout(<s, args->tsp, sizeof(lts)); } - return (error); } +#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ int linux_sched_rr_get_interval(struct thread *td, diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c index 67c70afa15b3..071f5fff6f47 100644 --- a/sys/i386/linux/linux_dummy_machdep.c +++ b/sys/i386/linux/linux_dummy_machdep.c @@ -74,7 +74,6 @@ DUMMY(timer_gettime64); DUMMY(timer_settime64); DUMMY(timerfd_gettime64); DUMMY(timerfd_settime64); -DUMMY(ppoll_time64); DUMMY(io_pgetevents_time64); DUMMY(recvmmsg_time64); DUMMY(mq_timedsend_time64); diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index 056ac42eaad7..f75b1253bc14 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -2418,7 +2418,13 @@ ); } 414 AUE_NULL STD { - int linux_ppoll_time64(void); + int linux_ppoll_time64( + struct pollfd *fds, + uint32_t nfds, + struct l_timespec64 *tsp, + l_sigset_t *sset, + l_size_t ssize + ); } 415 AUE_NULL UNIMPL nosys 416 AUE_NULL STD {