git: d4775425c16c - main - ffclock: add kern_ interfaces

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Mon, 09 Nov 2026 11:54:20 UTC
The branch main has been updated by brooks:

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

commit d4775425c16ceb3933c45cfe1a78bbed0a6fdf92
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2025-11-21 17:22:24 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-09 11:27:40 +0000

    ffclock: add kern_ interfaces
    
    Effort:         CHERI upstreaming
    Sponsored by:   Innovate UK
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
---
 sys/kern/kern_ffclock.c | 28 ++++++++++++++++++++++++----
 sys/sys/syscallsubr.h   |  7 +++++++
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/sys/kern/kern_ffclock.c b/sys/kern/kern_ffclock.c
index 6e32c82bc0b8..62e4b18f78de 100644
--- a/sys/kern/kern_ffclock.c
+++ b/sys/kern/kern_ffclock.c
@@ -41,8 +41,9 @@
 #include <sys/priv.h>
 #include <sys/proc.h>
 #include <sys/sbuf.h>
-#include <sys/sysproto.h>
+#include <sys/syscallsubr.h>
 #include <sys/sysctl.h>
+#include <sys/sysproto.h>
 #include <sys/systm.h>
 #include <sys/timeffc.h>
 
@@ -385,6 +386,12 @@ struct ffclock_getcounter_args {
 /* ARGSUSED */
 int
 sys_ffclock_getcounter(struct thread *td, struct ffclock_getcounter_args *uap)
+{
+	return (kern_ffclock_getcounter(td, uap->ffcount));
+}
+
+int
+kern_ffclock_getcounter(struct thread *td, ffcounter *uffcount)
 {
 	ffcounter ffcount;
 	int error;
@@ -393,7 +400,7 @@ sys_ffclock_getcounter(struct thread *td, struct ffclock_getcounter_args *uap)
 	ffclock_read_counter(&ffcount);
 	if (ffcount == 0)
 		return (EAGAIN);
-	error = copyout(&ffcount, uap->ffcount, sizeof(ffcounter));
+	error = copyout(&ffcount, uffcount, sizeof(ffcounter));
 
 	return (error);
 }
@@ -414,6 +421,13 @@ struct ffclock_setestimate_args {
 /* ARGSUSED */
 int
 sys_ffclock_setestimate(struct thread *td, struct ffclock_setestimate_args *uap)
+{
+	return (kern_ffclock_setestimate(td, uap->cest));
+}
+
+int
+kern_ffclock_setestimate(struct thread *td,
+    const struct ffclock_estimate *ucest)
 {
 	struct ffclock_estimate cest;
 	int error;
@@ -422,7 +436,7 @@ sys_ffclock_setestimate(struct thread *td, struct ffclock_setestimate_args *uap)
 	if ((error = priv_check(td, PRIV_CLOCK_SETTIME)) != 0)
 		return (error);
 
-	if ((error = copyin(uap->cest, &cest, sizeof(struct ffclock_estimate)))
+	if ((error = copyin(ucest, &cest, sizeof(struct ffclock_estimate)))
 	    != 0)
 		return (error);
 
@@ -446,6 +460,12 @@ struct ffclock_getestimate_args {
 /* ARGSUSED */
 int
 sys_ffclock_getestimate(struct thread *td, struct ffclock_getestimate_args *uap)
+{
+	return (kern_ffclock_getestimate(td, uap->cest));
+}
+
+int
+kern_ffclock_getestimate(struct thread *td, struct ffclock_estimate *ucest)
 {
 	struct ffclock_estimate cest;
 	int error;
@@ -453,7 +473,7 @@ sys_ffclock_getestimate(struct thread *td, struct ffclock_getestimate_args *uap)
 	mtx_lock(&ffclock_mtx);
 	memcpy(&cest, &ffclock_estimate, sizeof(struct ffclock_estimate));
 	mtx_unlock(&ffclock_mtx);
-	error = copyout(&cest, uap->cest, sizeof(struct ffclock_estimate));
+	error = copyout(&cest, ucest, sizeof(struct ffclock_estimate));
 	return (error);
 }
 
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 1f58fd06cb0b..5f91185729cc 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -31,6 +31,7 @@
 #include <sys/types.h>
 #include <sys/_cpuset.h>
 #include <sys/_domainset.h>
+#include <sys/_ffcounter.h>
 #include <sys/_uio.h>
 #include <sys/mac.h>
 #include <sys/mount.h>
@@ -39,6 +40,7 @@
 
 struct __wrusage;
 struct cpuset_copy_cb;
+struct ffclock_estimate;
 struct file;
 struct filecaps;
 enum idtype;
@@ -216,6 +218,11 @@ int	kern_fchownat(struct thread *td, int fd, const char *path,
 	    enum uio_seg pathseg, int uid, int gid, int flag);
 int	kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg);
 int	kern_fcntl_freebsd(struct thread *td, int fd, int cmd, intptr_t arg);
+int	kern_ffclock_getcounter(struct thread *td, ffcounter *ffcountp);
+int	kern_ffclock_getestimate(struct thread *td,
+	    struct ffclock_estimate *ucest);
+int	kern_ffclock_setestimate(struct thread *td,
+	    const struct ffclock_estimate *ucest);
 int	kern_fhopen(struct thread *td, const struct fhandle *u_fhp, int flags);
 int	kern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf);
 int	kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf);