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