2 * Copyright (c) 2003-2011 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/machine_routines.h>
36 #include <i386/pal_routines.h>
37 #include <i386/ucode.h>
38 #include <kern/clock.h>
39 #include <libkern/libkern.h>
40 #include <i386/lapic.h>
44 _i386_cpu_info SYSCTL_HANDLER_ARGS
46 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
55 if (arg2
== 0 && ((char *)ptr
)[0] == '\0') {
59 if (arg2
== sizeof(uint8_t)) {
60 value
= (uint32_t) *(uint8_t *)ptr
;
62 arg2
= sizeof(uint32_t);
64 return SYSCTL_OUT(req
, ptr
, arg2
? (size_t) arg2
: strlen((char *)ptr
)+1);
68 i386_cpu_info SYSCTL_HANDLER_ARGS
70 void *ptr
= (uint8_t *)cpuid_info() + (uintptr_t)arg1
;
71 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
75 i386_cpu_info_nonzero SYSCTL_HANDLER_ARGS
77 void *ptr
= (uint8_t *)cpuid_info() + (uintptr_t)arg1
;
78 int value
= *(uint32_t *)ptr
;
83 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
86 cpu_mwait SYSCTL_HANDLER_ARGS
88 i386_cpu_info_t
*cpu_info
= cpuid_info();
89 void *ptr
= (uint8_t *)cpu_info
->cpuid_mwait_leafp
+ (uintptr_t)arg1
;
90 if (cpu_info
->cpuid_mwait_leafp
== NULL
)
92 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
96 cpu_thermal SYSCTL_HANDLER_ARGS
98 i386_cpu_info_t
*cpu_info
= cpuid_info();
99 void *ptr
= (uint8_t *)cpu_info
->cpuid_thermal_leafp
+ (uintptr_t)arg1
;
100 if (cpu_info
->cpuid_thermal_leafp
== NULL
)
102 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
106 cpu_arch_perf SYSCTL_HANDLER_ARGS
108 i386_cpu_info_t
*cpu_info
= cpuid_info();
109 void *ptr
= (uint8_t *)cpu_info
->cpuid_arch_perf_leafp
+ (uintptr_t)arg1
;
110 if (cpu_info
->cpuid_arch_perf_leafp
== NULL
)
112 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
116 cpu_xsave SYSCTL_HANDLER_ARGS
118 i386_cpu_info_t
*cpu_info
= cpuid_info();
119 void *ptr
= (uint8_t *)cpu_info
->cpuid_xsave_leafp
+ (uintptr_t)arg1
;
120 if (cpu_info
->cpuid_xsave_leafp
== NULL
)
122 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
127 cpu_features SYSCTL_HANDLER_ARGS
129 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
130 __unused
void *unused_arg1
= arg1
;
131 __unused
int unused_arg2
= arg2
;
135 cpuid_get_feature_names(cpuid_features(), buf
, sizeof(buf
));
137 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
141 cpu_extfeatures SYSCTL_HANDLER_ARGS
143 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
144 __unused
void *unused_arg1
= arg1
;
145 __unused
int unused_arg2
= arg2
;
149 cpuid_get_extfeature_names(cpuid_extfeatures(), buf
, sizeof(buf
));
151 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
155 cpu_leaf7_features SYSCTL_HANDLER_ARGS
157 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
158 __unused
void *unused_arg1
= arg1
;
159 __unused
int unused_arg2
= arg2
;
162 uint32_t leaf7_features
= cpuid_info()->cpuid_leaf7_features
;
163 if (leaf7_features
== 0)
167 cpuid_get_leaf7_feature_names(leaf7_features
, buf
, sizeof(buf
));
169 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
173 cpu_logical_per_package SYSCTL_HANDLER_ARGS
175 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
176 __unused
void *unused_arg1
= arg1
;
177 __unused
int unused_arg2
= arg2
;
178 i386_cpu_info_t
*cpu_info
= cpuid_info();
180 if (!(cpuid_features() & CPUID_FEATURE_HTT
))
183 return SYSCTL_OUT(req
, &cpu_info
->cpuid_logical_per_package
,
184 sizeof(cpu_info
->cpuid_logical_per_package
));
188 cpu_flex_ratio_desired SYSCTL_HANDLER_ARGS
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();
195 if (cpu_info
->cpuid_model
!= 26)
198 return SYSCTL_OUT(req
, &flex_ratio
, sizeof(flex_ratio
));
202 cpu_flex_ratio_min SYSCTL_HANDLER_ARGS
204 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
205 __unused
void *unused_arg1
= arg1
;
206 __unused
int unused_arg2
= arg2
;
207 i386_cpu_info_t
*cpu_info
= cpuid_info();
209 if (cpu_info
->cpuid_model
!= 26)
212 return SYSCTL_OUT(req
, &flex_ratio_min
, sizeof(flex_ratio_min
));
216 cpu_flex_ratio_max SYSCTL_HANDLER_ARGS
218 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
219 __unused
void *unused_arg1
= arg1
;
220 __unused
int unused_arg2
= arg2
;
221 i386_cpu_info_t
*cpu_info
= cpuid_info();
223 if (cpu_info
->cpuid_model
!= 26)
226 return SYSCTL_OUT(req
, &flex_ratio_max
, sizeof(flex_ratio_max
));
230 cpu_ucode_update SYSCTL_HANDLER_ARGS
232 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
233 __unused
void *unused_arg1
= arg1
;
234 __unused
int unused_arg2
= arg2
;
238 error
= SYSCTL_IN(req
, &addr
, sizeof(addr
));
242 int ret
= ucode_interface(addr
);
246 extern uint64_t panic_restart_timeout
;
248 panic_set_restart_timeout(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
250 int new_value
= 0, old_value
= 0, changed
= 0, error
;
253 if (panic_restart_timeout
) {
254 absolutetime_to_nanoseconds(panic_restart_timeout
, &nstime
);
255 old_value
= nstime
/ NSEC_PER_SEC
;
258 error
= sysctl_io_number(req
, old_value
, sizeof(int), &new_value
, &changed
);
259 if (error
== 0 && changed
) {
260 nanoseconds_to_absolutetime(((uint64_t)new_value
) * NSEC_PER_SEC
, &panic_restart_timeout
);
266 * Populates the {CPU, vector, latency} triple for the maximum observed primary
270 misc_interrupt_latency_max(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
272 int changed
= 0, error
;
276 interrupt_populate_latency_stats(buf
, sizeof(buf
));
278 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
280 if (error
== 0 && changed
) {
281 interrupt_reset_latency_stats();
288 * Triggers a machine-check exception - for a suitably configured kernel only.
290 extern void mca_exception_panic(void);
292 misc_machine_check_panic(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
294 int changed
= 0, error
;
298 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
300 if (error
== 0 && changed
) {
301 mca_exception_panic();
307 SYSCTL_NODE(_machdep
, OID_AUTO
, cpu
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
310 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, max_basic
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
311 (void *)offsetof(i386_cpu_info_t
, cpuid_max_basic
),sizeof(uint32_t),
312 i386_cpu_info
, "IU", "Max Basic Information value");
314 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, max_ext
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
315 (void *)offsetof(i386_cpu_info_t
, cpuid_max_ext
), sizeof(uint32_t),
316 i386_cpu_info
, "IU", "Max Extended Function Information value");
318 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, vendor
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
319 (void *)offsetof(i386_cpu_info_t
, cpuid_vendor
), 0,
320 i386_cpu_info
, "A", "CPU vendor");
322 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand_string
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
323 (void *)offsetof(i386_cpu_info_t
, cpuid_brand_string
), 0,
324 i386_cpu_info
, "A", "CPU brand string");
326 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, family
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
327 (void *)offsetof(i386_cpu_info_t
, cpuid_family
), sizeof(uint8_t),
328 i386_cpu_info
, "I", "CPU family");
330 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
331 (void *)offsetof(i386_cpu_info_t
, cpuid_model
), sizeof(uint8_t),
332 i386_cpu_info
, "I", "CPU model");
334 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extmodel
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
335 (void *)offsetof(i386_cpu_info_t
, cpuid_extmodel
), sizeof(uint8_t),
336 i386_cpu_info
, "I", "CPU extended model");
338 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfamily
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
339 (void *)offsetof(i386_cpu_info_t
, cpuid_extfamily
), sizeof(uint8_t),
340 i386_cpu_info
, "I", "CPU extended family");
342 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, stepping
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
343 (void *)offsetof(i386_cpu_info_t
, cpuid_stepping
), sizeof(uint8_t),
344 i386_cpu_info
, "I", "CPU stepping");
346 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, feature_bits
, CTLTYPE_QUAD
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
347 (void *)offsetof(i386_cpu_info_t
, cpuid_features
), sizeof(uint64_t),
348 i386_cpu_info
, "IU", "CPU features");
350 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, leaf7_feature_bits
,
351 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
352 (void *)offsetof(i386_cpu_info_t
, cpuid_leaf7_features
),
354 i386_cpu_info_nonzero
, "IU", "CPU Leaf7 features");
356 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfeature_bits
, CTLTYPE_QUAD
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
357 (void *)offsetof(i386_cpu_info_t
, cpuid_extfeatures
), sizeof(uint64_t),
358 i386_cpu_info
, "IU", "CPU extended features");
360 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, signature
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
361 (void *)offsetof(i386_cpu_info_t
, cpuid_signature
), sizeof(uint32_t),
362 i386_cpu_info
, "I", "CPU signature");
364 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
365 (void *)offsetof(i386_cpu_info_t
, cpuid_brand
), sizeof(uint8_t),
366 i386_cpu_info
, "I", "CPU brand");
368 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, features
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
370 cpu_features
, "A", "CPU feature names");
372 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, leaf7_features
,
373 CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
375 cpu_leaf7_features
, "A", "CPU Leaf7 feature names");
377 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfeatures
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
379 cpu_extfeatures
, "A", "CPU extended feature names");
381 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, logical_per_package
,
382 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
384 cpu_logical_per_package
, "I", "CPU logical cpus per package");
386 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, cores_per_package
,
387 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
388 (void *)offsetof(i386_cpu_info_t
, cpuid_cores_per_package
),
390 i386_cpu_info
, "I", "CPU cores per package");
392 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, microcode_version
,
393 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
394 (void *)offsetof(i386_cpu_info_t
, cpuid_microcode_version
),
396 i386_cpu_info
, "I", "Microcode version number");
398 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, processor_flag
,
399 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
400 (void *)offsetof(i386_cpu_info_t
, cpuid_processor_flag
),
402 i386_cpu_info
, "I", "CPU processor flag");
405 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, mwait
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
408 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, linesize_min
,
409 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
410 (void *)offsetof(cpuid_mwait_leaf_t
, linesize_min
),
412 cpu_mwait
, "I", "Monitor/mwait minimum line size");
414 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, linesize_max
,
415 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
416 (void *)offsetof(cpuid_mwait_leaf_t
, linesize_max
),
418 cpu_mwait
, "I", "Monitor/mwait maximum line size");
420 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, extensions
,
421 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
422 (void *)offsetof(cpuid_mwait_leaf_t
, extensions
),
424 cpu_mwait
, "I", "Monitor/mwait extensions");
426 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, sub_Cstates
,
427 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
428 (void *)offsetof(cpuid_mwait_leaf_t
, sub_Cstates
),
430 cpu_mwait
, "I", "Monitor/mwait sub C-states");
433 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, thermal
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
436 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, sensor
,
437 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
438 (void *)offsetof(cpuid_thermal_leaf_t
, sensor
),
440 cpu_thermal
, "I", "Thermal sensor present");
442 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, dynamic_acceleration
,
443 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
444 (void *)offsetof(cpuid_thermal_leaf_t
, dynamic_acceleration
),
446 cpu_thermal
, "I", "Dynamic Acceleration Technology (Turbo Mode)");
448 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, invariant_APIC_timer
,
449 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
450 (void *)offsetof(cpuid_thermal_leaf_t
, invariant_APIC_timer
),
452 cpu_thermal
, "I", "Invariant APIC Timer");
454 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, thresholds
,
455 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
456 (void *)offsetof(cpuid_thermal_leaf_t
, thresholds
),
458 cpu_thermal
, "I", "Number of interrupt thresholds");
460 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, ACNT_MCNT
,
461 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
462 (void *)offsetof(cpuid_thermal_leaf_t
, ACNT_MCNT
),
464 cpu_thermal
, "I", "ACNT_MCNT capability");
466 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, core_power_limits
,
467 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
468 (void *)offsetof(cpuid_thermal_leaf_t
, core_power_limits
),
470 cpu_thermal
, "I", "Power Limit Notifications at a Core Level");
472 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, fine_grain_clock_mod
,
473 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
474 (void *)offsetof(cpuid_thermal_leaf_t
, fine_grain_clock_mod
),
476 cpu_thermal
, "I", "Fine Grain Clock Modulation");
478 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, package_thermal_intr
,
479 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
480 (void *)offsetof(cpuid_thermal_leaf_t
, package_thermal_intr
),
482 cpu_thermal
, "I", "Package Thermal interrupt and Status");
484 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, hardware_feedback
,
485 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
486 (void *)offsetof(cpuid_thermal_leaf_t
, hardware_feedback
),
488 cpu_thermal
, "I", "Hardware Coordination Feedback");
490 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, energy_policy
,
491 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
492 (void *)offsetof(cpuid_thermal_leaf_t
, energy_policy
),
494 cpu_thermal
, "I", "Energy Efficient Policy Support");
496 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, xsave
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
499 SYSCTL_PROC(_machdep_cpu_xsave
, OID_AUTO
, extended_state
,
500 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
502 sizeof(cpuid_xsave_leaf_t
),
503 cpu_xsave
, "IU", "XSAVE Extended State Main Leaf");
505 SYSCTL_PROC(_machdep_cpu_xsave
, OID_AUTO
, extended_state1
,
506 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
507 (void *) sizeof(cpuid_xsave_leaf_t
),
508 sizeof(cpuid_xsave_leaf_t
),
509 cpu_xsave
, "IU", "XSAVE Extended State Sub-leaf 1");
512 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, arch_perf
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
515 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, version
,
516 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
517 (void *)offsetof(cpuid_arch_perf_leaf_t
, version
),
519 cpu_arch_perf
, "I", "Architectural Performance Version Number");
521 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, number
,
522 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
523 (void *)offsetof(cpuid_arch_perf_leaf_t
, number
),
525 cpu_arch_perf
, "I", "Number of counters per logical cpu");
527 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, width
,
528 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
529 (void *)offsetof(cpuid_arch_perf_leaf_t
, width
),
531 cpu_arch_perf
, "I", "Bit width of counters");
533 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, events_number
,
534 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
535 (void *)offsetof(cpuid_arch_perf_leaf_t
, events_number
),
537 cpu_arch_perf
, "I", "Number of monitoring events");
539 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, events
,
540 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
541 (void *)offsetof(cpuid_arch_perf_leaf_t
, events
),
543 cpu_arch_perf
, "I", "Bit vector of events");
545 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, fixed_number
,
546 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
547 (void *)offsetof(cpuid_arch_perf_leaf_t
, fixed_number
),
549 cpu_arch_perf
, "I", "Number of fixed-function counters");
551 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, fixed_width
,
552 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
553 (void *)offsetof(cpuid_arch_perf_leaf_t
, fixed_width
),
555 cpu_arch_perf
, "I", "Bit-width of fixed-function counters");
558 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, cache
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
561 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, linesize
,
562 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
563 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_linesize
),
565 i386_cpu_info
, "I", "Cacheline size");
567 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, L2_associativity
,
568 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
569 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_L2_associativity
),
571 i386_cpu_info
, "I", "L2 cache associativity");
573 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, size
,
574 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
575 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_size
),
577 i386_cpu_info
, "I", "Cache size (in Kbytes)");
580 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, tlb
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
582 SYSCTL_NODE(_machdep_cpu_tlb
, OID_AUTO
, inst
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
584 SYSCTL_NODE(_machdep_cpu_tlb
, OID_AUTO
, data
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
587 SYSCTL_PROC(_machdep_cpu_tlb_inst
, OID_AUTO
, small
,
588 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
589 (void *)offsetof(i386_cpu_info_t
,
590 cpuid_tlb
[TLB_INST
][TLB_SMALL
][0]),
592 i386_cpu_info_nonzero
, "I",
593 "Number of small page instruction TLBs");
595 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, small
,
596 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
597 (void *)offsetof(i386_cpu_info_t
,
598 cpuid_tlb
[TLB_DATA
][TLB_SMALL
][0]),
600 i386_cpu_info_nonzero
, "I",
601 "Number of small page data TLBs (1st level)");
603 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, small_level1
,
604 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
605 (void *)offsetof(i386_cpu_info_t
,
606 cpuid_tlb
[TLB_DATA
][TLB_SMALL
][1]),
608 i386_cpu_info_nonzero
, "I",
609 "Number of small page data TLBs (2nd level)");
611 SYSCTL_PROC(_machdep_cpu_tlb_inst
, OID_AUTO
, large
,
612 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
613 (void *)offsetof(i386_cpu_info_t
,
614 cpuid_tlb
[TLB_INST
][TLB_LARGE
][0]),
616 i386_cpu_info_nonzero
, "I",
617 "Number of large page instruction TLBs");
619 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, large
,
620 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
621 (void *)offsetof(i386_cpu_info_t
,
622 cpuid_tlb
[TLB_DATA
][TLB_LARGE
][0]),
624 i386_cpu_info_nonzero
, "I",
625 "Number of large page data TLBs (1st level)");
627 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, large_level1
,
628 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
629 (void *)offsetof(i386_cpu_info_t
,
630 cpuid_tlb
[TLB_DATA
][TLB_LARGE
][1]),
632 i386_cpu_info_nonzero
, "I",
633 "Number of large page data TLBs (2nd level)");
635 SYSCTL_PROC(_machdep_cpu_tlb
, OID_AUTO
, shared
,
636 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
637 (void *)offsetof(i386_cpu_info_t
, cpuid_stlb
),
639 i386_cpu_info_nonzero
, "I",
640 "Number of shared TLBs");
643 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, address_bits
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
646 SYSCTL_PROC(_machdep_cpu_address_bits
, OID_AUTO
, physical
,
647 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
648 (void *)offsetof(i386_cpu_info_t
, cpuid_address_bits_physical
),
650 i386_cpu_info
, "I", "Number of physical address bits");
652 SYSCTL_PROC(_machdep_cpu_address_bits
, OID_AUTO
, virtual,
653 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
654 (void *)offsetof(i386_cpu_info_t
, cpuid_address_bits_virtual
),
656 i386_cpu_info
, "I", "Number of virtual address bits");
659 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, core_count
,
660 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
661 (void *)offsetof(i386_cpu_info_t
, core_count
),
663 i386_cpu_info
, "I", "Number of enabled cores per package");
665 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, thread_count
,
666 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
667 (void *)offsetof(i386_cpu_info_t
, thread_count
),
669 i386_cpu_info
, "I", "Number of enabled threads per package");
671 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, flex_ratio
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
674 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, desired
,
675 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
677 cpu_flex_ratio_desired
, "I", "Flex ratio desired (0 disabled)");
679 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, min
,
680 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
682 cpu_flex_ratio_min
, "I", "Flex ratio min (efficiency)");
684 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, max
,
685 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
687 cpu_flex_ratio_max
, "I", "Flex ratio max (non-turbo)");
689 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, ucupdate
,
690 CTLTYPE_INT
| CTLFLAG_WR
| CTLFLAG_LOCKED
, 0, 0,
691 cpu_ucode_update
, "S", "Microcode update interface");
693 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, tsc_ccc
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
694 "TSC/CCC frequency information");
696 SYSCTL_PROC(_machdep_cpu_tsc_ccc
, OID_AUTO
, numerator
,
697 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
698 (void *)offsetof(i386_cpu_info_t
, cpuid_tsc_leaf
.numerator
),
700 i386_cpu_info
, "I", "Numerator of TSC/CCC ratio");
702 SYSCTL_PROC(_machdep_cpu_tsc_ccc
, OID_AUTO
, denominator
,
703 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
704 (void *)offsetof(i386_cpu_info_t
, cpuid_tsc_leaf
.denominator
),
706 i386_cpu_info
, "I", "Denominator of TSC/CCC ratio");
708 static const uint32_t apic_timer_vector
= (LAPIC_DEFAULT_INTERRUPT_BASE
+ LAPIC_TIMER_INTERRUPT
);
709 static const uint32_t apic_IPI_vector
= (LAPIC_DEFAULT_INTERRUPT_BASE
+ LAPIC_INTERPROCESSOR_INTERRUPT
);
711 SYSCTL_NODE(_machdep
, OID_AUTO
, vectors
, CTLFLAG_RD
| CTLFLAG_LOCKED
, 0,
712 "Interrupt vector assignments");
714 SYSCTL_UINT (_machdep_vectors
, OID_AUTO
, timer
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, __DECONST(uint32_t *,&apic_timer_vector
), 0, "");
715 SYSCTL_UINT (_machdep_vectors
, OID_AUTO
, IPI
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, __DECONST(uint32_t *,&apic_IPI_vector
), 0, "");
717 uint64_t pmap_pv_hashlist_walks
;
718 uint64_t pmap_pv_hashlist_cnts
;
719 uint32_t pmap_pv_hashlist_max
;
720 uint32_t pmap_kernel_text_ps
= PAGE_SIZE
;
721 extern uint32_t pv_hashed_kern_low_water_mark
;
723 /*extern struct sysctl_oid_list sysctl__machdep_pmap_children;*/
725 SYSCTL_NODE(_machdep
, OID_AUTO
, pmap
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
728 SYSCTL_QUAD (_machdep_pmap
, OID_AUTO
, hashwalks
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_walks
, "");
729 SYSCTL_QUAD (_machdep_pmap
, OID_AUTO
, hashcnts
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_cnts
, "");
730 SYSCTL_INT (_machdep_pmap
, OID_AUTO
, hashmax
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_max
, 0, "");
731 SYSCTL_INT (_machdep_pmap
, OID_AUTO
, kernel_text_ps
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_kernel_text_ps
, 0, "");
732 SYSCTL_INT (_machdep_pmap
, OID_AUTO
, kern_pv_reserve
, CTLFLAG_RW
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pv_hashed_kern_low_water_mark
, 0, "");
734 SYSCTL_NODE(_machdep
, OID_AUTO
, memmap
, CTLFLAG_RD
|CTLFLAG_LOCKED
, NULL
, "physical memory map");
736 uint64_t firmware_Conventional_bytes
= 0;
737 uint64_t firmware_RuntimeServices_bytes
= 0;
738 uint64_t firmware_ACPIReclaim_bytes
= 0;
739 uint64_t firmware_ACPINVS_bytes
= 0;
740 uint64_t firmware_PalCode_bytes
= 0;
741 uint64_t firmware_Reserved_bytes
= 0;
742 uint64_t firmware_Unusable_bytes
= 0;
743 uint64_t firmware_other_bytes
= 0;
745 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Conventional
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_Conventional_bytes
, "");
746 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, RuntimeServices
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_RuntimeServices_bytes
, "");
747 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, ACPIReclaim
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_ACPIReclaim_bytes
, "");
748 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, ACPINVS
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_ACPINVS_bytes
, "");
749 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, PalCode
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_PalCode_bytes
, "");
750 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Reserved
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_Reserved_bytes
, "");
751 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Unusable
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_Unusable_bytes
, "");
752 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Other
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_other_bytes
, "");
754 SYSCTL_NODE(_machdep
, OID_AUTO
, tsc
, CTLFLAG_RD
|CTLFLAG_LOCKED
, NULL
, "Timestamp counter parameters");
756 SYSCTL_QUAD(_machdep_tsc
, OID_AUTO
, frequency
,
757 CTLFLAG_RD
|CTLFLAG_LOCKED
, &tscFreq
, "");
759 extern uint32_t deep_idle_rebase
;
760 SYSCTL_UINT(_machdep_tsc
, OID_AUTO
, deep_idle_rebase
,
761 CTLFLAG_RW
|CTLFLAG_KERN
|CTLFLAG_LOCKED
, &deep_idle_rebase
, 0, "");
763 SYSCTL_NODE(_machdep_tsc
, OID_AUTO
, nanotime
,
764 CTLFLAG_RD
|CTLFLAG_LOCKED
, NULL
, "TSC to ns conversion");
765 SYSCTL_QUAD(_machdep_tsc_nanotime
, OID_AUTO
, tsc_base
,
766 CTLFLAG_RD
| CTLFLAG_LOCKED
,
767 __DECONST(uint64_t *, &pal_rtc_nanotime_info
.tsc_base
), "");
768 SYSCTL_QUAD(_machdep_tsc_nanotime
, OID_AUTO
, ns_base
,
769 CTLFLAG_RD
| CTLFLAG_LOCKED
,
770 __DECONST(uint64_t *, &pal_rtc_nanotime_info
.ns_base
), "");
771 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, scale
,
772 CTLFLAG_RD
| CTLFLAG_LOCKED
,
773 __DECONST(uint32_t *, &pal_rtc_nanotime_info
.scale
), 0, "");
774 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, shift
,
775 CTLFLAG_RD
| CTLFLAG_LOCKED
,
776 __DECONST(uint32_t *, &pal_rtc_nanotime_info
.shift
), 0, "");
777 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, generation
,
778 CTLFLAG_RD
| CTLFLAG_LOCKED
,
779 __DECONST(uint32_t *, &pal_rtc_nanotime_info
.generation
), 0, "");
781 SYSCTL_NODE(_machdep
, OID_AUTO
, misc
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
782 "Miscellaneous x86 kernel parameters");
784 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, panic_restart_timeout
,
785 CTLTYPE_INT
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
787 panic_set_restart_timeout
, "I", "Panic restart timeout in seconds");
789 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, interrupt_latency_max
,
790 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
792 misc_interrupt_latency_max
, "A", "Maximum Interrupt latency");
794 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, machine_check_panic
,
795 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
797 misc_machine_check_panic
, "A", "Machine-check exception test");
799 #if DEVELOPMENT || DEBUG
800 SYSCTL_QUAD(_machdep
, OID_AUTO
, reportphyreadabs
,
801 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
802 &reportphyreaddelayabs
, "");
803 SYSCTL_INT(_machdep
, OID_AUTO
, reportphyreadosbt
,
804 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
805 &reportphyreadosbt
, 0, "");
808 extern void timer_queue_trace_cpu(int);
810 misc_timer_queue_trace(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
812 int changed
= 0, error
;
816 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
818 if (error
== 0 && changed
) {
819 timer_queue_trace_cpu(0);
824 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, timer_queue_trace
,
825 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
827 misc_timer_queue_trace
, "A", "Cut timer queue tracepoint");
829 extern long NMI_count
;
830 extern void NMI_cpus(void);
832 misc_nmis(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
834 int new = 0, old
= 0, changed
= 0, error
;
838 error
= sysctl_io_number(req
, old
, sizeof(int), &new, &changed
);
839 if (error
== 0 && changed
) {
846 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, nmis
,
847 CTLTYPE_INT
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
849 misc_nmis
, "I", "Report/increment NMI count");
851 /* Parameters related to timer coalescing tuning, to be replaced
852 * with a dedicated systemcall in the future.
854 /* Enable processing pending timers in the context of any other interrupt */
855 SYSCTL_INT(_kern
, OID_AUTO
, interrupt_timer_coalescing_enabled
,
856 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
857 &interrupt_timer_coalescing_enabled
, 0, "");
858 /* Upon entering idle, process pending timers with HW deadlines
859 * this far in the future.
861 SYSCTL_INT(_kern
, OID_AUTO
, timer_coalesce_idle_entry_hard_deadline_max
,
862 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
863 &idle_entry_timer_processing_hdeadline_threshold
, 0, "");
865 /* Track potentially expensive eager timer evaluations on QoS tier
868 extern uint32_t ml_timer_eager_evaluations
;
870 SYSCTL_INT(_machdep
, OID_AUTO
, eager_timer_evaluations
,
871 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
872 &ml_timer_eager_evaluations
, 0, "");
874 extern uint64_t ml_timer_eager_evaluation_max
;
876 SYSCTL_QUAD(_machdep
, OID_AUTO
, eager_timer_evaluation_max
,
877 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
878 &ml_timer_eager_evaluation_max
, "");
879 extern uint64_t x86_isr_fp_simd_use
;
880 SYSCTL_QUAD(_machdep
, OID_AUTO
, x86_fp_simd_isr_uses
,
881 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
882 &x86_isr_fp_simd_use
, "");