X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/6d2010ae8f7a6078e10b361c6962983bab233e0f..4b17d6b6e417f714551ec129064745ea9919780e:/bsd/dev/i386/sysctl.c diff --git a/bsd/dev/i386/sysctl.c b/bsd/dev/i386/sysctl.c index ba3bfc1ee..ddc9503e3 100644 --- a/bsd/dev/i386/sysctl.c +++ b/bsd/dev/i386/sysctl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2003-2011 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -36,6 +36,7 @@ #include #include #include +#include static int _i386_cpu_info SYSCTL_HANDLER_ARGS @@ -119,6 +120,7 @@ cpu_xsave SYSCTL_HANDLER_ARGS return _i386_cpu_info(oidp, ptr, arg2, req); } + static int cpu_features SYSCTL_HANDLER_ARGS { @@ -147,6 +149,24 @@ cpu_extfeatures SYSCTL_HANDLER_ARGS return SYSCTL_OUT(req, buf, strlen(buf) + 1); } +static int +cpu_leaf7_features SYSCTL_HANDLER_ARGS +{ + __unused struct sysctl_oid *unused_oidp = oidp; + __unused void *unused_arg1 = arg1; + __unused int unused_arg2 = arg2; + char buf[512]; + + uint32_t leaf7_features = cpuid_info()->cpuid_leaf7_features; + if (leaf7_features == 0) + return ENOENT; + + buf[0] = '\0'; + cpuid_get_leaf7_feature_names(leaf7_features, buf, sizeof(buf)); + + return SYSCTL_OUT(req, buf, strlen(buf) + 1); +} + static int cpu_logical_per_package SYSCTL_HANDLER_ARGS { @@ -262,6 +282,26 @@ misc_interrupt_latency_max(__unused struct sysctl_oid *oidp, __unused void *arg1 return error; } +/* + * Triggers a machine-check exception - for a suitably configured kernel only. + */ +extern void mca_exception_panic(void); +static int +misc_machine_check_panic(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req) +{ + int changed = 0, error; + char buf[128]; + buf[0] = '\0'; + + error = sysctl_io_string(req, buf, sizeof(buf), 0, &changed); + + if (error == 0 && changed) { + mca_exception_panic(); + } + return error; +} + + SYSCTL_NODE(_machdep, OID_AUTO, cpu, CTLFLAG_RW|CTLFLAG_LOCKED, 0, "CPU info"); @@ -305,6 +345,12 @@ SYSCTL_PROC(_machdep_cpu, OID_AUTO, feature_bits, CTLTYPE_QUAD | CTLFLAG_RD | CT (void *)offsetof(i386_cpu_info_t, cpuid_features), sizeof(uint64_t), i386_cpu_info, "IU", "CPU features"); +SYSCTL_PROC(_machdep_cpu, OID_AUTO, leaf7_feature_bits, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, + (void *)offsetof(i386_cpu_info_t, cpuid_leaf7_features), + sizeof(uint32_t), + i386_cpu_info_nonzero, "IU", "CPU Leaf7 features"); + SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfeature_bits, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_LOCKED, (void *)offsetof(i386_cpu_info_t, cpuid_extfeatures), sizeof(uint64_t), i386_cpu_info, "IU", "CPU extended features"); @@ -321,6 +367,11 @@ SYSCTL_PROC(_machdep_cpu, OID_AUTO, features, CTLTYPE_STRING | CTLFLAG_RD | CTLF 0, 0, cpu_features, "A", "CPU feature names"); +SYSCTL_PROC(_machdep_cpu, OID_AUTO, leaf7_features, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED, + 0, 0, + cpu_leaf7_features, "A", "CPU Leaf7 feature names"); + SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfeatures, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED, 0, 0, cpu_extfeatures, "A", "CPU extended feature names"); @@ -426,7 +477,7 @@ SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, package_thermal_intr, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, (void *)offsetof(cpuid_thermal_leaf_t, package_thermal_intr), sizeof(boolean_t), - cpu_thermal, "I", "Packge Thermal interrupt and Status"); + cpu_thermal, "I", "Package Thermal interrupt and Status"); SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, hardware_feedback, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, @@ -440,7 +491,6 @@ SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, energy_policy, sizeof(boolean_t), cpu_thermal, "I", "Energy Efficient Policy Support"); - SYSCTL_NODE(_machdep_cpu, OID_AUTO, xsave, CTLFLAG_RW|CTLFLAG_LOCKED, 0, "xsave"); @@ -632,6 +682,15 @@ SYSCTL_PROC(_machdep_cpu, OID_AUTO, ucupdate, CTLTYPE_INT | CTLFLAG_WR | CTLFLAG_LOCKED, 0, 0, cpu_ucode_update, "S", "Microcode update interface"); +static const uint32_t apic_timer_vector = (LAPIC_DEFAULT_INTERRUPT_BASE + LAPIC_TIMER_INTERRUPT); +static const uint32_t apic_IPI_vector = (LAPIC_DEFAULT_INTERRUPT_BASE + LAPIC_INTERPROCESSOR_INTERRUPT); + +SYSCTL_NODE(_machdep, OID_AUTO, vectors, CTLFLAG_RD | CTLFLAG_LOCKED, 0, + "Interrupt vector assignments"); + +SYSCTL_UINT (_machdep_vectors, OID_AUTO, timer, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (uint32_t *)&apic_timer_vector, 0, ""); +SYSCTL_UINT (_machdep_vectors, OID_AUTO, IPI, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (uint32_t *)&apic_IPI_vector, 0, ""); + uint64_t pmap_pv_hashlist_walks; uint64_t pmap_pv_hashlist_cnts; uint32_t pmap_pv_hashlist_max; @@ -681,6 +740,13 @@ SYSCTL_PROC(_machdep_misc, OID_AUTO, panic_restart_timeout, 0, 0, panic_set_restart_timeout, "I", "Panic restart timeout in seconds"); -SYSCTL_PROC(_machdep_misc, OID_AUTO, interrupt_latency_max, CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED, +SYSCTL_PROC(_machdep_misc, OID_AUTO, interrupt_latency_max, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED, 0, 0, misc_interrupt_latency_max, "A", "Maximum Interrupt latency"); + +SYSCTL_PROC(_machdep_misc, OID_AUTO, machine_check_panic, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED, + 0, 0, + misc_machine_check_panic, "A", "Machine-check exception test"); +