Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jun 2022 19:28:57 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: b004647240e7 - stable/13 - linux(4): Implement clock_settime64 system call.
Message-ID:  <202206171928.25HJSvOH096763@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=b004647240e7242b3246714c2db360563d8d76cb

commit b004647240e7242b3246714c2db360563d8d76cb
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2021-06-07 02:11:25 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:27:57 +0000

    linux(4): Implement clock_settime64 system call.
    
    MFC after:      2 weeks
    
    (cherry picked from commit 19f9a0e4df54f8d1e99234146024422bdcfa09ce)
---
 sys/amd64/linux32/linux32_dummy_machdep.c |  1 -
 sys/amd64/linux32/syscalls.master         |  5 ++-
 sys/compat/linux/linux_time.c             | 67 ++++++++++++++++++++++++-------
 sys/i386/linux/linux_dummy_machdep.c      |  1 -
 sys/i386/linux/syscalls.master            |  5 ++-
 5 files changed, 60 insertions(+), 19 deletions(-)

diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c
index 3ff38c7a8584..022fbcbdd0c6 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_settime64);
 DUMMY(clock_adjtime64);
 DUMMY(clock_getres_time64);
 DUMMY(clock_nanosleep_time64);
diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master
index dbba97da68f8..924fbce9eac7 100644
--- a/sys/amd64/linux32/syscalls.master
+++ b/sys/amd64/linux32/syscalls.master
@@ -2347,7 +2347,10 @@
 		);
 	}
 404	AUE_NULL	STD {
-		int linux_clock_settime64(void);
+		int linux_clock_settime64(
+		    clockid_t which,
+		    struct l_timespec64 *tp
+		);
 	}
 405	AUE_NULL	STD {
 		int linux_clock_adjtime64(void);
diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c
index 10df72ad29f8..65bb4e9b754f 100644
--- a/sys/compat/linux/linux_time.c
+++ b/sys/compat/linux/linux_time.c
@@ -87,8 +87,13 @@ 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_common_clock_settime, settime_error, "int");
+LIN_SDT_PROBE_DEFINE1(time, linux_common_clock_settime, conversion_error, "int");
 LIN_SDT_PROBE_DEFINE1(time, linux_clock_settime, copyin_error, "int");
+#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
+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");
@@ -104,6 +109,8 @@ LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, unsupported_clockid, "int");
 
 static int	linux_common_clock_gettime(struct thread *, clockid_t,
 		    struct timespec *);
+static int	linux_common_clock_settime(struct thread *, clockid_t,
+		    struct timespec *);
 
 int
 native_to_linux_timespec(struct l_timespec *ltp, struct timespec *ntp)
@@ -414,40 +421,70 @@ linux_clock_gettime64(struct thread *td, struct linux_clock_gettime64_args *args
 }
 #endif
 
-int
-linux_clock_settime(struct thread *td, struct linux_clock_settime_args *args)
+static int
+linux_common_clock_settime(struct thread *td, clockid_t which,
+    struct timespec *ts)
 {
-	struct timespec ts;
-	struct l_timespec lts;
 	int error;
 	clockid_t nwhich;
 
-	error = linux_to_native_clockid(&nwhich, args->which);
+	error = linux_to_native_clockid(&nwhich, which);
 	if (error != 0) {
 		linux_msg(curthread,
-		    "unsupported clock_settime clockid %d", args->which);
-		LIN_SDT_PROBE1(time, linux_clock_settime, conversion_error,
+		    "unsupported clock_settime clockid %d", which);
+		LIN_SDT_PROBE1(time, linux_common_clock_settime, conversion_error,
 		    error);
 		return (error);
 	}
-	error = copyin(args->tp, &lts, sizeof lts);
+
+	error = kern_clock_settime(td, nwhich, ts);
+	if (error != 0)
+		LIN_SDT_PROBE1(time, linux_common_clock_settime,
+		    settime_error, error);
+
+	return (error);
+}
+
+int
+linux_clock_settime(struct thread *td, struct linux_clock_settime_args *args)
+{
+	struct timespec ts;
+	struct l_timespec lts;
+	int error;
+
+	error = copyin(args->tp, &lts, sizeof(lts));
 	if (error != 0) {
 		LIN_SDT_PROBE1(time, linux_clock_settime, copyin_error, error);
 		return (error);
 	}
 	error = linux_to_native_timespec(&ts, &lts);
-	if (error != 0) {
+	if (error != 0)
 		LIN_SDT_PROBE1(time, linux_clock_settime, conversion_error,
 		    error);
+
+	return (linux_common_clock_settime(td, args->which, &ts));
+}
+
+#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
+int
+linux_clock_settime64(struct thread *td, struct linux_clock_settime64_args *args)
+{
+	struct timespec ts;
+	struct l_timespec64 lts;
+	int error;
+
+	error = copyin(args->tp, &lts, sizeof(lts));
+	if (error != 0) {
+		LIN_SDT_PROBE1(time, linux_clock_settime64, copyin_error, error);
 		return (error);
 	}
-
-	error = kern_clock_settime(td, nwhich, &ts);
+	error = linux_to_native_timespec64(&ts, &lts);
 	if (error != 0)
-		LIN_SDT_PROBE1(time, linux_clock_settime, settime_error, error);
-
-	return (error);
+		LIN_SDT_PROBE1(time, linux_clock_settime64, conversion_error,
+		    error);
+	return (linux_common_clock_settime(td, args->which, &ts));
 }
+#endif
 
 int
 linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args)
diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c
index 6855573c9358..762dc177b1b0 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_settime64);
 DUMMY(clock_adjtime64);
 DUMMY(clock_getres_time64);
 DUMMY(clock_nanosleep_time64);
diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master
index b0e305a45332..a8b41605b743 100644
--- a/sys/i386/linux/syscalls.master
+++ b/sys/i386/linux/syscalls.master
@@ -2365,7 +2365,10 @@
 		);
 	}
 404	AUE_NULL	STD {
-		int linux_clock_settime64(void);
+		int linux_clock_settime64(
+		    clockid_t which,
+		    struct l_timespec64 *tp
+		);
 	}
 405	AUE_NULL	STD {
 		int linux_clock_adjtime64(void);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202206171928.25HJSvOH096763>