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