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/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>
45 _i386_cpu_info SYSCTL_HANDLER_ARGS
47 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
56 if (arg2
== 0 && ((char *)ptr
)[0] == '\0') {
60 if (arg2
== sizeof(uint8_t)) {
61 value
= (uint32_t) *(uint8_t *)ptr
;
63 arg2
= sizeof(uint32_t);
65 return SYSCTL_OUT(req
, ptr
, arg2
? (size_t) arg2
: strlen((char *)ptr
)+1);
69 i386_cpu_info SYSCTL_HANDLER_ARGS
71 void *ptr
= (uint8_t *)cpuid_info() + (uintptr_t)arg1
;
72 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
76 i386_cpu_info_nonzero SYSCTL_HANDLER_ARGS
78 void *ptr
= (uint8_t *)cpuid_info() + (uintptr_t)arg1
;
79 int value
= *(uint32_t *)ptr
;
84 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
87 cpu_mwait SYSCTL_HANDLER_ARGS
89 i386_cpu_info_t
*cpu_info
= cpuid_info();
90 void *ptr
= (uint8_t *)cpu_info
->cpuid_mwait_leafp
+ (uintptr_t)arg1
;
91 if (cpu_info
->cpuid_mwait_leafp
== NULL
)
93 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
97 cpu_thermal SYSCTL_HANDLER_ARGS
99 i386_cpu_info_t
*cpu_info
= cpuid_info();
100 void *ptr
= (uint8_t *)cpu_info
->cpuid_thermal_leafp
+ (uintptr_t)arg1
;
101 if (cpu_info
->cpuid_thermal_leafp
== NULL
)
103 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
107 cpu_arch_perf SYSCTL_HANDLER_ARGS
109 i386_cpu_info_t
*cpu_info
= cpuid_info();
110 void *ptr
= (uint8_t *)cpu_info
->cpuid_arch_perf_leafp
+ (uintptr_t)arg1
;
111 if (cpu_info
->cpuid_arch_perf_leafp
== NULL
)
113 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
117 cpu_xsave SYSCTL_HANDLER_ARGS
119 i386_cpu_info_t
*cpu_info
= cpuid_info();
120 void *ptr
= (uint8_t *)cpu_info
->cpuid_xsave_leafp
+ (uintptr_t)arg1
;
121 if (cpu_info
->cpuid_xsave_leafp
== NULL
)
123 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
128 cpu_features SYSCTL_HANDLER_ARGS
130 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
131 __unused
void *unused_arg1
= arg1
;
132 __unused
int unused_arg2
= arg2
;
136 cpuid_get_feature_names(cpuid_features(), buf
, sizeof(buf
));
138 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
142 cpu_extfeatures SYSCTL_HANDLER_ARGS
144 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
145 __unused
void *unused_arg1
= arg1
;
146 __unused
int unused_arg2
= arg2
;
150 cpuid_get_extfeature_names(cpuid_extfeatures(), buf
, sizeof(buf
));
152 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
156 cpu_leaf7_features SYSCTL_HANDLER_ARGS
158 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
159 __unused
void *unused_arg1
= arg1
;
160 __unused
int unused_arg2
= arg2
;
163 uint32_t leaf7_features
= cpuid_info()->cpuid_leaf7_features
;
164 if (leaf7_features
== 0)
168 cpuid_get_leaf7_feature_names(leaf7_features
, buf
, sizeof(buf
));
170 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
174 cpu_logical_per_package SYSCTL_HANDLER_ARGS
176 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
177 __unused
void *unused_arg1
= arg1
;
178 __unused
int unused_arg2
= arg2
;
179 i386_cpu_info_t
*cpu_info
= cpuid_info();
181 if (!(cpuid_features() & CPUID_FEATURE_HTT
))
184 return SYSCTL_OUT(req
, &cpu_info
->cpuid_logical_per_package
,
185 sizeof(cpu_info
->cpuid_logical_per_package
));
189 cpu_flex_ratio_desired SYSCTL_HANDLER_ARGS
191 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
192 __unused
void *unused_arg1
= arg1
;
193 __unused
int unused_arg2
= arg2
;
194 i386_cpu_info_t
*cpu_info
= cpuid_info();
196 if (cpu_info
->cpuid_model
!= 26)
199 return SYSCTL_OUT(req
, &flex_ratio
, sizeof(flex_ratio
));
203 cpu_flex_ratio_min SYSCTL_HANDLER_ARGS
205 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
206 __unused
void *unused_arg1
= arg1
;
207 __unused
int unused_arg2
= arg2
;
208 i386_cpu_info_t
*cpu_info
= cpuid_info();
210 if (cpu_info
->cpuid_model
!= 26)
213 return SYSCTL_OUT(req
, &flex_ratio_min
, sizeof(flex_ratio_min
));
217 cpu_flex_ratio_max SYSCTL_HANDLER_ARGS
219 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
220 __unused
void *unused_arg1
= arg1
;
221 __unused
int unused_arg2
= arg2
;
222 i386_cpu_info_t
*cpu_info
= cpuid_info();
224 if (cpu_info
->cpuid_model
!= 26)
227 return SYSCTL_OUT(req
, &flex_ratio_max
, sizeof(flex_ratio_max
));
231 cpu_ucode_update SYSCTL_HANDLER_ARGS
233 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
234 __unused
void *unused_arg1
= arg1
;
235 __unused
int unused_arg2
= arg2
;
239 error
= SYSCTL_IN(req
, &addr
, sizeof(addr
));
243 int ret
= ucode_interface(addr
);
247 extern uint64_t panic_restart_timeout
;
249 panic_set_restart_timeout(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
251 int new_value
= 0, old_value
= 0, changed
= 0, error
;
254 if (panic_restart_timeout
) {
255 absolutetime_to_nanoseconds(panic_restart_timeout
, &nstime
);
256 old_value
= nstime
/ NSEC_PER_SEC
;
259 error
= sysctl_io_number(req
, old_value
, sizeof(int), &new_value
, &changed
);
260 if (error
== 0 && changed
) {
261 nanoseconds_to_absolutetime(((uint64_t)new_value
) * NSEC_PER_SEC
, &panic_restart_timeout
);
267 * Populates the {CPU, vector, latency} triple for the maximum observed primary
271 misc_interrupt_latency_max(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
273 int changed
= 0, error
;
277 interrupt_populate_latency_stats(buf
, sizeof(buf
));
279 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
281 if (error
== 0 && changed
) {
282 interrupt_reset_latency_stats();
289 * Triggers a machine-check exception - for a suitably configured kernel only.
291 extern void mca_exception_panic(void);
293 misc_machine_check_panic(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
295 int changed
= 0, error
;
299 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
301 if (error
== 0 && changed
) {
302 mca_exception_panic();
308 SYSCTL_NODE(_machdep
, OID_AUTO
, cpu
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
311 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, max_basic
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
312 (void *)offsetof(i386_cpu_info_t
, cpuid_max_basic
),sizeof(uint32_t),
313 i386_cpu_info
, "IU", "Max Basic Information value");
315 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, max_ext
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
316 (void *)offsetof(i386_cpu_info_t
, cpuid_max_ext
), sizeof(uint32_t),
317 i386_cpu_info
, "IU", "Max Extended Function Information value");
319 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, vendor
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
320 (void *)offsetof(i386_cpu_info_t
, cpuid_vendor
), 0,
321 i386_cpu_info
, "A", "CPU vendor");
323 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand_string
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
324 (void *)offsetof(i386_cpu_info_t
, cpuid_brand_string
), 0,
325 i386_cpu_info
, "A", "CPU brand string");
327 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, family
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
328 (void *)offsetof(i386_cpu_info_t
, cpuid_family
), sizeof(uint8_t),
329 i386_cpu_info
, "I", "CPU family");
331 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
332 (void *)offsetof(i386_cpu_info_t
, cpuid_model
), sizeof(uint8_t),
333 i386_cpu_info
, "I", "CPU model");
335 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extmodel
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
336 (void *)offsetof(i386_cpu_info_t
, cpuid_extmodel
), sizeof(uint8_t),
337 i386_cpu_info
, "I", "CPU extended model");
339 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfamily
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
340 (void *)offsetof(i386_cpu_info_t
, cpuid_extfamily
), sizeof(uint8_t),
341 i386_cpu_info
, "I", "CPU extended family");
343 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, stepping
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
344 (void *)offsetof(i386_cpu_info_t
, cpuid_stepping
), sizeof(uint8_t),
345 i386_cpu_info
, "I", "CPU stepping");
347 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, feature_bits
, CTLTYPE_QUAD
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
348 (void *)offsetof(i386_cpu_info_t
, cpuid_features
), sizeof(uint64_t),
349 i386_cpu_info
, "IU", "CPU features");
351 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, leaf7_feature_bits
,
352 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
353 (void *)offsetof(i386_cpu_info_t
, cpuid_leaf7_features
),
355 i386_cpu_info_nonzero
, "IU", "CPU Leaf7 features");
357 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfeature_bits
, CTLTYPE_QUAD
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
358 (void *)offsetof(i386_cpu_info_t
, cpuid_extfeatures
), sizeof(uint64_t),
359 i386_cpu_info
, "IU", "CPU extended features");
361 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, signature
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
362 (void *)offsetof(i386_cpu_info_t
, cpuid_signature
), sizeof(uint32_t),
363 i386_cpu_info
, "I", "CPU signature");
365 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
366 (void *)offsetof(i386_cpu_info_t
, cpuid_brand
), sizeof(uint8_t),
367 i386_cpu_info
, "I", "CPU brand");
369 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, features
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
371 cpu_features
, "A", "CPU feature names");
373 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, leaf7_features
,
374 CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
376 cpu_leaf7_features
, "A", "CPU Leaf7 feature names");
378 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfeatures
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
380 cpu_extfeatures
, "A", "CPU extended feature names");
382 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, logical_per_package
,
383 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
385 cpu_logical_per_package
, "I", "CPU logical cpus per package");
387 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, cores_per_package
,
388 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
389 (void *)offsetof(i386_cpu_info_t
, cpuid_cores_per_package
),
391 i386_cpu_info
, "I", "CPU cores per package");
393 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, microcode_version
,
394 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
395 (void *)offsetof(i386_cpu_info_t
, cpuid_microcode_version
),
397 i386_cpu_info
, "I", "Microcode version number");
399 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, processor_flag
,
400 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
401 (void *)offsetof(i386_cpu_info_t
, cpuid_processor_flag
),
403 i386_cpu_info
, "I", "CPU processor flag");
406 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, mwait
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
409 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, linesize_min
,
410 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
411 (void *)offsetof(cpuid_mwait_leaf_t
, linesize_min
),
413 cpu_mwait
, "I", "Monitor/mwait minimum line size");
415 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, linesize_max
,
416 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
417 (void *)offsetof(cpuid_mwait_leaf_t
, linesize_max
),
419 cpu_mwait
, "I", "Monitor/mwait maximum line size");
421 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, extensions
,
422 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
423 (void *)offsetof(cpuid_mwait_leaf_t
, extensions
),
425 cpu_mwait
, "I", "Monitor/mwait extensions");
427 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, sub_Cstates
,
428 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
429 (void *)offsetof(cpuid_mwait_leaf_t
, sub_Cstates
),
431 cpu_mwait
, "I", "Monitor/mwait sub C-states");
434 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, thermal
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
437 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, sensor
,
438 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
439 (void *)offsetof(cpuid_thermal_leaf_t
, sensor
),
441 cpu_thermal
, "I", "Thermal sensor present");
443 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, dynamic_acceleration
,
444 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
445 (void *)offsetof(cpuid_thermal_leaf_t
, dynamic_acceleration
),
447 cpu_thermal
, "I", "Dynamic Acceleration Technology (Turbo Mode)");
449 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, invariant_APIC_timer
,
450 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
451 (void *)offsetof(cpuid_thermal_leaf_t
, invariant_APIC_timer
),
453 cpu_thermal
, "I", "Invariant APIC Timer");
455 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, thresholds
,
456 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
457 (void *)offsetof(cpuid_thermal_leaf_t
, thresholds
),
459 cpu_thermal
, "I", "Number of interrupt thresholds");
461 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, ACNT_MCNT
,
462 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
463 (void *)offsetof(cpuid_thermal_leaf_t
, ACNT_MCNT
),
465 cpu_thermal
, "I", "ACNT_MCNT capability");
467 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, core_power_limits
,
468 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
469 (void *)offsetof(cpuid_thermal_leaf_t
, core_power_limits
),
471 cpu_thermal
, "I", "Power Limit Notifications at a Core Level");
473 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, fine_grain_clock_mod
,
474 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
475 (void *)offsetof(cpuid_thermal_leaf_t
, fine_grain_clock_mod
),
477 cpu_thermal
, "I", "Fine Grain Clock Modulation");
479 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, package_thermal_intr
,
480 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
481 (void *)offsetof(cpuid_thermal_leaf_t
, package_thermal_intr
),
483 cpu_thermal
, "I", "Package Thermal interrupt and Status");
485 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, hardware_feedback
,
486 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
487 (void *)offsetof(cpuid_thermal_leaf_t
, hardware_feedback
),
489 cpu_thermal
, "I", "Hardware Coordination Feedback");
491 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, energy_policy
,
492 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
493 (void *)offsetof(cpuid_thermal_leaf_t
, energy_policy
),
495 cpu_thermal
, "I", "Energy Efficient Policy Support");
497 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, xsave
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
500 SYSCTL_PROC(_machdep_cpu_xsave
, OID_AUTO
, extended_state
,
501 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
503 sizeof(cpuid_xsave_leaf_t
),
504 cpu_xsave
, "IU", "XSAVE Extended State Main Leaf");
506 SYSCTL_PROC(_machdep_cpu_xsave
, OID_AUTO
, extended_state1
,
507 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
508 (void *) sizeof(cpuid_xsave_leaf_t
),
509 sizeof(cpuid_xsave_leaf_t
),
510 cpu_xsave
, "IU", "XSAVE Extended State Sub-leaf 1");
513 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, arch_perf
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
516 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, version
,
517 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
518 (void *)offsetof(cpuid_arch_perf_leaf_t
, version
),
520 cpu_arch_perf
, "I", "Architectural Performance Version Number");
522 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, number
,
523 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
524 (void *)offsetof(cpuid_arch_perf_leaf_t
, number
),
526 cpu_arch_perf
, "I", "Number of counters per logical cpu");
528 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, width
,
529 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
530 (void *)offsetof(cpuid_arch_perf_leaf_t
, width
),
532 cpu_arch_perf
, "I", "Bit width of counters");
534 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, events_number
,
535 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
536 (void *)offsetof(cpuid_arch_perf_leaf_t
, events_number
),
538 cpu_arch_perf
, "I", "Number of monitoring events");
540 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, events
,
541 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
542 (void *)offsetof(cpuid_arch_perf_leaf_t
, events
),
544 cpu_arch_perf
, "I", "Bit vector of events");
546 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, fixed_number
,
547 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
548 (void *)offsetof(cpuid_arch_perf_leaf_t
, fixed_number
),
550 cpu_arch_perf
, "I", "Number of fixed-function counters");
552 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, fixed_width
,
553 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
554 (void *)offsetof(cpuid_arch_perf_leaf_t
, fixed_width
),
556 cpu_arch_perf
, "I", "Bit-width of fixed-function counters");
559 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, cache
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
562 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, linesize
,
563 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
564 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_linesize
),
566 i386_cpu_info
, "I", "Cacheline size");
568 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, L2_associativity
,
569 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
570 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_L2_associativity
),
572 i386_cpu_info
, "I", "L2 cache associativity");
574 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, size
,
575 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
576 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_size
),
578 i386_cpu_info
, "I", "Cache size (in Kbytes)");
581 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, tlb
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
583 SYSCTL_NODE(_machdep_cpu_tlb
, OID_AUTO
, inst
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
585 SYSCTL_NODE(_machdep_cpu_tlb
, OID_AUTO
, data
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
588 SYSCTL_PROC(_machdep_cpu_tlb_inst
, OID_AUTO
, small
,
589 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
590 (void *)offsetof(i386_cpu_info_t
,
591 cpuid_tlb
[TLB_INST
][TLB_SMALL
][0]),
593 i386_cpu_info_nonzero
, "I",
594 "Number of small page instruction TLBs");
596 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, small
,
597 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
598 (void *)offsetof(i386_cpu_info_t
,
599 cpuid_tlb
[TLB_DATA
][TLB_SMALL
][0]),
601 i386_cpu_info_nonzero
, "I",
602 "Number of small page data TLBs (1st level)");
604 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, small_level1
,
605 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
606 (void *)offsetof(i386_cpu_info_t
,
607 cpuid_tlb
[TLB_DATA
][TLB_SMALL
][1]),
609 i386_cpu_info_nonzero
, "I",
610 "Number of small page data TLBs (2nd level)");
612 SYSCTL_PROC(_machdep_cpu_tlb_inst
, OID_AUTO
, large
,
613 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
614 (void *)offsetof(i386_cpu_info_t
,
615 cpuid_tlb
[TLB_INST
][TLB_LARGE
][0]),
617 i386_cpu_info_nonzero
, "I",
618 "Number of large page instruction TLBs");
620 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, large
,
621 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
622 (void *)offsetof(i386_cpu_info_t
,
623 cpuid_tlb
[TLB_DATA
][TLB_LARGE
][0]),
625 i386_cpu_info_nonzero
, "I",
626 "Number of large page data TLBs (1st level)");
628 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, large_level1
,
629 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
630 (void *)offsetof(i386_cpu_info_t
,
631 cpuid_tlb
[TLB_DATA
][TLB_LARGE
][1]),
633 i386_cpu_info_nonzero
, "I",
634 "Number of large page data TLBs (2nd level)");
636 SYSCTL_PROC(_machdep_cpu_tlb
, OID_AUTO
, shared
,
637 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
638 (void *)offsetof(i386_cpu_info_t
, cpuid_stlb
),
640 i386_cpu_info_nonzero
, "I",
641 "Number of shared TLBs");
644 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, address_bits
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
647 SYSCTL_PROC(_machdep_cpu_address_bits
, OID_AUTO
, physical
,
648 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
649 (void *)offsetof(i386_cpu_info_t
, cpuid_address_bits_physical
),
651 i386_cpu_info
, "I", "Number of physical address bits");
653 SYSCTL_PROC(_machdep_cpu_address_bits
, OID_AUTO
, virtual,
654 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
655 (void *)offsetof(i386_cpu_info_t
, cpuid_address_bits_virtual
),
657 i386_cpu_info
, "I", "Number of virtual address bits");
660 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, core_count
,
661 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
662 (void *)offsetof(i386_cpu_info_t
, core_count
),
664 i386_cpu_info
, "I", "Number of enabled cores per package");
666 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, thread_count
,
667 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
668 (void *)offsetof(i386_cpu_info_t
, thread_count
),
670 i386_cpu_info
, "I", "Number of enabled threads per package");
672 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, flex_ratio
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
675 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, desired
,
676 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
678 cpu_flex_ratio_desired
, "I", "Flex ratio desired (0 disabled)");
680 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, min
,
681 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
683 cpu_flex_ratio_min
, "I", "Flex ratio min (efficiency)");
685 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, max
,
686 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
688 cpu_flex_ratio_max
, "I", "Flex ratio max (non-turbo)");
690 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, ucupdate
,
691 CTLTYPE_INT
| CTLFLAG_WR
| CTLFLAG_LOCKED
, 0, 0,
692 cpu_ucode_update
, "S", "Microcode update interface");
694 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, tsc_ccc
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
695 "TSC/CCC frequency information");
697 SYSCTL_PROC(_machdep_cpu_tsc_ccc
, OID_AUTO
, numerator
,
698 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
699 (void *)offsetof(i386_cpu_info_t
, cpuid_tsc_leaf
.numerator
),
701 i386_cpu_info
, "I", "Numerator of TSC/CCC ratio");
703 SYSCTL_PROC(_machdep_cpu_tsc_ccc
, OID_AUTO
, denominator
,
704 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
705 (void *)offsetof(i386_cpu_info_t
, cpuid_tsc_leaf
.denominator
),
707 i386_cpu_info
, "I", "Denominator of TSC/CCC ratio");
709 static const uint32_t apic_timer_vector
= (LAPIC_DEFAULT_INTERRUPT_BASE
+ LAPIC_TIMER_INTERRUPT
);
710 static const uint32_t apic_IPI_vector
= (LAPIC_DEFAULT_INTERRUPT_BASE
+ LAPIC_INTERPROCESSOR_INTERRUPT
);
712 SYSCTL_NODE(_machdep
, OID_AUTO
, vectors
, CTLFLAG_RD
| CTLFLAG_LOCKED
, 0,
713 "Interrupt vector assignments");
715 SYSCTL_UINT (_machdep_vectors
, OID_AUTO
, timer
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, __DECONST(uint32_t *,&apic_timer_vector
), 0, "");
716 SYSCTL_UINT (_machdep_vectors
, OID_AUTO
, IPI
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, __DECONST(uint32_t *,&apic_IPI_vector
), 0, "");
718 uint64_t pmap_pv_hashlist_walks
;
719 uint64_t pmap_pv_hashlist_cnts
;
720 uint32_t pmap_pv_hashlist_max
;
721 uint32_t pmap_kernel_text_ps
= PAGE_SIZE
;
722 extern uint32_t pv_hashed_kern_low_water_mark
;
724 /*extern struct sysctl_oid_list sysctl__machdep_pmap_children;*/
726 SYSCTL_NODE(_machdep
, OID_AUTO
, pmap
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
729 SYSCTL_QUAD (_machdep_pmap
, OID_AUTO
, hashwalks
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_walks
, "");
730 SYSCTL_QUAD (_machdep_pmap
, OID_AUTO
, hashcnts
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_cnts
, "");
731 SYSCTL_INT (_machdep_pmap
, OID_AUTO
, hashmax
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_max
, 0, "");
732 SYSCTL_INT (_machdep_pmap
, OID_AUTO
, kernel_text_ps
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_kernel_text_ps
, 0, "");
733 SYSCTL_INT (_machdep_pmap
, OID_AUTO
, kern_pv_reserve
, CTLFLAG_RW
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pv_hashed_kern_low_water_mark
, 0, "");
735 SYSCTL_NODE(_machdep
, OID_AUTO
, memmap
, CTLFLAG_RD
|CTLFLAG_LOCKED
, NULL
, "physical memory map");
737 uint64_t firmware_Conventional_bytes
= 0;
738 uint64_t firmware_RuntimeServices_bytes
= 0;
739 uint64_t firmware_ACPIReclaim_bytes
= 0;
740 uint64_t firmware_ACPINVS_bytes
= 0;
741 uint64_t firmware_PalCode_bytes
= 0;
742 uint64_t firmware_Reserved_bytes
= 0;
743 uint64_t firmware_Unusable_bytes
= 0;
744 uint64_t firmware_other_bytes
= 0;
746 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Conventional
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_Conventional_bytes
, "");
747 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, RuntimeServices
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_RuntimeServices_bytes
, "");
748 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, ACPIReclaim
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_ACPIReclaim_bytes
, "");
749 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, ACPINVS
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_ACPINVS_bytes
, "");
750 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, PalCode
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_PalCode_bytes
, "");
751 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Reserved
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_Reserved_bytes
, "");
752 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Unusable
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_Unusable_bytes
, "");
753 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Other
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_other_bytes
, "");
755 SYSCTL_NODE(_machdep
, OID_AUTO
, tsc
, CTLFLAG_RD
|CTLFLAG_LOCKED
, NULL
, "Timestamp counter parameters");
757 SYSCTL_QUAD(_machdep_tsc
, OID_AUTO
, frequency
,
758 CTLFLAG_RD
|CTLFLAG_LOCKED
, &tscFreq
, "");
760 extern uint32_t deep_idle_rebase
;
761 SYSCTL_UINT(_machdep_tsc
, OID_AUTO
, deep_idle_rebase
,
762 CTLFLAG_RD
|CTLFLAG_LOCKED
, &deep_idle_rebase
, 0, "");
763 SYSCTL_QUAD(_machdep_tsc
, OID_AUTO
, at_boot
,
764 CTLFLAG_RD
|CTLFLAG_LOCKED
, &tsc_at_boot
, "");
765 SYSCTL_QUAD(_machdep_tsc
, OID_AUTO
, rebase_abs_time
,
766 CTLFLAG_RD
|CTLFLAG_LOCKED
, &tsc_rebase_abs_time
, "");
768 SYSCTL_NODE(_machdep_tsc
, OID_AUTO
, nanotime
,
769 CTLFLAG_RD
|CTLFLAG_LOCKED
, NULL
, "TSC to ns conversion");
770 SYSCTL_QUAD(_machdep_tsc_nanotime
, OID_AUTO
, tsc_base
,
771 CTLFLAG_RD
| CTLFLAG_LOCKED
,
772 __DECONST(uint64_t *, &pal_rtc_nanotime_info
.tsc_base
), "");
773 SYSCTL_QUAD(_machdep_tsc_nanotime
, OID_AUTO
, ns_base
,
774 CTLFLAG_RD
| CTLFLAG_LOCKED
,
775 __DECONST(uint64_t *, &pal_rtc_nanotime_info
.ns_base
), "");
776 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, scale
,
777 CTLFLAG_RD
| CTLFLAG_LOCKED
,
778 __DECONST(uint32_t *, &pal_rtc_nanotime_info
.scale
), 0, "");
779 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, shift
,
780 CTLFLAG_RD
| CTLFLAG_LOCKED
,
781 __DECONST(uint32_t *, &pal_rtc_nanotime_info
.shift
), 0, "");
782 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, generation
,
783 CTLFLAG_RD
| CTLFLAG_LOCKED
,
784 __DECONST(uint32_t *, &pal_rtc_nanotime_info
.generation
), 0, "");
786 SYSCTL_NODE(_machdep
, OID_AUTO
, misc
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
787 "Miscellaneous x86 kernel parameters");
789 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, panic_restart_timeout
,
790 CTLTYPE_INT
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
792 panic_set_restart_timeout
, "I", "Panic restart timeout in seconds");
794 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, interrupt_latency_max
,
795 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
797 misc_interrupt_latency_max
, "A", "Maximum Interrupt latency");
799 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, machine_check_panic
,
800 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
802 misc_machine_check_panic
, "A", "Machine-check exception test");
804 #if DEVELOPMENT || DEBUG
805 SYSCTL_QUAD(_machdep
, OID_AUTO
, reportphyreadabs
,
806 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
807 &reportphyreaddelayabs
, "");
808 SYSCTL_INT(_machdep
, OID_AUTO
, reportphyreadosbt
,
809 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
810 &reportphyreadosbt
, 0, "");
813 extern void timer_queue_trace_cpu(int);
815 misc_timer_queue_trace(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
817 int changed
= 0, error
;
821 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
823 if (error
== 0 && changed
) {
824 timer_queue_trace_cpu(0);
829 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, timer_queue_trace
,
830 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
832 misc_timer_queue_trace
, "A", "Cut timer queue tracepoint");
834 extern long NMI_count
;
835 extern void NMI_cpus(void);
837 misc_nmis(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
839 int new = 0, old
= 0, changed
= 0, error
;
843 error
= sysctl_io_number(req
, old
, sizeof(int), &new, &changed
);
844 if (error
== 0 && changed
) {
851 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, nmis
,
852 CTLTYPE_INT
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
854 misc_nmis
, "I", "Report/increment NMI count");
856 /* Parameters related to timer coalescing tuning, to be replaced
857 * with a dedicated systemcall in the future.
859 /* Enable processing pending timers in the context of any other interrupt */
860 SYSCTL_INT(_kern
, OID_AUTO
, interrupt_timer_coalescing_enabled
,
861 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
862 &interrupt_timer_coalescing_enabled
, 0, "");
863 /* Upon entering idle, process pending timers with HW deadlines
864 * this far in the future.
866 SYSCTL_INT(_kern
, OID_AUTO
, timer_coalesce_idle_entry_hard_deadline_max
,
867 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
868 &idle_entry_timer_processing_hdeadline_threshold
, 0, "");
870 /* Track potentially expensive eager timer evaluations on QoS tier
873 extern uint32_t ml_timer_eager_evaluations
;
875 SYSCTL_INT(_machdep
, OID_AUTO
, eager_timer_evaluations
,
876 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
877 &ml_timer_eager_evaluations
, 0, "");
879 extern uint64_t ml_timer_eager_evaluation_max
;
881 SYSCTL_QUAD(_machdep
, OID_AUTO
, eager_timer_evaluation_max
,
882 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
883 &ml_timer_eager_evaluation_max
, "");
884 extern uint64_t x86_isr_fp_simd_use
;
885 SYSCTL_QUAD(_machdep
, OID_AUTO
, x86_fp_simd_isr_uses
,
886 CTLFLAG_KERN
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
887 &x86_isr_fp_simd_use
, "");