2019-05-27 06:55:21 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2010-05-18 06:35:13 +00:00
|
|
|
/*
|
2021-03-13 01:55:35 +00:00
|
|
|
* APEI Hardware Error Source Table support
|
2010-05-18 06:35:13 +00:00
|
|
|
*
|
|
|
|
* HEST describes error sources in detail; communicates operational
|
|
|
|
* parameters (i.e. severity levels, masking bits, and threshold
|
|
|
|
* values) to Linux as necessary. It also allows the BIOS to report
|
|
|
|
* non-standard error sources to Linux (for example, chipset-specific
|
|
|
|
* error registers).
|
|
|
|
*
|
|
|
|
* For more information about HEST, please refer to ACPI Specification
|
|
|
|
* version 4.0, section 17.3.2.
|
|
|
|
*
|
|
|
|
* Copyright 2009 Intel Corp.
|
|
|
|
* Author: Huang Ying <ying.huang@intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/acpi.h>
|
|
|
|
#include <linux/kdebug.h>
|
|
|
|
#include <linux/highmem.h>
|
|
|
|
#include <linux/io.h>
|
2010-08-02 07:48:24 +00:00
|
|
|
#include <linux/platform_device.h>
|
2010-05-18 06:35:13 +00:00
|
|
|
#include <acpi/apei.h>
|
2019-01-29 18:48:40 +00:00
|
|
|
#include <acpi/ghes.h>
|
2010-05-18 06:35:13 +00:00
|
|
|
|
|
|
|
#include "apei-internal.h"
|
|
|
|
|
|
|
|
#define HEST_PFX "HEST: "
|
|
|
|
|
2017-08-29 13:20:20 +00:00
|
|
|
int hest_disable;
|
2010-05-18 06:35:13 +00:00
|
|
|
EXPORT_SYMBOL_GPL(hest_disable);
|
|
|
|
|
|
|
|
/* HEST table parsing */
|
|
|
|
|
2010-12-07 14:58:44 +00:00
|
|
|
static struct acpi_table_hest *__read_mostly hest_tab;
|
2010-05-18 06:35:13 +00:00
|
|
|
|
2010-12-07 14:58:44 +00:00
|
|
|
static const int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {
|
2010-05-18 06:35:13 +00:00
|
|
|
[ACPI_HEST_TYPE_IA32_CHECK] = -1, /* need further calculation */
|
|
|
|
[ACPI_HEST_TYPE_IA32_CORRECTED_CHECK] = -1,
|
|
|
|
[ACPI_HEST_TYPE_IA32_NMI] = sizeof(struct acpi_hest_ia_nmi),
|
|
|
|
[ACPI_HEST_TYPE_AER_ROOT_PORT] = sizeof(struct acpi_hest_aer_root),
|
|
|
|
[ACPI_HEST_TYPE_AER_ENDPOINT] = sizeof(struct acpi_hest_aer),
|
|
|
|
[ACPI_HEST_TYPE_AER_BRIDGE] = sizeof(struct acpi_hest_aer_bridge),
|
|
|
|
[ACPI_HEST_TYPE_GENERIC_ERROR] = sizeof(struct acpi_hest_generic),
|
2017-06-21 18:17:04 +00:00
|
|
|
[ACPI_HEST_TYPE_GENERIC_ERROR_V2] = sizeof(struct acpi_hest_generic_v2),
|
2018-11-12 19:00:55 +00:00
|
|
|
[ACPI_HEST_TYPE_IA32_DEFERRED_CHECK] = -1,
|
2010-05-18 06:35:13 +00:00
|
|
|
};
|
|
|
|
|
2021-01-26 16:32:01 +00:00
|
|
|
static inline bool is_generic_error(struct acpi_hest_header *hest_hdr)
|
|
|
|
{
|
|
|
|
return hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR ||
|
|
|
|
hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR_V2;
|
|
|
|
}
|
|
|
|
|
2010-05-18 06:35:13 +00:00
|
|
|
static int hest_esrc_len(struct acpi_hest_header *hest_hdr)
|
|
|
|
{
|
|
|
|
u16 hest_type = hest_hdr->type;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (hest_type >= ACPI_HEST_TYPE_RESERVED)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
len = hest_esrc_len_tab[hest_type];
|
|
|
|
|
|
|
|
if (hest_type == ACPI_HEST_TYPE_IA32_CORRECTED_CHECK) {
|
|
|
|
struct acpi_hest_ia_corrected *cmc;
|
|
|
|
cmc = (struct acpi_hest_ia_corrected *)hest_hdr;
|
|
|
|
len = sizeof(*cmc) + cmc->num_hardware_banks *
|
|
|
|
sizeof(struct acpi_hest_ia_error_bank);
|
|
|
|
} else if (hest_type == ACPI_HEST_TYPE_IA32_CHECK) {
|
|
|
|
struct acpi_hest_ia_machine_check *mc;
|
|
|
|
mc = (struct acpi_hest_ia_machine_check *)hest_hdr;
|
|
|
|
len = sizeof(*mc) + mc->num_hardware_banks *
|
|
|
|
sizeof(struct acpi_hest_ia_error_bank);
|
2018-11-12 19:00:55 +00:00
|
|
|
} else if (hest_type == ACPI_HEST_TYPE_IA32_DEFERRED_CHECK) {
|
|
|
|
struct acpi_hest_ia_deferred_check *mc;
|
|
|
|
mc = (struct acpi_hest_ia_deferred_check *)hest_hdr;
|
|
|
|
len = sizeof(*mc) + mc->num_hardware_banks *
|
|
|
|
sizeof(struct acpi_hest_ia_error_bank);
|
2010-05-18 06:35:13 +00:00
|
|
|
}
|
|
|
|
BUG_ON(len == -1);
|
|
|
|
|
|
|
|
return len;
|
|
|
|
};
|
|
|
|
|
2021-10-27 06:54:38 +00:00
|
|
|
typedef int (*apei_hest_func_t)(struct acpi_hest_header *hest_hdr, void *data);
|
|
|
|
|
|
|
|
static int apei_hest_parse(apei_hest_func_t func, void *data)
|
2010-05-18 06:35:13 +00:00
|
|
|
{
|
|
|
|
struct acpi_hest_header *hest_hdr;
|
|
|
|
int i, rc, len;
|
|
|
|
|
2013-02-22 23:14:57 +00:00
|
|
|
if (hest_disable || !hest_tab)
|
2010-05-18 06:35:13 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
hest_hdr = (struct acpi_hest_header *)(hest_tab + 1);
|
|
|
|
for (i = 0; i < hest_tab->error_source_count; i++) {
|
|
|
|
len = hest_esrc_len(hest_hdr);
|
|
|
|
if (!len) {
|
2019-10-18 03:18:25 +00:00
|
|
|
pr_warn(FW_WARN HEST_PFX
|
|
|
|
"Unknown or unused hardware error source "
|
|
|
|
"type: %d for hardware error source: %d.\n",
|
|
|
|
hest_hdr->type, hest_hdr->source_id);
|
2010-05-18 06:35:13 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
if ((void *)hest_hdr + len >
|
|
|
|
(void *)hest_tab + hest_tab->header.length) {
|
2019-10-18 03:18:25 +00:00
|
|
|
pr_warn(FW_BUG HEST_PFX
|
2010-05-18 06:35:13 +00:00
|
|
|
"Table contents overflow for hardware error source: %d.\n",
|
|
|
|
hest_hdr->source_id);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = func(hest_hdr, data);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
hest_hdr = (void *)hest_hdr + len;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-01 15:38:47 +00:00
|
|
|
/*
|
|
|
|
* Check if firmware advertises firmware first mode. We need FF bit to be set
|
|
|
|
* along with a set of MC banks which work in FF mode.
|
|
|
|
*/
|
|
|
|
static int __init hest_parse_cmc(struct acpi_hest_header *hest_hdr, void *data)
|
|
|
|
{
|
2016-12-01 13:51:12 +00:00
|
|
|
if (hest_hdr->type != ACPI_HEST_TYPE_IA32_CORRECTED_CHECK)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!acpi_disable_cmcff)
|
|
|
|
return !arch_apei_enable_cmcff(hest_hdr, data);
|
|
|
|
|
|
|
|
return 0;
|
2013-07-01 15:38:47 +00:00
|
|
|
}
|
|
|
|
|
2010-08-02 07:48:24 +00:00
|
|
|
struct ghes_arr {
|
|
|
|
struct platform_device **ghes_devs;
|
|
|
|
unsigned int count;
|
|
|
|
};
|
|
|
|
|
2010-12-07 14:58:44 +00:00
|
|
|
static int __init hest_parse_ghes_count(struct acpi_hest_header *hest_hdr, void *data)
|
2010-08-02 07:48:24 +00:00
|
|
|
{
|
|
|
|
int *count = data;
|
|
|
|
|
2021-01-26 16:32:01 +00:00
|
|
|
if (is_generic_error(hest_hdr))
|
2010-08-02 07:48:24 +00:00
|
|
|
(*count)++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-07 14:58:44 +00:00
|
|
|
static int __init hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data)
|
2010-08-02 07:48:24 +00:00
|
|
|
{
|
|
|
|
struct platform_device *ghes_dev;
|
|
|
|
struct ghes_arr *ghes_arr = data;
|
2011-07-13 05:14:12 +00:00
|
|
|
int rc, i;
|
2010-08-02 07:48:24 +00:00
|
|
|
|
2021-01-26 16:32:01 +00:00
|
|
|
if (!is_generic_error(hest_hdr))
|
2010-08-02 07:48:24 +00:00
|
|
|
return 0;
|
2010-09-29 11:53:53 +00:00
|
|
|
|
|
|
|
if (!((struct acpi_hest_generic *)hest_hdr)->enabled)
|
2010-08-02 07:48:24 +00:00
|
|
|
return 0;
|
2011-07-13 05:14:12 +00:00
|
|
|
for (i = 0; i < ghes_arr->count; i++) {
|
|
|
|
struct acpi_hest_header *hdr;
|
|
|
|
ghes_dev = ghes_arr->ghes_devs[i];
|
|
|
|
hdr = *(struct acpi_hest_header **)ghes_dev->dev.platform_data;
|
|
|
|
if (hdr->source_id == hest_hdr->source_id) {
|
2019-10-18 03:18:25 +00:00
|
|
|
pr_warn(FW_WARN HEST_PFX "Duplicated hardware error source ID: %d.\n",
|
|
|
|
hdr->source_id);
|
2011-07-13 05:14:12 +00:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
2010-08-02 07:48:24 +00:00
|
|
|
ghes_dev = platform_device_alloc("GHES", hest_hdr->source_id);
|
|
|
|
if (!ghes_dev)
|
|
|
|
return -ENOMEM;
|
2010-09-29 11:53:53 +00:00
|
|
|
|
|
|
|
rc = platform_device_add_data(ghes_dev, &hest_hdr, sizeof(void *));
|
|
|
|
if (rc)
|
|
|
|
goto err;
|
|
|
|
|
2010-08-02 07:48:24 +00:00
|
|
|
rc = platform_device_add(ghes_dev);
|
|
|
|
if (rc)
|
|
|
|
goto err;
|
|
|
|
ghes_arr->ghes_devs[ghes_arr->count++] = ghes_dev;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
err:
|
|
|
|
platform_device_put(ghes_dev);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-12-07 14:58:44 +00:00
|
|
|
static int __init hest_ghes_dev_register(unsigned int ghes_count)
|
2010-08-02 07:48:24 +00:00
|
|
|
{
|
|
|
|
int rc, i;
|
|
|
|
struct ghes_arr ghes_arr;
|
|
|
|
|
|
|
|
ghes_arr.count = 0;
|
treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:
kmalloc(a * b, gfp)
with:
kmalloc_array(a * b, gfp)
as well as handling cases of:
kmalloc(a * b * c, gfp)
with:
kmalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kmalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kmalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kmalloc
+ kmalloc_array
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kmalloc(sizeof(THING) * C2, ...)
|
kmalloc(sizeof(TYPE) * C2, ...)
|
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * E2
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 20:55:00 +00:00
|
|
|
ghes_arr.ghes_devs = kmalloc_array(ghes_count, sizeof(void *),
|
|
|
|
GFP_KERNEL);
|
2010-08-02 07:48:24 +00:00
|
|
|
if (!ghes_arr.ghes_devs)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
rc = apei_hest_parse(hest_parse_ghes, &ghes_arr);
|
|
|
|
if (rc)
|
|
|
|
goto err;
|
2019-01-29 18:48:40 +00:00
|
|
|
|
2019-01-29 18:48:41 +00:00
|
|
|
rc = ghes_estatus_pool_init(ghes_count);
|
2019-01-29 18:48:40 +00:00
|
|
|
if (rc)
|
|
|
|
goto err;
|
|
|
|
|
2010-08-02 07:48:24 +00:00
|
|
|
out:
|
|
|
|
kfree(ghes_arr.ghes_devs);
|
|
|
|
return rc;
|
|
|
|
err:
|
|
|
|
for (i = 0; i < ghes_arr.count; i++)
|
|
|
|
platform_device_unregister(ghes_arr.ghes_devs[i]);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2010-05-18 06:35:13 +00:00
|
|
|
static int __init setup_hest_disable(char *str)
|
|
|
|
{
|
2017-08-29 13:20:20 +00:00
|
|
|
hest_disable = HEST_DISABLED;
|
2022-03-06 02:46:20 +00:00
|
|
|
return 1;
|
2010-05-18 06:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__setup("hest_disable", setup_hest_disable);
|
|
|
|
|
2011-01-06 23:55:09 +00:00
|
|
|
void __init acpi_hest_init(void)
|
2010-05-18 06:35:13 +00:00
|
|
|
{
|
|
|
|
acpi_status status;
|
2020-07-22 17:06:08 +00:00
|
|
|
int rc;
|
2010-08-02 07:48:24 +00:00
|
|
|
unsigned int ghes_count = 0;
|
2010-05-18 06:35:13 +00:00
|
|
|
|
|
|
|
if (hest_disable) {
|
2011-01-06 23:55:09 +00:00
|
|
|
pr_info(HEST_PFX "Table parsing disabled.\n");
|
|
|
|
return;
|
2010-05-18 06:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
status = acpi_get_table(ACPI_SIG_HEST, 0,
|
|
|
|
(struct acpi_table_header **)&hest_tab);
|
2017-08-29 13:20:20 +00:00
|
|
|
if (status == AE_NOT_FOUND) {
|
|
|
|
hest_disable = HEST_NOT_FOUND;
|
|
|
|
return;
|
|
|
|
} else if (ACPI_FAILURE(status)) {
|
2010-05-18 06:35:13 +00:00
|
|
|
const char *msg = acpi_format_exception(status);
|
|
|
|
pr_err(HEST_PFX "Failed to get table, %s\n", msg);
|
2020-05-07 09:09:18 +00:00
|
|
|
hest_disable = HEST_DISABLED;
|
|
|
|
return;
|
2010-05-18 06:35:13 +00:00
|
|
|
}
|
|
|
|
|
2016-12-01 13:51:12 +00:00
|
|
|
rc = apei_hest_parse(hest_parse_cmc, NULL);
|
|
|
|
if (rc)
|
|
|
|
goto err;
|
2013-07-01 15:38:47 +00:00
|
|
|
|
2011-07-13 05:14:19 +00:00
|
|
|
if (!ghes_disable) {
|
|
|
|
rc = apei_hest_parse(hest_parse_ghes_count, &ghes_count);
|
|
|
|
if (rc)
|
|
|
|
goto err;
|
2019-01-29 18:48:40 +00:00
|
|
|
|
|
|
|
if (ghes_count)
|
|
|
|
rc = hest_ghes_dev_register(ghes_count);
|
2011-07-13 05:14:19 +00:00
|
|
|
if (rc)
|
|
|
|
goto err;
|
2011-01-06 23:55:09 +00:00
|
|
|
}
|
2010-05-18 06:35:13 +00:00
|
|
|
|
2011-07-13 05:14:19 +00:00
|
|
|
pr_info(HEST_PFX "Table parsing has been initialized.\n");
|
|
|
|
return;
|
2010-05-18 06:35:13 +00:00
|
|
|
err:
|
2017-08-29 13:20:20 +00:00
|
|
|
hest_disable = HEST_DISABLED;
|
2020-05-07 09:09:18 +00:00
|
|
|
acpi_put_table((struct acpi_table_header *)hest_tab);
|
2010-05-18 06:35:13 +00:00
|
|
|
}
|