2 * Copyright (c) 2003-2020 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 #include <sys/param.h>
31 #include <sys/kernel.h>
32 #include <sys/sysctl.h>
33 #include <i386/cpuid.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>
43 #include <kern/kalloc.h>
45 #if DEBUG || DEVELOPMENT
46 #include <kern/hvg_hypercall.h>
51 _i386_cpu_info SYSCTL_HANDLER_ARGS
53 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
62 if (arg2
== 0 && ((char *)ptr
)[0] == '\0') {
66 if (arg2
== sizeof(uint8_t)) {
67 value
= (uint32_t) *(uint8_t *)ptr
;
69 arg2
= sizeof(uint32_t);
71 return SYSCTL_OUT(req
, ptr
, arg2
? (size_t) arg2
: strlen((char *)ptr
) + 1);
75 i386_cpu_info SYSCTL_HANDLER_ARGS
77 void *ptr
= (uint8_t *)cpuid_info() + (uintptr_t)arg1
;
78 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
82 i386_cpu_info_nonzero SYSCTL_HANDLER_ARGS
84 void *ptr
= (uint8_t *)cpuid_info() + (uintptr_t)arg1
;
85 int value
= *(uint32_t *)ptr
;
91 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
94 cpu_mwait SYSCTL_HANDLER_ARGS
96 i386_cpu_info_t
*cpu_info
= cpuid_info();
97 void *ptr
= (uint8_t *)cpu_info
->cpuid_mwait_leafp
+ (uintptr_t)arg1
;
98 if (cpu_info
->cpuid_mwait_leafp
== NULL
) {
101 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
105 cpu_thermal SYSCTL_HANDLER_ARGS
107 i386_cpu_info_t
*cpu_info
= cpuid_info();
108 void *ptr
= (uint8_t *)cpu_info
->cpuid_thermal_leafp
+ (uintptr_t)arg1
;
109 if (cpu_info
->cpuid_thermal_leafp
== NULL
) {
112 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
116 cpu_arch_perf SYSCTL_HANDLER_ARGS
118 i386_cpu_info_t
*cpu_info
= cpuid_info();
119 void *ptr
= (uint8_t *)cpu_info
->cpuid_arch_perf_leafp
+ (uintptr_t)arg1
;
120 if (cpu_info
->cpuid_arch_perf_leafp
== NULL
) {
123 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
127 cpu_xsave SYSCTL_HANDLER_ARGS
129 i386_cpu_info_t
*cpu_info
= cpuid_info();
130 void *ptr
= (uint8_t *)cpu_info
->cpuid_xsave_leafp
+ (uintptr_t)arg1
;
131 if (cpu_info
->cpuid_xsave_leafp
== NULL
) {
134 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
139 cpu_features SYSCTL_HANDLER_ARGS
141 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
142 __unused
void *unused_arg1
= arg1
;
143 __unused
int unused_arg2
= arg2
;
147 cpuid_get_feature_names(cpuid_features(), buf
, sizeof(buf
));
149 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
153 cpu_extfeatures SYSCTL_HANDLER_ARGS
155 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
156 __unused
void *unused_arg1
= arg1
;
157 __unused
int unused_arg2
= arg2
;
161 cpuid_get_extfeature_names(cpuid_extfeatures(), buf
, sizeof(buf
));
163 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
167 cpu_leaf7_features SYSCTL_HANDLER_ARGS
169 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
170 __unused
void *unused_arg1
= arg1
;
171 __unused
int unused_arg2
= arg2
;
174 uint64_t leaf7_features
= cpuid_info()->cpuid_leaf7_features
;
175 uint64_t leaf7_extfeatures
= cpuid_info()->cpuid_leaf7_extfeatures
;
176 if (leaf7_features
== 0 && leaf7_extfeatures
== 0) {
181 cpuid_get_leaf7_feature_names(leaf7_features
, buf
, sizeof(buf
));
182 if (leaf7_extfeatures
!= 0) {
183 strlcat(buf
, " ", sizeof(buf
));
184 cpuid_get_leaf7_extfeature_names(leaf7_extfeatures
, buf
+ strlen(buf
),
185 (unsigned int)(sizeof(buf
) - strlen(buf
)));
188 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
192 cpu_logical_per_package SYSCTL_HANDLER_ARGS
194 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
195 __unused
void *unused_arg1
= arg1
;
196 __unused
int unused_arg2
= arg2
;
197 i386_cpu_info_t
*cpu_info
= cpuid_info();
199 if (!(cpuid_features() & CPUID_FEATURE_HTT
)) {
203 return SYSCTL_OUT(req
, &cpu_info
->cpuid_logical_per_package
,
204 sizeof(cpu_info
->cpuid_logical_per_package
));
208 cpu_flex_ratio_desired SYSCTL_HANDLER_ARGS
210 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
211 __unused
void *unused_arg1
= arg1
;
212 __unused
int unused_arg2
= arg2
;
213 i386_cpu_info_t
*cpu_info
= cpuid_info();
215 if (cpu_info
->cpuid_model
!= 26) {
219 return SYSCTL_OUT(req
, &flex_ratio
, sizeof(flex_ratio
));
223 cpu_flex_ratio_min SYSCTL_HANDLER_ARGS
225 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
226 __unused
void *unused_arg1
= arg1
;
227 __unused
int unused_arg2
= arg2
;
228 i386_cpu_info_t
*cpu_info
= cpuid_info();
230 if (cpu_info
->cpuid_model
!= 26) {
234 return SYSCTL_OUT(req
, &flex_ratio_min
, sizeof(flex_ratio_min
));
238 cpu_flex_ratio_max SYSCTL_HANDLER_ARGS
240 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
241 __unused
void *unused_arg1
= arg1
;
242 __unused
int unused_arg2
= arg2
;
243 i386_cpu_info_t
*cpu_info
= cpuid_info();
245 if (cpu_info
->cpuid_model
!= 26) {
249 return SYSCTL_OUT(req
, &flex_ratio_max
, sizeof(flex_ratio_max
));
253 cpu_ucode_update SYSCTL_HANDLER_ARGS
255 #pragma unused(oidp, arg1, arg2)
259 /* Can't update microcode from within a VM. */
261 if (cpuid_features() & CPUID_FEATURE_VMM
) {
265 if (req
->newptr
== USER_ADDR_NULL
) {
269 error
= SYSCTL_IN(req
, &addr
, sizeof(addr
));
274 return ucode_interface(addr
);
277 extern uint64_t panic_restart_timeout
;
279 panic_set_restart_timeout(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
281 int new_value
= 0, old_value
= 0, changed
= 0, error
;
284 if (panic_restart_timeout
) {
285 absolutetime_to_nanoseconds(panic_restart_timeout
, &nstime
);
286 old_value
= (int)MIN(nstime
/ NSEC_PER_SEC
, INT_MAX
);
289 error
= sysctl_io_number(req
, old_value
, sizeof(old_value
), &new_value
, &changed
);
290 if (error
== 0 && changed
) {
291 if (new_value
>= 0) {
292 nanoseconds_to_absolutetime(((uint64_t)new_value
) * NSEC_PER_SEC
, &panic_restart_timeout
);
301 * Populates the {CPU, vector, latency} triple for the maximum observed primary
305 misc_interrupt_latency_max(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
307 int changed
= 0, error
;
311 interrupt_populate_latency_stats(buf
, sizeof(buf
));
313 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
315 if (error
== 0 && changed
) {
316 interrupt_reset_latency_stats();
322 #if DEVELOPMENT || DEBUG
324 * Populates a string with each CPU's tsc synch delta.
327 x86_cpu_tsc_deltas(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
330 uint32_t ncpus
= ml_wait_max_cpus();
331 uint32_t buflen
= (2 /* hex digits */ * sizeof(uint64_t) + 3 /* for "0x" + " " */) * ncpus
+ 1;
332 char *buf
= kalloc(buflen
);
334 cpu_data_tsc_sync_deltas_string(buf
, buflen
, 0, ncpus
- 1);
336 err
= sysctl_io_string(req
, buf
, buflen
, 0, 0);
344 * Triggers a machine-check exception - for a suitably configured kernel only.
346 extern void mca_exception_panic(void);
348 misc_machine_check_panic(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
350 int changed
= 0, error
;
354 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
356 if (error
== 0 && changed
) {
357 mca_exception_panic();
363 * Triggers a non-responsive processor timeout panic - for a suitably configured kernel only.
365 static uint64_t kernel_timeout_spin
= 0;
367 misc_kernel_timeout_spin(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
371 int changed
= 0, error
;
375 absolutetime_to_nanoseconds(kernel_timeout_spin
, &old_value
);
377 error
= sysctl_io_number(req
, old_value
, sizeof(uint64_t), &new_value
, &changed
);
378 if (error
== 0 && changed
) {
379 nanoseconds_to_absolutetime(((uint64_t)new_value
), &kernel_timeout_spin
);
380 kernel_spin(kernel_timeout_spin
);
384 #endif /* DEVELOPMENT || DEBUG */
387 SYSCTL_NODE(_machdep
, OID_AUTO
, cpu
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
390 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, max_basic
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
391 (void *)offsetof(i386_cpu_info_t
, cpuid_max_basic
), sizeof(uint32_t),
392 i386_cpu_info
, "IU", "Max Basic Information value");
394 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, max_ext
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
395 (void *)offsetof(i386_cpu_info_t
, cpuid_max_ext
), sizeof(uint32_t),
396 i386_cpu_info
, "IU", "Max Extended Function Information value");
398 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, vendor
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
399 (void *)offsetof(i386_cpu_info_t
, cpuid_vendor
), 0,
400 i386_cpu_info
, "A", "CPU vendor");
402 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand_string
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
403 (void *)offsetof(i386_cpu_info_t
, cpuid_brand_string
), 0,
404 i386_cpu_info
, "A", "CPU brand string");
406 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, family
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
407 (void *)offsetof(i386_cpu_info_t
, cpuid_family
), sizeof(uint8_t),
408 i386_cpu_info
, "I", "CPU family");
410 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
411 (void *)offsetof(i386_cpu_info_t
, cpuid_model
), sizeof(uint8_t),
412 i386_cpu_info
, "I", "CPU model");
414 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extmodel
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
415 (void *)offsetof(i386_cpu_info_t
, cpuid_extmodel
), sizeof(uint8_t),
416 i386_cpu_info
, "I", "CPU extended model");
418 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfamily
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
419 (void *)offsetof(i386_cpu_info_t
, cpuid_extfamily
), sizeof(uint8_t),
420 i386_cpu_info
, "I", "CPU extended family");
422 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, stepping
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
423 (void *)offsetof(i386_cpu_info_t
, cpuid_stepping
), sizeof(uint8_t),
424 i386_cpu_info
, "I", "CPU stepping");
426 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, feature_bits
, CTLTYPE_QUAD
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
427 (void *)offsetof(i386_cpu_info_t
, cpuid_features
), sizeof(uint64_t),
428 i386_cpu_info
, "IU", "CPU features");
430 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, leaf7_feature_bits
,
431 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
432 (void *)offsetof(i386_cpu_info_t
, cpuid_leaf7_features
),
434 i386_cpu_info_nonzero
, "IU", "CPU Leaf7 features [EBX ECX]");
436 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, leaf7_feature_bits_edx
,
437 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
438 (void *)offsetof(i386_cpu_info_t
, cpuid_leaf7_extfeatures
),
440 i386_cpu_info_nonzero
, "IU", "CPU Leaf7 features [EDX]");
442 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfeature_bits
, CTLTYPE_QUAD
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
443 (void *)offsetof(i386_cpu_info_t
, cpuid_extfeatures
), sizeof(uint64_t),
444 i386_cpu_info
, "IU", "CPU extended features");
446 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, signature
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
447 (void *)offsetof(i386_cpu_info_t
, cpuid_signature
), sizeof(uint32_t),
448 i386_cpu_info
, "I", "CPU signature");
450 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
451 (void *)offsetof(i386_cpu_info_t
, cpuid_brand
), sizeof(uint8_t),
452 i386_cpu_info
, "I", "CPU brand");
454 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, features
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
456 cpu_features
, "A", "CPU feature names");
458 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, leaf7_features
,
459 CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
461 cpu_leaf7_features
, "A", "CPU Leaf7 feature names");
463 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfeatures
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
465 cpu_extfeatures
, "A", "CPU extended feature names");
467 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, logical_per_package
,
468 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
470 cpu_logical_per_package
, "I", "CPU logical cpus per package");
472 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, cores_per_package
,
473 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
474 (void *)offsetof(i386_cpu_info_t
, cpuid_cores_per_package
),
476 i386_cpu_info
, "I", "CPU cores per package");
478 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, microcode_version
,
479 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
480 (void *)offsetof(i386_cpu_info_t
, cpuid_microcode_version
),
482 i386_cpu_info
, "I", "Microcode version number");
484 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, processor_flag
,
485 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
486 (void *)offsetof(i386_cpu_info_t
, cpuid_processor_flag
),
488 i386_cpu_info
, "I", "CPU processor flag");
491 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, mwait
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
494 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, linesize_min
,
495 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
496 (void *)offsetof(cpuid_mwait_leaf_t
, linesize_min
),
498 cpu_mwait
, "I", "Monitor/mwait minimum line size");
500 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, linesize_max
,
501 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
502 (void *)offsetof(cpuid_mwait_leaf_t
, linesize_max
),
504 cpu_mwait
, "I", "Monitor/mwait maximum line size");
506 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, extensions
,
507 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
508 (void *)offsetof(cpuid_mwait_leaf_t
, extensions
),
510 cpu_mwait
, "I", "Monitor/mwait extensions");
512 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, sub_Cstates
,
513 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
514 (void *)offsetof(cpuid_mwait_leaf_t
, sub_Cstates
),
516 cpu_mwait
, "I", "Monitor/mwait sub C-states");
519 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, thermal
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
522 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, sensor
,
523 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
524 (void *)offsetof(cpuid_thermal_leaf_t
, sensor
),
526 cpu_thermal
, "I", "Thermal sensor present");
528 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, dynamic_acceleration
,
529 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
530 (void *)offsetof(cpuid_thermal_leaf_t
, dynamic_acceleration
),
532 cpu_thermal
, "I", "Dynamic Acceleration Technology (Turbo Mode)");
534 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, invariant_APIC_timer
,
535 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
536 (void *)offsetof(cpuid_thermal_leaf_t
, invariant_APIC_timer
),
538 cpu_thermal
, "I", "Invariant APIC Timer");
540 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, thresholds
,
541 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
542 (void *)offsetof(cpuid_thermal_leaf_t
, thresholds
),
544 cpu_thermal
, "I", "Number of interrupt thresholds");
546 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, ACNT_MCNT
,
547 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
548 (void *)offsetof(cpuid_thermal_leaf_t
, ACNT_MCNT
),
550 cpu_thermal
, "I", "ACNT_MCNT capability");
552 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, core_power_limits
,
553 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
554 (void *)offsetof(cpuid_thermal_leaf_t
, core_power_limits
),
556 cpu_thermal
, "I", "Power Limit Notifications at a Core Level");
558 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, fine_grain_clock_mod
,
559 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
560 (void *)offsetof(cpuid_thermal_leaf_t
, fine_grain_clock_mod
),
562 cpu_thermal
, "I", "Fine Grain Clock Modulation");
564 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, package_thermal_intr
,
565 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
566 (void *)offsetof(cpuid_thermal_leaf_t
, package_thermal_intr
),
568 cpu_thermal
, "I", "Package Thermal interrupt and Status");
570 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, hardware_feedback
,
571 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
572 (void *)offsetof(cpuid_thermal_leaf_t
, hardware_feedback
),
574 cpu_thermal
, "I", "Hardware Coordination Feedback");
576 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, energy_policy
,
577 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
578 (void *)offsetof(cpuid_thermal_leaf_t
, energy_policy
),
580 cpu_thermal
, "I", "Energy Efficient Policy Support");
582 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, xsave
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
585 SYSCTL_PROC(_machdep_cpu_xsave
, OID_AUTO
, extended_state
,
586 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
588 sizeof(cpuid_xsave_leaf_t
),
589 cpu_xsave
, "IU", "XSAVE Extended State Main Leaf");
591 SYSCTL_PROC(_machdep_cpu_xsave
, OID_AUTO
, extended_state1
,
592 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
593 (void *) sizeof(cpuid_xsave_leaf_t
),
594 sizeof(cpuid_xsave_leaf_t
),
595 cpu_xsave
, "IU", "XSAVE Extended State Sub-leaf 1");
598 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, arch_perf
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
601 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, version
,
602 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
603 (void *)offsetof(cpuid_arch_perf_leaf_t
, version
),
605 cpu_arch_perf
, "I", "Architectural Performance Version Number");
607 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, number
,
608 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
609 (void *)offsetof(cpuid_arch_perf_leaf_t
, number
),
611 cpu_arch_perf
, "I", "Number of counters per logical cpu");
613 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, width
,
614 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
615 (void *)offsetof(cpuid_arch_perf_leaf_t
, width
),
617 cpu_arch_perf
, "I", "Bit width of counters");
619 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, events_number
,
620 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
621 (void *)offsetof(cpuid_arch_perf_leaf_t
, events_number
),
623 cpu_arch_perf
, "I", "Number of monitoring events");
625 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, events
,
626 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
627 (void *)offsetof(cpuid_arch_perf_leaf_t
, events
),
629 cpu_arch_perf
, "I", "Bit vector of events");
631 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, fixed_number
,
632 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
633 (void *)offsetof(cpuid_arch_perf_leaf_t
, fixed_number
),
635 cpu_arch_perf
, "I", "Number of fixed-function counters");
637 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, fixed_width
,
638 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
639 (void *)offsetof(cpuid_arch_perf_leaf_t
, fixed_width
),
641 cpu_arch_perf
, "I", "Bit-width of fixed-function counters");
644 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, cache
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
647 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, linesize
,
648 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
649 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_linesize
),
651 i386_cpu_info
, "I", "Cacheline size");
653 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, L2_associativity
,
654 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
655 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_L2_associativity
),
657 i386_cpu_info
, "I", "L2 cache associativity");
659 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, size
,
660 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
661 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_size
),
663 i386_cpu_info
, "I", "Cache size (in Kbytes)");
666 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, tlb
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
668 SYSCTL_NODE(_machdep_cpu_tlb
, OID_AUTO
, inst
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
670 SYSCTL_NODE(_machdep_cpu_tlb
, OID_AUTO
, data
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
673 SYSCTL_PROC(_machdep_cpu_tlb_inst
, OID_AUTO
, small
,
674 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
675 (void *)offsetof(i386_cpu_info_t
,
676 cpuid_tlb
[TLB_INST
][TLB_SMALL
][0]),
678 i386_cpu_info_nonzero
, "I",
679 "Number of small page instruction TLBs");
681 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, small
,
682 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
683 (void *)offsetof(i386_cpu_info_t
,
684 cpuid_tlb
[TLB_DATA
][TLB_SMALL
][0]),
686 i386_cpu_info_nonzero
, "I",
687 "Number of small page data TLBs (1st level)");
689 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, small_level1
,
690 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
691 (void *)offsetof(i386_cpu_info_t
,
692 cpuid_tlb
[TLB_DATA
][TLB_SMALL
][1]),
694 i386_cpu_info_nonzero
, "I",
695 "Number of small page data TLBs (2nd level)");
697 SYSCTL_PROC(_machdep_cpu_tlb_inst
, OID_AUTO
, large
,
698 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
699 (void *)offsetof(i386_cpu_info_t
,
700 cpuid_tlb
[TLB_INST
][TLB_LARGE
][0]),
702 i386_cpu_info_nonzero
, "I",
703 "Number of large page instruction TLBs");
705 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, large
,
706 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
707 (void *)offsetof(i386_cpu_info_t
,
708 cpuid_tlb
[TLB_DATA
][TLB_LARGE
][0]),
710 i386_cpu_info_nonzero
, "I",
711 "Number of large page data TLBs (1st level)");
713 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, large_level1
,
714 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
715 (void *)offsetof(i386_cpu_info_t
,
716 cpuid_tlb
[TLB_DATA
][TLB_LARGE
][1]),
718 i386_cpu_info_nonzero
, "I",
719 "Number of large page data TLBs (2nd level)");
721 SYSCTL_PROC(_machdep_cpu_tlb
, OID_AUTO
, shared
,
722 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
723 (void *)offsetof(i386_cpu_info_t
, cpuid_stlb
),
725 i386_cpu_info_nonzero
, "I",
726 "Number of shared TLBs");
729 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, address_bits
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
732 SYSCTL_PROC(_machdep_cpu_address_bits
, OID_AUTO
, physical
,
733 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
734 (void *)offsetof(i386_cpu_info_t
, cpuid_address_bits_physical
),
736 i386_cpu_info
, "I", "Number of physical address bits");
738 SYSCTL_PROC(_machdep_cpu_address_bits
, OID_AUTO
, virtual,
739 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
740 (void *)offsetof(i386_cpu_info_t
, cpuid_address_bits_virtual
),
742 i386_cpu_info
, "I", "Number of virtual address bits");
745 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, core_count
,
746 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
747 (void *)offsetof(i386_cpu_info_t
, core_count
),
749 i386_cpu_info
, "I", "Number of enabled cores per package");
751 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, thread_count
,
752 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
753 (void *)offsetof(i386_cpu_info_t
, thread_count
),
755 i386_cpu_info
, "I", "Number of enabled threads per package");
757 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, flex_ratio
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
760 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, desired
,
761 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
763 cpu_flex_ratio_desired
, "I", "Flex ratio desired (0 disabled)");
765 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, min
,
766 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
768 cpu_flex_ratio_min
, "I", "Flex ratio min (efficiency)");
770 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, max
,
771 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
773 cpu_flex_ratio_max
, "I", "Flex ratio max (non-turbo)");
775 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, ucupdate
,
776 CTLTYPE_INT
| CTLFLAG_WR
| CTLFLAG_LOCKED
, 0, 0,
777 cpu_ucode_update
, "S", "Microcode update interface");
779 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, tsc_ccc
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
780 "TSC/CCC frequency information");
782 SYSCTL_PROC(_machdep_cpu_tsc_ccc
, OID_AUTO
, numerator
,
783 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
784 (void *)offsetof(i386_cpu_info_t
, cpuid_tsc_leaf
.numerator
),
786 i386_cpu_info
, "I", "Numerator of TSC/CCC ratio");
788 SYSCTL_PROC(_machdep_cpu_tsc_ccc
, OID_AUTO
, denominator
,
789 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
790 (void *)offsetof(i386_cpu_info_t
, cpuid_tsc_leaf
.denominator
),
792 i386_cpu_info
, "I", "Denominator of TSC/CCC ratio");
794 static const uint32_t apic_timer_vector
= (LAPIC_DEFAULT_INTERRUPT_BASE
+ LAPIC_TIMER_INTERRUPT
);
795 static const uint32_t apic_IPI_vector
= (LAPIC_DEFAULT_INTERRUPT_BASE
+ LAPIC_INTERPROCESSOR_INTERRUPT
);
797 SYSCTL_NODE(_machdep
, OID_AUTO
, vectors
, CTLFLAG_RD
| CTLFLAG_LOCKED
, 0,
798 "Interrupt vector assignments");
800 SYSCTL_UINT(_machdep_vectors
, OID_AUTO
, timer
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, __DECONST(uint32_t *, &apic_timer_vector
), 0, "");
801 SYSCTL_UINT(_machdep_vectors
, OID_AUTO
, IPI
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, __DECONST(uint32_t *, &apic_IPI_vector
), 0, "");
803 uint64_t pmap_pv_hashlist_walks
;
804 uint64_t pmap_pv_hashlist_cnts
;
805 uint32_t pmap_pv_hashlist_max
;
806 uint32_t pmap_kernel_text_ps
= PAGE_SIZE
;
807 extern uint32_t pv_hashed_kern_low_water_mark
;
809 /*extern struct sysctl_oid_list sysctl__machdep_pmap_children;*/
811 SYSCTL_NODE(_machdep
, OID_AUTO
, pmap
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
814 SYSCTL_QUAD(_machdep_pmap
, OID_AUTO
, hashwalks
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_walks
, "");
815 SYSCTL_QUAD(_machdep_pmap
, OID_AUTO
, hashcnts
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_cnts
, "");
816 SYSCTL_INT(_machdep_pmap
, OID_AUTO
, hashmax
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_max
, 0, "");
817 SYSCTL_INT(_machdep_pmap
, OID_AUTO
, kernel_text_ps
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_kernel_text_ps
, 0, "");
818 SYSCTL_INT(_machdep_pmap
, OID_AUTO
, kern_pv_reserve
, CTLFLAG_RW
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pv_hashed_kern_low_water_mark
, 0, "");
820 SYSCTL_NODE(_machdep
, OID_AUTO
, memmap
, CTLFLAG_RD
| CTLFLAG_LOCKED
, NULL
, "physical memory map");
822 uint64_t firmware_Conventional_bytes
= 0;
823 uint64_t firmware_RuntimeServices_bytes
= 0;
824 uint64_t firmware_ACPIReclaim_bytes
= 0;
825 uint64_t firmware_ACPINVS_bytes
= 0;
826 uint64_t firmware_PalCode_bytes
= 0;
827 uint64_t firmware_Reserved_bytes
= 0;
828 uint64_t firmware_Unusable_bytes
= 0;
829 uint64_t firmware_other_bytes
= 0;
831 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Conventional
, CTLFLAG_RD
| CTLFLAG_LOCKED
, &firmware_Conventional_bytes
, "");
832 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, RuntimeServices
, CTLFLAG_RD
| CTLFLAG_LOCKED
, &firmware_RuntimeServices_bytes
, "");
833 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, ACPIReclaim
, CTLFLAG_RD
| CTLFLAG_LOCKED
, &firmware_ACPIReclaim_bytes
, "");
834 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, ACPINVS
, CTLFLAG_RD
| CTLFLAG_LOCKED
, &firmware_ACPINVS_bytes
, "");
835 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, PalCode
, CTLFLAG_RD
| CTLFLAG_LOCKED
, &firmware_PalCode_bytes
, "");
836 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Reserved
, CTLFLAG_RD
| CTLFLAG_LOCKED
, &firmware_Reserved_bytes
, "");
837 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Unusable
, CTLFLAG_RD
| CTLFLAG_LOCKED
, &firmware_Unusable_bytes
, "");
838 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Other
, CTLFLAG_RD
| CTLFLAG_LOCKED
, &firmware_other_bytes
, "");
840 SYSCTL_NODE(_machdep
, OID_AUTO
, tsc
, CTLFLAG_RD
| CTLFLAG_LOCKED
, NULL
, "Timestamp counter parameters");
842 SYSCTL_QUAD(_machdep_tsc
, OID_AUTO
, frequency
,
843 CTLFLAG_RD
| CTLFLAG_LOCKED
, &tscFreq
, "");
845 extern uint32_t deep_idle_rebase
;
846 SYSCTL_UINT(_machdep_tsc
, OID_AUTO
, deep_idle_rebase
,
847 CTLFLAG_RD
| CTLFLAG_LOCKED
, &deep_idle_rebase
, 0, "");
848 SYSCTL_QUAD(_machdep_tsc
, OID_AUTO
, at_boot
,
849 CTLFLAG_RD
| CTLFLAG_LOCKED
, &tsc_at_boot
, "");
850 SYSCTL_QUAD(_machdep_tsc
, OID_AUTO
, rebase_abs_time
,
851 CTLFLAG_RD
| CTLFLAG_LOCKED
, &tsc_rebase_abs_time
, "");
852 #if DEVELOPMENT || DEBUG
853 SYSCTL_PROC(_machdep_tsc
, OID_AUTO
, synch_deltas
,
854 CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
855 0, 0, x86_cpu_tsc_deltas
, "A", "TSC synch deltas");
858 SYSCTL_NODE(_machdep_tsc
, OID_AUTO
, nanotime
,
859 CTLFLAG_RD
| CTLFLAG_LOCKED
, NULL
, "TSC to ns conversion");
860 SYSCTL_QUAD(_machdep_tsc_nanotime
, OID_AUTO
, tsc_base
,
861 CTLFLAG_RD
| CTLFLAG_LOCKED
,
862 __DECONST(uint64_t *, &pal_rtc_nanotime_info
.tsc_base
), "");
863 SYSCTL_QUAD(_machdep_tsc_nanotime
, OID_AUTO
, ns_base
,
864 CTLFLAG_RD
| CTLFLAG_LOCKED
,
865 __DECONST(uint64_t *, &pal_rtc_nanotime_info
.ns_base
), "");
866 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, scale
,
867 CTLFLAG_RD
| CTLFLAG_LOCKED
,
868 __DECONST(uint32_t *, &pal_rtc_nanotime_info
.scale
), 0, "");
869 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, shift
,
870 CTLFLAG_RD
| CTLFLAG_LOCKED
,
871 __DECONST(uint32_t *, &pal_rtc_nanotime_info
.shift
), 0, "");
872 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, generation
,
873 CTLFLAG_RD
| CTLFLAG_LOCKED
,
874 __DECONST(uint32_t *, &pal_rtc_nanotime_info
.generation
), 0, "");
876 SYSCTL_NODE(_machdep
, OID_AUTO
, misc
, CTLFLAG_RW
| CTLFLAG_LOCKED
, 0,
877 "Miscellaneous x86 kernel parameters");
879 #if (DEVELOPMENT || DEBUG)
880 extern uint32_t mp_interrupt_watchdog_events
;
881 SYSCTL_UINT(_machdep_misc
, OID_AUTO
, interrupt_watchdog_events
,
882 CTLFLAG_RW
| CTLFLAG_LOCKED
, &mp_interrupt_watchdog_events
, 0, "");
884 extern int insnstream_force_cacheline_mismatch
;
885 SYSCTL_INT(_machdep_misc
, OID_AUTO
, insnstream_force_clmismatch
,
886 CTLFLAG_RW
| CTLFLAG_LOCKED
, &insnstream_force_cacheline_mismatch
, 0, "");
890 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, panic_restart_timeout
,
891 CTLTYPE_INT
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
893 panic_set_restart_timeout
, "I", "Panic restart timeout in seconds");
895 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, interrupt_latency_max
,
896 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
898 misc_interrupt_latency_max
, "A", "Maximum Interrupt latency");
900 extern boolean_t is_x2apic
;
901 SYSCTL_INT(_machdep
, OID_AUTO
, x2apic_enabled
,
902 CTLFLAG_KERN
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
905 #if DEVELOPMENT || DEBUG
906 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, machine_check_panic
,
907 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
909 misc_machine_check_panic
, "A", "Machine-check exception test");
911 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, kernel_timeout_spin
,
912 CTLTYPE_QUAD
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
913 0, sizeof(kernel_timeout_spin
),
914 misc_kernel_timeout_spin
, "Q", "Kernel timeout panic test");
916 SYSCTL_QUAD(_machdep
, OID_AUTO
, reportphyreadabs
,
917 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
918 &reportphyreaddelayabs
, "");
919 SYSCTL_QUAD(_machdep
, OID_AUTO
, reportphywriteabs
,
920 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
921 &reportphywritedelayabs
, "");
922 SYSCTL_QUAD(_machdep
, OID_AUTO
, tracephyreadabs
,
923 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
924 &tracephyreaddelayabs
, "");
925 SYSCTL_QUAD(_machdep
, OID_AUTO
, tracephywriteabs
,
926 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
927 &tracephywritedelayabs
, "");
928 SYSCTL_INT(_machdep
, OID_AUTO
, reportphyreadosbt
,
929 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
930 &reportphyreadosbt
, 0, "");
931 SYSCTL_INT(_machdep
, OID_AUTO
, reportphywriteosbt
,
932 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
933 &reportphywriteosbt
, 0, "");
934 SYSCTL_INT(_machdep
, OID_AUTO
, phyreaddelaypanic
,
935 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
936 &phyreadpanic
, 0, "");
937 SYSCTL_INT(_machdep
, OID_AUTO
, phywritedelaypanic
,
938 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
939 &phywritepanic
, 0, "");
940 #if DEVELOPMENT || DEBUG
941 extern uint64_t simulate_stretched_io
;
942 SYSCTL_QUAD(_machdep
, OID_AUTO
, sim_stretched_io_ns
,
943 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
944 &simulate_stretched_io
, "");
947 extern int pmap_pagezero_mitigation
;
948 extern int pmap_asserts_enabled
, pmap_asserts_traced
;
949 /* On DEV/DEBUG kernels, clear this to disable the SMAP emulation
950 * (address space disconnect) for pagezero-less processes.
952 SYSCTL_INT(_machdep
, OID_AUTO
, pmap_pagezero_mitigation
,
953 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
954 &pmap_pagezero_mitigation
, 0, "");
955 /* Toggle pmap assertions */
956 SYSCTL_INT(_machdep
, OID_AUTO
, pmap_asserts
,
957 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
958 &pmap_asserts_enabled
, 0, "");
959 /* Transform pmap assertions into kernel trace terminations */
960 SYSCTL_INT(_machdep
, OID_AUTO
, pmap_asserts_traced
,
961 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
962 &pmap_asserts_traced
, 0, "");
965 misc_svisor_read(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
967 uint64_t new_value
= 0, old_value
= 0;
968 int changed
= 0, error
;
970 error
= sysctl_io_number(req
, old_value
, sizeof(uint64_t), &new_value
, &changed
);
971 if ((error
== 0) && changed
) {
972 volatile uint32_t *raddr
= (uint32_t *) new_value
;
973 printf("Supervisor: value at 0x%llx is 0x%x\n", new_value
, *raddr
);
978 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, misc_svisor_read
,
979 CTLTYPE_QUAD
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
981 misc_svisor_read
, "I", "supervisor mode read");
983 #endif /* DEVELOPMENT || DEBUG */
985 extern void timer_queue_trace_cpu(int);
987 misc_timer_queue_trace(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
989 int changed
= 0, error
;
993 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
995 if (error
== 0 && changed
) {
996 timer_queue_trace_cpu(0);
1001 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, timer_queue_trace
,
1002 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1004 misc_timer_queue_trace
, "A", "Cut timer queue tracepoint");
1006 extern long NMI_count
;
1007 extern void NMI_cpus(void);
1009 misc_nmis(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
1011 int new = 0, old
= 0, changed
= 0, error
;
1013 old
= (int)MIN(NMI_count
, INT_MAX
);
1015 error
= sysctl_io_number(req
, old
, sizeof(int), &new, &changed
);
1016 if (error
== 0 && changed
) {
1023 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, nmis
,
1024 CTLTYPE_INT
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1026 misc_nmis
, "I", "Report/increment NMI count");
1028 /* Parameters related to timer coalescing tuning, to be replaced
1029 * with a dedicated systemcall in the future.
1031 /* Enable processing pending timers in the context of any other interrupt */
1032 SYSCTL_INT(_kern
, OID_AUTO
, interrupt_timer_coalescing_enabled
,
1033 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1034 &interrupt_timer_coalescing_enabled
, 0, "");
1035 /* Upon entering idle, process pending timers with HW deadlines
1036 * this far in the future.
1038 SYSCTL_INT(_kern
, OID_AUTO
, timer_coalesce_idle_entry_hard_deadline_max
,
1039 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1040 &idle_entry_timer_processing_hdeadline_threshold
, 0, "");
1042 /* Track potentially expensive eager timer evaluations on QoS tier
1045 extern uint32_t ml_timer_eager_evaluations
;
1047 SYSCTL_INT(_machdep
, OID_AUTO
, eager_timer_evaluations
,
1048 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1049 &ml_timer_eager_evaluations
, 0, "");
1051 extern uint64_t ml_timer_eager_evaluation_max
;
1053 SYSCTL_QUAD(_machdep
, OID_AUTO
, eager_timer_evaluation_max
,
1054 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1055 &ml_timer_eager_evaluation_max
, "");
1056 extern uint64_t x86_isr_fp_simd_use
;
1057 SYSCTL_QUAD(_machdep
, OID_AUTO
, x86_fp_simd_isr_uses
,
1058 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1059 &x86_isr_fp_simd_use
, "");
1060 #if DEVELOPMENT || DEBUG
1062 extern int plctrace_enabled
;
1064 SYSCTL_INT(_machdep
, OID_AUTO
, pltrace
,
1065 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1066 &plctrace_enabled
, 0, "");
1068 /* Intentionally not declared as volatile here: */
1069 extern int mmiotrace_enabled
;
1071 SYSCTL_INT(_machdep
, OID_AUTO
, MMIOtrace
,
1072 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1073 &mmiotrace_enabled
, 0, "");
1075 extern int fpsimd_fault_popc
;
1076 SYSCTL_INT(_machdep
, OID_AUTO
, fpsimd_fault_popc
,
1077 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1078 &fpsimd_fault_popc
, 0, "");
1080 volatile int stop_spinning
;
1082 spin_in_the_kernel(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
1084 int new = 0, old
= 0, changed
= 0, error
;
1086 error
= sysctl_io_number(req
, old
, sizeof(int), &new, &changed
);
1087 if (error
== 0 && changed
) {
1088 stop_spinning
= FALSE
;
1089 while (stop_spinning
== FALSE
) {
1090 __builtin_ia32_pause();
1092 } else if (error
== 0) {
1093 stop_spinning
= TRUE
;
1099 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, spin_forever
,
1100 CTLTYPE_INT
| CTLFLAG_RW
| CTLFLAG_LOCKED
| CTLFLAG_MASKED
,
1102 spin_in_the_kernel
, "I", "Spin forever");
1105 extern int traptrace_enabled
;
1106 SYSCTL_INT(_machdep_misc
, OID_AUTO
, traptrace_enabled
,
1107 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
1108 &traptrace_enabled
, 0, "Enabled/disable trap trace");
1112 * Trigger a guest kernel core dump (internal only)
1113 * Usage: sysctl kern.trigger_kernel_coredump = 1
1114 * (option selector must be 1, other values reserved)
1118 sysctl_trigger_kernel_coredump(struct sysctl_oid
*oidp __unused
, void *arg1
, int arg2
, struct sysctl_req
*req
)
1121 hvg_hcall_return_t hv_ret
;
1122 char buf
[2]; // 1 digit for dump option + 1 '\0'
1126 if (req
->newlen
> 1) {
1129 error
= SYSCTL_IN(req
, buf
, req
->newlen
);
1130 buf
[req
->newlen
] = '\0';
1132 if (strcmp(buf
, "1") != 0) {
1135 /* Issue hypercall to trigger a dump */
1136 hv_ret
= hvg_hcall_trigger_dump(arg1
, HVG_HCALL_DUMP_OPTION_REGULAR
);
1138 /* Translate hypercall error code to syscall error code */
1140 case HVG_HCALL_SUCCESS
:
1141 error
= SYSCTL_OUT(req
, arg1
, 41);
1143 case HVG_HCALL_ACCESS_DENIED
:
1146 case HVG_HCALL_INVALID_CODE
:
1147 case HVG_HCALL_INVALID_PARAMETER
:
1150 case HVG_HCALL_IO_FAILED
:
1153 case HVG_HCALL_FEAT_DISABLED
:
1154 case HVG_HCALL_UNSUPPORTED
:
1163 error
= SYSCTL_OUT(req
, arg1
, arg2
);
1169 static hvg_hcall_vmcore_file_t sysctl_vmcore
;
1174 if (!cpuid_vmm_present()) {
1178 if ((cpuid_vmm_get_applepv_features() & CPUID_LEAF_FEATURE_COREDUMP
) != 0) {
1179 /* Register an OID in the sysctl MIB tree for kern.trigger_kernel_coredump */
1180 struct sysctl_oid
*hcall_trigger_dump_oid
= zalloc_permanent(sizeof(struct sysctl_oid
), ZALIGN(struct sysctl_oid
));
1181 struct sysctl_oid oid
= SYSCTL_STRUCT_INIT(_kern
,
1183 trigger_kernel_coredump
,
1184 CTLTYPE_STRING
| CTLFLAG_RW
,
1185 &sysctl_vmcore
, sizeof(sysctl_vmcore
),
1186 sysctl_trigger_kernel_coredump
,
1187 "A", "Request that the hypervisor take a live kernel dump");
1188 *hcall_trigger_dump_oid
= oid
;
1189 sysctl_register_oid(hcall_trigger_dump_oid
);
1193 #endif /* DEVELOPMENT || DEBUG */