summaryrefslogtreecommitdiffstats
path: root/sys/amd64/include
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2009-05-13 17:53:04 +0000
committerjhb <jhb@FreeBSD.org>2009-05-13 17:53:04 +0000
commit370298a10816df8eee3cd3453607323546e4cf9c (patch)
treee92a8666a427cd3b54074a55134d6d643f102bf6 /sys/amd64/include
parentdeae02e77d33ac35960ebc9548741d1c2b9a22c2 (diff)
downloadFreeBSD-src-370298a10816df8eee3cd3453607323546e4cf9c.zip
FreeBSD-src-370298a10816df8eee3cd3453607323546e4cf9c.tar.gz
Implement simple machine check support for amd64 and i386.
- For CPUs that only support MCE (the machine check exception) but not MCA (i.e. Pentium), all this does is print out the value of the machine check registers and then panic when a machine check exception occurs. - For CPUs that support MCA (the machine check architecture), the support is a bit more involved. - First, there is limited support for decoding the CPU-independent MCA error codes in the kernel, and the kernel uses this to output a short description of any machine check events that occur. - When a machine check exception occurs, all of the MCx banks on the current CPU are scanned and any events are reported to the console before panic'ing. - To catch events for correctable errors, a periodic timer kicks off a task which scans the MCx banks on all CPUs. The frequency of these checks is controlled via the "hw.mca.interval" sysctl. - Userland can request an immediate scan of the MCx banks by writing a non-zero value to "hw.mca.force_scan". - If any correctable events are encountered, the appropriate details are stored in a 'struct mca_record' (defined in <machine/mca.h>). The "hw.mca.count" is a count of such records and each record may be queried via the "hw.mca.records" tree by specifying the record index (0 .. count - 1) as the next name in the MIB similar to using PIDs with the kern.proc.* sysctls. The idea is to export machine check events to userland for more detailed processing. - The periodic timer and hw.mca sysctls are only present if the CPU supports MCA. Discussed with: emaste (briefly) MFC after: 1 month
Diffstat (limited to 'sys/amd64/include')
-rw-r--r--sys/amd64/include/mca.h48
-rw-r--r--sys/amd64/include/specialreg.h28
2 files changed, 76 insertions, 0 deletions
diff --git a/sys/amd64/include/mca.h b/sys/amd64/include/mca.h
new file mode 100644
index 0000000..c43d989
--- /dev/null
+++ b/sys/amd64/include/mca.h
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2009 Advanced Computing Technologies LLC
+ * Written by: John H. Baldwin <jhb@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __MACHINE_MCA_H__
+#define __MACHINE_MCA_H__
+
+struct mca_record {
+ uint64_t mr_status;
+ uint64_t mr_addr;
+ uint64_t mr_misc;
+ uint64_t mr_tsc;
+ int mr_apic_id;
+};
+
+#ifdef _KERNEL
+
+void mca_init(void);
+int mca_intr(void);
+
+#endif
+
+#endif /* !__MACHINE_MCA_H__ */
diff --git a/sys/amd64/include/specialreg.h b/sys/amd64/include/specialreg.h
index afc6580..88ff734 100644
--- a/sys/amd64/include/specialreg.h
+++ b/sys/amd64/include/specialreg.h
@@ -346,6 +346,34 @@
#define DIR1 0xff
/*
+ * Machine Check register constants.
+ */
+#define MCG_CAP_COUNT 0x000000ff
+#define MCG_CAP_CTL_P 0x00000100
+#define MCG_CAP_EXT_P 0x00000200
+#define MCG_CAP_TES_P 0x00000800
+#define MCG_CAP_EXT_CNT 0x00ff0000
+#define MCG_STATUS_RIPV 0x00000001
+#define MCG_STATUS_EIPV 0x00000002
+#define MCG_STATUS_MCIP 0x00000004
+#define MCG_CTL_ENABLE 0xffffffffffffffffUL
+#define MCG_CTL_DISABLE 0x0000000000000000UL
+#define MSR_MC_CTL(x) (MSR_MC0_CTL + (x) * 4)
+#define MSR_MC_STATUS(x) (MSR_MC0_STATUS + (x) * 4)
+#define MSR_MC_ADDR(x) (MSR_MC0_ADDR + (x) * 4)
+#define MSR_MC_MISC(x) (MSR_MC0_MISC + (x) * 4)
+#define MC_STATUS_MCA_ERROR 0x000000000000ffffUL
+#define MC_STATUS_MODEL_ERROR 0x00000000ffff0000UL
+#define MC_STATUS_OTHER_INFO 0x01ffffff00000000UL
+#define MC_STATUS_PCC 0x0200000000000000UL
+#define MC_STATUS_ADDRV 0x0400000000000000UL
+#define MC_STATUS_MISCV 0x0800000000000000UL
+#define MC_STATUS_EN 0x1000000000000000UL
+#define MC_STATUS_UC 0x2000000000000000UL
+#define MC_STATUS_OVER 0x4000000000000000UL
+#define MC_STATUS_VAL 0x8000000000000000UL
+
+/*
* The following four 3-byte registers control the non-cacheable regions.
* These registers must be written as three separate bytes.
*
OpenPOWER on IntegriCloud