From: Huang Ying <ying.huang(a)intel.com>
ACPI/APEI is designed to verifiy/report H/W errors, like Corrected
Error(CE) and Uncorrected Error(UC). It contains four tables: HEST,
ERST, EINJ and BERT. The first three tables have been merged for
a long time, but because of lacking BIOS support for BERT, the
support for BERT is pending until now. Recently on ARM 64 platform
it is has been supported. So here we come.
Under normal circumstances, when a hardware error occurs, kernel will
be notified via NMI, MCE or some other method, then kernel will
process the error condition, report it, and recover it if possible.
But sometime, the situation is so bad, so that firmware may choose to
reset directly without notifying Linux kernel.
Linux kernel can use the Boot Error Record Table (BERT) to get the
un-notified hardware errors that occurred in a previous boot. In this
patch, the error information is reported via printk.
For more information about BERT, please refer to ACPI Specification
version 6.0, section 18.3.1:
http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf
The following log is a BERT record after system reboot because of hitting
a fatal memory error:
BERT: Error records from previous boot:
[Hardware Error]: It has been corrected by h/w and requires no further action
[Hardware Error]: event severity: corrected
[Hardware Error]: Error 0, type: recoverable
[Hardware Error]: section_type: memory error
[Hardware Error]: error_status: 0x0000000000000400
[Hardware Error]: physical_address: 0xffffffffffffffff
[Hardware Error]: card: 1 module: 2 bank: 3 row: 1 column: 2 bit_position: 5
[Hardware Error]: error_type: 2, single-bit ECC
[Tomasz Nowicki: Clear error status at the end of error handling]
[Tony: Applied some cleanups suggested by Fu Wei]
[Fu Wei: delete EXPORT_SYMBOL_GPL(bert_disable), improve the code]
Signed-off-by: Huang Ying <ying.huang(a)intel.com>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki(a)linaro.org>
Signed-off-by: Chen, Gong <gong.chen(a)linux.intel.com>
Tested-by: Jonathan (Zhixiong) Zhang <zjzhang(a)codeaurora.org>
Signed-off-by: Tony Luck <tony.luck(a)intel.com>
Signed-off-by: Fu Wei <fu.wei(a)linaro.org>
Tested-by: Tyler Baicar <tbaicar(a)codeaurora.org>
---
Changelog:
v5: Drop some superfluous comments.
Use the introduce of BERT in ACPI Specification instead of original one
at the head of bert.c.
Fix typo in apei-internal.h
Simplify the introduce of bert_disable.
v4: https://lkml.org/lkml/2016/1/8/382
Fix the "#undef" bug
Improve the instruction of "bert_disable",
Delete the useless declaration in include/acpi/apei.h.
v3: https://lkml.org/lkml/2016/1/7/214
Merge the two patches
Do some improvements according to Borislav's suggestion.
v2: https://lkml.org/lkml/2015/8/18/336
Delete EXPORT_SYMBOL_GPL(bert_disable), because "bert_disable" is only
used in bert.c for now.
Do some code-style cleanups.
v1: The first upstream version submitted in linux-acpi mailing list:
http://www.spinics.net/lists/linux-acpi/msg57384.html
Documentation/kernel-parameters.txt | 3 +
drivers/acpi/apei/Makefile | 2 +-
drivers/acpi/apei/apei-internal.h | 2 +-
drivers/acpi/apei/bert.c | 150 ++++++++++++++++++++++++++++++++++++
4 files changed, 155 insertions(+), 2 deletions(-)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 3ea869d..acb772e 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -564,6 +564,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
bootmem_debug [KNL] Enable bootmem allocator debug messages.
+ bert_disable [ACPI]
+ Disable BERT OS support on buggy BIOSes.
+
bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards)
bttv.radio= Most important insmod options are available as
kernel args too.
diff --git a/drivers/acpi/apei/Makefile b/drivers/acpi/apei/Makefile
index 5d575a9..e50573d 100644
--- a/drivers/acpi/apei/Makefile
+++ b/drivers/acpi/apei/Makefile
@@ -3,4 +3,4 @@ obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o
obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o
obj-$(CONFIG_ACPI_APEI_ERST_DEBUG) += erst-dbg.o
-apei-y := apei-base.o hest.o erst.o
+apei-y := apei-base.o hest.o erst.o bert.o
diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index 16129c7..6e9f14c 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -1,6 +1,6 @@
/*
* apei-internal.h - ACPI Platform Error Interface internal
- * definations.
+ * definitions.
*/
#ifndef APEI_INTERNAL_H
diff --git a/drivers/acpi/apei/bert.c b/drivers/acpi/apei/bert.c
new file mode 100644
index 0000000..a05b5c0
--- /dev/null
+++ b/drivers/acpi/apei/bert.c
@@ -0,0 +1,150 @@
+/*
+ * APEI Boot Error Record Table (BERT) support
+ *
+ * Copyright 2011 Intel Corp.
+ * Author: Huang Ying <ying.huang(a)intel.com>
+ *
+ * Under normal circumstances, when a hardware error occurs, the error
+ * handler receives control and processes the error. This gives OSPM a
+ * chance to process the error condition, report it, and optionally attempt
+ * recovery. In some cases, the system is unable to process an error.
+ * For example, system firmware or a management controller may choose to
+ * reset the system or the system might experience an uncontrolled crash
+ * or reset.The boot error source is used to report unhandled errors that
+ * occurred in a previous boot. This mechanism is described in the BERT
+ * table.
+ *
+ * For more information about BERT, please refer to ACPI Specification
+ * version 4.0, section 17.3.1
+ *
+ * This file is licensed under GPLv2.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/acpi.h>
+#include <linux/io.h>
+
+#include "apei-internal.h"
+
+#undef pr_fmt
+#define pr_fmt(fmt) "BERT: " fmt
+
+static int bert_disable;
+
+static void __init bert_print_all(struct acpi_bert_region *region,
+ unsigned int region_len)
+{
+ struct acpi_hest_generic_status *estatus =
+ (struct acpi_hest_generic_status *)region;
+ int remain = region_len;
+ u32 estatus_len;
+
+ if (!estatus->block_status)
+ return;
+
+ while (remain > sizeof(struct acpi_bert_region)) {
+ if (cper_estatus_check(estatus)) {
+ pr_err(FW_BUG "Invalid error record.\n");
+ return;
+ }
+
+ estatus_len = cper_estatus_len(estatus);
+ if (remain < estatus_len) {
+ pr_err(FW_BUG "Truncated status block (length: %u).\n",
+ estatus_len);
+ return;
+ }
+
+ pr_info_once("Error records from previous boot:\n");
+
+ cper_estatus_print(KERN_INFO HW_ERR, estatus);
+
+ /*
+ * Because the boot error source is "one-time polled" type,
+ * clear Block Status of current Generic Error Status Block,
+ * once it's printed.
+ */
+ estatus->block_status = 0;
+
+ estatus = (void *)estatus + estatus_len;
+ /* No more error records. */
+ if (!estatus->block_status)
+ return;
+
+ remain -= estatus_len;
+ }
+}
+
+static int __init setup_bert_disable(char *str)
+{
+ bert_disable = 1;
+
+ return 0;
+}
+__setup("bert_disable", setup_bert_disable);
+
+static int __init bert_check_table(struct acpi_table_bert *bert_tab)
+{
+ if (bert_tab->header.length < sizeof(struct acpi_table_bert) ||
+ bert_tab->region_length < sizeof(struct acpi_bert_region))
+ return -EINVAL;
+
+ return 0;
+}
+
+static int __init bert_init(void)
+{
+ struct acpi_bert_region *boot_error_region;
+ struct acpi_table_bert *bert_tab;
+ unsigned int region_len;
+ acpi_status status;
+ int rc = 0;
+
+ if (acpi_disabled)
+ return 0;
+
+ if (bert_disable) {
+ pr_info("Boot Error Record Table support is disabled.\n");
+ return 0;
+ }
+
+ status = acpi_get_table(ACPI_SIG_BERT, 0, (struct acpi_table_header **)&bert_tab);
+ if (status == AE_NOT_FOUND)
+ return 0;
+
+ if (ACPI_FAILURE(status)) {
+ pr_err("get table failed, %s.\n", acpi_format_exception(status));
+ return -EINVAL;
+ }
+
+ rc = bert_check_table(bert_tab);
+ if (rc) {
+ pr_err(FW_BUG "table invalid.\n");
+ return rc;
+ }
+
+ region_len = bert_tab->region_length;
+ if (!request_mem_region(bert_tab->address, region_len, "APEI BERT")) {
+ pr_err("Can't request iomem region <%016llx-%016llx>.\n",
+ (unsigned long long)bert_tab->address,
+ (unsigned long long)bert_tab->address + region_len - 1);
+ return -EIO;
+ }
+
+ boot_error_region = ioremap_cache(bert_tab->address, region_len);
+ if (boot_error_region) {
+ bert_print_all(boot_error_region, region_len);
+ iounmap(boot_error_region);
+ } else {
+ rc = -ENOMEM;
+ }
+
+ release_mem_region(bert_tab->address, region_len);
+
+ return rc;
+}
+
+late_initcall(bert_init);
--
2.5.0
From: Huang Ying <ying.huang(a)intel.com>
ACPI/APEI is designed to verifiy/report H/W errors, like Corrected
Error(CE) and Uncorrected Error(UC). It contains four tables: HEST,
ERST, EINJ and BERT. The first three tables have been merged for
a long time, but because of lacking BIOS support for BERT, the
support for BERT is pending until now. Recently on ARM 64 platform
it is has been supported. So here we come.
Under normal circumstances, when a hardware error occurs, kernel will
be notified via NMI, MCE or some other method, then kernel will
process the error condition, report it, and recover it if possible.
But sometime, the situation is so bad, so that firmware may choose to
reset directly without notifying Linux kernel.
Linux kernel can use the Boot Error Record Table (BERT) to get the
un-notified hardware errors that occurred in a previous boot. In this
patch, the error information is reported via printk.
For more information about BERT, please refer to ACPI Specification
version 6.0, section 18.3.1:
http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf
The following log is a BERT record after system reboot because of hitting
a fatal memory error:
BERT: Error records from previous boot:
[Hardware Error]: It has been corrected by h/w and requires no further action
[Hardware Error]: event severity: corrected
[Hardware Error]: Error 0, type: recoverable
[Hardware Error]: section_type: memory error
[Hardware Error]: error_status: 0x0000000000000400
[Hardware Error]: physical_address: 0xffffffffffffffff
[Hardware Error]: card: 1 module: 2 bank: 3 row: 1 column: 2 bit_position: 5
[Hardware Error]: error_type: 2, single-bit ECC
[Tomasz Nowicki: Clear error status at the end of error handling]
[Tony: Applied some cleanups suggested by Fu Wei]
[Fu Wei: delete EXPORT_SYMBOL_GPL(bert_disable), improve the code]
Signed-off-by: Huang Ying <ying.huang(a)intel.com>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki(a)linaro.org>
Signed-off-by: Chen, Gong <gong.chen(a)linux.intel.com>
Tested-by: Jonathan (Zhixiong) Zhang <zjzhang(a)codeaurora.org>
Signed-off-by: Tony Luck <tony.luck(a)intel.com>
Signed-off-by: Fu Wei <fu.wei(a)linaro.org>
Tested-by: Tyler Baicar <tbaicar(a)codeaurora.org>
---
Changelog:
v4: fix the "#undef" bug
Improve the instruction of "bert_disable",
delete the useless declaration in include/acpi/apei.h.
v3: https://lkml.org/lkml/2016/1/7/214
Merge the two patches
Do some improvements according to Borislav's suggestion.
v2: https://lkml.org/lkml/2015/8/18/336
Delete EXPORT_SYMBOL_GPL(bert_disable), because "bert_disable" is only
used in bert.c for now.
Do some code-style cleanups.
v1: The first upstream version submitted in linux-acpi mailing list:
http://www.spinics.net/lists/linux-acpi/msg57384.html
Documentation/kernel-parameters.txt | 6 ++
drivers/acpi/apei/Makefile | 2 +-
drivers/acpi/apei/bert.c | 158 ++++++++++++++++++++++++++++++++++++
include/acpi/apei.h | 1 +
4 files changed, 166 insertions(+), 1 deletion(-)
create mode 100644 drivers/acpi/apei/bert.c
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 742f69d..2c527a9 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -555,6 +555,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
bootmem_debug [KNL] Enable bootmem allocator debug messages.
+ bert_disable [ACPI]
+ Disable Boot Error Record Table (BERT) support.
+ Use this if to workaround buggy firmware which produces
+ the malformed BERT table or incorrect error status
+ block.
+
bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards)
bttv.radio= Most important insmod options are available as
kernel args too.
diff --git a/drivers/acpi/apei/Makefile b/drivers/acpi/apei/Makefile
index 5d575a9..e50573d 100644
--- a/drivers/acpi/apei/Makefile
+++ b/drivers/acpi/apei/Makefile
@@ -3,4 +3,4 @@ obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o
obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o
obj-$(CONFIG_ACPI_APEI_ERST_DEBUG) += erst-dbg.o
-apei-y := apei-base.o hest.o erst.o
+apei-y := apei-base.o hest.o erst.o bert.o
diff --git a/drivers/acpi/apei/bert.c b/drivers/acpi/apei/bert.c
new file mode 100644
index 0000000..ffcbf4b
--- /dev/null
+++ b/drivers/acpi/apei/bert.c
@@ -0,0 +1,158 @@
+/*
+ * APEI Boot Error Record Table (BERT) support
+ *
+ * Copyright 2011 Intel Corp.
+ * Author: Huang Ying <ying.huang(a)intel.com>
+ *
+ * Under normal circumstances, when a hardware error occurs, kernel
+ * will be notified via NMI, MCE or some other method, then kernel
+ * will process the error condition, report it, and recover it if
+ * possible. But sometime, the situation is so bad, so that firmware
+ * may choose to reset directly without notifying Linux kernel.
+ *
+ * Linux kernel can use the Boot Error Record Table (BERT) to get the
+ * un-notified hardware errors that occurred in a previous boot.
+ *
+ * For more information about BERT, please refer to ACPI Specification
+ * version 4.0, section 17.3.1
+ *
+ * This file is licensed under GPLv2.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/acpi.h>
+#include <linux/io.h>
+
+#include "apei-internal.h"
+
+#undef pr_fmt
+#define pr_fmt(fmt) "BERT: " fmt
+
+static int bert_disable;
+
+static void __init bert_print_all(struct acpi_bert_region *region,
+ unsigned int region_len)
+{
+ /*
+ * We use cper_estatus_* which uses struct acpi_hest_generic_status,
+ * struct acpi_hest_generic_status and acpi_bert_region are the same
+ * (Generic Error Status Block), so we declare the "estatus" here.
+ */
+ struct acpi_hest_generic_status *estatus =
+ (struct acpi_hest_generic_status *)region;
+ int remain = region_len;
+ u32 estatus_len;
+
+ /* The records have been polled*/
+ if (!estatus->block_status)
+ return;
+
+ while (remain > sizeof(struct acpi_bert_region)) {
+ /*
+ * Test Generic Error Status Block first,
+ * if the data(Offset, Length) is invalid, we just return,
+ * because we can't trust the length data from this block.
+ */
+ if (cper_estatus_check(estatus)) {
+ pr_err(FW_BUG "Invalid error record\n");
+ return;
+ }
+
+ estatus_len = cper_estatus_len(estatus);
+ if (remain < estatus_len) {
+ pr_err(FW_BUG "Invalid status block length (%u)\n",
+ estatus_len);
+ return;
+ }
+
+ pr_info_once("Error records from previous boot:\n");
+
+ cper_estatus_print(KERN_INFO HW_ERR, estatus);
+
+ /*
+ * Because the boot error source is "one-time polled" type,
+ * clear Block Status of current Generic Error Status Block,
+ * once it's printed.
+ */
+ estatus->block_status = 0;
+
+ estatus = (void *)estatus + estatus_len;
+ if (!estatus->block_status)
+ return; /* No more error records */
+
+ remain -= estatus_len;
+ }
+}
+
+static int __init setup_bert_disable(char *str)
+{
+ bert_disable = 1;
+
+ return 0;
+}
+__setup("bert_disable", setup_bert_disable);
+
+static int __init bert_check_table(struct acpi_table_bert *bert_tab)
+{
+ if (bert_tab->header.length < sizeof(struct acpi_table_bert) ||
+ bert_tab->region_length < sizeof(struct acpi_bert_region))
+ return -EINVAL;
+
+ return 0;
+}
+
+static int __init bert_init(void)
+{
+ struct acpi_bert_region *boot_error_region;
+ struct acpi_table_bert *bert_tab;
+ unsigned int region_len;
+ acpi_status status;
+ int rc = 0;
+
+ if (acpi_disabled)
+ return 0;
+
+ if (bert_disable) {
+ pr_info("Boot Error Record Table support is disabled\n");
+ return 0;
+ }
+
+ status = acpi_get_table(ACPI_SIG_BERT, 0, (struct acpi_table_header **)&bert_tab);
+ if (status == AE_NOT_FOUND)
+ return 0;
+ if (ACPI_FAILURE(status)) {
+ pr_err("get table failed, %s\n", acpi_format_exception(status));
+ return -EINVAL;
+ }
+
+ rc = bert_check_table(bert_tab);
+ if (rc) {
+ pr_err(FW_BUG "table invalid\n");
+ return rc;
+ }
+
+ region_len = bert_tab->region_length;
+ if (!request_mem_region(bert_tab->address, region_len, "APEI BERT")) {
+ pr_err("Can't request iomem region <%016llx-%016llx>\n",
+ (unsigned long long)bert_tab->address,
+ (unsigned long long)bert_tab->address + region_len - 1);
+ return -EIO;
+ }
+
+ boot_error_region = ioremap_cache(bert_tab->address, region_len);
+ if (boot_error_region) {
+ bert_print_all(boot_error_region, region_len);
+ iounmap(boot_error_region);
+ } else {
+ rc = -ENOMEM;
+ }
+
+ release_mem_region(bert_tab->address, region_len);
+
+ return rc;
+}
+
+late_initcall(bert_init);
--
2.5.0
>From the functionality point of view this series might be split into the
following logic parts:
1. Make MMCONFIG code arch-agnostic which allows all architectures to collect
PCI config regions and used when necessary.
2. Move non-arch specific bits to the core code.
3. Use MMCONFIG code and implement generic ACPI based PCI host
controller driver.
4. Enable above driver on ARM64
Patches has been built on top of 4.4-rc4 and can be found here:
git@github.com:semihalf-nowicki-tomasz/linux.git (pci-acpi-v2)
NOTE, this patch set depends on Matthew's patches:
http://www.spinics.net/lists/linux-pci/msg45950.htmlhttps://github.com/Vality/linux/tree/pci-fixes
This has been tested on Cavium ThunderX 1 socket server and QEMU.
Any help in reviewing and testing is very appreciated.
v1 -> v2
- moved non-arch specific piece of code to dirver/acpi/ directory
- fixed IO resource handling
- introduced PCI config accessors quirks matching
- moved ACPI_COMPANION_SET to generic code
Liu Jiang (1):
ACPI, PCI: Refine the way to handle translation_offset for ACPI
resources
Tomasz Nowicki (22):
x86, pci: Reorder logic of pci_mmconfig_insert() function
x86, pci, acpi: Move arch-agnostic MMCONFIG (aka ECAM) and ACPI code
out of arch/x86/ directory
pci, acpi, mcfg: Provide generic implementation of MCFG code
initialization.
x86, pci: mmconfig_{32,64}.c code refactoring - remove code
duplication.
x86, pci, ecam: mmconfig_64.c becomes default implementation for ECAM
driver.
XEN / PCI: Remove the dependence on arch x86 when PCI_MMCONFIG=y
pci, acpi, mcfg: Provide default RAW ACPI PCI config space accessors.
arm64, acpi: Use empty PCI config space accessors from mcfg.c file.
pci, acpi, ecam: Add flag to indicate whether ECAM region was hot
added or not.
x86, pci: Cleanup platform specific MCFG data using previously added
ECAM hot_added flag.
arm64, pci: Remove useless boot time IRQ assignment when booting with
DT.
pci, acpi: Move ACPI host bridge device companion assignment to core
code.
x86, ia64, pci: Remove ACPI companion device from platform specific
data.
pci, acpi: Provide generic way to assign bus domain number.
x86, ia64, pci: Convert arches to use PCI_DOMAINS_GENERIC.
x86, ia64: Include acpi_pci_{add|remove}_bus to the default
pcibios_{add|remove}_bus implementation.
acpi, mcfg: Implement two calls that might be used to inject/remove
MCFG region.
x86, acpi, pci: Use equivalent function introduced in previous patch.
acpi, mcfg: Add default PCI config accessors implementation and
initial support for related quirks.
pci, acpi: Support for ACPI based PCI hostbridge init
pci, acpi: Match PCI config space accessors against platfrom specific
quirks.
arm64, pci, acpi: Start using ACPI based PCI host bridge driver for
ARM64.
arch/arm64/Kconfig | 10 ++
arch/arm64/kernel/pci.c | 35 ------
arch/ia64/Kconfig | 3 +
arch/ia64/include/asm/pci.h | 3 -
arch/ia64/pci/pci.c | 53 +++-----
arch/x86/Kconfig | 7 ++
arch/x86/include/asm/pci.h | 10 --
arch/x86/include/asm/pci_x86.h | 28 +----
arch/x86/pci/acpi.c | 43 ++-----
arch/x86/pci/common.c | 10 --
arch/x86/pci/irq.c | 10 --
arch/x86/pci/mmconfig-shared.c | 250 ++++++--------------------------------
arch/x86/pci/mmconfig_32.c | 11 +-
arch/x86/pci/mmconfig_64.c | 67 +---------
arch/x86/pci/numachip.c | 1 +
drivers/acpi/Makefile | 1 +
drivers/acpi/mcfg.c | 203 +++++++++++++++++++++++++++++++
drivers/acpi/pci_root.c | 5 +-
drivers/acpi/resource.c | 12 +-
drivers/pci/Kconfig | 10 ++
drivers/pci/Makefile | 5 +
drivers/pci/ecam.c | 234 +++++++++++++++++++++++++++++++++++
drivers/pci/host/Kconfig | 6 +
drivers/pci/host/Makefile | 1 +
drivers/pci/host/pci-host-acpi.c | 138 +++++++++++++++++++++
drivers/pci/pci.c | 29 ++++-
drivers/pci/probe.c | 5 +
drivers/xen/pci.c | 7 +-
include/asm-generic/vmlinux.lds.h | 7 ++
include/linux/acpi.h | 2 +
include/linux/ecam.h | 61 ++++++++++
include/linux/pci-acpi.h | 17 +++
32 files changed, 817 insertions(+), 467 deletions(-)
create mode 100644 drivers/acpi/mcfg.c
create mode 100644 drivers/pci/ecam.c
create mode 100644 drivers/pci/host/pci-host-acpi.c
create mode 100644 include/linux/ecam.h
--
1.9.1
Support for configuring bootconsole and console via the ACPI tables
DBG2 (Debug Port Table 2) [1] and SPCR (Serial Port Console Redirection
Table) [2], defined by Microsoft, has been discussed on and off over the
years.
[1] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639131(v=vs.85)…
[2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85)…
Licensing concerns have prevented this happening in the past, but as of
10 August 2015, these tables have both been released also under OWF 1.0
(http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0)
which is think is noncontroversially GPL-compatible?
This set is a first attempt at implementing this.
Submitting as an RFC since the SPCR handling currently depends on the
console driver being initialized after subsystem initcalls. Workaround
to enable testing surrounding infrastructure in 5/5, _really_ not
intended to be merged.
(Suggestions for acceptable ways of working around this appreciated.)
For testing the DBG2 stuff with pl011, you would need:
- A patch to unbreak pl011 earlycon, like
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/433219
- A QEMU that generates DBG2 tables, like current HEAD with the
addition of
http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg01719.html
SPCR support is included in QEMU's ARM mach-virt since 2.4 release.
DBG2 support has an Intel copyright notice added to it since my starting
point was Lv Zheng's 2012 DBGP/DBG2 set (although not much of the
original remains - this is quite a cut-down version).
Leif Lindholm (4):
arm64: move acpi/dt decision earlier in boot process
of/serial: move earlycon early_param handling to serial
acpi/serial: add DBG2 earlycon support
HACK: serial: move pl011 initcall to device_initcall
Torez Smith (1):
tty/console: use SPCR table to define console
arch/arm64/kernel/acpi.c | 55 +++++----
drivers/acpi/Makefile | 1 +
drivers/acpi/console.c | 260 +++++++++++++++++++++++++++++++++++++++
drivers/of/fdt.c | 13 +-
drivers/tty/serial/amba-pl011.c | 2 +-
drivers/tty/serial/earlycon.c | 18 ++-
drivers/tty/serial/serial_core.c | 14 ++-
include/linux/acpi.h | 13 ++
include/linux/of_fdt.h | 1 +
include/linux/serial_core.h | 9 +-
10 files changed, 337 insertions(+), 49 deletions(-)
create mode 100644 drivers/acpi/console.c
--
2.1.4
This patch series adds in specific ACPI compliance testing for the MADT
and all of its various subtables (16, currently). The first patch adds
tests for the MADT and all subtables currently defined in FWTS. The last
two patches add in the relatively new GIC ITS subtable and compliance tests
for it.
There are still multiple TODOs in the compliance checks; these will be
added as clarification of the spec becomes available.
Changes for v2:
-- Clean up the white space problems
-- Fix errors found by checkpatch (minor syntax things)
-- Fix one logic error: while MADT and FADT table revisions *should* be
in sync, they seldom are, so report this as a test failure and continue
to test as much as possible instead of aborting completely, in some of
those cases.
Al Stone (3):
ACPI: MADT: add in compliance tests for the MADT and subtables
ACPI: Add in MADT subtable description for GIC ITS subtable
ACPI: MADT: add in compliance checks for the GIC ITS subtable
src/Makefile.am | 1 +
src/acpi/compliance/madt.c | 1372 +++++++++++++++++++++++++++++++++++++++++++
src/lib/include/fwts_acpi.h | 10 +
3 files changed, 1383 insertions(+)
create mode 100644 src/acpi/compliance/madt.c
--
2.5.0
From: Huang Ying <ying.huang(a)intel.com>
ACPI/APEI is designed to verifiy/report H/W errors, like Corrected
Error(CE) and Uncorrected Error(UC). It contains four tables: HEST,
ERST, EINJ and BERT. The first three tables have been merged for
a long time, but because of lacking BIOS support for BERT, the
support for BERT is pending until now. Recently on ARM 64 platform
it is has been supported. So here we come.
Under normal circumstances, when a hardware error occurs, kernel will
be notified via NMI, MCE or some other method, then kernel will
process the error condition, report it, and recover it if possible.
But sometime, the situation is so bad, so that firmware may choose to
reset directly without notifying Linux kernel.
Linux kernel can use the Boot Error Record Table (BERT) to get the
un-notified hardware errors that occurred in a previous boot. In this
patch, the error information is reported via printk.
For more information about BERT, please refer to ACPI Specification
version 6.0, section 18.3.1:
http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf
The following log is a BERT record after system reboot because of
hitting a fatal error.
BERT: Obtained BERT iomem region <00000000fe801000-00000000fe802000> for BERT.
[Hardware Error]: Error record from previous boot:
[Hardware Error]: event severity: fatal
[Hardware Error]: Error 0, type: fatal
[Hardware Error]: section_type: memory error
[Hardware Error]: physical_address: 0x00000000fe800000
[Hardware Error]: physical_address_mask: 0x0000000000000fff
[Hardware Error]: card: 0 module: 1 bank: 0 device: 1 row: 1 column: 1 bit_pos
[Tomasz Nowicki: Clear error status at the end of error handling]
[Tony: Applied some cleanups suggested by Fu Wei]
[Fu Wei: delete EXPORT_SYMBOL_GPL(bert_disable), improve the code]
Signed-off-by: Huang Ying <ying.huang(a)intel.com>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki(a)linaro.org>
Signed-off-by: Chen, Gong <gong.chen(a)linux.intel.com>
Tested-by: Jonathan (Zhixiong) Zhang <zjzhang(a)codeaurora.org>
Signed-off-by: Tony Luck <tony.luck(a)intel.com>
Signed-off-by: Fu Wei <fu.wei(a)linaro.org>
Tested-by: Tyler Baicar <tbaicar(a)codeaurora.org>
---
Changelog:
v3: Merge the two patches
Do some improvements according to Borislav's suggestion.
v2: https://lkml.org/lkml/2015/8/18/336
Delete EXPORT_SYMBOL_GPL(bert_disable), because "bert_disable" is only used
in bert.c for now.
Do some code-style cleanups.
v1: The first upstream version submitted in linux-acpi mailing list:
http://www.spinics.net/lists/linux-acpi/msg57384.html
Documentation/kernel-parameters.txt | 3 +
drivers/acpi/apei/Makefile | 2 +-
drivers/acpi/apei/bert.c | 158 ++++++++++++++++++++++++++++++++++++
include/acpi/apei.h | 1 +
4 files changed, 163 insertions(+), 1 deletion(-)
create mode 100644 drivers/acpi/apei/bert.c
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 742f69d..2310e97 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -555,6 +555,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
bootmem_debug [KNL] Enable bootmem allocator debug messages.
+ bert_disable [ACPI]
+ Disable Boot Error Record Table (BERT) support.
+
bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards)
bttv.radio= Most important insmod options are available as
kernel args too.
diff --git a/drivers/acpi/apei/Makefile b/drivers/acpi/apei/Makefile
index 5d575a9..e50573d 100644
--- a/drivers/acpi/apei/Makefile
+++ b/drivers/acpi/apei/Makefile
@@ -3,4 +3,4 @@ obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o
obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o
obj-$(CONFIG_ACPI_APEI_ERST_DEBUG) += erst-dbg.o
-apei-y := apei-base.o hest.o erst.o
+apei-y := apei-base.o hest.o erst.o bert.o
diff --git a/drivers/acpi/apei/bert.c b/drivers/acpi/apei/bert.c
new file mode 100644
index 0000000..6f6ae38
--- /dev/null
+++ b/drivers/acpi/apei/bert.c
@@ -0,0 +1,158 @@
+/*
+ * APEI Boot Error Record Table (BERT) support
+ *
+ * Copyright 2011 Intel Corp.
+ * Author: Huang Ying <ying.huang(a)intel.com>
+ *
+ * Under normal circumstances, when a hardware error occurs, kernel
+ * will be notified via NMI, MCE or some other method, then kernel
+ * will process the error condition, report it, and recover it if
+ * possible. But sometime, the situation is so bad, so that firmware
+ * may choose to reset directly without notifying Linux kernel.
+ *
+ * Linux kernel can use the Boot Error Record Table (BERT) to get the
+ * un-notified hardware errors that occurred in a previous boot.
+ *
+ * For more information about BERT, please refer to ACPI Specification
+ * version 4.0, section 17.3.1
+ *
+ * This file is licensed under GPLv2.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/acpi.h>
+#include <linux/io.h>
+
+#include "apei-internal.h"
+
+#undef pr_fmt(fmt)
+#define pr_fmt(fmt) "BERT: " fmt
+
+static int bert_disable;
+
+static void __init bert_print_all(struct acpi_bert_region *region,
+ unsigned int region_len)
+{
+ /*
+ * We use cper_estatus_* which uses struct acpi_hest_generic_status,
+ * struct acpi_hest_generic_status and acpi_bert_region are the same
+ * (Generic Error Status Block), so we declare the "estatus" here.
+ */
+ struct acpi_hest_generic_status *estatus =
+ (struct acpi_hest_generic_status *)region;
+ int remain = region_len;
+ u32 estatus_len;
+
+ /* The records have been polled*/
+ if (!estatus->block_status)
+ return;
+
+ while (remain > sizeof(struct acpi_bert_region)) {
+ /*
+ * Test Generic Error Status Block first,
+ * if the data(Offset, Length) is invalid, we just return,
+ * because we can't trust the length data from this block.
+ */
+ if (cper_estatus_check(estatus)) {
+ pr_err(FW_BUG "Invalid error record\n");
+ return;
+ }
+
+ estatus_len = cper_estatus_len(estatus);
+ if (remain < estatus_len) {
+ pr_err(FW_BUG "Invalid status block length (%u)\n",
+ estatus_len);
+ return;
+ }
+
+ pr_info_once(HW_ERR "Error records from previous boot:\n");
+
+ cper_estatus_print(KERN_INFO HW_ERR, estatus);
+
+ /*
+ * Because the boot error source is "one-time polled" type,
+ * clear Block Status of current Generic Error Status Block,
+ * once it's printed.
+ */
+ estatus->block_status = 0;
+
+ estatus = (void *)estatus + estatus_len;
+ if (!estatus->block_status)
+ return; /* No more error records */
+
+ remain -= estatus_len;
+ }
+}
+
+static int __init setup_bert_disable(char *str)
+{
+ bert_disable = 1;
+
+ return 0;
+}
+__setup("bert_disable", setup_bert_disable);
+
+static int __init bert_check_table(struct acpi_table_bert *bert_tab)
+{
+ if (bert_tab->header.length < sizeof(struct acpi_table_bert) ||
+ bert_tab->region_length < sizeof(struct acpi_bert_region))
+ return -EINVAL;
+
+ return 0;
+}
+
+static int __init bert_init(void)
+{
+ struct acpi_bert_region *boot_error_region;
+ struct acpi_table_bert *bert_tab;
+ unsigned int region_len;
+ acpi_status status;
+ int rc = 0;
+
+ if (acpi_disabled)
+ return 0;
+
+ if (bert_disable) {
+ pr_info("Boot Error Record Table support is disabled\n");
+ return 0;
+ }
+
+ status = acpi_get_table(ACPI_SIG_BERT, 0, (struct acpi_table_header **)&bert_tab);
+ if (status == AE_NOT_FOUND)
+ return 0;
+ if (ACPI_FAILURE(status)) {
+ pr_err("get table failed, %s\n", acpi_format_exception(status));
+ return -EINVAL;
+ }
+
+ rc = bert_check_table(bert_tab);
+ if (rc) {
+ pr_err(FW_BUG "table invalid\n");
+ return rc;
+ }
+
+ region_len = bert_tab->region_length;
+ if (!request_mem_region(bert_tab->address, region_len, "APEI BERT")) {
+ pr_err("Can't request iomem region <%016llx-%016llx>\n",
+ (unsigned long long)bert_tab->address,
+ (unsigned long long)bert_tab->address + region_len - 1);
+ return -EIO;
+ }
+
+ boot_error_region = ioremap_cache(bert_tab->address, region_len);
+ if (boot_error_region) {
+ bert_print_all(boot_error_region, region_len);
+ iounmap(boot_error_region);
+ } else {
+ rc = -ENOMEM;
+ }
+
+ release_mem_region(bert_tab->address, region_len);
+
+ return rc;
+}
+
+late_initcall(bert_init);
diff --git a/include/acpi/apei.h b/include/acpi/apei.h
index 76284bb..284801a 100644
--- a/include/acpi/apei.h
+++ b/include/acpi/apei.h
@@ -23,6 +23,7 @@ extern bool ghes_disable;
#else
#define ghes_disable 1
#endif
+extern int bert_disable;
#ifdef CONFIG_ACPI_APEI
void __init acpi_hest_init(void);
--
2.5.0
From: Fu Wei <fu.wei(a)linaro.org>
ACPI/APEI is designed to verifiy/report H/W errors, like Corrected
Error(CE) and Uncorrected Error(UC). It contains four tables: HEST,
ERST, EINJ and BERT. The first three tables have been merged for
a long time, but because of lacking BIOS support for BERT, the
support for BERT is pending until now. Recently on ARM 64 platform
it is has been supported. So here we come.
The following log is a BERT record after system reboot because of
hitting a fatal error.
BERT: Obtained BERT iomem region <00000000fe801000-00000000fe802000> for BERT.
[Hardware Error]: Error record from previous boot:
[Hardware Error]: event severity: fatal
[Hardware Error]: Error 0, type: fatal
[Hardware Error]: section_type: memory error
[Hardware Error]: physical_address: 0x00000000fe800000
[Hardware Error]: physical_address_mask: 0x0000000000000fff
[Hardware Error]: card: 0 module: 1 bank: 0 device: 1 row: 1 column: 1 bit_pos
Changelog:
v2: Delete EXPORT_SYMBOL_GPL(bert_disable), because "bert_disable" is only used
in bert.c for now.
Do some code-style cleanups.
v1: The first upstream version submitted in linux-acpi mailing list:
http://www.spinics.net/lists/linux-acpi/msg57384.html
Huang Ying (1):
ACPI, APEI, Boot Error Record Table (BERT) support
Tomasz Nowicki (1):
acpi, apei, bert: Clear error status at the end of error handling
Documentation/kernel-parameters.txt | 3 +
drivers/acpi/apei/Makefile | 2 +-
drivers/acpi/apei/bert.c | 165 ++++++++++++++++++++++++++++++++++++
include/acpi/apei.h | 1 +
4 files changed, 170 insertions(+), 1 deletion(-)
create mode 100644 drivers/acpi/apei/bert.c
--
2.4.3