]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/i386/sysctl.c
f971730756e2460f084c997f587b9543164c1b3a
[apple/xnu.git] / bsd / dev / i386 / sysctl.c
1 /*
2 * Copyright (c) 2003-2011 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #include <string.h>
30 #include <sys/param.h>
31 #include <sys/kernel.h>
32 #include <sys/sysctl.h>
33 #include <i386/cpuid.h>
34 #include <i386/tsc.h>
35 #include <i386/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>
41 #include <i386/pmCPU.h>
42
43
44 static int
45 _i386_cpu_info SYSCTL_HANDLER_ARGS
46 {
47 __unused struct sysctl_oid *unused_oidp = oidp;
48 void *ptr = arg1;
49 int value;
50
51 if (arg2 == -1) {
52 ptr = *(void **)ptr;
53 arg2 = 0;
54 }
55
56 if (arg2 == 0 && ((char *)ptr)[0] == '\0') {
57 return ENOENT;
58 }
59
60 if (arg2 == sizeof(uint8_t)) {
61 value = (uint32_t) *(uint8_t *)ptr;
62 ptr = &value;
63 arg2 = sizeof(uint32_t);
64 }
65 return SYSCTL_OUT(req, ptr, arg2 ? (size_t) arg2 : strlen((char *)ptr)+1);
66 }
67
68 static int
69 i386_cpu_info SYSCTL_HANDLER_ARGS
70 {
71 void *ptr = (uint8_t *)cpuid_info() + (uintptr_t)arg1;
72 return _i386_cpu_info(oidp, ptr, arg2, req);
73 }
74
75 static int
76 i386_cpu_info_nonzero SYSCTL_HANDLER_ARGS
77 {
78 void *ptr = (uint8_t *)cpuid_info() + (uintptr_t)arg1;
79 int value = *(uint32_t *)ptr;
80
81 if (value == 0)
82 return ENOENT;
83
84 return _i386_cpu_info(oidp, ptr, arg2, req);
85 }
86 static int
87 cpu_mwait SYSCTL_HANDLER_ARGS
88 {
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)
92 return ENOENT;
93 return _i386_cpu_info(oidp, ptr, arg2, req);
94 }
95
96 static int
97 cpu_thermal SYSCTL_HANDLER_ARGS
98 {
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)
102 return ENOENT;
103 return _i386_cpu_info(oidp, ptr, arg2, req);
104 }
105
106 static int
107 cpu_arch_perf SYSCTL_HANDLER_ARGS
108 {
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)
112 return ENOENT;
113 return _i386_cpu_info(oidp, ptr, arg2, req);
114 }
115
116 static int
117 cpu_xsave SYSCTL_HANDLER_ARGS
118 {
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)
122 return ENOENT;
123 return _i386_cpu_info(oidp, ptr, arg2, req);
124 }
125
126
127 static int
128 cpu_features SYSCTL_HANDLER_ARGS
129 {
130 __unused struct sysctl_oid *unused_oidp = oidp;
131 __unused void *unused_arg1 = arg1;
132 __unused int unused_arg2 = arg2;
133 char buf[512];
134
135 buf[0] = '\0';
136 cpuid_get_feature_names(cpuid_features(), buf, sizeof(buf));
137
138 return SYSCTL_OUT(req, buf, strlen(buf) + 1);
139 }
140
141 static int
142 cpu_extfeatures SYSCTL_HANDLER_ARGS
143 {
144 __unused struct sysctl_oid *unused_oidp = oidp;
145 __unused void *unused_arg1 = arg1;
146 __unused int unused_arg2 = arg2;
147 char buf[512];
148
149 buf[0] = '\0';
150 cpuid_get_extfeature_names(cpuid_extfeatures(), buf, sizeof(buf));
151
152 return SYSCTL_OUT(req, buf, strlen(buf) + 1);
153 }
154
155 static int
156 cpu_leaf7_features SYSCTL_HANDLER_ARGS
157 {
158 __unused struct sysctl_oid *unused_oidp = oidp;
159 __unused void *unused_arg1 = arg1;
160 __unused int unused_arg2 = arg2;
161 char buf[512];
162
163 uint32_t leaf7_features = cpuid_info()->cpuid_leaf7_features;
164 if (leaf7_features == 0)
165 return ENOENT;
166
167 buf[0] = '\0';
168 cpuid_get_leaf7_feature_names(leaf7_features, buf, sizeof(buf));
169
170 return SYSCTL_OUT(req, buf, strlen(buf) + 1);
171 }
172
173 static int
174 cpu_logical_per_package SYSCTL_HANDLER_ARGS
175 {
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();
180
181 if (!(cpuid_features() & CPUID_FEATURE_HTT))
182 return ENOENT;
183
184 return SYSCTL_OUT(req, &cpu_info->cpuid_logical_per_package,
185 sizeof(cpu_info->cpuid_logical_per_package));
186 }
187
188 static int
189 cpu_flex_ratio_desired SYSCTL_HANDLER_ARGS
190 {
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();
195
196 if (cpu_info->cpuid_model != 26)
197 return ENOENT;
198
199 return SYSCTL_OUT(req, &flex_ratio, sizeof(flex_ratio));
200 }
201
202 static int
203 cpu_flex_ratio_min SYSCTL_HANDLER_ARGS
204 {
205 __unused struct sysctl_oid *unused_oidp = oidp;
206 __unused void *unused_arg1 = arg1;
207 __unused int unused_arg2 = arg2;
208 i386_cpu_info_t *cpu_info = cpuid_info();
209
210 if (cpu_info->cpuid_model != 26)
211 return ENOENT;
212
213 return SYSCTL_OUT(req, &flex_ratio_min, sizeof(flex_ratio_min));
214 }
215
216 static int
217 cpu_flex_ratio_max SYSCTL_HANDLER_ARGS
218 {
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();
223
224 if (cpu_info->cpuid_model != 26)
225 return ENOENT;
226
227 return SYSCTL_OUT(req, &flex_ratio_max, sizeof(flex_ratio_max));
228 }
229
230 static int
231 cpu_ucode_update SYSCTL_HANDLER_ARGS
232 {
233 __unused struct sysctl_oid *unused_oidp = oidp;
234 __unused void *unused_arg1 = arg1;
235 __unused int unused_arg2 = arg2;
236 uint64_t addr;
237 int error;
238
239 error = SYSCTL_IN(req, &addr, sizeof(addr));
240 if (error)
241 return error;
242
243 int ret = ucode_interface(addr);
244 return ret;
245 }
246
247 extern uint64_t panic_restart_timeout;
248 static int
249 panic_set_restart_timeout(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
250 {
251 int new_value = 0, old_value = 0, changed = 0, error;
252 uint64_t nstime;
253
254 if (panic_restart_timeout) {
255 absolutetime_to_nanoseconds(panic_restart_timeout, &nstime);
256 old_value = nstime / NSEC_PER_SEC;
257 }
258
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);
262 }
263 return error;
264 }
265
266 /*
267 * Populates the {CPU, vector, latency} triple for the maximum observed primary
268 * interrupt latency
269 */
270 static int
271 misc_interrupt_latency_max(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
272 {
273 int changed = 0, error;
274 char buf[128];
275 buf[0] = '\0';
276
277 interrupt_populate_latency_stats(buf, sizeof(buf));
278
279 error = sysctl_io_string(req, buf, sizeof(buf), 0, &changed);
280
281 if (error == 0 && changed) {
282 interrupt_reset_latency_stats();
283 }
284
285 return error;
286 }
287
288 /*
289 * Triggers a machine-check exception - for a suitably configured kernel only.
290 */
291 extern void mca_exception_panic(void);
292 static int
293 misc_machine_check_panic(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
294 {
295 int changed = 0, error;
296 char buf[128];
297 buf[0] = '\0';
298
299 error = sysctl_io_string(req, buf, sizeof(buf), 0, &changed);
300
301 if (error == 0 && changed) {
302 mca_exception_panic();
303 }
304 return error;
305 }
306
307
308 SYSCTL_NODE(_machdep, OID_AUTO, cpu, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
309 "CPU info");
310
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");
314
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");
318
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");
322
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");
326
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");
330
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");
334
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");
338
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");
342
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");
346
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");
350
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),
354 sizeof(uint32_t),
355 i386_cpu_info_nonzero, "IU", "CPU Leaf7 features");
356
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");
360
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");
364
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");
368
369 SYSCTL_PROC(_machdep_cpu, OID_AUTO, features, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
370 0, 0,
371 cpu_features, "A", "CPU feature names");
372
373 SYSCTL_PROC(_machdep_cpu, OID_AUTO, leaf7_features,
374 CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
375 0, 0,
376 cpu_leaf7_features, "A", "CPU Leaf7 feature names");
377
378 SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfeatures, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
379 0, 0,
380 cpu_extfeatures, "A", "CPU extended feature names");
381
382 SYSCTL_PROC(_machdep_cpu, OID_AUTO, logical_per_package,
383 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
384 0, 0,
385 cpu_logical_per_package, "I", "CPU logical cpus per package");
386
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),
390 sizeof(uint32_t),
391 i386_cpu_info, "I", "CPU cores per package");
392
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),
396 sizeof(uint32_t),
397 i386_cpu_info, "I", "Microcode version number");
398
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),
402 sizeof(uint32_t),
403 i386_cpu_info, "I", "CPU processor flag");
404
405
406 SYSCTL_NODE(_machdep_cpu, OID_AUTO, mwait, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
407 "mwait");
408
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),
412 sizeof(uint32_t),
413 cpu_mwait, "I", "Monitor/mwait minimum line size");
414
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),
418 sizeof(uint32_t),
419 cpu_mwait, "I", "Monitor/mwait maximum line size");
420
421 SYSCTL_PROC(_machdep_cpu_mwait, OID_AUTO, extensions,
422 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
423 (void *)offsetof(cpuid_mwait_leaf_t, extensions),
424 sizeof(uint32_t),
425 cpu_mwait, "I", "Monitor/mwait extensions");
426
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),
430 sizeof(uint32_t),
431 cpu_mwait, "I", "Monitor/mwait sub C-states");
432
433
434 SYSCTL_NODE(_machdep_cpu, OID_AUTO, thermal, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
435 "thermal");
436
437 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, sensor,
438 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
439 (void *)offsetof(cpuid_thermal_leaf_t, sensor),
440 sizeof(boolean_t),
441 cpu_thermal, "I", "Thermal sensor present");
442
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),
446 sizeof(boolean_t),
447 cpu_thermal, "I", "Dynamic Acceleration Technology (Turbo Mode)");
448
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),
452 sizeof(boolean_t),
453 cpu_thermal, "I", "Invariant APIC Timer");
454
455 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, thresholds,
456 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
457 (void *)offsetof(cpuid_thermal_leaf_t, thresholds),
458 sizeof(uint32_t),
459 cpu_thermal, "I", "Number of interrupt thresholds");
460
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),
464 sizeof(boolean_t),
465 cpu_thermal, "I", "ACNT_MCNT capability");
466
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),
470 sizeof(boolean_t),
471 cpu_thermal, "I", "Power Limit Notifications at a Core Level");
472
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),
476 sizeof(boolean_t),
477 cpu_thermal, "I", "Fine Grain Clock Modulation");
478
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),
482 sizeof(boolean_t),
483 cpu_thermal, "I", "Package Thermal interrupt and Status");
484
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),
488 sizeof(boolean_t),
489 cpu_thermal, "I", "Hardware Coordination Feedback");
490
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),
494 sizeof(boolean_t),
495 cpu_thermal, "I", "Energy Efficient Policy Support");
496
497 SYSCTL_NODE(_machdep_cpu, OID_AUTO, xsave, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
498 "xsave");
499
500 SYSCTL_PROC(_machdep_cpu_xsave, OID_AUTO, extended_state,
501 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
502 (void *)offsetof(cpuid_xsave_leaf_t, extended_state),
503 sizeof(cpuid_xsave_leaf_t),
504 cpu_xsave, "IU", "XSAVE Extended State");
505
506
507 SYSCTL_NODE(_machdep_cpu, OID_AUTO, arch_perf, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
508 "arch_perf");
509
510 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, version,
511 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
512 (void *)offsetof(cpuid_arch_perf_leaf_t, version),
513 sizeof(uint8_t),
514 cpu_arch_perf, "I", "Architectural Performance Version Number");
515
516 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, number,
517 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
518 (void *)offsetof(cpuid_arch_perf_leaf_t, number),
519 sizeof(uint8_t),
520 cpu_arch_perf, "I", "Number of counters per logical cpu");
521
522 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, width,
523 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
524 (void *)offsetof(cpuid_arch_perf_leaf_t, width),
525 sizeof(uint8_t),
526 cpu_arch_perf, "I", "Bit width of counters");
527
528 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, events_number,
529 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
530 (void *)offsetof(cpuid_arch_perf_leaf_t, events_number),
531 sizeof(uint8_t),
532 cpu_arch_perf, "I", "Number of monitoring events");
533
534 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, events,
535 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
536 (void *)offsetof(cpuid_arch_perf_leaf_t, events),
537 sizeof(uint32_t),
538 cpu_arch_perf, "I", "Bit vector of events");
539
540 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, fixed_number,
541 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
542 (void *)offsetof(cpuid_arch_perf_leaf_t, fixed_number),
543 sizeof(uint8_t),
544 cpu_arch_perf, "I", "Number of fixed-function counters");
545
546 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, fixed_width,
547 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
548 (void *)offsetof(cpuid_arch_perf_leaf_t, fixed_width),
549 sizeof(uint8_t),
550 cpu_arch_perf, "I", "Bit-width of fixed-function counters");
551
552
553 SYSCTL_NODE(_machdep_cpu, OID_AUTO, cache, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
554 "cache");
555
556 SYSCTL_PROC(_machdep_cpu_cache, OID_AUTO, linesize,
557 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
558 (void *)offsetof(i386_cpu_info_t, cpuid_cache_linesize),
559 sizeof(uint32_t),
560 i386_cpu_info, "I", "Cacheline size");
561
562 SYSCTL_PROC(_machdep_cpu_cache, OID_AUTO, L2_associativity,
563 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
564 (void *)offsetof(i386_cpu_info_t, cpuid_cache_L2_associativity),
565 sizeof(uint32_t),
566 i386_cpu_info, "I", "L2 cache associativity");
567
568 SYSCTL_PROC(_machdep_cpu_cache, OID_AUTO, size,
569 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
570 (void *)offsetof(i386_cpu_info_t, cpuid_cache_size),
571 sizeof(uint32_t),
572 i386_cpu_info, "I", "Cache size (in Kbytes)");
573
574
575 SYSCTL_NODE(_machdep_cpu, OID_AUTO, tlb, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
576 "tlb");
577 SYSCTL_NODE(_machdep_cpu_tlb, OID_AUTO, inst, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
578 "inst");
579 SYSCTL_NODE(_machdep_cpu_tlb, OID_AUTO, data, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
580 "data");
581
582 SYSCTL_PROC(_machdep_cpu_tlb_inst, OID_AUTO, small,
583 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
584 (void *)offsetof(i386_cpu_info_t,
585 cpuid_tlb[TLB_INST][TLB_SMALL][0]),
586 sizeof(uint32_t),
587 i386_cpu_info_nonzero, "I",
588 "Number of small page instruction TLBs");
589
590 SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, small,
591 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
592 (void *)offsetof(i386_cpu_info_t,
593 cpuid_tlb[TLB_DATA][TLB_SMALL][0]),
594 sizeof(uint32_t),
595 i386_cpu_info_nonzero, "I",
596 "Number of small page data TLBs (1st level)");
597
598 SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, small_level1,
599 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
600 (void *)offsetof(i386_cpu_info_t,
601 cpuid_tlb[TLB_DATA][TLB_SMALL][1]),
602 sizeof(uint32_t),
603 i386_cpu_info_nonzero, "I",
604 "Number of small page data TLBs (2nd level)");
605
606 SYSCTL_PROC(_machdep_cpu_tlb_inst, OID_AUTO, large,
607 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
608 (void *)offsetof(i386_cpu_info_t,
609 cpuid_tlb[TLB_INST][TLB_LARGE][0]),
610 sizeof(uint32_t),
611 i386_cpu_info_nonzero, "I",
612 "Number of large page instruction TLBs");
613
614 SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, large,
615 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
616 (void *)offsetof(i386_cpu_info_t,
617 cpuid_tlb[TLB_DATA][TLB_LARGE][0]),
618 sizeof(uint32_t),
619 i386_cpu_info_nonzero, "I",
620 "Number of large page data TLBs (1st level)");
621
622 SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, large_level1,
623 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
624 (void *)offsetof(i386_cpu_info_t,
625 cpuid_tlb[TLB_DATA][TLB_LARGE][1]),
626 sizeof(uint32_t),
627 i386_cpu_info_nonzero, "I",
628 "Number of large page data TLBs (2nd level)");
629
630 SYSCTL_PROC(_machdep_cpu_tlb, OID_AUTO, shared,
631 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
632 (void *)offsetof(i386_cpu_info_t, cpuid_stlb),
633 sizeof(uint32_t),
634 i386_cpu_info_nonzero, "I",
635 "Number of shared TLBs");
636
637
638 SYSCTL_NODE(_machdep_cpu, OID_AUTO, address_bits, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
639 "address_bits");
640
641 SYSCTL_PROC(_machdep_cpu_address_bits, OID_AUTO, physical,
642 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
643 (void *)offsetof(i386_cpu_info_t, cpuid_address_bits_physical),
644 sizeof(uint32_t),
645 i386_cpu_info, "I", "Number of physical address bits");
646
647 SYSCTL_PROC(_machdep_cpu_address_bits, OID_AUTO, virtual,
648 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
649 (void *)offsetof(i386_cpu_info_t, cpuid_address_bits_virtual),
650 sizeof(uint32_t),
651 i386_cpu_info, "I", "Number of virtual address bits");
652
653
654 SYSCTL_PROC(_machdep_cpu, OID_AUTO, core_count,
655 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
656 (void *)offsetof(i386_cpu_info_t, core_count),
657 sizeof(uint32_t),
658 i386_cpu_info, "I", "Number of enabled cores per package");
659
660 SYSCTL_PROC(_machdep_cpu, OID_AUTO, thread_count,
661 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
662 (void *)offsetof(i386_cpu_info_t, thread_count),
663 sizeof(uint32_t),
664 i386_cpu_info, "I", "Number of enabled threads per package");
665
666 SYSCTL_NODE(_machdep_cpu, OID_AUTO, flex_ratio, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
667 "Flex ratio");
668
669 SYSCTL_PROC(_machdep_cpu_flex_ratio, OID_AUTO, desired,
670 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
671 0, 0,
672 cpu_flex_ratio_desired, "I", "Flex ratio desired (0 disabled)");
673
674 SYSCTL_PROC(_machdep_cpu_flex_ratio, OID_AUTO, min,
675 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
676 0, 0,
677 cpu_flex_ratio_min, "I", "Flex ratio min (efficiency)");
678
679 SYSCTL_PROC(_machdep_cpu_flex_ratio, OID_AUTO, max,
680 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
681 0, 0,
682 cpu_flex_ratio_max, "I", "Flex ratio max (non-turbo)");
683
684 SYSCTL_PROC(_machdep_cpu, OID_AUTO, ucupdate,
685 CTLTYPE_INT | CTLFLAG_WR | CTLFLAG_LOCKED, 0, 0,
686 cpu_ucode_update, "S", "Microcode update interface");
687
688 static const uint32_t apic_timer_vector = (LAPIC_DEFAULT_INTERRUPT_BASE + LAPIC_TIMER_INTERRUPT);
689 static const uint32_t apic_IPI_vector = (LAPIC_DEFAULT_INTERRUPT_BASE + LAPIC_INTERPROCESSOR_INTERRUPT);
690
691 SYSCTL_NODE(_machdep, OID_AUTO, vectors, CTLFLAG_RD | CTLFLAG_LOCKED, 0,
692 "Interrupt vector assignments");
693
694 SYSCTL_UINT (_machdep_vectors, OID_AUTO, timer, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (uint32_t *)&apic_timer_vector, 0, "");
695 SYSCTL_UINT (_machdep_vectors, OID_AUTO, IPI, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (uint32_t *)&apic_IPI_vector, 0, "");
696
697 uint64_t pmap_pv_hashlist_walks;
698 uint64_t pmap_pv_hashlist_cnts;
699 uint32_t pmap_pv_hashlist_max;
700 uint32_t pmap_kernel_text_ps = PAGE_SIZE;
701 extern uint32_t pv_hashed_kern_low_water_mark;
702
703 /*extern struct sysctl_oid_list sysctl__machdep_pmap_children;*/
704
705 SYSCTL_NODE(_machdep, OID_AUTO, pmap, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
706 "PMAP info");
707
708 SYSCTL_QUAD (_machdep_pmap, OID_AUTO, hashwalks, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_pv_hashlist_walks, "");
709 SYSCTL_QUAD (_machdep_pmap, OID_AUTO, hashcnts, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_pv_hashlist_cnts, "");
710 SYSCTL_INT (_machdep_pmap, OID_AUTO, hashmax, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_pv_hashlist_max, 0, "");
711 SYSCTL_INT (_machdep_pmap, OID_AUTO, kernel_text_ps, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_kernel_text_ps, 0, "");
712 SYSCTL_INT (_machdep_pmap, OID_AUTO, kern_pv_reserve, CTLFLAG_RW | CTLFLAG_KERN | CTLFLAG_LOCKED, &pv_hashed_kern_low_water_mark, 0, "");
713
714 SYSCTL_NODE(_machdep, OID_AUTO, memmap, CTLFLAG_RD|CTLFLAG_LOCKED, NULL, "physical memory map");
715
716 uint64_t firmware_Conventional_bytes = 0;
717 uint64_t firmware_RuntimeServices_bytes = 0;
718 uint64_t firmware_ACPIReclaim_bytes = 0;
719 uint64_t firmware_ACPINVS_bytes = 0;
720 uint64_t firmware_PalCode_bytes = 0;
721 uint64_t firmware_Reserved_bytes = 0;
722 uint64_t firmware_Unusable_bytes = 0;
723 uint64_t firmware_other_bytes = 0;
724
725 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Conventional, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_Conventional_bytes, "");
726 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, RuntimeServices, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_RuntimeServices_bytes, "");
727 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, ACPIReclaim, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_ACPIReclaim_bytes, "");
728 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, ACPINVS, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_ACPINVS_bytes, "");
729 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, PalCode, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_PalCode_bytes, "");
730 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Reserved, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_Reserved_bytes, "");
731 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Unusable, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_Unusable_bytes, "");
732 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Other, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_other_bytes, "");
733
734 SYSCTL_NODE(_machdep, OID_AUTO, tsc, CTLFLAG_RD|CTLFLAG_LOCKED, NULL, "Timestamp counter parameters");
735
736 SYSCTL_QUAD(_machdep_tsc, OID_AUTO, frequency,
737 CTLFLAG_RD|CTLFLAG_LOCKED, &tscFreq, "");
738
739 extern uint32_t deep_idle_rebase;
740 SYSCTL_UINT(_machdep_tsc, OID_AUTO, deep_idle_rebase,
741 CTLFLAG_RW|CTLFLAG_KERN|CTLFLAG_LOCKED, &deep_idle_rebase, 0, "");
742
743 SYSCTL_NODE(_machdep_tsc, OID_AUTO, nanotime,
744 CTLFLAG_RD|CTLFLAG_LOCKED, NULL, "TSC to ns conversion");
745 SYSCTL_QUAD(_machdep_tsc_nanotime, OID_AUTO, tsc_base,
746 CTLFLAG_RD | CTLFLAG_LOCKED,
747 (uint64_t *) &pal_rtc_nanotime_info.tsc_base, "");
748 SYSCTL_QUAD(_machdep_tsc_nanotime, OID_AUTO, ns_base,
749 CTLFLAG_RD | CTLFLAG_LOCKED,
750 (uint64_t *)&pal_rtc_nanotime_info.ns_base, "");
751 SYSCTL_UINT(_machdep_tsc_nanotime, OID_AUTO, scale,
752 CTLFLAG_RD | CTLFLAG_LOCKED,
753 (uint32_t *)&pal_rtc_nanotime_info.scale, 0, "");
754 SYSCTL_UINT(_machdep_tsc_nanotime, OID_AUTO, shift,
755 CTLFLAG_RD | CTLFLAG_LOCKED,
756 (uint32_t *)&pal_rtc_nanotime_info.shift, 0, "");
757 SYSCTL_UINT(_machdep_tsc_nanotime, OID_AUTO, generation,
758 CTLFLAG_RD | CTLFLAG_LOCKED,
759 (uint32_t *)&pal_rtc_nanotime_info.generation, 0, "");
760
761 SYSCTL_NODE(_machdep, OID_AUTO, misc, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
762 "Miscellaneous x86 kernel parameters");
763
764 SYSCTL_PROC(_machdep_misc, OID_AUTO, panic_restart_timeout,
765 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_LOCKED,
766 0, 0,
767 panic_set_restart_timeout, "I", "Panic restart timeout in seconds");
768
769 SYSCTL_PROC(_machdep_misc, OID_AUTO, interrupt_latency_max,
770 CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED,
771 0, 0,
772 misc_interrupt_latency_max, "A", "Maximum Interrupt latency");
773
774 SYSCTL_PROC(_machdep_misc, OID_AUTO, machine_check_panic,
775 CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED,
776 0, 0,
777 misc_machine_check_panic, "A", "Machine-check exception test");
778