From nobody Fri Jun 17 19:28:59 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8570D8470C2; Fri, 17 Jun 2022 19:29:01 +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 4LPpxm4Qn3z3GhB; Fri, 17 Jun 2022 19:29:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wT3lPUMtb1IMwMj+hdlMewE3TC7xes2gNcKpdSJjYIU=; b=LQk/biTzwNENVBUAJJFWTe/54ycytibYZSPEwS9oR/ctiNwRv0sNOIZrF6WeGsy59JI1Ab 5n8Cp2hIOamN+tmrJljwt2sNjOPl8VUIga50wrUEvPjaoS6aDCy2Vu6jks67lS2GpY52mZ dI7+8jqhYZXJHAtH0YrpgAwq4cQR2AS7ybdNkX2TfYEEggC0mn9jBKH3X58kCZU5X/eWJ6 DuqY8cnL/I4dQdg33qDrfu2rrnU5HGr+x4o4X9E4zLQkWiZtWhgttF762QAVxdG1LoieWT fHPRZaKiK/lTs19bgHZBkZm0hVQCYY4XDSlbheiFEM0fFJIAFv5rC0+BGxqs8w== 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 E52C82554B; Fri, 17 Jun 2022 19:28:59 +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 25HJSxXC096814; Fri, 17 Jun 2022 19:28:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJSxeG096813; Fri, 17 Jun 2022 19:28:59 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:28:59 GMT Message-Id: <202206171928.25HJSxeG096813@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 58504e171072 - stable/13 - linux(4): Implement clock_getres_time64 system call. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 58504e1710722e276725a683c5e1dc628271f445 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wT3lPUMtb1IMwMj+hdlMewE3TC7xes2gNcKpdSJjYIU=; b=LejNBUMCM5pFG1BS0Z2JYZQlogBRZVaa4hpz5uqR1REDBGyzqS3LHSC8hqzNnS+T2ae1t5 A/cww9W45PxTH8DR3FAmlao4iN/+YyvS4W0i07bD5wZ84Mh7gBtrItO3i5yTJjUVWFIUo7 XIESkbCyNEtKcmGJ0KbvOIsSJRoVdAIqIf/Oxr7D/qoNgjHhP3M7mCkZ9HHFLS4LujMV8+ zmMl7VEwdX958+LL4G+FV+tHSxkTLR8NlyI1TPrNVoN9Jabu0id6vAQI+gTfdGefa7pbl+ e+iMbL/Y5xTfinVLSKe3TEYIwbpz8HeSoR+mgtQKdOArDPChHYSOeyeCgLK4Qg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494140; a=rsa-sha256; cv=none; b=Bx6Qaiqlz9DTlGL6WIWb4wulZYuFiVEY10ZPN2EBhp80wScqQLmT9TMteAinSP6eVWPk6H BLndOeZ2a8u41h7rnLeMYRQGDa7rc4+3aAgmtcwVSQWkyj3z9fA7h3v69B1dzaC9TxCrL6 tOx1G38FfQKCwBgTlM1g+l7NWoT/wWUOanSIzP7zC1jbDoiX8E9rw/xbuhdmxSOGDjN0E3 fseNMLSxQTtgfwaKKjGT80VjZcyGrzyrdPF4X9EAh6nMXLsG4GH7eZSEBUf8+lrdrGbj+y ETlBZ/RBCZtdOmMb/vTSAToXA4njlNJGmG8yGHdpM5k9AJLO4JhnETgJPoIEGg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=58504e1710722e276725a683c5e1dc628271f445 commit 58504e1710722e276725a683c5e1dc628271f445 Author: Dmitry Chagin AuthorDate: 2021-06-07 02:21:32 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:27:57 +0000 linux(4): Implement clock_getres_time64 system call. MFC after: 2 weeks (cherry picked from commit 187715a420237e1ed94dd5aef158eada7dcdc559) --- sys/amd64/linux32/linux32_dummy_machdep.c | 1 - sys/amd64/linux32/syscalls.master | 5 +- sys/compat/linux/linux_time.c | 92 +++++++++++++++++++++++-------- sys/i386/linux/linux_dummy_machdep.c | 1 - sys/i386/linux/syscalls.master | 5 +- 5 files changed, 76 insertions(+), 28 deletions(-) diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c index 022fbcbdd0c6..3f8dfe711dba 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_getres_time64); DUMMY(clock_nanosleep_time64); DUMMY(timer_gettime64); DUMMY(timer_settime64); diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index 924fbce9eac7..27034c0216ff 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -2356,7 +2356,10 @@ int linux_clock_adjtime64(void); } 406 AUE_NULL STD { - int linux_clock_getres_time64(void); + int linux_clock_getres_time64( + clockid_t which, + struct l_timespec64 *tp + ); } 407 AUE_NULL STD { int linux_clock_nanosleep_time64(void); diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c index 65bb4e9b754f..43db8871a0d8 100644 --- a/sys/compat/linux/linux_time.c +++ b/sys/compat/linux/linux_time.c @@ -94,10 +94,13 @@ LIN_SDT_PROBE_DEFINE1(time, linux_clock_settime, copyin_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_settime64, conversion_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_settime64, copyin_error, "int"); #endif -LIN_SDT_PROBE_DEFINE0(time, linux_clock_getres, nullcall); -LIN_SDT_PROBE_DEFINE1(time, linux_clock_getres, conversion_error, "int"); -LIN_SDT_PROBE_DEFINE1(time, linux_clock_getres, getres_error, "int"); +LIN_SDT_PROBE_DEFINE0(time, linux_common_clock_getres, nullcall); +LIN_SDT_PROBE_DEFINE1(time, linux_common_clock_getres, conversion_error, "int"); +LIN_SDT_PROBE_DEFINE1(time, linux_common_clock_getres, getres_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_getres, copyout_error, "int"); +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +LIN_SDT_PROBE_DEFINE1(time, linux_clock_getres_time64, copyout_error, "int"); +#endif LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, conversion_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, copyout_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, copyin_error, "int"); @@ -111,6 +114,8 @@ static int linux_common_clock_gettime(struct thread *, clockid_t, struct timespec *); static int linux_common_clock_settime(struct thread *, clockid_t, struct timespec *); +static int linux_common_clock_getres(struct thread *, clockid_t, + struct timespec *); int native_to_linux_timespec(struct l_timespec *ltp, struct timespec *ntp) @@ -486,23 +491,22 @@ linux_clock_settime64(struct thread *td, struct linux_clock_settime64_args *args } #endif -int -linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) +static int +linux_common_clock_getres(struct thread *td, clockid_t which, + struct timespec *ts) { struct proc *p; - struct timespec ts; - struct l_timespec lts; int error, clockwhich; clockid_t nwhich; pid_t pid; lwpid_t tid; - error = linux_to_native_clockid(&nwhich, args->which); + error = linux_to_native_clockid(&nwhich, which); if (error != 0) { linux_msg(curthread, - "unsupported clock_getres clockid %d", args->which); - LIN_SDT_PROBE1(time, linux_clock_getres, conversion_error, - error); + "unsupported clock_getres clockid %d", which); + LIN_SDT_PROBE1(time, linux_common_clock_getres, + conversion_error, error); return (error); } @@ -510,10 +514,10 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) * Check user supplied clock id in case of per-process * or thread-specific cpu-time clock. */ - if (args->which < 0) { + if (which < 0) { switch (nwhich) { case CLOCK_THREAD_CPUTIME_ID: - tid = LINUX_CPUCLOCK_ID(args->which); + tid = LINUX_CPUCLOCK_ID(which); if (tid != 0) { p = td->td_proc; if (linux_tdfind(td, tid, p->p_pid) == NULL) @@ -522,7 +526,7 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) } break; case CLOCK_PROCESS_CPUTIME_ID: - pid = LINUX_CPUCLOCK_ID(args->which); + pid = LINUX_CPUCLOCK_ID(which); if (pid != 0) { error = pget(pid, PGET_CANSEE, &p); if (error != 0) @@ -533,15 +537,15 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) } } - if (args->tp == NULL) { - LIN_SDT_PROBE0(time, linux_clock_getres, nullcall); + if (ts == NULL) { + LIN_SDT_PROBE0(time, linux_common_clock_getres, nullcall); return (0); } switch (nwhich) { case CLOCK_THREAD_CPUTIME_ID: case CLOCK_PROCESS_CPUTIME_ID: - clockwhich = LINUX_CPUCLOCK_WHICH(args->which); + clockwhich = LINUX_CPUCLOCK_WHICH(which); /* * In both cases (when the clock id obtained by a call to * clock_getcpuclockid() or using the clock @@ -550,9 +554,9 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) * * See Linux posix_cpu_clock_getres() implementation. */ - if (args->which > 0 || clockwhich == LINUX_CPUCLOCK_SCHED) { - ts.tv_sec = 0; - ts.tv_nsec = 1; + if (which > 0 || clockwhich == LINUX_CPUCLOCK_SCHED) { + ts->tv_sec = 0; + ts->tv_nsec = 1; goto out; } @@ -571,22 +575,62 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) default: break; } - error = kern_clock_getres(td, nwhich, &ts); + error = kern_clock_getres(td, nwhich, ts); if (error != 0) { - LIN_SDT_PROBE1(time, linux_clock_getres, getres_error, error); + LIN_SDT_PROBE1(time, linux_common_clock_getres, + getres_error, error); return (error); } out: + return (error); +} + +int +linux_clock_getres(struct thread *td, + struct linux_clock_getres_args *args) +{ + struct timespec ts; + struct l_timespec lts; + int error; + + error = linux_common_clock_getres(td, args->which, &ts); + if (error != 0 || args->tp == NULL) + return (error); + error = native_to_linux_timespec(<s, &ts); if (error != 0) return (error); - error = copyout(<s, args->tp, sizeof lts); + error = copyout(<s, args->tp, sizeof(lts)); if (error != 0) - LIN_SDT_PROBE1(time, linux_clock_getres, copyout_error, error); + LIN_SDT_PROBE1(time, linux_clock_getres, + copyout_error, error); + return (error); +} + +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int +linux_clock_getres_time64(struct thread *td, + struct linux_clock_getres_time64_args *args) +{ + struct timespec ts; + struct l_timespec64 lts; + int error; + + error = linux_common_clock_getres(td, args->which, &ts); + if (error != 0 || args->tp == NULL) + return (error); + error = native_to_linux_timespec64(<s, &ts); + if (error != 0) + return (error); + error = copyout(<s, args->tp, sizeof(lts)); + if (error != 0) + LIN_SDT_PROBE1(time, linux_clock_getres_time64, + copyout_error, error); return (error); } +#endif int linux_nanosleep(struct thread *td, struct linux_nanosleep_args *args) diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c index 762dc177b1b0..6e4c9c66edcb 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_getres_time64); DUMMY(clock_nanosleep_time64); DUMMY(timer_gettime64); DUMMY(timer_settime64); diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index a8b41605b743..0876a039ea05 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -2374,7 +2374,10 @@ int linux_clock_adjtime64(void); } 406 AUE_NULL STD { - int linux_clock_getres_time64(void); + int linux_clock_getres_time64( + clockid_t which, + struct l_timespec64 *tp + ); } 407 AUE_NULL STD { int linux_clock_nanosleep_time64(void);