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