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