Date: Thu, 10 Jun 2021 12:19:36 GMT From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: ed61e0ce1d29 - main - linux(4): Implement ppoll_time64 system call. Message-ID: <202106101219.15ACJadH047096@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=ed61e0ce1d293d659b86e382def05a31ac337e03 commit ed61e0ce1d293d659b86e382def05a31ac337e03 Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2021-06-10 12:18:46 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> 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 {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106101219.15ACJadH047096>