From nobody Fri Jun 17 19:28:55 2022 X-Original-To: dev-commits-src-branches@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 6A149846BE6; Fri, 17 Jun 2022 19:28:56 +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 4LPpxg6rMFz3Gl7; Fri, 17 Jun 2022 19:28:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494136; 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=GPNRGqb31Q9wFBCx139nEdjMB70JiP2E8ayDAvVQ57w=; b=auuEE1RhMl4HO9Aws44nj2xSuiq3TOblC+APWdPmP7snx4ikv8K/T1lHiGp0DMbOMg26PX eWpsFBMARqqV6pLdLpsOsbryvGojTxaMR25knlIb25466fQVYfDZqfk77V1qAA2fh9Sue8 pizndEsGgZcWYNkw4OnOC0ISrlDjVy8VXlx9lrqe6K778SlyKQLn31qUvOs5Zwp+/EGYwp tco6segPEvVMUOoF+fE2LYmRP0VfO8PB3D4K+ucrfy9ayZjdU5ncEtJdeUli9Gb8GJ+aIe EzbSO5bM7PyfsnRqjObe8lbNQswfUhATmxo/abOYP0rzliio+12KyNg2klDqFg== 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 737FD25644; Fri, 17 Jun 2022 19:28:55 +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 25HJSt3k096716; Fri, 17 Jun 2022 19:28:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJStGG096715; Fri, 17 Jun 2022 19:28:55 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:28:55 GMT Message-Id: <202206171928.25HJStGG096715@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: ead9f9b1c477 - stable/13 - linux(4): Implement clock_gettime64 system call. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: ead9f9b1c4776cd36ce0bbe66f61c1a692252bbe Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494136; 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=GPNRGqb31Q9wFBCx139nEdjMB70JiP2E8ayDAvVQ57w=; b=ovz2sZdwemW4fM2Vd+OQdlCWgwLoHiU+dK3xZXwVwAbOGFlZklD3zOay2XW+609fPI5kN3 ++JQSOU4wDLFq4mbZvnwVIfGRw84016cVX2nC9tbGIshuYsvQHGv5V9IU5YoupzsQRQHmh 77xvojUlH+tSlxPDc6+VrUyDEbWGupjQUxnbA53WFRY1zCnV8H+UCidVIOOrbrYu1bVzZU JYrSbMoRnQIXNIl6hyc2dqeF3USEIn0ZaXvmRtMcN2xIP8qO0O9DVBYADDEhTKVO2i0W5M D03F+QD0H1Y5b4LEIm1GS/JdbtQ0QiXZMBCLFbuud142IpQcZTdix5WOh+IQCg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494136; a=rsa-sha256; cv=none; b=mRcsaC+mFpuSwlAJ9o1eC+4i+2yB95+hrN0UlEoL3OYDvz3MME65MoZxAKXbF3m44nl9aw RZAbkgshBDszaDlCva4CYmuJQbOZOIGM+EyfCdxAYNmpnEE0asuEpcz1c1mBG1Ae6mN9U7 i00nv24at5yOsM7pBNUTCwd/DaOT9U9kz1tnMwXb8Dl654v0Bff1RQevkYFr7V6mMHlOJ/ D5CTaiWiO98G4x0wmo0FuBoVW57dIfRYaJ+rqTsRxbh5GG0XQm9IPsdtvcp+KO7CxkfQgT 5NpBNmTrdHgDOislyGQmfJiysYtrWxrPuiCIqliaAD1j8fLvs+QCamyu83cDLA== 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=ead9f9b1c4776cd36ce0bbe66f61c1a692252bbe commit ead9f9b1c4776cd36ce0bbe66f61c1a692252bbe Author: Dmitry Chagin AuthorDate: 2021-06-07 02:04:42 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:27:56 +0000 linux(4): Implement clock_gettime64 system call. MFC after: 2 weeks (cherry picked from commit 99b6f430698fa00a33184dd61591d8b6518ed9d3) --- sys/amd64/linux32/linux32_dummy_machdep.c | 1 - sys/amd64/linux32/syscalls.master | 5 +- sys/compat/linux/linux_time.c | 88 +++++++++++++++++++++++-------- sys/i386/linux/linux_dummy_machdep.c | 1 - sys/i386/linux/syscalls.master | 5 +- 5 files changed, 73 insertions(+), 27 deletions(-) diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c index be07eb033e77..3ff38c7a8584 100644 --- a/sys/amd64/linux32/linux32_dummy_machdep.c +++ b/sys/amd64/linux32/linux32_dummy_machdep.c @@ -67,7 +67,6 @@ DUMMY(mq_getsetattr); /* Linux 4.11: */ DUMMY(arch_prctl); /* Linux 5.0: */ -DUMMY(clock_gettime64); DUMMY(clock_settime64); DUMMY(clock_adjtime64); DUMMY(clock_getres_time64); diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index 67591b487652..dbba97da68f8 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -2341,7 +2341,10 @@ } ; Linux 5.0: 403 AUE_NULL STD { - int linux_clock_gettime64(void); + int linux_clock_gettime64( + clockid_t which, + struct l_timespec64 *tp + ); } 404 AUE_NULL STD { int linux_clock_settime64(void); diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c index 2f1430faf702..10df72ad29f8 100644 --- a/sys/compat/linux/linux_time.c +++ b/sys/compat/linux/linux_time.c @@ -79,9 +79,13 @@ LIN_SDT_PROBE_DEFINE1(time, linux_to_native_clockid, unsupported_clockid, "clockid_t"); LIN_SDT_PROBE_DEFINE1(time, linux_to_native_clockid, unknown_clockid, "clockid_t"); -LIN_SDT_PROBE_DEFINE1(time, linux_clock_gettime, conversion_error, "int"); +LIN_SDT_PROBE_DEFINE1(time, linux_common_clock_gettime, conversion_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_gettime, gettime_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_gettime, copyout_error, "int"); +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +LIN_SDT_PROBE_DEFINE1(time, linux_clock_gettime64, gettime_error, "int"); +LIN_SDT_PROBE_DEFINE1(time, linux_clock_gettime64, copyout_error, "int"); +#endif LIN_SDT_PROBE_DEFINE1(time, linux_clock_settime, conversion_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_settime, settime_error, "int"); LIN_SDT_PROBE_DEFINE1(time, linux_clock_settime, copyin_error, "int"); @@ -98,6 +102,9 @@ 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"); +static int linux_common_clock_gettime(struct thread *, clockid_t, + struct timespec *); + int native_to_linux_timespec(struct l_timespec *ltp, struct timespec *ntp) { @@ -239,11 +246,10 @@ linux_to_native_timerflags(int *nflags, int flags) return (0); } -int -linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) +static int +linux_common_clock_gettime(struct thread *td, clockid_t which, + struct timespec *tp) { - struct l_timespec lts; - struct timespec tp; struct rusage ru; struct thread *targettd; struct proc *p; @@ -252,20 +258,20 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) 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_gettime clockid %d", args->which); - LIN_SDT_PROBE1(time, linux_clock_gettime, conversion_error, - error); + "unsupported clock_gettime clockid %d", which); + LIN_SDT_PROBE1(time, linux_common_clock_gettime, + conversion_error, error); return (error); } switch (nwhich) { case CLOCK_PROCESS_CPUTIME_ID: - if (args->which < 0) { - clockwhich = LINUX_CPUCLOCK_WHICH(args->which); - pid = LINUX_CPUCLOCK_ID(args->which); + if (which < 0) { + clockwhich = LINUX_CPUCLOCK_WHICH(which); + pid = LINUX_CPUCLOCK_ID(which); } else { clockwhich = LINUX_CPUCLOCK_SCHED; pid = 0; @@ -285,17 +291,17 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) PROC_STATUNLOCK(p); PROC_UNLOCK(p); timevaladd(&ru.ru_utime, &ru.ru_stime); - TIMEVAL_TO_TIMESPEC(&ru.ru_utime, &tp); + TIMEVAL_TO_TIMESPEC(&ru.ru_utime, tp); break; case LINUX_CPUCLOCK_VIRT: PROC_STATLOCK(p); calcru(p, &ru.ru_utime, &ru.ru_stime); PROC_STATUNLOCK(p); PROC_UNLOCK(p); - TIMEVAL_TO_TIMESPEC(&ru.ru_utime, &tp); + TIMEVAL_TO_TIMESPEC(&ru.ru_utime, tp); break; case LINUX_CPUCLOCK_SCHED: - kern_process_cputime(p, &tp); + kern_process_cputime(p, tp); PROC_UNLOCK(p); break; default: @@ -306,9 +312,9 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) break; case CLOCK_THREAD_CPUTIME_ID: - if (args->which < 0) { - clockwhich = LINUX_CPUCLOCK_WHICH(args->which); - tid = LINUX_CPUCLOCK_ID(args->which); + if (which < 0) { + clockwhich = LINUX_CPUCLOCK_WHICH(which); + tid = LINUX_CPUCLOCK_ID(which); } else { clockwhich = LINUX_CPUCLOCK_SCHED; tid = 0; @@ -331,7 +337,7 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) PROC_STATUNLOCK(p); PROC_UNLOCK(p); timevaladd(&ru.ru_utime, &ru.ru_stime); - TIMEVAL_TO_TIMESPEC(&ru.ru_utime, &tp); + TIMEVAL_TO_TIMESPEC(&ru.ru_utime, tp); break; case LINUX_CPUCLOCK_VIRT: PROC_STATLOCK(p); @@ -340,12 +346,12 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) thread_unlock(targettd); PROC_STATUNLOCK(p); PROC_UNLOCK(p); - TIMEVAL_TO_TIMESPEC(&ru.ru_utime, &tp); + TIMEVAL_TO_TIMESPEC(&ru.ru_utime, tp); break; case LINUX_CPUCLOCK_SCHED: if (td == targettd) targettd = NULL; - kern_thread_cputime(targettd, &tp); + kern_thread_cputime(targettd, tp); PROC_UNLOCK(p); break; default: @@ -355,9 +361,21 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) break; default: - error = kern_clock_gettime(td, nwhich, &tp); + error = kern_clock_gettime(td, nwhich, tp); break; } + + return (error); +} + +int +linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) +{ + struct l_timespec lts; + struct timespec tp; + int error; + + error = linux_common_clock_gettime(td, args->which, &tp); if (error != 0) { LIN_SDT_PROBE1(time, linux_clock_gettime, gettime_error, error); return (error); @@ -365,13 +383,37 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) error = native_to_linux_timespec(<s, &tp); 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_gettime, copyout_error, error); return (error); } +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int +linux_clock_gettime64(struct thread *td, struct linux_clock_gettime64_args *args) +{ + struct l_timespec64 lts; + struct timespec tp; + int error; + + error = linux_common_clock_gettime(td, args->which, &tp); + if (error != 0) { + LIN_SDT_PROBE1(time, linux_clock_gettime64, gettime_error, error); + return (error); + } + error = native_to_linux_timespec64(<s, &tp); + if (error != 0) + return (error); + error = copyout(<s, args->tp, sizeof(lts)); + if (error != 0) + LIN_SDT_PROBE1(time, linux_clock_gettime64, copyout_error, error); + + return (error); +} +#endif + int linux_clock_settime(struct thread *td, struct linux_clock_settime_args *args) { diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c index d479ecde7a01..6855573c9358 100644 --- a/sys/i386/linux/linux_dummy_machdep.c +++ b/sys/i386/linux/linux_dummy_machdep.c @@ -69,7 +69,6 @@ DUMMY(vm86old); /* Linux 4.11: */ DUMMY(arch_prctl); /* Linux 5.0: */ -DUMMY(clock_gettime64); DUMMY(clock_settime64); DUMMY(clock_adjtime64); DUMMY(clock_getres_time64); diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index 5ba21877f42c..b0e305a45332 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -2359,7 +2359,10 @@ } ; Linux 5.0: 403 AUE_NULL STD { - int linux_clock_gettime64(void); + int linux_clock_gettime64( + clockid_t which, + struct l_timespec64 *tp + ); } 404 AUE_NULL STD { int linux_clock_settime64(void);