From owner-dev-commits-src-all@freebsd.org Sun Jun 6 14:29:11 2021 Return-Path: Delivered-To: dev-commits-src-all@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 33DFB65F6C9; Sun, 6 Jun 2021 14:29:11 +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 4Fyf5M11Prz4rRY; Sun, 6 Jun 2021 14:29:11 +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 0B14F251F1; Sun, 6 Jun 2021 14:29:11 +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 156ETAQI046709; Sun, 6 Jun 2021 14:29:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 156ETAFs046708; Sun, 6 Jun 2021 14:29:10 GMT (envelope-from git) Date: Sun, 6 Jun 2021 14:29:10 GMT Message-Id: <202106061429.156ETAFs046708@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: 6501370a7dfb - main - linux(4): Implement clock_nanosleep_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: 6501370a7dfb358daf07555136742bc064e68cb7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jun 2021 14:29:11 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6501370a7dfb358daf07555136742bc064e68cb7 commit 6501370a7dfb358daf07555136742bc064e68cb7 Author: Dmitry Chagin AuthorDate: 2021-06-07 02:26:48 +0000 Commit: Dmitry Chagin CommitDate: 2021-06-07 02:26:48 +0000 linux(4): Implement clock_nanosleep_time64 system call. MFC after: 2 weeks --- sys/amd64/linux32/linux32_dummy_machdep.c | 1 - sys/amd64/linux32/syscalls.master | 7 +- sys/compat/linux/linux_time.c | 109 ++++++++++++++++++++++++------ sys/i386/linux/linux_dummy_machdep.c | 1 - sys/i386/linux/syscalls.master | 7 +- 5 files changed, 99 insertions(+), 26 deletions(-) diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c index 3f8dfe711dba..041156bd514b 100644 --- a/sys/amd64/linux32/linux32_dummy_machdep.c +++ b/sys/amd64/linux32/linux32_dummy_machdep.c @@ -68,7 +68,6 @@ DUMMY(mq_getsetattr); DUMMY(arch_prctl); /* Linux 5.0: */ DUMMY(clock_adjtime64); -DUMMY(clock_nanosleep_time64); DUMMY(timer_gettime64); DUMMY(timer_settime64); DUMMY(timerfd_gettime64); diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index 27034c0216ff..d3a124c6e8c2 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -2362,7 +2362,12 @@ ); } 407 AUE_NULL STD { - int linux_clock_nanosleep_time64(void); + int linux_clock_nanosleep_time64( + clockid_t which, + l_int flags, + struct l_timespec64 *rqtp, + struct l_timespec64 *rmtp + ); } 408 AUE_NULL STD { int linux_timer_gettime64(void); diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c index 43db8871a0d8..184de336fd99 100644 --- a/sys/compat/linux/linux_time.c +++ b/sys/compat/linux/linux_time.c @@ -107,8 +107,13 @@ LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, copyin_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, conversion_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, copyout_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, copyin_error, "int"); -LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, unsupported_flags, "int"); -LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, unsupported_clockid, "int"); +LIN_SDT_PROBE_DEFINE1(time, linux_common_clock_nanosleep, unsupported_flags, "int"); +LIN_SDT_PROBE_DEFINE1(time, linux_common_clock_nanosleep, unsupported_clockid, "int"); +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep_time64, conversion_error, "int"); +LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep_time64, copyout_error, "int"); +LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep_time64, copyin_error, "int"); +#endif static int linux_common_clock_gettime(struct thread *, clockid_t, struct timespec *); @@ -116,6 +121,8 @@ static int linux_common_clock_settime(struct thread *, clockid_t, struct timespec *); static int linux_common_clock_getres(struct thread *, clockid_t, struct timespec *); +static int linux_common_clock_nanosleep(struct thread *, clockid_t, + l_int, struct timespec *, struct timespec *); int native_to_linux_timespec(struct l_timespec *ltp, struct timespec *ntp) @@ -672,31 +679,41 @@ linux_nanosleep(struct thread *td, struct linux_nanosleep_args *args) return (error); } -int -linux_clock_nanosleep(struct thread *td, struct linux_clock_nanosleep_args *args) +static int +linux_common_clock_nanosleep(struct thread *td, clockid_t which, + l_int lflags, struct timespec *rqtp, struct timespec *rmtp) { - struct timespec *rmtp; - struct l_timespec lrqts, lrmts; - struct timespec rqts, rmts; - int error, error2, flags; + int error, flags; clockid_t clockid; - error = linux_to_native_timerflags(&flags, args->flags); + error = linux_to_native_timerflags(&flags, lflags); if (error != 0) { - LIN_SDT_PROBE1(time, linux_clock_nanosleep, unsupported_flags, - args->flags); + LIN_SDT_PROBE1(time, linux_common_clock_nanosleep, + unsupported_flags, lflags); return (error); } - error = linux_to_native_clockid(&clockid, args->which); + error = linux_to_native_clockid(&clockid, which); if (error != 0) { linux_msg(curthread, - "unsupported clock_nanosleep clockid %d", args->which); - LIN_SDT_PROBE1(time, linux_clock_nanosleep, unsupported_clockid, - args->which); + "unsupported clock_nanosleep clockid %d", which); + LIN_SDT_PROBE1(time, linux_common_clock_nanosleep, + unsupported_clockid, which); return (error); } + return (kern_clock_nanosleep(td, clockid, flags, rqtp, rmtp)); +} + +int +linux_clock_nanosleep(struct thread *td, + struct linux_clock_nanosleep_args *args) +{ + struct timespec *rmtp; + struct l_timespec lrqts, lrmts; + struct timespec rqts, rmts; + int error, error2; + error = copyin(args->rqtp, &lrqts, sizeof(lrqts)); if (error != 0) { LIN_SDT_PROBE1(time, linux_clock_nanosleep, copyin_error, @@ -704,19 +721,21 @@ linux_clock_nanosleep(struct thread *td, struct linux_clock_nanosleep_args *args return (error); } - if (args->rmtp != NULL) - rmtp = &rmts; - else - rmtp = NULL; - error = linux_to_native_timespec(&rqts, &lrqts); if (error != 0) { LIN_SDT_PROBE1(time, linux_clock_nanosleep, conversion_error, error); return (error); } - error = kern_clock_nanosleep(td, clockid, flags, &rqts, rmtp); - if (error == EINTR && (flags & TIMER_ABSTIME) == 0 && + + if (args->rmtp != NULL) + rmtp = &rmts; + else + rmtp = NULL; + + error = linux_common_clock_nanosleep(td, args->which, args->flags, + &rqts, rmtp); + if (error == EINTR && (args->flags & LINUX_TIMER_ABSTIME) == 0 && args->rmtp != NULL) { error2 = native_to_linux_timespec(&lrmts, rmtp); if (error2 != 0) @@ -728,6 +747,52 @@ linux_clock_nanosleep(struct thread *td, struct linux_clock_nanosleep_args *args return (error2); } } + return (error); +} +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int +linux_clock_nanosleep_time64(struct thread *td, + struct linux_clock_nanosleep_time64_args *args) +{ + struct timespec *rmtp; + struct l_timespec64 lrqts, lrmts; + struct timespec rqts, rmts; + int error, error2; + + error = copyin(args->rqtp, &lrqts, sizeof(lrqts)); + if (error != 0) { + LIN_SDT_PROBE1(time, linux_clock_nanosleep_time64, + copyin_error, error); + return (error); + } + + error = linux_to_native_timespec64(&rqts, &lrqts); + if (error != 0) { + LIN_SDT_PROBE1(time, linux_clock_nanosleep_time64, + conversion_error, error); + return (error); + } + + if (args->rmtp != NULL) + rmtp = &rmts; + else + rmtp = NULL; + + error = linux_common_clock_nanosleep(td, args->which, args->flags, + &rqts, rmtp); + if (error == EINTR && (args->flags & LINUX_TIMER_ABSTIME) == 0 && + args->rmtp != NULL) { + error2 = native_to_linux_timespec64(&lrmts, rmtp); + if (error2 != 0) + return (error2); + error2 = copyout(&lrmts, args->rmtp, sizeof(lrmts)); + if (error2 != 0) { + LIN_SDT_PROBE1(time, linux_clock_nanosleep_time64, + copyout_error, error2); + return (error2); + } + } return (error); } +#endif diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c index 6e4c9c66edcb..f679e090c7c1 100644 --- a/sys/i386/linux/linux_dummy_machdep.c +++ b/sys/i386/linux/linux_dummy_machdep.c @@ -70,7 +70,6 @@ DUMMY(vm86old); DUMMY(arch_prctl); /* Linux 5.0: */ DUMMY(clock_adjtime64); -DUMMY(clock_nanosleep_time64); DUMMY(timer_gettime64); DUMMY(timer_settime64); DUMMY(timerfd_gettime64); diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index 0876a039ea05..7e1ab24e9f75 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -2380,7 +2380,12 @@ ); } 407 AUE_NULL STD { - int linux_clock_nanosleep_time64(void); + int linux_clock_nanosleep_time64( + clockid_t which, + l_int flags, + struct l_timespec64 *rqtp, + struct l_timespec64 *rmtp + ); } 408 AUE_NULL STD { int linux_timer_gettime64(void);