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