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