Tested with the usual diff of sysctl machdep. OK?
>From 0d628f5c7eb69f7964beca7945f634d26af34834 Mon Sep 17 00:00:00 2001 From: Greg Steuck <[email protected]> Date: Wed, 18 Nov 2020 20:33:37 -0800 Subject: [PATCH] Turn simple sysctl_rdint into cpuctl_vars entries --- sys/arch/amd64/amd64/machdep.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git sys/arch/amd64/amd64/machdep.c sys/arch/amd64/amd64/machdep.c index e12700c1576..b6a050f4da7 100644 --- sys/arch/amd64/amd64/machdep.c +++ sys/arch/amd64/amd64/machdep.c @@ -469,9 +469,16 @@ bios_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, /* NOTREACHED */ } +extern int tsc_is_invariant; +extern int amd64_has_xcrypt; + const struct sysctl_bounded_args cpuctl_vars[] = { { CPU_LIDACTION, &lid_action, 0, 2 }, { CPU_PWRACTION, &pwr_action, 0, 2 }, + { CPU_CPUID, &cpu_id, 1, 0 }, + { CPU_CPUFEATURE, &cpu_feature, 1, 0 }, + { CPU_XCRYPT, &amd64_has_xcrypt, 1, 0 }, + { CPU_INVARIANTTSC, &tsc_is_invariant, 1, 0 }, }; /* @@ -482,8 +489,6 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen, struct proc *p) { extern uint64_t tsc_frequency; - extern int tsc_is_invariant; - extern int amd64_has_xcrypt; dev_t consdev; dev_t dev; @@ -507,10 +512,6 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, newp, newlen, p); case CPU_CPUVENDOR: return (sysctl_rdstring(oldp, oldlenp, newp, cpu_vendor)); - case CPU_CPUID: - return (sysctl_rdint(oldp, oldlenp, newp, cpu_id)); - case CPU_CPUFEATURE: - return (sysctl_rdint(oldp, oldlenp, newp, cpu_feature)); case CPU_KBDRESET: if (securelevel > 0) return (sysctl_rdint(oldp, oldlenp, newp, @@ -531,8 +532,6 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, #else return (sysctl_rdint(oldp, oldlenp, newp, 0)); #endif - case CPU_XCRYPT: - return (sysctl_rdint(oldp, oldlenp, newp, amd64_has_xcrypt)); #if NPCKBC > 0 && NUKBD > 0 case CPU_FORCEUKBD: { @@ -549,8 +548,6 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, #endif case CPU_TSCFREQ: return (sysctl_rdquad(oldp, oldlenp, newp, tsc_frequency)); - case CPU_INVARIANTTSC: - return (sysctl_rdint(oldp, oldlenp, newp, tsc_is_invariant)); default: return (sysctl_bounded_arr(cpuctl_vars, nitems(cpuctl_vars), name, namelen, oldp, oldlenp, newp, newlen)); -- 2.29.2
