xref: /xnu-10002.81.5/bsd/dev/i386/sysctl.c (revision 5e3eaea39dcf651e66cb99ba7d70e32cc4a99587)
1*5e3eaea3SApple OSS Distributions /*
2*5e3eaea3SApple OSS Distributions  * Copyright (c) 2003-2020 Apple Inc. All rights reserved.
3*5e3eaea3SApple OSS Distributions  *
4*5e3eaea3SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*5e3eaea3SApple OSS Distributions  *
6*5e3eaea3SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*5e3eaea3SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*5e3eaea3SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*5e3eaea3SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*5e3eaea3SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*5e3eaea3SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*5e3eaea3SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*5e3eaea3SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*5e3eaea3SApple OSS Distributions  *
15*5e3eaea3SApple OSS Distributions  * Please obtain a copy of the License at
16*5e3eaea3SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*5e3eaea3SApple OSS Distributions  *
18*5e3eaea3SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*5e3eaea3SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*5e3eaea3SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*5e3eaea3SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*5e3eaea3SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*5e3eaea3SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*5e3eaea3SApple OSS Distributions  * limitations under the License.
25*5e3eaea3SApple OSS Distributions  *
26*5e3eaea3SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*5e3eaea3SApple OSS Distributions  */
28*5e3eaea3SApple OSS Distributions 
29*5e3eaea3SApple OSS Distributions #include <string.h>
30*5e3eaea3SApple OSS Distributions #include <sys/param.h>
31*5e3eaea3SApple OSS Distributions #include <sys/kernel.h>
32*5e3eaea3SApple OSS Distributions #include <sys/sysctl.h>
33*5e3eaea3SApple OSS Distributions #include <i386/cpuid.h>
34*5e3eaea3SApple OSS Distributions #include <i386/tsc.h>
35*5e3eaea3SApple OSS Distributions #include <i386/rtclock_protos.h>
36*5e3eaea3SApple OSS Distributions #include <i386/machine_routines.h>
37*5e3eaea3SApple OSS Distributions #include <i386/pal_routines.h>
38*5e3eaea3SApple OSS Distributions #include <i386/ucode.h>
39*5e3eaea3SApple OSS Distributions #include <kern/clock.h>
40*5e3eaea3SApple OSS Distributions #include <libkern/libkern.h>
41*5e3eaea3SApple OSS Distributions #include <i386/lapic.h>
42*5e3eaea3SApple OSS Distributions #include <i386/mp.h>
43*5e3eaea3SApple OSS Distributions #include <kern/kalloc.h>
44*5e3eaea3SApple OSS Distributions #include <i386/pmap.h>
45*5e3eaea3SApple OSS Distributions 
46*5e3eaea3SApple OSS Distributions 
47*5e3eaea3SApple OSS Distributions static int
48*5e3eaea3SApple OSS Distributions _i386_cpu_info SYSCTL_HANDLER_ARGS
49*5e3eaea3SApple OSS Distributions {
50*5e3eaea3SApple OSS Distributions 	__unused struct sysctl_oid *unused_oidp = oidp;
51*5e3eaea3SApple OSS Distributions 	void *ptr = arg1;
52*5e3eaea3SApple OSS Distributions 	int value;
53*5e3eaea3SApple OSS Distributions 
54*5e3eaea3SApple OSS Distributions 	if (arg2 == -1) {
55*5e3eaea3SApple OSS Distributions 		ptr = *(void **)ptr;
56*5e3eaea3SApple OSS Distributions 		arg2 = 0;
57*5e3eaea3SApple OSS Distributions 	}
58*5e3eaea3SApple OSS Distributions 
59*5e3eaea3SApple OSS Distributions 	if (arg2 == 0 && ((char *)ptr)[0] == '\0') {
60*5e3eaea3SApple OSS Distributions 		return ENOENT;
61*5e3eaea3SApple OSS Distributions 	}
62*5e3eaea3SApple OSS Distributions 
63*5e3eaea3SApple OSS Distributions 	if (arg2 == sizeof(uint8_t)) {
64*5e3eaea3SApple OSS Distributions 		value = (uint32_t) *(uint8_t *)ptr;
65*5e3eaea3SApple OSS Distributions 		ptr = &value;
66*5e3eaea3SApple OSS Distributions 		arg2 = sizeof(uint32_t);
67*5e3eaea3SApple OSS Distributions 	}
68*5e3eaea3SApple OSS Distributions 	return SYSCTL_OUT(req, ptr, arg2 ? (size_t) arg2 : strlen((char *)ptr) + 1);
69*5e3eaea3SApple OSS Distributions }
70*5e3eaea3SApple OSS Distributions 
71*5e3eaea3SApple OSS Distributions static int
72*5e3eaea3SApple OSS Distributions i386_cpu_info SYSCTL_HANDLER_ARGS
73*5e3eaea3SApple OSS Distributions {
74*5e3eaea3SApple OSS Distributions 	void *ptr = (uint8_t *)cpuid_info() + (uintptr_t)arg1;
75*5e3eaea3SApple OSS Distributions 	return _i386_cpu_info(oidp, ptr, arg2, req);
76*5e3eaea3SApple OSS Distributions }
77*5e3eaea3SApple OSS Distributions 
78*5e3eaea3SApple OSS Distributions static int
79*5e3eaea3SApple OSS Distributions i386_cpu_info_nonzero SYSCTL_HANDLER_ARGS
80*5e3eaea3SApple OSS Distributions {
81*5e3eaea3SApple OSS Distributions 	void *ptr = (uint8_t *)cpuid_info() + (uintptr_t)arg1;
82*5e3eaea3SApple OSS Distributions 	int value = *(uint32_t *)ptr;
83*5e3eaea3SApple OSS Distributions 
84*5e3eaea3SApple OSS Distributions 	if (value == 0) {
85*5e3eaea3SApple OSS Distributions 		return ENOENT;
86*5e3eaea3SApple OSS Distributions 	}
87*5e3eaea3SApple OSS Distributions 
88*5e3eaea3SApple OSS Distributions 	return _i386_cpu_info(oidp, ptr, arg2, req);
89*5e3eaea3SApple OSS Distributions }
90*5e3eaea3SApple OSS Distributions static int
91*5e3eaea3SApple OSS Distributions cpu_mwait SYSCTL_HANDLER_ARGS
92*5e3eaea3SApple OSS Distributions {
93*5e3eaea3SApple OSS Distributions 	i386_cpu_info_t *cpu_info = cpuid_info();
94*5e3eaea3SApple OSS Distributions 	void *ptr = (uint8_t *)cpu_info->cpuid_mwait_leafp + (uintptr_t)arg1;
95*5e3eaea3SApple OSS Distributions 	if (cpu_info->cpuid_mwait_leafp == NULL) {
96*5e3eaea3SApple OSS Distributions 		return ENOENT;
97*5e3eaea3SApple OSS Distributions 	}
98*5e3eaea3SApple OSS Distributions 	return _i386_cpu_info(oidp, ptr, arg2, req);
99*5e3eaea3SApple OSS Distributions }
100*5e3eaea3SApple OSS Distributions 
101*5e3eaea3SApple OSS Distributions static int
102*5e3eaea3SApple OSS Distributions cpu_thermal SYSCTL_HANDLER_ARGS
103*5e3eaea3SApple OSS Distributions {
104*5e3eaea3SApple OSS Distributions 	i386_cpu_info_t *cpu_info = cpuid_info();
105*5e3eaea3SApple OSS Distributions 	void *ptr = (uint8_t *)cpu_info->cpuid_thermal_leafp + (uintptr_t)arg1;
106*5e3eaea3SApple OSS Distributions 	if (cpu_info->cpuid_thermal_leafp == NULL) {
107*5e3eaea3SApple OSS Distributions 		return ENOENT;
108*5e3eaea3SApple OSS Distributions 	}
109*5e3eaea3SApple OSS Distributions 	return _i386_cpu_info(oidp, ptr, arg2, req);
110*5e3eaea3SApple OSS Distributions }
111*5e3eaea3SApple OSS Distributions 
112*5e3eaea3SApple OSS Distributions static int
113*5e3eaea3SApple OSS Distributions cpu_arch_perf SYSCTL_HANDLER_ARGS
114*5e3eaea3SApple OSS Distributions {
115*5e3eaea3SApple OSS Distributions 	i386_cpu_info_t *cpu_info = cpuid_info();
116*5e3eaea3SApple OSS Distributions 	void *ptr = (uint8_t *)cpu_info->cpuid_arch_perf_leafp + (uintptr_t)arg1;
117*5e3eaea3SApple OSS Distributions 	if (cpu_info->cpuid_arch_perf_leafp == NULL) {
118*5e3eaea3SApple OSS Distributions 		return ENOENT;
119*5e3eaea3SApple OSS Distributions 	}
120*5e3eaea3SApple OSS Distributions 	return _i386_cpu_info(oidp, ptr, arg2, req);
121*5e3eaea3SApple OSS Distributions }
122*5e3eaea3SApple OSS Distributions 
123*5e3eaea3SApple OSS Distributions static int
124*5e3eaea3SApple OSS Distributions cpu_xsave SYSCTL_HANDLER_ARGS
125*5e3eaea3SApple OSS Distributions {
126*5e3eaea3SApple OSS Distributions 	i386_cpu_info_t *cpu_info = cpuid_info();
127*5e3eaea3SApple OSS Distributions 	void *ptr = (uint8_t *)cpu_info->cpuid_xsave_leafp + (uintptr_t)arg1;
128*5e3eaea3SApple OSS Distributions 	if (cpu_info->cpuid_xsave_leafp == NULL) {
129*5e3eaea3SApple OSS Distributions 		return ENOENT;
130*5e3eaea3SApple OSS Distributions 	}
131*5e3eaea3SApple OSS Distributions 	return _i386_cpu_info(oidp, ptr, arg2, req);
132*5e3eaea3SApple OSS Distributions }
133*5e3eaea3SApple OSS Distributions 
134*5e3eaea3SApple OSS Distributions 
135*5e3eaea3SApple OSS Distributions static int
136*5e3eaea3SApple OSS Distributions cpu_features SYSCTL_HANDLER_ARGS
137*5e3eaea3SApple OSS Distributions {
138*5e3eaea3SApple OSS Distributions 	__unused struct sysctl_oid *unused_oidp = oidp;
139*5e3eaea3SApple OSS Distributions 	__unused void *unused_arg1 = arg1;
140*5e3eaea3SApple OSS Distributions 	__unused int unused_arg2 = arg2;
141*5e3eaea3SApple OSS Distributions 	char buf[512];
142*5e3eaea3SApple OSS Distributions 
143*5e3eaea3SApple OSS Distributions 	buf[0] = '\0';
144*5e3eaea3SApple OSS Distributions 	cpuid_get_feature_names(cpuid_features(), buf, sizeof(buf));
145*5e3eaea3SApple OSS Distributions 
146*5e3eaea3SApple OSS Distributions 	return SYSCTL_OUT(req, buf, strlen(buf) + 1);
147*5e3eaea3SApple OSS Distributions }
148*5e3eaea3SApple OSS Distributions 
149*5e3eaea3SApple OSS Distributions static int
150*5e3eaea3SApple OSS Distributions cpu_extfeatures SYSCTL_HANDLER_ARGS
151*5e3eaea3SApple OSS Distributions {
152*5e3eaea3SApple OSS Distributions 	__unused struct sysctl_oid *unused_oidp = oidp;
153*5e3eaea3SApple OSS Distributions 	__unused void *unused_arg1 = arg1;
154*5e3eaea3SApple OSS Distributions 	__unused int unused_arg2 = arg2;
155*5e3eaea3SApple OSS Distributions 	char buf[512];
156*5e3eaea3SApple OSS Distributions 
157*5e3eaea3SApple OSS Distributions 	buf[0] = '\0';
158*5e3eaea3SApple OSS Distributions 	cpuid_get_extfeature_names(cpuid_extfeatures(), buf, sizeof(buf));
159*5e3eaea3SApple OSS Distributions 
160*5e3eaea3SApple OSS Distributions 	return SYSCTL_OUT(req, buf, strlen(buf) + 1);
161*5e3eaea3SApple OSS Distributions }
162*5e3eaea3SApple OSS Distributions 
163*5e3eaea3SApple OSS Distributions static int
164*5e3eaea3SApple OSS Distributions cpu_leaf7_features SYSCTL_HANDLER_ARGS
165*5e3eaea3SApple OSS Distributions {
166*5e3eaea3SApple OSS Distributions 	__unused struct sysctl_oid *unused_oidp = oidp;
167*5e3eaea3SApple OSS Distributions 	__unused void *unused_arg1 = arg1;
168*5e3eaea3SApple OSS Distributions 	__unused int unused_arg2 = arg2;
169*5e3eaea3SApple OSS Distributions 	char buf[512];
170*5e3eaea3SApple OSS Distributions 
171*5e3eaea3SApple OSS Distributions 	uint64_t    leaf7_features = cpuid_info()->cpuid_leaf7_features;
172*5e3eaea3SApple OSS Distributions 	uint64_t    leaf7_extfeatures = cpuid_info()->cpuid_leaf7_extfeatures;
173*5e3eaea3SApple OSS Distributions 	if (leaf7_features == 0 && leaf7_extfeatures == 0) {
174*5e3eaea3SApple OSS Distributions 		return ENOENT;
175*5e3eaea3SApple OSS Distributions 	}
176*5e3eaea3SApple OSS Distributions 
177*5e3eaea3SApple OSS Distributions 	buf[0] = '\0';
178*5e3eaea3SApple OSS Distributions 	cpuid_get_leaf7_feature_names(leaf7_features, buf, sizeof(buf));
179*5e3eaea3SApple OSS Distributions 	if (leaf7_extfeatures != 0) {
180*5e3eaea3SApple OSS Distributions 		strlcat(buf, " ", sizeof(buf));
181*5e3eaea3SApple OSS Distributions 		cpuid_get_leaf7_extfeature_names(leaf7_extfeatures, buf + strlen(buf),
182*5e3eaea3SApple OSS Distributions 		    (unsigned int)(sizeof(buf) - strlen(buf)));
183*5e3eaea3SApple OSS Distributions 	}
184*5e3eaea3SApple OSS Distributions 
185*5e3eaea3SApple OSS Distributions 	return SYSCTL_OUT(req, buf, strlen(buf) + 1);
186*5e3eaea3SApple OSS Distributions }
187*5e3eaea3SApple OSS Distributions 
188*5e3eaea3SApple OSS Distributions static int
189*5e3eaea3SApple OSS Distributions cpu_logical_per_package SYSCTL_HANDLER_ARGS
190*5e3eaea3SApple OSS Distributions {
191*5e3eaea3SApple OSS Distributions 	__unused struct sysctl_oid *unused_oidp = oidp;
192*5e3eaea3SApple OSS Distributions 	__unused void *unused_arg1 = arg1;
193*5e3eaea3SApple OSS Distributions 	__unused int unused_arg2 = arg2;
194*5e3eaea3SApple OSS Distributions 	i386_cpu_info_t *cpu_info = cpuid_info();
195*5e3eaea3SApple OSS Distributions 
196*5e3eaea3SApple OSS Distributions 	if (!(cpuid_features() & CPUID_FEATURE_HTT)) {
197*5e3eaea3SApple OSS Distributions 		return ENOENT;
198*5e3eaea3SApple OSS Distributions 	}
199*5e3eaea3SApple OSS Distributions 
200*5e3eaea3SApple OSS Distributions 	return SYSCTL_OUT(req, &cpu_info->cpuid_logical_per_package,
201*5e3eaea3SApple OSS Distributions 	           sizeof(cpu_info->cpuid_logical_per_package));
202*5e3eaea3SApple OSS Distributions }
203*5e3eaea3SApple OSS Distributions 
204*5e3eaea3SApple OSS Distributions static int
205*5e3eaea3SApple OSS Distributions cpu_flex_ratio_desired SYSCTL_HANDLER_ARGS
206*5e3eaea3SApple OSS Distributions {
207*5e3eaea3SApple OSS Distributions 	__unused struct sysctl_oid *unused_oidp = oidp;
208*5e3eaea3SApple OSS Distributions 	__unused void *unused_arg1 = arg1;
209*5e3eaea3SApple OSS Distributions 	__unused int unused_arg2 = arg2;
210*5e3eaea3SApple OSS Distributions 	i386_cpu_info_t *cpu_info = cpuid_info();
211*5e3eaea3SApple OSS Distributions 
212*5e3eaea3SApple OSS Distributions 	if (cpu_info->cpuid_model != 26) {
213*5e3eaea3SApple OSS Distributions 		return ENOENT;
214*5e3eaea3SApple OSS Distributions 	}
215*5e3eaea3SApple OSS Distributions 
216*5e3eaea3SApple OSS Distributions 	return SYSCTL_OUT(req, &flex_ratio, sizeof(flex_ratio));
217*5e3eaea3SApple OSS Distributions }
218*5e3eaea3SApple OSS Distributions 
219*5e3eaea3SApple OSS Distributions static int
220*5e3eaea3SApple OSS Distributions cpu_flex_ratio_min SYSCTL_HANDLER_ARGS
221*5e3eaea3SApple OSS Distributions {
222*5e3eaea3SApple OSS Distributions 	__unused struct sysctl_oid *unused_oidp = oidp;
223*5e3eaea3SApple OSS Distributions 	__unused void *unused_arg1 = arg1;
224*5e3eaea3SApple OSS Distributions 	__unused int unused_arg2 = arg2;
225*5e3eaea3SApple OSS Distributions 	i386_cpu_info_t *cpu_info = cpuid_info();
226*5e3eaea3SApple OSS Distributions 
227*5e3eaea3SApple OSS Distributions 	if (cpu_info->cpuid_model != 26) {
228*5e3eaea3SApple OSS Distributions 		return ENOENT;
229*5e3eaea3SApple OSS Distributions 	}
230*5e3eaea3SApple OSS Distributions 
231*5e3eaea3SApple OSS Distributions 	return SYSCTL_OUT(req, &flex_ratio_min, sizeof(flex_ratio_min));
232*5e3eaea3SApple OSS Distributions }
233*5e3eaea3SApple OSS Distributions 
234*5e3eaea3SApple OSS Distributions static int
235*5e3eaea3SApple OSS Distributions cpu_flex_ratio_max SYSCTL_HANDLER_ARGS
236*5e3eaea3SApple OSS Distributions {
237*5e3eaea3SApple OSS Distributions 	__unused struct sysctl_oid *unused_oidp = oidp;
238*5e3eaea3SApple OSS Distributions 	__unused void *unused_arg1 = arg1;
239*5e3eaea3SApple OSS Distributions 	__unused int unused_arg2 = arg2;
240*5e3eaea3SApple OSS Distributions 	i386_cpu_info_t *cpu_info = cpuid_info();
241*5e3eaea3SApple OSS Distributions 
242*5e3eaea3SApple OSS Distributions 	if (cpu_info->cpuid_model != 26) {
243*5e3eaea3SApple OSS Distributions 		return ENOENT;
244*5e3eaea3SApple OSS Distributions 	}
245*5e3eaea3SApple OSS Distributions 
246*5e3eaea3SApple OSS Distributions 	return SYSCTL_OUT(req, &flex_ratio_max, sizeof(flex_ratio_max));
247*5e3eaea3SApple OSS Distributions }
248*5e3eaea3SApple OSS Distributions 
249*5e3eaea3SApple OSS Distributions static int
250*5e3eaea3SApple OSS Distributions cpu_ucode_update SYSCTL_HANDLER_ARGS
251*5e3eaea3SApple OSS Distributions {
252*5e3eaea3SApple OSS Distributions #pragma unused(oidp, arg1, arg2)
253*5e3eaea3SApple OSS Distributions 	uint64_t addr;
254*5e3eaea3SApple OSS Distributions 	int error;
255*5e3eaea3SApple OSS Distributions 
256*5e3eaea3SApple OSS Distributions 	/* Can't update microcode from within a VM. */
257*5e3eaea3SApple OSS Distributions 
258*5e3eaea3SApple OSS Distributions 	if (cpuid_features() & CPUID_FEATURE_VMM) {
259*5e3eaea3SApple OSS Distributions 		return ENODEV;
260*5e3eaea3SApple OSS Distributions 	}
261*5e3eaea3SApple OSS Distributions 
262*5e3eaea3SApple OSS Distributions 	if (req->newptr == USER_ADDR_NULL) {
263*5e3eaea3SApple OSS Distributions 		return EINVAL;
264*5e3eaea3SApple OSS Distributions 	}
265*5e3eaea3SApple OSS Distributions 
266*5e3eaea3SApple OSS Distributions 	error = SYSCTL_IN(req, &addr, sizeof(addr));
267*5e3eaea3SApple OSS Distributions 	if (error) {
268*5e3eaea3SApple OSS Distributions 		return error;
269*5e3eaea3SApple OSS Distributions 	}
270*5e3eaea3SApple OSS Distributions 
271*5e3eaea3SApple OSS Distributions 	return ucode_interface(addr);
272*5e3eaea3SApple OSS Distributions }
273*5e3eaea3SApple OSS Distributions 
274*5e3eaea3SApple OSS Distributions extern uint64_t panic_restart_timeout;
275*5e3eaea3SApple OSS Distributions static int
panic_set_restart_timeout(__unused struct sysctl_oid * oidp,__unused void * arg1,__unused int arg2,struct sysctl_req * req)276*5e3eaea3SApple OSS Distributions panic_set_restart_timeout(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
277*5e3eaea3SApple OSS Distributions {
278*5e3eaea3SApple OSS Distributions 	int new_value = 0, old_value = 0, changed = 0, error;
279*5e3eaea3SApple OSS Distributions 	uint64_t nstime;
280*5e3eaea3SApple OSS Distributions 
281*5e3eaea3SApple OSS Distributions 	if (panic_restart_timeout) {
282*5e3eaea3SApple OSS Distributions 		absolutetime_to_nanoseconds(panic_restart_timeout, &nstime);
283*5e3eaea3SApple OSS Distributions 		old_value = (int)MIN(nstime / NSEC_PER_SEC, INT_MAX);
284*5e3eaea3SApple OSS Distributions 	}
285*5e3eaea3SApple OSS Distributions 
286*5e3eaea3SApple OSS Distributions 	error = sysctl_io_number(req, old_value, sizeof(old_value), &new_value, &changed);
287*5e3eaea3SApple OSS Distributions 	if (error == 0 && changed) {
288*5e3eaea3SApple OSS Distributions 		if (new_value >= 0) {
289*5e3eaea3SApple OSS Distributions 			nanoseconds_to_absolutetime(((uint64_t)new_value) * NSEC_PER_SEC, &panic_restart_timeout);
290*5e3eaea3SApple OSS Distributions 		} else {
291*5e3eaea3SApple OSS Distributions 			error = EDOM;
292*5e3eaea3SApple OSS Distributions 		}
293*5e3eaea3SApple OSS Distributions 	}
294*5e3eaea3SApple OSS Distributions 	return error;
295*5e3eaea3SApple OSS Distributions }
296*5e3eaea3SApple OSS Distributions 
297*5e3eaea3SApple OSS Distributions /*
298*5e3eaea3SApple OSS Distributions  * Populates the {CPU, vector, latency} triple for the maximum observed primary
299*5e3eaea3SApple OSS Distributions  * interrupt latency
300*5e3eaea3SApple OSS Distributions  */
301*5e3eaea3SApple OSS Distributions static int
misc_interrupt_latency_max(__unused struct sysctl_oid * oidp,__unused void * arg1,__unused int arg2,struct sysctl_req * req)302*5e3eaea3SApple OSS Distributions misc_interrupt_latency_max(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
303*5e3eaea3SApple OSS Distributions {
304*5e3eaea3SApple OSS Distributions 	int changed = 0, error;
305*5e3eaea3SApple OSS Distributions 	char buf[128];
306*5e3eaea3SApple OSS Distributions 	buf[0] = '\0';
307*5e3eaea3SApple OSS Distributions 
308*5e3eaea3SApple OSS Distributions 	interrupt_populate_latency_stats(buf, sizeof(buf));
309*5e3eaea3SApple OSS Distributions 
310*5e3eaea3SApple OSS Distributions 	error = sysctl_io_string(req, buf, sizeof(buf), 0, &changed);
311*5e3eaea3SApple OSS Distributions 
312*5e3eaea3SApple OSS Distributions 	if (error == 0 && changed) {
313*5e3eaea3SApple OSS Distributions 		interrupt_reset_latency_stats();
314*5e3eaea3SApple OSS Distributions 	}
315*5e3eaea3SApple OSS Distributions 
316*5e3eaea3SApple OSS Distributions 	return error;
317*5e3eaea3SApple OSS Distributions }
318*5e3eaea3SApple OSS Distributions 
319*5e3eaea3SApple OSS Distributions #if DEVELOPMENT || DEBUG
320*5e3eaea3SApple OSS Distributions /*
321*5e3eaea3SApple OSS Distributions  * Populates a string with each CPU's tsc synch delta.
322*5e3eaea3SApple OSS Distributions  */
323*5e3eaea3SApple OSS Distributions static int
x86_cpu_tsc_deltas(__unused struct sysctl_oid * oidp,__unused void * arg1,__unused int arg2,struct sysctl_req * req)324*5e3eaea3SApple OSS Distributions x86_cpu_tsc_deltas(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
325*5e3eaea3SApple OSS Distributions {
326*5e3eaea3SApple OSS Distributions 	int err;
327*5e3eaea3SApple OSS Distributions 	uint32_t ncpus = ml_wait_max_cpus();
328*5e3eaea3SApple OSS Distributions 	uint32_t buflen = (2 /* hex digits */ * sizeof(uint64_t) + 3 /* for "0x" + " " */) * ncpus + 1;
329*5e3eaea3SApple OSS Distributions 	char *buf = (char *)kalloc_data(buflen, Z_WAITOK);
330*5e3eaea3SApple OSS Distributions 
331*5e3eaea3SApple OSS Distributions 	cpu_data_tsc_sync_deltas_string(buf, buflen, 0, ncpus - 1);
332*5e3eaea3SApple OSS Distributions 
333*5e3eaea3SApple OSS Distributions 	err = sysctl_io_string(req, buf, buflen, 0, 0);
334*5e3eaea3SApple OSS Distributions 
335*5e3eaea3SApple OSS Distributions 	kfree_data(buf, buflen);
336*5e3eaea3SApple OSS Distributions 
337*5e3eaea3SApple OSS Distributions 	return err;
338*5e3eaea3SApple OSS Distributions }
339*5e3eaea3SApple OSS Distributions 
340*5e3eaea3SApple OSS Distributions /*
341*5e3eaea3SApple OSS Distributions  * Triggers a machine-check exception - for a suitably configured kernel only.
342*5e3eaea3SApple OSS Distributions  */
343*5e3eaea3SApple OSS Distributions extern void mca_exception_panic(void);
344*5e3eaea3SApple OSS Distributions static int
misc_machine_check_panic(__unused struct sysctl_oid * oidp,__unused void * arg1,__unused int arg2,struct sysctl_req * req)345*5e3eaea3SApple OSS Distributions misc_machine_check_panic(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
346*5e3eaea3SApple OSS Distributions {
347*5e3eaea3SApple OSS Distributions 	int changed = 0, error;
348*5e3eaea3SApple OSS Distributions 	char buf[128];
349*5e3eaea3SApple OSS Distributions 	buf[0] = '\0';
350*5e3eaea3SApple OSS Distributions 
351*5e3eaea3SApple OSS Distributions 	error = sysctl_io_string(req, buf, sizeof(buf), 0, &changed);
352*5e3eaea3SApple OSS Distributions 
353*5e3eaea3SApple OSS Distributions 	if (error == 0 && changed) {
354*5e3eaea3SApple OSS Distributions 		mca_exception_panic();
355*5e3eaea3SApple OSS Distributions 	}
356*5e3eaea3SApple OSS Distributions 	return error;
357*5e3eaea3SApple OSS Distributions }
358*5e3eaea3SApple OSS Distributions 
359*5e3eaea3SApple OSS Distributions /*
360*5e3eaea3SApple OSS Distributions  * Triggers a non-responsive processor timeout panic - for a suitably configured kernel only.
361*5e3eaea3SApple OSS Distributions  */
362*5e3eaea3SApple OSS Distributions static uint64_t kernel_timeout_spin = 0;
363*5e3eaea3SApple OSS Distributions static int
misc_kernel_timeout_spin(__unused struct sysctl_oid * oidp,__unused void * arg1,__unused int arg2,struct sysctl_req * req)364*5e3eaea3SApple OSS Distributions misc_kernel_timeout_spin(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
365*5e3eaea3SApple OSS Distributions {
366*5e3eaea3SApple OSS Distributions 	uint64_t        old_value;
367*5e3eaea3SApple OSS Distributions 	uint64_t        new_value;
368*5e3eaea3SApple OSS Distributions 	int changed = 0, error;
369*5e3eaea3SApple OSS Distributions 	char buf[128];
370*5e3eaea3SApple OSS Distributions 	buf[0] = '\0';
371*5e3eaea3SApple OSS Distributions 
372*5e3eaea3SApple OSS Distributions 	absolutetime_to_nanoseconds(kernel_timeout_spin, &old_value);
373*5e3eaea3SApple OSS Distributions 
374*5e3eaea3SApple OSS Distributions 	error = sysctl_io_number(req, old_value, sizeof(uint64_t), &new_value, &changed);
375*5e3eaea3SApple OSS Distributions 	if (error == 0 && changed) {
376*5e3eaea3SApple OSS Distributions 		nanoseconds_to_absolutetime(((uint64_t)new_value), &kernel_timeout_spin);
377*5e3eaea3SApple OSS Distributions 		kernel_spin(kernel_timeout_spin);
378*5e3eaea3SApple OSS Distributions 	}
379*5e3eaea3SApple OSS Distributions 	return error;
380*5e3eaea3SApple OSS Distributions }
381*5e3eaea3SApple OSS Distributions #endif /* DEVELOPMENT || DEBUG */
382*5e3eaea3SApple OSS Distributions 
383*5e3eaea3SApple OSS Distributions 
384*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep, OID_AUTO, cpu, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
385*5e3eaea3SApple OSS Distributions     "CPU info");
386*5e3eaea3SApple OSS Distributions 
387*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, max_basic, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
388*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_max_basic), sizeof(uint32_t),
389*5e3eaea3SApple OSS Distributions     i386_cpu_info, "IU", "Max Basic Information value");
390*5e3eaea3SApple OSS Distributions 
391*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, max_ext, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
392*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_max_ext), sizeof(uint32_t),
393*5e3eaea3SApple OSS Distributions     i386_cpu_info, "IU", "Max Extended Function Information value");
394*5e3eaea3SApple OSS Distributions 
395*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, vendor, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
396*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_vendor), 0,
397*5e3eaea3SApple OSS Distributions     i386_cpu_info, "A", "CPU vendor");
398*5e3eaea3SApple OSS Distributions 
399*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, brand_string, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
400*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_brand_string), 0,
401*5e3eaea3SApple OSS Distributions     i386_cpu_info, "A", "CPU brand string");
402*5e3eaea3SApple OSS Distributions 
403*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, family, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
404*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_family), sizeof(uint8_t),
405*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "CPU family");
406*5e3eaea3SApple OSS Distributions 
407*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, model, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
408*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_model), sizeof(uint8_t),
409*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "CPU model");
410*5e3eaea3SApple OSS Distributions 
411*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, extmodel, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
412*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_extmodel), sizeof(uint8_t),
413*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "CPU extended model");
414*5e3eaea3SApple OSS Distributions 
415*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfamily, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
416*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_extfamily), sizeof(uint8_t),
417*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "CPU extended family");
418*5e3eaea3SApple OSS Distributions 
419*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, stepping, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
420*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_stepping), sizeof(uint8_t),
421*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "CPU stepping");
422*5e3eaea3SApple OSS Distributions 
423*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, feature_bits, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_LOCKED,
424*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_features), sizeof(uint64_t),
425*5e3eaea3SApple OSS Distributions     i386_cpu_info, "IU", "CPU features");
426*5e3eaea3SApple OSS Distributions 
427*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, leaf7_feature_bits,
428*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
429*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_leaf7_features),
430*5e3eaea3SApple OSS Distributions     sizeof(uint64_t),
431*5e3eaea3SApple OSS Distributions     i386_cpu_info_nonzero, "IU", "CPU Leaf7 features [EBX ECX]");
432*5e3eaea3SApple OSS Distributions 
433*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, leaf7_feature_bits_edx,
434*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
435*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_leaf7_extfeatures),
436*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
437*5e3eaea3SApple OSS Distributions     i386_cpu_info_nonzero, "IU", "CPU Leaf7 features [EDX]");
438*5e3eaea3SApple OSS Distributions 
439*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfeature_bits, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_LOCKED,
440*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_extfeatures), sizeof(uint64_t),
441*5e3eaea3SApple OSS Distributions     i386_cpu_info, "IU", "CPU extended features");
442*5e3eaea3SApple OSS Distributions 
443*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, signature, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
444*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_signature), sizeof(uint32_t),
445*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "CPU signature");
446*5e3eaea3SApple OSS Distributions 
447*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, brand, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
448*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_brand), sizeof(uint8_t),
449*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "CPU brand");
450*5e3eaea3SApple OSS Distributions 
451*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, features, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
452*5e3eaea3SApple OSS Distributions     0, 0,
453*5e3eaea3SApple OSS Distributions     cpu_features, "A", "CPU feature names");
454*5e3eaea3SApple OSS Distributions 
455*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, leaf7_features,
456*5e3eaea3SApple OSS Distributions     CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
457*5e3eaea3SApple OSS Distributions     0, 0,
458*5e3eaea3SApple OSS Distributions     cpu_leaf7_features, "A", "CPU Leaf7 feature names");
459*5e3eaea3SApple OSS Distributions 
460*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfeatures, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
461*5e3eaea3SApple OSS Distributions     0, 0,
462*5e3eaea3SApple OSS Distributions     cpu_extfeatures, "A", "CPU extended feature names");
463*5e3eaea3SApple OSS Distributions 
464*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, logical_per_package,
465*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
466*5e3eaea3SApple OSS Distributions     0, 0,
467*5e3eaea3SApple OSS Distributions     cpu_logical_per_package, "I", "CPU logical cpus per package");
468*5e3eaea3SApple OSS Distributions 
469*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, cores_per_package,
470*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
471*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_cores_per_package),
472*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
473*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "CPU cores per package");
474*5e3eaea3SApple OSS Distributions 
475*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, microcode_version,
476*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
477*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_microcode_version),
478*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
479*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "Microcode version number");
480*5e3eaea3SApple OSS Distributions 
481*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, processor_flag,
482*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
483*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_processor_flag),
484*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
485*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "CPU processor flag");
486*5e3eaea3SApple OSS Distributions 
487*5e3eaea3SApple OSS Distributions 
488*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu, OID_AUTO, mwait, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
489*5e3eaea3SApple OSS Distributions     "mwait");
490*5e3eaea3SApple OSS Distributions 
491*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_mwait, OID_AUTO, linesize_min,
492*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
493*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_mwait_leaf_t, linesize_min),
494*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
495*5e3eaea3SApple OSS Distributions     cpu_mwait, "I", "Monitor/mwait minimum line size");
496*5e3eaea3SApple OSS Distributions 
497*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_mwait, OID_AUTO, linesize_max,
498*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
499*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_mwait_leaf_t, linesize_max),
500*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
501*5e3eaea3SApple OSS Distributions     cpu_mwait, "I", "Monitor/mwait maximum line size");
502*5e3eaea3SApple OSS Distributions 
503*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_mwait, OID_AUTO, extensions,
504*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
505*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_mwait_leaf_t, extensions),
506*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
507*5e3eaea3SApple OSS Distributions     cpu_mwait, "I", "Monitor/mwait extensions");
508*5e3eaea3SApple OSS Distributions 
509*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_mwait, OID_AUTO, sub_Cstates,
510*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
511*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_mwait_leaf_t, sub_Cstates),
512*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
513*5e3eaea3SApple OSS Distributions     cpu_mwait, "I", "Monitor/mwait sub C-states");
514*5e3eaea3SApple OSS Distributions 
515*5e3eaea3SApple OSS Distributions 
516*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu, OID_AUTO, thermal, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
517*5e3eaea3SApple OSS Distributions     "thermal");
518*5e3eaea3SApple OSS Distributions 
519*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, sensor,
520*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
521*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_thermal_leaf_t, sensor),
522*5e3eaea3SApple OSS Distributions     sizeof(boolean_t),
523*5e3eaea3SApple OSS Distributions     cpu_thermal, "I", "Thermal sensor present");
524*5e3eaea3SApple OSS Distributions 
525*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, dynamic_acceleration,
526*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
527*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_thermal_leaf_t, dynamic_acceleration),
528*5e3eaea3SApple OSS Distributions     sizeof(boolean_t),
529*5e3eaea3SApple OSS Distributions     cpu_thermal, "I", "Dynamic Acceleration Technology (Turbo Mode)");
530*5e3eaea3SApple OSS Distributions 
531*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, invariant_APIC_timer,
532*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
533*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_thermal_leaf_t, invariant_APIC_timer),
534*5e3eaea3SApple OSS Distributions     sizeof(boolean_t),
535*5e3eaea3SApple OSS Distributions     cpu_thermal, "I", "Invariant APIC Timer");
536*5e3eaea3SApple OSS Distributions 
537*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, thresholds,
538*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
539*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_thermal_leaf_t, thresholds),
540*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
541*5e3eaea3SApple OSS Distributions     cpu_thermal, "I", "Number of interrupt thresholds");
542*5e3eaea3SApple OSS Distributions 
543*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, ACNT_MCNT,
544*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
545*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_thermal_leaf_t, ACNT_MCNT),
546*5e3eaea3SApple OSS Distributions     sizeof(boolean_t),
547*5e3eaea3SApple OSS Distributions     cpu_thermal, "I", "ACNT_MCNT capability");
548*5e3eaea3SApple OSS Distributions 
549*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, core_power_limits,
550*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
551*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_thermal_leaf_t, core_power_limits),
552*5e3eaea3SApple OSS Distributions     sizeof(boolean_t),
553*5e3eaea3SApple OSS Distributions     cpu_thermal, "I", "Power Limit Notifications at a Core Level");
554*5e3eaea3SApple OSS Distributions 
555*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, fine_grain_clock_mod,
556*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
557*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_thermal_leaf_t, fine_grain_clock_mod),
558*5e3eaea3SApple OSS Distributions     sizeof(boolean_t),
559*5e3eaea3SApple OSS Distributions     cpu_thermal, "I", "Fine Grain Clock Modulation");
560*5e3eaea3SApple OSS Distributions 
561*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, package_thermal_intr,
562*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
563*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_thermal_leaf_t, package_thermal_intr),
564*5e3eaea3SApple OSS Distributions     sizeof(boolean_t),
565*5e3eaea3SApple OSS Distributions     cpu_thermal, "I", "Package Thermal interrupt and Status");
566*5e3eaea3SApple OSS Distributions 
567*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, hardware_feedback,
568*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
569*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_thermal_leaf_t, hardware_feedback),
570*5e3eaea3SApple OSS Distributions     sizeof(boolean_t),
571*5e3eaea3SApple OSS Distributions     cpu_thermal, "I", "Hardware Coordination Feedback");
572*5e3eaea3SApple OSS Distributions 
573*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, energy_policy,
574*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
575*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_thermal_leaf_t, energy_policy),
576*5e3eaea3SApple OSS Distributions     sizeof(boolean_t),
577*5e3eaea3SApple OSS Distributions     cpu_thermal, "I", "Energy Efficient Policy Support");
578*5e3eaea3SApple OSS Distributions 
579*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu, OID_AUTO, xsave, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
580*5e3eaea3SApple OSS Distributions     "xsave");
581*5e3eaea3SApple OSS Distributions 
582*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_xsave, OID_AUTO, extended_state,
583*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
584*5e3eaea3SApple OSS Distributions     (void *) 0,
585*5e3eaea3SApple OSS Distributions     sizeof(cpuid_xsave_leaf_t),
586*5e3eaea3SApple OSS Distributions     cpu_xsave, "IU", "XSAVE Extended State Main Leaf");
587*5e3eaea3SApple OSS Distributions 
588*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_xsave, OID_AUTO, extended_state1,
589*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
590*5e3eaea3SApple OSS Distributions     (void *) sizeof(cpuid_xsave_leaf_t),
591*5e3eaea3SApple OSS Distributions     sizeof(cpuid_xsave_leaf_t),
592*5e3eaea3SApple OSS Distributions     cpu_xsave, "IU", "XSAVE Extended State Sub-leaf 1");
593*5e3eaea3SApple OSS Distributions 
594*5e3eaea3SApple OSS Distributions 
595*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu, OID_AUTO, arch_perf, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
596*5e3eaea3SApple OSS Distributions     "arch_perf");
597*5e3eaea3SApple OSS Distributions 
598*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, version,
599*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
600*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_arch_perf_leaf_t, version),
601*5e3eaea3SApple OSS Distributions     sizeof(uint8_t),
602*5e3eaea3SApple OSS Distributions     cpu_arch_perf, "I", "Architectural Performance Version Number");
603*5e3eaea3SApple OSS Distributions 
604*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, number,
605*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
606*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_arch_perf_leaf_t, number),
607*5e3eaea3SApple OSS Distributions     sizeof(uint8_t),
608*5e3eaea3SApple OSS Distributions     cpu_arch_perf, "I", "Number of counters per logical cpu");
609*5e3eaea3SApple OSS Distributions 
610*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, width,
611*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
612*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_arch_perf_leaf_t, width),
613*5e3eaea3SApple OSS Distributions     sizeof(uint8_t),
614*5e3eaea3SApple OSS Distributions     cpu_arch_perf, "I", "Bit width of counters");
615*5e3eaea3SApple OSS Distributions 
616*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, events_number,
617*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
618*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_arch_perf_leaf_t, events_number),
619*5e3eaea3SApple OSS Distributions     sizeof(uint8_t),
620*5e3eaea3SApple OSS Distributions     cpu_arch_perf, "I", "Number of monitoring events");
621*5e3eaea3SApple OSS Distributions 
622*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, events,
623*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
624*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_arch_perf_leaf_t, events),
625*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
626*5e3eaea3SApple OSS Distributions     cpu_arch_perf, "I", "Bit vector of events");
627*5e3eaea3SApple OSS Distributions 
628*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, fixed_number,
629*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
630*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_arch_perf_leaf_t, fixed_number),
631*5e3eaea3SApple OSS Distributions     sizeof(uint8_t),
632*5e3eaea3SApple OSS Distributions     cpu_arch_perf, "I", "Number of fixed-function counters");
633*5e3eaea3SApple OSS Distributions 
634*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, fixed_width,
635*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
636*5e3eaea3SApple OSS Distributions     (void *)offsetof(cpuid_arch_perf_leaf_t, fixed_width),
637*5e3eaea3SApple OSS Distributions     sizeof(uint8_t),
638*5e3eaea3SApple OSS Distributions     cpu_arch_perf, "I", "Bit-width of fixed-function counters");
639*5e3eaea3SApple OSS Distributions 
640*5e3eaea3SApple OSS Distributions 
641*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu, OID_AUTO, cache, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
642*5e3eaea3SApple OSS Distributions     "cache");
643*5e3eaea3SApple OSS Distributions 
644*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_cache, OID_AUTO, linesize,
645*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
646*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_cache_linesize),
647*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
648*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "Cacheline size");
649*5e3eaea3SApple OSS Distributions 
650*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_cache, OID_AUTO, L2_associativity,
651*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
652*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_cache_L2_associativity),
653*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
654*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "L2 cache associativity");
655*5e3eaea3SApple OSS Distributions 
656*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_cache, OID_AUTO, size,
657*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
658*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_cache_size),
659*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
660*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "Cache size (in Kbytes)");
661*5e3eaea3SApple OSS Distributions 
662*5e3eaea3SApple OSS Distributions 
663*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu, OID_AUTO, tlb, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
664*5e3eaea3SApple OSS Distributions     "tlb");
665*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu_tlb, OID_AUTO, inst, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
666*5e3eaea3SApple OSS Distributions     "inst");
667*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu_tlb, OID_AUTO, data, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
668*5e3eaea3SApple OSS Distributions     "data");
669*5e3eaea3SApple OSS Distributions 
670*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_tlb_inst, OID_AUTO, small,
671*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
672*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t,
673*5e3eaea3SApple OSS Distributions     cpuid_tlb[TLB_INST][TLB_SMALL][0]),
674*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
675*5e3eaea3SApple OSS Distributions     i386_cpu_info_nonzero, "I",
676*5e3eaea3SApple OSS Distributions     "Number of small page instruction TLBs");
677*5e3eaea3SApple OSS Distributions 
678*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, small,
679*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
680*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t,
681*5e3eaea3SApple OSS Distributions     cpuid_tlb[TLB_DATA][TLB_SMALL][0]),
682*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
683*5e3eaea3SApple OSS Distributions     i386_cpu_info_nonzero, "I",
684*5e3eaea3SApple OSS Distributions     "Number of small page data TLBs (1st level)");
685*5e3eaea3SApple OSS Distributions 
686*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, small_level1,
687*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
688*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t,
689*5e3eaea3SApple OSS Distributions     cpuid_tlb[TLB_DATA][TLB_SMALL][1]),
690*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
691*5e3eaea3SApple OSS Distributions     i386_cpu_info_nonzero, "I",
692*5e3eaea3SApple OSS Distributions     "Number of small page data TLBs (2nd level)");
693*5e3eaea3SApple OSS Distributions 
694*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_tlb_inst, OID_AUTO, large,
695*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
696*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t,
697*5e3eaea3SApple OSS Distributions     cpuid_tlb[TLB_INST][TLB_LARGE][0]),
698*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
699*5e3eaea3SApple OSS Distributions     i386_cpu_info_nonzero, "I",
700*5e3eaea3SApple OSS Distributions     "Number of large page instruction TLBs");
701*5e3eaea3SApple OSS Distributions 
702*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, large,
703*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
704*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t,
705*5e3eaea3SApple OSS Distributions     cpuid_tlb[TLB_DATA][TLB_LARGE][0]),
706*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
707*5e3eaea3SApple OSS Distributions     i386_cpu_info_nonzero, "I",
708*5e3eaea3SApple OSS Distributions     "Number of large page data TLBs (1st level)");
709*5e3eaea3SApple OSS Distributions 
710*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, large_level1,
711*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
712*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t,
713*5e3eaea3SApple OSS Distributions     cpuid_tlb[TLB_DATA][TLB_LARGE][1]),
714*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
715*5e3eaea3SApple OSS Distributions     i386_cpu_info_nonzero, "I",
716*5e3eaea3SApple OSS Distributions     "Number of large page data TLBs (2nd level)");
717*5e3eaea3SApple OSS Distributions 
718*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_tlb, OID_AUTO, shared,
719*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
720*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_stlb),
721*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
722*5e3eaea3SApple OSS Distributions     i386_cpu_info_nonzero, "I",
723*5e3eaea3SApple OSS Distributions     "Number of shared TLBs");
724*5e3eaea3SApple OSS Distributions 
725*5e3eaea3SApple OSS Distributions 
726*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu, OID_AUTO, address_bits, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
727*5e3eaea3SApple OSS Distributions     "address_bits");
728*5e3eaea3SApple OSS Distributions 
729*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_address_bits, OID_AUTO, physical,
730*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
731*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_address_bits_physical),
732*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
733*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "Number of physical address bits");
734*5e3eaea3SApple OSS Distributions 
735*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_address_bits, OID_AUTO, virtual,
736*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
737*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_address_bits_virtual),
738*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
739*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "Number of virtual address bits");
740*5e3eaea3SApple OSS Distributions 
741*5e3eaea3SApple OSS Distributions 
742*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, core_count,
743*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
744*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, core_count),
745*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
746*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "Number of enabled cores per package");
747*5e3eaea3SApple OSS Distributions 
748*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, thread_count,
749*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
750*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, thread_count),
751*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
752*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "Number of enabled threads per package");
753*5e3eaea3SApple OSS Distributions 
754*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu, OID_AUTO, flex_ratio, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
755*5e3eaea3SApple OSS Distributions     "Flex ratio");
756*5e3eaea3SApple OSS Distributions 
757*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_flex_ratio, OID_AUTO, desired,
758*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
759*5e3eaea3SApple OSS Distributions     0, 0,
760*5e3eaea3SApple OSS Distributions     cpu_flex_ratio_desired, "I", "Flex ratio desired (0 disabled)");
761*5e3eaea3SApple OSS Distributions 
762*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_flex_ratio, OID_AUTO, min,
763*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
764*5e3eaea3SApple OSS Distributions     0, 0,
765*5e3eaea3SApple OSS Distributions     cpu_flex_ratio_min, "I", "Flex ratio min (efficiency)");
766*5e3eaea3SApple OSS Distributions 
767*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_flex_ratio, OID_AUTO, max,
768*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
769*5e3eaea3SApple OSS Distributions     0, 0,
770*5e3eaea3SApple OSS Distributions     cpu_flex_ratio_max, "I", "Flex ratio max (non-turbo)");
771*5e3eaea3SApple OSS Distributions 
772*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu, OID_AUTO, ucupdate,
773*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_WR | CTLFLAG_LOCKED, 0, 0,
774*5e3eaea3SApple OSS Distributions     cpu_ucode_update, "S", "Microcode update interface");
775*5e3eaea3SApple OSS Distributions 
776*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_cpu, OID_AUTO, tsc_ccc, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
777*5e3eaea3SApple OSS Distributions     "TSC/CCC frequency information");
778*5e3eaea3SApple OSS Distributions 
779*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_tsc_ccc, OID_AUTO, numerator,
780*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
781*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_tsc_leaf.numerator),
782*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
783*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "Numerator of TSC/CCC ratio");
784*5e3eaea3SApple OSS Distributions 
785*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_cpu_tsc_ccc, OID_AUTO, denominator,
786*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
787*5e3eaea3SApple OSS Distributions     (void *)offsetof(i386_cpu_info_t, cpuid_tsc_leaf.denominator),
788*5e3eaea3SApple OSS Distributions     sizeof(uint32_t),
789*5e3eaea3SApple OSS Distributions     i386_cpu_info, "I", "Denominator of TSC/CCC ratio");
790*5e3eaea3SApple OSS Distributions 
791*5e3eaea3SApple OSS Distributions static const uint32_t apic_timer_vector = (LAPIC_DEFAULT_INTERRUPT_BASE + LAPIC_TIMER_INTERRUPT);
792*5e3eaea3SApple OSS Distributions static const uint32_t apic_IPI_vector = (LAPIC_DEFAULT_INTERRUPT_BASE + LAPIC_INTERPROCESSOR_INTERRUPT);
793*5e3eaea3SApple OSS Distributions 
794*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep, OID_AUTO, vectors, CTLFLAG_RD | CTLFLAG_LOCKED, 0,
795*5e3eaea3SApple OSS Distributions     "Interrupt vector assignments");
796*5e3eaea3SApple OSS Distributions 
797*5e3eaea3SApple OSS Distributions SYSCTL_UINT(_machdep_vectors, OID_AUTO, timer, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, __DECONST(uint32_t *, &apic_timer_vector), 0, "");
798*5e3eaea3SApple OSS Distributions SYSCTL_UINT(_machdep_vectors, OID_AUTO, IPI, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, __DECONST(uint32_t *, &apic_IPI_vector), 0, "");
799*5e3eaea3SApple OSS Distributions 
800*5e3eaea3SApple OSS Distributions uint64_t pmap_pv_hashlist_walks;
801*5e3eaea3SApple OSS Distributions uint64_t pmap_pv_hashlist_cnts;
802*5e3eaea3SApple OSS Distributions uint32_t pmap_pv_hashlist_max;
803*5e3eaea3SApple OSS Distributions uint32_t pmap_kernel_text_ps = PAGE_SIZE;
804*5e3eaea3SApple OSS Distributions extern uint32_t pv_hashed_kern_low_water_mark;
805*5e3eaea3SApple OSS Distributions 
806*5e3eaea3SApple OSS Distributions /*extern struct sysctl_oid_list sysctl__machdep_pmap_children;*/
807*5e3eaea3SApple OSS Distributions 
808*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep, OID_AUTO, pmap, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
809*5e3eaea3SApple OSS Distributions     "PMAP info");
810*5e3eaea3SApple OSS Distributions 
811*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_pmap, OID_AUTO, hashwalks, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_pv_hashlist_walks, "");
812*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_pmap, OID_AUTO, hashcnts, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_pv_hashlist_cnts, "");
813*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep_pmap, OID_AUTO, hashmax, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_pv_hashlist_max, 0, "");
814*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep_pmap, OID_AUTO, kernel_text_ps, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_kernel_text_ps, 0, "");
815*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep_pmap, OID_AUTO, kern_pv_reserve, CTLFLAG_RW | CTLFLAG_KERN | CTLFLAG_LOCKED, &pv_hashed_kern_low_water_mark, 0, "");
816*5e3eaea3SApple OSS Distributions 
817*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep, OID_AUTO, memmap, CTLFLAG_RD | CTLFLAG_LOCKED, NULL, "physical memory map");
818*5e3eaea3SApple OSS Distributions 
819*5e3eaea3SApple OSS Distributions uint64_t firmware_Conventional_bytes = 0;
820*5e3eaea3SApple OSS Distributions uint64_t firmware_RuntimeServices_bytes = 0;
821*5e3eaea3SApple OSS Distributions uint64_t firmware_ACPIReclaim_bytes = 0;
822*5e3eaea3SApple OSS Distributions uint64_t firmware_ACPINVS_bytes = 0;
823*5e3eaea3SApple OSS Distributions uint64_t firmware_PalCode_bytes = 0;
824*5e3eaea3SApple OSS Distributions uint64_t firmware_Reserved_bytes = 0;
825*5e3eaea3SApple OSS Distributions uint64_t firmware_Unusable_bytes = 0;
826*5e3eaea3SApple OSS Distributions uint64_t firmware_other_bytes = 0;
827*5e3eaea3SApple OSS Distributions 
828*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Conventional, CTLFLAG_RD | CTLFLAG_LOCKED, &firmware_Conventional_bytes, "");
829*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_memmap, OID_AUTO, RuntimeServices, CTLFLAG_RD | CTLFLAG_LOCKED, &firmware_RuntimeServices_bytes, "");
830*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_memmap, OID_AUTO, ACPIReclaim, CTLFLAG_RD | CTLFLAG_LOCKED, &firmware_ACPIReclaim_bytes, "");
831*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_memmap, OID_AUTO, ACPINVS, CTLFLAG_RD | CTLFLAG_LOCKED, &firmware_ACPINVS_bytes, "");
832*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_memmap, OID_AUTO, PalCode, CTLFLAG_RD | CTLFLAG_LOCKED, &firmware_PalCode_bytes, "");
833*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Reserved, CTLFLAG_RD | CTLFLAG_LOCKED, &firmware_Reserved_bytes, "");
834*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Unusable, CTLFLAG_RD | CTLFLAG_LOCKED, &firmware_Unusable_bytes, "");
835*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Other, CTLFLAG_RD | CTLFLAG_LOCKED, &firmware_other_bytes, "");
836*5e3eaea3SApple OSS Distributions 
837*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep, OID_AUTO, tsc, CTLFLAG_RD | CTLFLAG_LOCKED, NULL, "Timestamp counter parameters");
838*5e3eaea3SApple OSS Distributions 
839*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_tsc, OID_AUTO, frequency,
840*5e3eaea3SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED, &tscFreq, "");
841*5e3eaea3SApple OSS Distributions 
842*5e3eaea3SApple OSS Distributions extern uint32_t deep_idle_rebase;
843*5e3eaea3SApple OSS Distributions SYSCTL_UINT(_machdep_tsc, OID_AUTO, deep_idle_rebase,
844*5e3eaea3SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED, &deep_idle_rebase, 0, "");
845*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_tsc, OID_AUTO, at_boot,
846*5e3eaea3SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED, &tsc_at_boot, "");
847*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_tsc, OID_AUTO, rebase_abs_time,
848*5e3eaea3SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED, &tsc_rebase_abs_time, "");
849*5e3eaea3SApple OSS Distributions #if DEVELOPMENT || DEBUG
850*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_tsc, OID_AUTO, synch_deltas,
851*5e3eaea3SApple OSS Distributions     CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
852*5e3eaea3SApple OSS Distributions     0, 0, x86_cpu_tsc_deltas, "A", "TSC synch deltas");
853*5e3eaea3SApple OSS Distributions #endif
854*5e3eaea3SApple OSS Distributions 
855*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep_tsc, OID_AUTO, nanotime,
856*5e3eaea3SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED, NULL, "TSC to ns conversion");
857*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_tsc_nanotime, OID_AUTO, tsc_base,
858*5e3eaea3SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED,
859*5e3eaea3SApple OSS Distributions     __DECONST(uint64_t *, &pal_rtc_nanotime_info.tsc_base), "");
860*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep_tsc_nanotime, OID_AUTO, ns_base,
861*5e3eaea3SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED,
862*5e3eaea3SApple OSS Distributions     __DECONST(uint64_t *, &pal_rtc_nanotime_info.ns_base), "");
863*5e3eaea3SApple OSS Distributions SYSCTL_UINT(_machdep_tsc_nanotime, OID_AUTO, scale,
864*5e3eaea3SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED,
865*5e3eaea3SApple OSS Distributions     __DECONST(uint32_t *, &pal_rtc_nanotime_info.scale), 0, "");
866*5e3eaea3SApple OSS Distributions SYSCTL_UINT(_machdep_tsc_nanotime, OID_AUTO, shift,
867*5e3eaea3SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED,
868*5e3eaea3SApple OSS Distributions     __DECONST(uint32_t *, &pal_rtc_nanotime_info.shift), 0, "");
869*5e3eaea3SApple OSS Distributions SYSCTL_UINT(_machdep_tsc_nanotime, OID_AUTO, generation,
870*5e3eaea3SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED,
871*5e3eaea3SApple OSS Distributions     __DECONST(uint32_t *, &pal_rtc_nanotime_info.generation), 0, "");
872*5e3eaea3SApple OSS Distributions 
873*5e3eaea3SApple OSS Distributions SYSCTL_NODE(_machdep, OID_AUTO, misc, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
874*5e3eaea3SApple OSS Distributions     "Miscellaneous x86 kernel parameters");
875*5e3eaea3SApple OSS Distributions 
876*5e3eaea3SApple OSS Distributions #if (DEVELOPMENT || DEBUG)
877*5e3eaea3SApple OSS Distributions extern uint32_t mp_interrupt_watchdog_events;
878*5e3eaea3SApple OSS Distributions SYSCTL_UINT(_machdep_misc, OID_AUTO, interrupt_watchdog_events,
879*5e3eaea3SApple OSS Distributions     CTLFLAG_RW | CTLFLAG_LOCKED, &mp_interrupt_watchdog_events, 0, "");
880*5e3eaea3SApple OSS Distributions 
881*5e3eaea3SApple OSS Distributions extern int insnstream_force_cacheline_mismatch;
882*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep_misc, OID_AUTO, insnstream_force_clmismatch,
883*5e3eaea3SApple OSS Distributions     CTLFLAG_RW | CTLFLAG_LOCKED, &insnstream_force_cacheline_mismatch, 0, "");
884*5e3eaea3SApple OSS Distributions #endif
885*5e3eaea3SApple OSS Distributions 
886*5e3eaea3SApple OSS Distributions 
887*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_misc, OID_AUTO, panic_restart_timeout,
888*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_LOCKED,
889*5e3eaea3SApple OSS Distributions     0, 0,
890*5e3eaea3SApple OSS Distributions     panic_set_restart_timeout, "I", "Panic restart timeout in seconds");
891*5e3eaea3SApple OSS Distributions 
892*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_misc, OID_AUTO, interrupt_latency_max,
893*5e3eaea3SApple OSS Distributions     CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED,
894*5e3eaea3SApple OSS Distributions     0, 0,
895*5e3eaea3SApple OSS Distributions     misc_interrupt_latency_max, "A", "Maximum Interrupt latency");
896*5e3eaea3SApple OSS Distributions 
897*5e3eaea3SApple OSS Distributions extern boolean_t is_x2apic;
898*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep, OID_AUTO, x2apic_enabled,
899*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RD | CTLFLAG_LOCKED,
900*5e3eaea3SApple OSS Distributions     &is_x2apic, 0, "");
901*5e3eaea3SApple OSS Distributions 
902*5e3eaea3SApple OSS Distributions #if DEVELOPMENT || DEBUG
903*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_misc, OID_AUTO, machine_check_panic,
904*5e3eaea3SApple OSS Distributions     CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED,
905*5e3eaea3SApple OSS Distributions     0, 0,
906*5e3eaea3SApple OSS Distributions     misc_machine_check_panic, "A", "Machine-check exception test");
907*5e3eaea3SApple OSS Distributions 
908*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_misc, OID_AUTO, kernel_timeout_spin,
909*5e3eaea3SApple OSS Distributions     CTLTYPE_QUAD | CTLFLAG_RW | CTLFLAG_LOCKED,
910*5e3eaea3SApple OSS Distributions     0, sizeof(kernel_timeout_spin),
911*5e3eaea3SApple OSS Distributions     misc_kernel_timeout_spin, "Q", "Kernel timeout panic test");
912*5e3eaea3SApple OSS Distributions 
913*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep, OID_AUTO, reportphyreadabs,
914*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
915*5e3eaea3SApple OSS Distributions     &report_phy_read_delay, "");
916*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep, OID_AUTO, reportphywriteabs,
917*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
918*5e3eaea3SApple OSS Distributions     &report_phy_write_delay, "");
919*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep, OID_AUTO, tracephyreadabs,
920*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
921*5e3eaea3SApple OSS Distributions     &trace_phy_read_delay, "");
922*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep, OID_AUTO, tracephywriteabs,
923*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
924*5e3eaea3SApple OSS Distributions     &trace_phy_write_delay, "");
925*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep, OID_AUTO, phyreaddelaypanic,
926*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
927*5e3eaea3SApple OSS Distributions     &phy_read_panic, 0, "");
928*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep, OID_AUTO, phywritedelaypanic,
929*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
930*5e3eaea3SApple OSS Distributions     &phy_write_panic, 0, "");
931*5e3eaea3SApple OSS Distributions #if DEVELOPMENT || DEBUG
932*5e3eaea3SApple OSS Distributions extern uint64_t simulate_stretched_io;
933*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep, OID_AUTO, sim_stretched_io_ns,
934*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
935*5e3eaea3SApple OSS Distributions     &simulate_stretched_io, "");
936*5e3eaea3SApple OSS Distributions #endif
937*5e3eaea3SApple OSS Distributions 
938*5e3eaea3SApple OSS Distributions extern int pmap_pagezero_mitigation;
939*5e3eaea3SApple OSS Distributions extern int pmap_asserts_enabled, pmap_asserts_traced;
940*5e3eaea3SApple OSS Distributions /* On DEV/DEBUG kernels, clear this to disable the SMAP emulation
941*5e3eaea3SApple OSS Distributions  * (address space disconnect) for pagezero-less processes.
942*5e3eaea3SApple OSS Distributions  */
943*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep, OID_AUTO, pmap_pagezero_mitigation,
944*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
945*5e3eaea3SApple OSS Distributions     &pmap_pagezero_mitigation, 0, "");
946*5e3eaea3SApple OSS Distributions /* Toggle pmap assertions */
947*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep, OID_AUTO, pmap_asserts,
948*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
949*5e3eaea3SApple OSS Distributions     &pmap_asserts_enabled, 0, "");
950*5e3eaea3SApple OSS Distributions /* Transform pmap assertions into kernel trace terminations */
951*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep, OID_AUTO, pmap_asserts_traced,
952*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
953*5e3eaea3SApple OSS Distributions     &pmap_asserts_traced, 0, "");
954*5e3eaea3SApple OSS Distributions 
955*5e3eaea3SApple OSS Distributions static int
misc_svisor_read(__unused struct sysctl_oid * oidp,__unused void * arg1,__unused int arg2,struct sysctl_req * req)956*5e3eaea3SApple OSS Distributions misc_svisor_read(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
957*5e3eaea3SApple OSS Distributions {
958*5e3eaea3SApple OSS Distributions 	uint64_t new_value = 0, old_value = 0;
959*5e3eaea3SApple OSS Distributions 	int changed = 0, error;
960*5e3eaea3SApple OSS Distributions 
961*5e3eaea3SApple OSS Distributions 	error = sysctl_io_number(req, old_value, sizeof(uint64_t), &new_value, &changed);
962*5e3eaea3SApple OSS Distributions 	if ((error == 0) && changed) {
963*5e3eaea3SApple OSS Distributions 		volatile uint32_t *raddr = (uint32_t *) new_value;
964*5e3eaea3SApple OSS Distributions 		printf("Supervisor: value at 0x%llx is 0x%x\n", new_value, *raddr);
965*5e3eaea3SApple OSS Distributions 	}
966*5e3eaea3SApple OSS Distributions 	return error;
967*5e3eaea3SApple OSS Distributions }
968*5e3eaea3SApple OSS Distributions 
969*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_misc, OID_AUTO, misc_svisor_read,
970*5e3eaea3SApple OSS Distributions     CTLTYPE_QUAD | CTLFLAG_RW | CTLFLAG_LOCKED,
971*5e3eaea3SApple OSS Distributions     0, 0,
972*5e3eaea3SApple OSS Distributions     misc_svisor_read, "I", "supervisor mode read");
973*5e3eaea3SApple OSS Distributions 
974*5e3eaea3SApple OSS Distributions #endif /* DEVELOPMENT || DEBUG */
975*5e3eaea3SApple OSS Distributions 
976*5e3eaea3SApple OSS Distributions extern void timer_queue_trace_cpu(int);
977*5e3eaea3SApple OSS Distributions static int
misc_timer_queue_trace(__unused struct sysctl_oid * oidp,__unused void * arg1,__unused int arg2,struct sysctl_req * req)978*5e3eaea3SApple OSS Distributions misc_timer_queue_trace(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
979*5e3eaea3SApple OSS Distributions {
980*5e3eaea3SApple OSS Distributions 	int changed = 0, error;
981*5e3eaea3SApple OSS Distributions 	char buf[128];
982*5e3eaea3SApple OSS Distributions 	buf[0] = '\0';
983*5e3eaea3SApple OSS Distributions 
984*5e3eaea3SApple OSS Distributions 	error = sysctl_io_string(req, buf, sizeof(buf), 0, &changed);
985*5e3eaea3SApple OSS Distributions 
986*5e3eaea3SApple OSS Distributions 	if (error == 0 && changed) {
987*5e3eaea3SApple OSS Distributions 		timer_queue_trace_cpu(0);
988*5e3eaea3SApple OSS Distributions 	}
989*5e3eaea3SApple OSS Distributions 	return error;
990*5e3eaea3SApple OSS Distributions }
991*5e3eaea3SApple OSS Distributions 
992*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_misc, OID_AUTO, timer_queue_trace,
993*5e3eaea3SApple OSS Distributions     CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED,
994*5e3eaea3SApple OSS Distributions     0, 0,
995*5e3eaea3SApple OSS Distributions     misc_timer_queue_trace, "A", "Cut timer queue tracepoint");
996*5e3eaea3SApple OSS Distributions 
997*5e3eaea3SApple OSS Distributions extern long NMI_count;
998*5e3eaea3SApple OSS Distributions extern void NMI_cpus(void);
999*5e3eaea3SApple OSS Distributions static int
misc_nmis(__unused struct sysctl_oid * oidp,__unused void * arg1,__unused int arg2,struct sysctl_req * req)1000*5e3eaea3SApple OSS Distributions misc_nmis(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
1001*5e3eaea3SApple OSS Distributions {
1002*5e3eaea3SApple OSS Distributions 	int new = 0, old = 0, changed = 0, error;
1003*5e3eaea3SApple OSS Distributions 
1004*5e3eaea3SApple OSS Distributions 	old = (int)MIN(NMI_count, INT_MAX);
1005*5e3eaea3SApple OSS Distributions 
1006*5e3eaea3SApple OSS Distributions 	error = sysctl_io_number(req, old, sizeof(int), &new, &changed);
1007*5e3eaea3SApple OSS Distributions 	if (error == 0 && changed) {
1008*5e3eaea3SApple OSS Distributions 		NMI_cpus();
1009*5e3eaea3SApple OSS Distributions 	}
1010*5e3eaea3SApple OSS Distributions 
1011*5e3eaea3SApple OSS Distributions 	return error;
1012*5e3eaea3SApple OSS Distributions }
1013*5e3eaea3SApple OSS Distributions 
1014*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_misc, OID_AUTO, nmis,
1015*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_LOCKED,
1016*5e3eaea3SApple OSS Distributions     0, 0,
1017*5e3eaea3SApple OSS Distributions     misc_nmis, "I", "Report/increment NMI count");
1018*5e3eaea3SApple OSS Distributions 
1019*5e3eaea3SApple OSS Distributions /* Parameters related to timer coalescing tuning, to be replaced
1020*5e3eaea3SApple OSS Distributions  * with a dedicated systemcall in the future.
1021*5e3eaea3SApple OSS Distributions  */
1022*5e3eaea3SApple OSS Distributions /* Enable processing pending timers in the context of any other interrupt */
1023*5e3eaea3SApple OSS Distributions SYSCTL_INT(_kern, OID_AUTO, interrupt_timer_coalescing_enabled,
1024*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
1025*5e3eaea3SApple OSS Distributions     &interrupt_timer_coalescing_enabled, 0, "");
1026*5e3eaea3SApple OSS Distributions /* Upon entering idle, process pending timers with HW deadlines
1027*5e3eaea3SApple OSS Distributions  * this far in the future.
1028*5e3eaea3SApple OSS Distributions  */
1029*5e3eaea3SApple OSS Distributions SYSCTL_INT(_kern, OID_AUTO, timer_coalesce_idle_entry_hard_deadline_max,
1030*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
1031*5e3eaea3SApple OSS Distributions     &idle_entry_timer_processing_hdeadline_threshold, 0, "");
1032*5e3eaea3SApple OSS Distributions 
1033*5e3eaea3SApple OSS Distributions /* Track potentially expensive eager timer evaluations on QoS tier
1034*5e3eaea3SApple OSS Distributions  * switches.
1035*5e3eaea3SApple OSS Distributions  */
1036*5e3eaea3SApple OSS Distributions extern uint32_t ml_timer_eager_evaluations;
1037*5e3eaea3SApple OSS Distributions 
1038*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep, OID_AUTO, eager_timer_evaluations,
1039*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
1040*5e3eaea3SApple OSS Distributions     &ml_timer_eager_evaluations, 0, "");
1041*5e3eaea3SApple OSS Distributions 
1042*5e3eaea3SApple OSS Distributions extern uint64_t ml_timer_eager_evaluation_max;
1043*5e3eaea3SApple OSS Distributions 
1044*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep, OID_AUTO, eager_timer_evaluation_max,
1045*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
1046*5e3eaea3SApple OSS Distributions     &ml_timer_eager_evaluation_max, "");
1047*5e3eaea3SApple OSS Distributions extern uint64_t x86_isr_fp_simd_use;
1048*5e3eaea3SApple OSS Distributions SYSCTL_QUAD(_machdep, OID_AUTO, x86_fp_simd_isr_uses,
1049*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
1050*5e3eaea3SApple OSS Distributions     &x86_isr_fp_simd_use, "");
1051*5e3eaea3SApple OSS Distributions 
1052*5e3eaea3SApple OSS Distributions static int
1053*5e3eaea3SApple OSS Distributions sysctl_kern_insn_copy_optout_task SYSCTL_HANDLER_ARGS
1054*5e3eaea3SApple OSS Distributions {
1055*5e3eaea3SApple OSS Distributions #pragma unused(oidp, arg1, arg2)
1056*5e3eaea3SApple OSS Distributions 	uint32_t soflags = 0;
1057*5e3eaea3SApple OSS Distributions 	uint32_t old_value = curtask_get_insn_copy_optout() ? 1 : 0;
1058*5e3eaea3SApple OSS Distributions 
1059*5e3eaea3SApple OSS Distributions 	int error = SYSCTL_IN(req, &soflags, sizeof(soflags));
1060*5e3eaea3SApple OSS Distributions 	if (error) {
1061*5e3eaea3SApple OSS Distributions 		return error;
1062*5e3eaea3SApple OSS Distributions 	}
1063*5e3eaea3SApple OSS Distributions 
1064*5e3eaea3SApple OSS Distributions 	if (soflags) {
1065*5e3eaea3SApple OSS Distributions 		curtask_set_insn_copy_optout();
1066*5e3eaea3SApple OSS Distributions 	}
1067*5e3eaea3SApple OSS Distributions 
1068*5e3eaea3SApple OSS Distributions 	return SYSCTL_OUT(req, &old_value, sizeof(old_value));
1069*5e3eaea3SApple OSS Distributions }
1070*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep, OID_AUTO, insn_copy_optout_task,
1071*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_LOCKED | CTLFLAG_MASKED | CTLFLAG_ANYBODY,
1072*5e3eaea3SApple OSS Distributions     0, 0, sysctl_kern_insn_copy_optout_task, "I", "");
1073*5e3eaea3SApple OSS Distributions 
1074*5e3eaea3SApple OSS Distributions 
1075*5e3eaea3SApple OSS Distributions #if DEVELOPMENT || DEBUG
1076*5e3eaea3SApple OSS Distributions 
1077*5e3eaea3SApple OSS Distributions extern int plctrace_enabled;
1078*5e3eaea3SApple OSS Distributions 
1079*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep, OID_AUTO, pltrace,
1080*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
1081*5e3eaea3SApple OSS Distributions     &plctrace_enabled, 0, "");
1082*5e3eaea3SApple OSS Distributions 
1083*5e3eaea3SApple OSS Distributions extern int fpsimd_fault_popc;
1084*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep, OID_AUTO, fpsimd_fault_popc,
1085*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
1086*5e3eaea3SApple OSS Distributions     &fpsimd_fault_popc, 0, "");
1087*5e3eaea3SApple OSS Distributions 
1088*5e3eaea3SApple OSS Distributions volatile int stop_spinning;
1089*5e3eaea3SApple OSS Distributions static int
spin_in_the_kernel(__unused struct sysctl_oid * oidp,__unused void * arg1,__unused int arg2,struct sysctl_req * req)1090*5e3eaea3SApple OSS Distributions spin_in_the_kernel(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
1091*5e3eaea3SApple OSS Distributions {
1092*5e3eaea3SApple OSS Distributions 	int new = 0, old = 0, changed = 0, error;
1093*5e3eaea3SApple OSS Distributions 
1094*5e3eaea3SApple OSS Distributions 	error = sysctl_io_number(req, old, sizeof(int), &new, &changed);
1095*5e3eaea3SApple OSS Distributions 	if (error == 0 && changed) {
1096*5e3eaea3SApple OSS Distributions 		stop_spinning = FALSE;
1097*5e3eaea3SApple OSS Distributions 		while (stop_spinning == FALSE) {
1098*5e3eaea3SApple OSS Distributions 			__builtin_ia32_pause();
1099*5e3eaea3SApple OSS Distributions 		}
1100*5e3eaea3SApple OSS Distributions 	} else if (error == 0) {
1101*5e3eaea3SApple OSS Distributions 		stop_spinning = TRUE;
1102*5e3eaea3SApple OSS Distributions 	}
1103*5e3eaea3SApple OSS Distributions 
1104*5e3eaea3SApple OSS Distributions 	return error;
1105*5e3eaea3SApple OSS Distributions }
1106*5e3eaea3SApple OSS Distributions 
1107*5e3eaea3SApple OSS Distributions SYSCTL_PROC(_machdep_misc, OID_AUTO, spin_forever,
1108*5e3eaea3SApple OSS Distributions     CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_LOCKED | CTLFLAG_MASKED,
1109*5e3eaea3SApple OSS Distributions     0, 0,
1110*5e3eaea3SApple OSS Distributions     spin_in_the_kernel, "I", "Spin forever");
1111*5e3eaea3SApple OSS Distributions 
1112*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep_misc, OID_AUTO, fake_pte_corruption,
1113*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
1114*5e3eaea3SApple OSS Distributions     &pmap_inject_pte_corruption, 0,
1115*5e3eaea3SApple OSS Distributions     "Fake a PTE corruption event (induces NMI IPIs and panics the system)");
1116*5e3eaea3SApple OSS Distributions 
1117*5e3eaea3SApple OSS Distributions extern int traptrace_enabled;
1118*5e3eaea3SApple OSS Distributions SYSCTL_INT(_machdep_misc, OID_AUTO, traptrace_enabled,
1119*5e3eaea3SApple OSS Distributions     CTLFLAG_KERN | CTLFLAG_RW | CTLFLAG_LOCKED,
1120*5e3eaea3SApple OSS Distributions     &traptrace_enabled, 0, "Enabled/disable trap trace");
1121*5e3eaea3SApple OSS Distributions 
1122*5e3eaea3SApple OSS Distributions #endif /* DEVELOPMENT || DEBUG */
1123