Merge branch 'acpi-apei'
* acpi-apei: (29 commits) efi: cper: Fix possible out-of-bounds access ACPI: APEI: Fix possible out-of-bounds access to BERT region MAINTAINERS: Add James Morse to the list of APEI reviewers ACPI / APEI: Add support for the SDEI GHES Notification type firmware: arm_sdei: Add ACPI GHES registration helper ACPI / APEI: Use separate fixmap pages for arm64 NMI-like notifications ACPI / APEI: Only use queued estatus entry during in_nmi_queue_one_entry() ACPI / APEI: Split ghes_read_estatus() to allow a peek at the CPER length ACPI / APEI: Make GHES estatus header validation more user friendly ACPI / APEI: Pass ghes and estatus separately to avoid a later copy ACPI / APEI: Let the notification helper specify the fixmap slot ACPI / APEI: Move locking to the notification helper arm64: KVM/mm: Move SEA handling behind a single 'claim' interface KVM: arm/arm64: Add kvm_ras.h to collect kvm specific RAS plumbing ACPI / APEI: Switch NOTIFY_SEA to use the estatus queue ACPI / APEI: Move NOTIFY_SEA between the estatus-queue and NOTIFY_NMI ACPI / APEI: Don't allow ghes_ack_error() to mask earlier errors ACPI / APEI: Generalise the estatus queue's notify code ACPI / APEI: Don't update struct ghes' flags in read/clear estatus ACPI / APEI: Remove spurious GHES_TO_CLEAR check ...
This commit is contained in:
commit
dcaed592b2
|
@ -331,6 +331,7 @@ ACPI APEI
|
||||||
M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
|
M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
|
||||||
M: Len Brown <lenb@kernel.org>
|
M: Len Brown <lenb@kernel.org>
|
||||||
L: linux-acpi@vger.kernel.org
|
L: linux-acpi@vger.kernel.org
|
||||||
|
R: James Morse <james.morse@arm.com>
|
||||||
R: Tony Luck <tony.luck@intel.com>
|
R: Tony Luck <tony.luck@intel.com>
|
||||||
R: Borislav Petkov <bp@alien8.de>
|
R: Borislav Petkov <bp@alien8.de>
|
||||||
F: drivers/acpi/apei/
|
F: drivers/acpi/apei/
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
/* Copyright (C) 2018 - Arm Ltd */
|
||||||
|
|
||||||
|
#ifndef __ARM_KVM_RAS_H__
|
||||||
|
#define __ARM_KVM_RAS_H__
|
||||||
|
|
||||||
|
#include <linux/types.h>
|
||||||
|
|
||||||
|
static inline int kvm_handle_guest_sea(phys_addr_t addr, unsigned int esr)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __ARM_KVM_RAS_H__ */
|
|
@ -38,11 +38,6 @@ static inline void harden_branch_predictor(void)
|
||||||
|
|
||||||
extern unsigned int user_debug;
|
extern unsigned int user_debug;
|
||||||
|
|
||||||
static inline int handle_guest_sea(phys_addr_t addr, unsigned int esr)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !__ASSEMBLY__ */
|
#endif /* !__ASSEMBLY__ */
|
||||||
|
|
||||||
#endif /* __ASM_ARM_SYSTEM_MISC_H */
|
#endif /* __ASM_ARM_SYSTEM_MISC_H */
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <asm/cputype.h>
|
#include <asm/cputype.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
#include <asm/ptrace.h>
|
||||||
#include <asm/smp_plat.h>
|
#include <asm/smp_plat.h>
|
||||||
#include <asm/tlbflush.h>
|
#include <asm/tlbflush.h>
|
||||||
|
|
||||||
|
@ -110,9 +111,10 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
|
||||||
|
|
||||||
static inline void arch_fix_phys_package_id(int num, u32 slot) { }
|
static inline void arch_fix_phys_package_id(int num, u32 slot) { }
|
||||||
void __init acpi_init_cpus(void);
|
void __init acpi_init_cpus(void);
|
||||||
|
int apei_claim_sea(struct pt_regs *regs);
|
||||||
#else
|
#else
|
||||||
static inline void acpi_init_cpus(void) { }
|
static inline void acpi_init_cpus(void) { }
|
||||||
|
static inline int apei_claim_sea(struct pt_regs *regs) { return -ENOENT; }
|
||||||
#endif /* CONFIG_ACPI */
|
#endif /* CONFIG_ACPI */
|
||||||
|
|
||||||
#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
|
#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#define DAIF_PROCCTX 0
|
#define DAIF_PROCCTX 0
|
||||||
#define DAIF_PROCCTX_NOIRQ PSR_I_BIT
|
#define DAIF_PROCCTX_NOIRQ PSR_I_BIT
|
||||||
|
#define DAIF_ERRCTX (PSR_I_BIT | PSR_A_BIT)
|
||||||
|
|
||||||
/* mask/save/unmask/restore all exceptions, including interrupts. */
|
/* mask/save/unmask/restore all exceptions, including interrupts. */
|
||||||
static inline void local_daif_mask(void)
|
static inline void local_daif_mask(void)
|
||||||
|
|
|
@ -55,7 +55,11 @@ enum fixed_addresses {
|
||||||
#ifdef CONFIG_ACPI_APEI_GHES
|
#ifdef CONFIG_ACPI_APEI_GHES
|
||||||
/* Used for GHES mapping from assorted contexts */
|
/* Used for GHES mapping from assorted contexts */
|
||||||
FIX_APEI_GHES_IRQ,
|
FIX_APEI_GHES_IRQ,
|
||||||
FIX_APEI_GHES_NMI,
|
FIX_APEI_GHES_SEA,
|
||||||
|
#ifdef CONFIG_ARM_SDE_INTERFACE
|
||||||
|
FIX_APEI_GHES_SDEI_NORMAL,
|
||||||
|
FIX_APEI_GHES_SDEI_CRITICAL,
|
||||||
|
#endif
|
||||||
#endif /* CONFIG_ACPI_APEI_GHES */
|
#endif /* CONFIG_ACPI_APEI_GHES */
|
||||||
|
|
||||||
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
|
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
/* Copyright (C) 2018 - Arm Ltd */
|
||||||
|
|
||||||
|
#ifndef __ARM64_KVM_RAS_H__
|
||||||
|
#define __ARM64_KVM_RAS_H__
|
||||||
|
|
||||||
|
#include <linux/acpi.h>
|
||||||
|
#include <linux/errno.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
|
||||||
|
#include <asm/acpi.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Was this synchronous external abort a RAS notification?
|
||||||
|
* Returns '0' for errors handled by some RAS subsystem, or -ENOENT.
|
||||||
|
*/
|
||||||
|
static inline int kvm_handle_guest_sea(phys_addr_t addr, unsigned int esr)
|
||||||
|
{
|
||||||
|
/* apei_claim_sea(NULL) expects to mask interrupts itself */
|
||||||
|
lockdep_assert_irqs_enabled();
|
||||||
|
|
||||||
|
return apei_claim_sea(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __ARM64_KVM_RAS_H__ */
|
|
@ -46,8 +46,6 @@ extern void __show_regs(struct pt_regs *);
|
||||||
|
|
||||||
extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
|
extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
|
||||||
|
|
||||||
int handle_guest_sea(phys_addr_t addr, unsigned int esr);
|
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|
||||||
#endif /* __ASM_SYSTEM_MISC_H */
|
#endif /* __ASM_SYSTEM_MISC_H */
|
||||||
|
|
|
@ -27,8 +27,10 @@
|
||||||
#include <linux/smp.h>
|
#include <linux/smp.h>
|
||||||
#include <linux/serial_core.h>
|
#include <linux/serial_core.h>
|
||||||
|
|
||||||
|
#include <acpi/ghes.h>
|
||||||
#include <asm/cputype.h>
|
#include <asm/cputype.h>
|
||||||
#include <asm/cpu_ops.h>
|
#include <asm/cpu_ops.h>
|
||||||
|
#include <asm/daifflags.h>
|
||||||
#include <asm/pgtable.h>
|
#include <asm/pgtable.h>
|
||||||
#include <asm/smp_plat.h>
|
#include <asm/smp_plat.h>
|
||||||
|
|
||||||
|
@ -256,3 +258,32 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr)
|
||||||
return __pgprot(PROT_NORMAL_NC);
|
return __pgprot(PROT_NORMAL_NC);
|
||||||
return __pgprot(PROT_DEVICE_nGnRnE);
|
return __pgprot(PROT_DEVICE_nGnRnE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Claim Synchronous External Aborts as a firmware first notification.
|
||||||
|
*
|
||||||
|
* Used by KVM and the arch do_sea handler.
|
||||||
|
* @regs may be NULL when called from process context.
|
||||||
|
*/
|
||||||
|
int apei_claim_sea(struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
int err = -ENOENT;
|
||||||
|
unsigned long current_flags;
|
||||||
|
|
||||||
|
if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES))
|
||||||
|
return err;
|
||||||
|
|
||||||
|
current_flags = arch_local_save_flags();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SEA can interrupt SError, mask it and describe this as an NMI so
|
||||||
|
* that APEI defers the handling.
|
||||||
|
*/
|
||||||
|
local_daif_restore(DAIF_ERRCTX);
|
||||||
|
nmi_enter();
|
||||||
|
err = ghes_notify_sea();
|
||||||
|
nmi_exit();
|
||||||
|
local_daif_restore(current_flags);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/acpi.h>
|
||||||
#include <linux/extable.h>
|
#include <linux/extable.h>
|
||||||
#include <linux/signal.h>
|
#include <linux/signal.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
|
@ -33,6 +34,7 @@
|
||||||
#include <linux/preempt.h>
|
#include <linux/preempt.h>
|
||||||
#include <linux/hugetlb.h>
|
#include <linux/hugetlb.h>
|
||||||
|
|
||||||
|
#include <asm/acpi.h>
|
||||||
#include <asm/bug.h>
|
#include <asm/bug.h>
|
||||||
#include <asm/cmpxchg.h>
|
#include <asm/cmpxchg.h>
|
||||||
#include <asm/cpufeature.h>
|
#include <asm/cpufeature.h>
|
||||||
|
@ -47,8 +49,6 @@
|
||||||
#include <asm/tlbflush.h>
|
#include <asm/tlbflush.h>
|
||||||
#include <asm/traps.h>
|
#include <asm/traps.h>
|
||||||
|
|
||||||
#include <acpi/ghes.h>
|
|
||||||
|
|
||||||
struct fault_info {
|
struct fault_info {
|
||||||
int (*fn)(unsigned long addr, unsigned int esr,
|
int (*fn)(unsigned long addr, unsigned int esr,
|
||||||
struct pt_regs *regs);
|
struct pt_regs *regs);
|
||||||
|
@ -643,19 +643,10 @@ static int do_sea(unsigned long addr, unsigned int esr, struct pt_regs *regs)
|
||||||
inf = esr_to_fault_info(esr);
|
inf = esr_to_fault_info(esr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Synchronous aborts may interrupt code which had interrupts masked.
|
* Return value ignored as we rely on signal merging.
|
||||||
* Before calling out into the wider kernel tell the interested
|
* Future patches will make this more robust.
|
||||||
* subsystems.
|
|
||||||
*/
|
*/
|
||||||
if (IS_ENABLED(CONFIG_ACPI_APEI_SEA)) {
|
apei_claim_sea(regs);
|
||||||
if (interrupts_enabled(regs))
|
|
||||||
nmi_enter();
|
|
||||||
|
|
||||||
ghes_notify_sea();
|
|
||||||
|
|
||||||
if (interrupts_enabled(regs))
|
|
||||||
nmi_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (esr & ESR_ELx_FnV)
|
if (esr & ESR_ELx_FnV)
|
||||||
siaddr = NULL;
|
siaddr = NULL;
|
||||||
|
@ -733,11 +724,6 @@ static const struct fault_info fault_info[] = {
|
||||||
{ do_bad, SIGKILL, SI_KERNEL, "unknown 63" },
|
{ do_bad, SIGKILL, SI_KERNEL, "unknown 63" },
|
||||||
};
|
};
|
||||||
|
|
||||||
int handle_guest_sea(phys_addr_t addr, unsigned int esr)
|
|
||||||
{
|
|
||||||
return ghes_notify_sea();
|
|
||||||
}
|
|
||||||
|
|
||||||
asmlinkage void __exception do_mem_abort(unsigned long addr, unsigned int esr,
|
asmlinkage void __exception do_mem_abort(unsigned long addr, unsigned int esr,
|
||||||
struct pt_regs *regs)
|
struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,19 +41,9 @@ config ACPI_APEI_PCIEAER
|
||||||
Turn on this option to enable the corresponding support.
|
Turn on this option to enable the corresponding support.
|
||||||
|
|
||||||
config ACPI_APEI_SEA
|
config ACPI_APEI_SEA
|
||||||
bool "APEI Synchronous External Abort logging/recovering support"
|
bool
|
||||||
depends on ARM64 && ACPI_APEI_GHES
|
depends on ARM64 && ACPI_APEI_GHES
|
||||||
default y
|
default y
|
||||||
help
|
|
||||||
This option should be enabled if the system supports
|
|
||||||
firmware first handling of SEA (Synchronous External Abort).
|
|
||||||
SEA happens with certain faults of data abort or instruction
|
|
||||||
abort synchronous exceptions on ARMv8 systems. If a system
|
|
||||||
supports firmware first handling of SEA, the platform analyzes
|
|
||||||
and handles hardware error notifications from SEA, and it may then
|
|
||||||
form a HW error record for the OS to parse and handle. This
|
|
||||||
option allows the OS to look for such hardware error record, and
|
|
||||||
take appropriate action.
|
|
||||||
|
|
||||||
config ACPI_APEI_MEMORY_FAILURE
|
config ACPI_APEI_MEMORY_FAILURE
|
||||||
bool "APEI memory error recovering support"
|
bool "APEI memory error recovering support"
|
||||||
|
|
|
@ -42,15 +42,7 @@ static void __init bert_print_all(struct acpi_bert_region *region,
|
||||||
int remain = region_len;
|
int remain = region_len;
|
||||||
u32 estatus_len;
|
u32 estatus_len;
|
||||||
|
|
||||||
if (!estatus->block_status)
|
while (remain >= sizeof(struct acpi_bert_region)) {
|
||||||
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);
|
estatus_len = cper_estatus_len(estatus);
|
||||||
if (remain < estatus_len) {
|
if (remain < estatus_len) {
|
||||||
pr_err(FW_BUG "Truncated status block (length: %u).\n",
|
pr_err(FW_BUG "Truncated status block (length: %u).\n",
|
||||||
|
@ -58,6 +50,15 @@ static void __init bert_print_all(struct acpi_bert_region *region,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* No more error records. */
|
||||||
|
if (!estatus->block_status)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cper_estatus_check(estatus)) {
|
||||||
|
pr_err(FW_BUG "Invalid error record.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pr_info_once("Error records from previous boot:\n");
|
pr_info_once("Error records from previous boot:\n");
|
||||||
|
|
||||||
cper_estatus_print(KERN_INFO HW_ERR, estatus);
|
cper_estatus_print(KERN_INFO HW_ERR, estatus);
|
||||||
|
@ -70,10 +71,6 @@ static void __init bert_print_all(struct acpi_bert_region *region,
|
||||||
estatus->block_status = 0;
|
estatus->block_status = 0;
|
||||||
|
|
||||||
estatus = (void *)estatus + estatus_len;
|
estatus = (void *)estatus + estatus_len;
|
||||||
/* No more error records. */
|
|
||||||
if (!estatus->block_status)
|
|
||||||
return;
|
|
||||||
|
|
||||||
remain -= estatus_len;
|
remain -= estatus_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -644,8 +644,8 @@ static int error_type_set(void *data, u64 val)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_SIMPLE_ATTRIBUTE(error_type_fops, error_type_get,
|
DEFINE_DEBUGFS_ATTRIBUTE(error_type_fops, error_type_get, error_type_set,
|
||||||
error_type_set, "0x%llx\n");
|
"0x%llx\n");
|
||||||
|
|
||||||
static int error_inject_set(void *data, u64 val)
|
static int error_inject_set(void *data, u64 val)
|
||||||
{
|
{
|
||||||
|
@ -656,8 +656,7 @@ static int error_inject_set(void *data, u64 val)
|
||||||
error_param3, error_param4);
|
error_param3, error_param4);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_SIMPLE_ATTRIBUTE(error_inject_fops, NULL,
|
DEFINE_DEBUGFS_ATTRIBUTE(error_inject_fops, NULL, error_inject_set, "%llu\n");
|
||||||
error_inject_set, "%llu\n");
|
|
||||||
|
|
||||||
static int einj_check_table(struct acpi_table_einj *einj_tab)
|
static int einj_check_table(struct acpi_table_einj *einj_tab)
|
||||||
{
|
{
|
||||||
|
@ -709,10 +708,10 @@ static int __init einj_init(void)
|
||||||
|
|
||||||
debugfs_create_file("available_error_type", S_IRUSR, einj_debug_dir,
|
debugfs_create_file("available_error_type", S_IRUSR, einj_debug_dir,
|
||||||
NULL, &available_error_type_fops);
|
NULL, &available_error_type_fops);
|
||||||
debugfs_create_file("error_type", S_IRUSR | S_IWUSR, einj_debug_dir,
|
debugfs_create_file_unsafe("error_type", 0600, einj_debug_dir,
|
||||||
NULL, &error_type_fops);
|
NULL, &error_type_fops);
|
||||||
debugfs_create_file("error_inject", S_IWUSR, einj_debug_dir,
|
debugfs_create_file_unsafe("error_inject", 0200, einj_debug_dir,
|
||||||
NULL, &error_inject_fops);
|
NULL, &error_inject_fops);
|
||||||
|
|
||||||
apei_resources_init(&einj_resources);
|
apei_resources_init(&einj_resources);
|
||||||
einj_exec_ctx_init(&ctx);
|
einj_exec_ctx_init(&ctx);
|
||||||
|
|
|
@ -938,17 +938,17 @@ static struct pstore_info erst_info = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CPER_CREATOR_PSTORE \
|
#define CPER_CREATOR_PSTORE \
|
||||||
UUID_LE(0x75a574e3, 0x5052, 0x4b29, 0x8a, 0x8e, 0xbe, 0x2c, \
|
GUID_INIT(0x75a574e3, 0x5052, 0x4b29, 0x8a, 0x8e, 0xbe, 0x2c, \
|
||||||
0x64, 0x90, 0xb8, 0x9d)
|
0x64, 0x90, 0xb8, 0x9d)
|
||||||
#define CPER_SECTION_TYPE_DMESG \
|
#define CPER_SECTION_TYPE_DMESG \
|
||||||
UUID_LE(0xc197e04e, 0xd545, 0x4a70, 0x9c, 0x17, 0xa5, 0x54, \
|
GUID_INIT(0xc197e04e, 0xd545, 0x4a70, 0x9c, 0x17, 0xa5, 0x54, \
|
||||||
0x94, 0x19, 0xeb, 0x12)
|
0x94, 0x19, 0xeb, 0x12)
|
||||||
#define CPER_SECTION_TYPE_DMESG_Z \
|
#define CPER_SECTION_TYPE_DMESG_Z \
|
||||||
UUID_LE(0x4f118707, 0x04dd, 0x4055, 0xb5, 0xdd, 0x95, 0x6d, \
|
GUID_INIT(0x4f118707, 0x04dd, 0x4055, 0xb5, 0xdd, 0x95, 0x6d, \
|
||||||
0x34, 0xdd, 0xfa, 0xc6)
|
0x34, 0xdd, 0xfa, 0xc6)
|
||||||
#define CPER_SECTION_TYPE_MCE \
|
#define CPER_SECTION_TYPE_MCE \
|
||||||
UUID_LE(0xfe08ffbe, 0x95e4, 0x4be7, 0xbc, 0x73, 0x40, 0x96, \
|
GUID_INIT(0xfe08ffbe, 0x95e4, 0x4be7, 0xbc, 0x73, 0x40, 0x96, \
|
||||||
0x04, 0x4a, 0x38, 0xfc)
|
0x04, 0x4a, 0x38, 0xfc)
|
||||||
|
|
||||||
struct cper_pstore_record {
|
struct cper_pstore_record {
|
||||||
struct cper_record_header hdr;
|
struct cper_record_header hdr;
|
||||||
|
@ -1012,7 +1012,7 @@ skip:
|
||||||
rc = -EIO;
|
rc = -EIO;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (uuid_le_cmp(rcd->hdr.creator_id, CPER_CREATOR_PSTORE) != 0)
|
if (!guid_equal(&rcd->hdr.creator_id, &CPER_CREATOR_PSTORE))
|
||||||
goto skip;
|
goto skip;
|
||||||
|
|
||||||
record->buf = kmalloc(len, GFP_KERNEL);
|
record->buf = kmalloc(len, GFP_KERNEL);
|
||||||
|
@ -1024,15 +1024,12 @@ skip:
|
||||||
record->id = record_id;
|
record->id = record_id;
|
||||||
record->compressed = false;
|
record->compressed = false;
|
||||||
record->ecc_notice_size = 0;
|
record->ecc_notice_size = 0;
|
||||||
if (uuid_le_cmp(rcd->sec_hdr.section_type,
|
if (guid_equal(&rcd->sec_hdr.section_type, &CPER_SECTION_TYPE_DMESG_Z)) {
|
||||||
CPER_SECTION_TYPE_DMESG_Z) == 0) {
|
|
||||||
record->type = PSTORE_TYPE_DMESG;
|
record->type = PSTORE_TYPE_DMESG;
|
||||||
record->compressed = true;
|
record->compressed = true;
|
||||||
} else if (uuid_le_cmp(rcd->sec_hdr.section_type,
|
} else if (guid_equal(&rcd->sec_hdr.section_type, &CPER_SECTION_TYPE_DMESG))
|
||||||
CPER_SECTION_TYPE_DMESG) == 0)
|
|
||||||
record->type = PSTORE_TYPE_DMESG;
|
record->type = PSTORE_TYPE_DMESG;
|
||||||
else if (uuid_le_cmp(rcd->sec_hdr.section_type,
|
else if (guid_equal(&rcd->sec_hdr.section_type, &CPER_SECTION_TYPE_MCE))
|
||||||
CPER_SECTION_TYPE_MCE) == 0)
|
|
||||||
record->type = PSTORE_TYPE_MCE;
|
record->type = PSTORE_TYPE_MCE;
|
||||||
else
|
else
|
||||||
record->type = PSTORE_TYPE_MAX;
|
record->type = PSTORE_TYPE_MAX;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/arm_sdei.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
|
@ -33,7 +34,6 @@
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/timer.h>
|
#include <linux/timer.h>
|
||||||
#include <linux/cper.h>
|
#include <linux/cper.h>
|
||||||
#include <linux/kdebug.h>
|
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/ratelimit.h>
|
#include <linux/ratelimit.h>
|
||||||
|
@ -42,6 +42,7 @@
|
||||||
#include <linux/llist.h>
|
#include <linux/llist.h>
|
||||||
#include <linux/genalloc.h>
|
#include <linux/genalloc.h>
|
||||||
#include <linux/pci.h>
|
#include <linux/pci.h>
|
||||||
|
#include <linux/pfn.h>
|
||||||
#include <linux/aer.h>
|
#include <linux/aer.h>
|
||||||
#include <linux/nmi.h>
|
#include <linux/nmi.h>
|
||||||
#include <linux/sched/clock.h>
|
#include <linux/sched/clock.h>
|
||||||
|
@ -85,6 +86,15 @@
|
||||||
((struct acpi_hest_generic_status *) \
|
((struct acpi_hest_generic_status *) \
|
||||||
((struct ghes_estatus_node *)(estatus_node) + 1))
|
((struct ghes_estatus_node *)(estatus_node) + 1))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NMI-like notifications vary by architecture, before the compiler can prune
|
||||||
|
* unused static functions it needs a value for these enums.
|
||||||
|
*/
|
||||||
|
#ifndef CONFIG_ARM_SDE_INTERFACE
|
||||||
|
#define FIX_APEI_GHES_SDEI_NORMAL __end_of_fixed_addresses
|
||||||
|
#define FIX_APEI_GHES_SDEI_CRITICAL __end_of_fixed_addresses
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline bool is_hest_type_generic_v2(struct ghes *ghes)
|
static inline bool is_hest_type_generic_v2(struct ghes *ghes)
|
||||||
{
|
{
|
||||||
return ghes->generic->header.type == ACPI_HEST_TYPE_GENERIC_ERROR_V2;
|
return ghes->generic->header.type == ACPI_HEST_TYPE_GENERIC_ERROR_V2;
|
||||||
|
@ -115,11 +125,10 @@ static DEFINE_MUTEX(ghes_list_mutex);
|
||||||
* handler, but general ioremap can not be used in atomic context, so
|
* handler, but general ioremap can not be used in atomic context, so
|
||||||
* the fixmap is used instead.
|
* the fixmap is used instead.
|
||||||
*
|
*
|
||||||
* These 2 spinlocks are used to prevent the fixmap entries from being used
|
* This spinlock is used to prevent the fixmap entry from being used
|
||||||
* simultaneously.
|
* simultaneously.
|
||||||
*/
|
*/
|
||||||
static DEFINE_RAW_SPINLOCK(ghes_ioremap_lock_nmi);
|
static DEFINE_SPINLOCK(ghes_notify_lock_irq);
|
||||||
static DEFINE_SPINLOCK(ghes_ioremap_lock_irq);
|
|
||||||
|
|
||||||
static struct gen_pool *ghes_estatus_pool;
|
static struct gen_pool *ghes_estatus_pool;
|
||||||
static unsigned long ghes_estatus_pool_size_request;
|
static unsigned long ghes_estatus_pool_size_request;
|
||||||
|
@ -129,82 +138,49 @@ static atomic_t ghes_estatus_cache_alloced;
|
||||||
|
|
||||||
static int ghes_panic_timeout __read_mostly = 30;
|
static int ghes_panic_timeout __read_mostly = 30;
|
||||||
|
|
||||||
static void __iomem *ghes_ioremap_pfn_nmi(u64 pfn)
|
static void __iomem *ghes_map(u64 pfn, enum fixed_addresses fixmap_idx)
|
||||||
{
|
{
|
||||||
phys_addr_t paddr;
|
phys_addr_t paddr;
|
||||||
pgprot_t prot;
|
pgprot_t prot;
|
||||||
|
|
||||||
paddr = pfn << PAGE_SHIFT;
|
paddr = PFN_PHYS(pfn);
|
||||||
prot = arch_apei_get_mem_attribute(paddr);
|
prot = arch_apei_get_mem_attribute(paddr);
|
||||||
__set_fixmap(FIX_APEI_GHES_NMI, paddr, prot);
|
__set_fixmap(fixmap_idx, paddr, prot);
|
||||||
|
|
||||||
return (void __iomem *) fix_to_virt(FIX_APEI_GHES_NMI);
|
return (void __iomem *) __fix_to_virt(fixmap_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __iomem *ghes_ioremap_pfn_irq(u64 pfn)
|
static void ghes_unmap(void __iomem *vaddr, enum fixed_addresses fixmap_idx)
|
||||||
{
|
{
|
||||||
phys_addr_t paddr;
|
int _idx = virt_to_fix((unsigned long)vaddr);
|
||||||
pgprot_t prot;
|
|
||||||
|
|
||||||
paddr = pfn << PAGE_SHIFT;
|
WARN_ON_ONCE(fixmap_idx != _idx);
|
||||||
prot = arch_apei_get_mem_attribute(paddr);
|
clear_fixmap(fixmap_idx);
|
||||||
__set_fixmap(FIX_APEI_GHES_IRQ, paddr, prot);
|
|
||||||
|
|
||||||
return (void __iomem *) fix_to_virt(FIX_APEI_GHES_IRQ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ghes_iounmap_nmi(void)
|
int ghes_estatus_pool_init(int num_ghes)
|
||||||
{
|
{
|
||||||
clear_fixmap(FIX_APEI_GHES_NMI);
|
unsigned long addr, len;
|
||||||
}
|
|
||||||
|
|
||||||
static void ghes_iounmap_irq(void)
|
|
||||||
{
|
|
||||||
clear_fixmap(FIX_APEI_GHES_IRQ);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ghes_estatus_pool_init(void)
|
|
||||||
{
|
|
||||||
ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1);
|
ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1);
|
||||||
if (!ghes_estatus_pool)
|
if (!ghes_estatus_pool)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ghes_estatus_pool_free_chunk_page(struct gen_pool *pool,
|
len = GHES_ESTATUS_CACHE_AVG_SIZE * GHES_ESTATUS_CACHE_ALLOCED_MAX;
|
||||||
struct gen_pool_chunk *chunk,
|
len += (num_ghes * GHES_ESOURCE_PREALLOC_MAX_SIZE);
|
||||||
void *data)
|
|
||||||
{
|
|
||||||
free_page(chunk->start_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ghes_estatus_pool_exit(void)
|
ghes_estatus_pool_size_request = PAGE_ALIGN(len);
|
||||||
{
|
addr = (unsigned long)vmalloc(PAGE_ALIGN(len));
|
||||||
gen_pool_for_each_chunk(ghes_estatus_pool,
|
if (!addr)
|
||||||
ghes_estatus_pool_free_chunk_page, NULL);
|
return -ENOMEM;
|
||||||
gen_pool_destroy(ghes_estatus_pool);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ghes_estatus_pool_expand(unsigned long len)
|
/*
|
||||||
{
|
* New allocation must be visible in all pgd before it can be found by
|
||||||
unsigned long i, pages, size, addr;
|
* an NMI allocating from the pool.
|
||||||
int ret;
|
*/
|
||||||
|
vmalloc_sync_all();
|
||||||
|
|
||||||
ghes_estatus_pool_size_request += PAGE_ALIGN(len);
|
return gen_pool_add(ghes_estatus_pool, addr, PAGE_ALIGN(len), -1);
|
||||||
size = gen_pool_size(ghes_estatus_pool);
|
|
||||||
if (size >= ghes_estatus_pool_size_request)
|
|
||||||
return 0;
|
|
||||||
pages = (ghes_estatus_pool_size_request - size) / PAGE_SIZE;
|
|
||||||
for (i = 0; i < pages; i++) {
|
|
||||||
addr = __get_free_page(GFP_KERNEL);
|
|
||||||
if (!addr)
|
|
||||||
return -ENOMEM;
|
|
||||||
ret = gen_pool_add(ghes_estatus_pool, addr, PAGE_SIZE, -1);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int map_gen_v2(struct ghes *ghes)
|
static int map_gen_v2(struct ghes *ghes)
|
||||||
|
@ -217,6 +193,21 @@ static void unmap_gen_v2(struct ghes *ghes)
|
||||||
apei_unmap_generic_address(&ghes->generic_v2->read_ack_register);
|
apei_unmap_generic_address(&ghes->generic_v2->read_ack_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ghes_ack_error(struct acpi_hest_generic_v2 *gv2)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
u64 val = 0;
|
||||||
|
|
||||||
|
rc = apei_read(&val, &gv2->read_ack_register);
|
||||||
|
if (rc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
val &= gv2->read_ack_preserve << gv2->read_ack_register.bit_offset;
|
||||||
|
val |= gv2->read_ack_write << gv2->read_ack_register.bit_offset;
|
||||||
|
|
||||||
|
apei_write(val, &gv2->read_ack_register);
|
||||||
|
}
|
||||||
|
|
||||||
static struct ghes *ghes_new(struct acpi_hest_generic *generic)
|
static struct ghes *ghes_new(struct acpi_hest_generic *generic)
|
||||||
{
|
{
|
||||||
struct ghes *ghes;
|
struct ghes *ghes;
|
||||||
|
@ -289,23 +280,16 @@ static inline int ghes_severity(int severity)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len,
|
static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len,
|
||||||
int from_phys)
|
int from_phys,
|
||||||
|
enum fixed_addresses fixmap_idx)
|
||||||
{
|
{
|
||||||
void __iomem *vaddr;
|
void __iomem *vaddr;
|
||||||
unsigned long flags = 0;
|
|
||||||
int in_nmi = in_nmi();
|
|
||||||
u64 offset;
|
u64 offset;
|
||||||
u32 trunk;
|
u32 trunk;
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
offset = paddr - (paddr & PAGE_MASK);
|
offset = paddr - (paddr & PAGE_MASK);
|
||||||
if (in_nmi) {
|
vaddr = ghes_map(PHYS_PFN(paddr), fixmap_idx);
|
||||||
raw_spin_lock(&ghes_ioremap_lock_nmi);
|
|
||||||
vaddr = ghes_ioremap_pfn_nmi(paddr >> PAGE_SHIFT);
|
|
||||||
} else {
|
|
||||||
spin_lock_irqsave(&ghes_ioremap_lock_irq, flags);
|
|
||||||
vaddr = ghes_ioremap_pfn_irq(paddr >> PAGE_SHIFT);
|
|
||||||
}
|
|
||||||
trunk = PAGE_SIZE - offset;
|
trunk = PAGE_SIZE - offset;
|
||||||
trunk = min(trunk, len);
|
trunk = min(trunk, len);
|
||||||
if (from_phys)
|
if (from_phys)
|
||||||
|
@ -315,72 +299,114 @@ static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len,
|
||||||
len -= trunk;
|
len -= trunk;
|
||||||
paddr += trunk;
|
paddr += trunk;
|
||||||
buffer += trunk;
|
buffer += trunk;
|
||||||
if (in_nmi) {
|
ghes_unmap(vaddr, fixmap_idx);
|
||||||
ghes_iounmap_nmi();
|
|
||||||
raw_spin_unlock(&ghes_ioremap_lock_nmi);
|
|
||||||
} else {
|
|
||||||
ghes_iounmap_irq();
|
|
||||||
spin_unlock_irqrestore(&ghes_ioremap_lock_irq, flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ghes_read_estatus(struct ghes *ghes, int silent)
|
/* Check the top-level record header has an appropriate size. */
|
||||||
|
static int __ghes_check_estatus(struct ghes *ghes,
|
||||||
|
struct acpi_hest_generic_status *estatus)
|
||||||
|
{
|
||||||
|
u32 len = cper_estatus_len(estatus);
|
||||||
|
|
||||||
|
if (len < sizeof(*estatus)) {
|
||||||
|
pr_warn_ratelimited(FW_WARN GHES_PFX "Truncated error status block!\n");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > ghes->generic->error_block_length) {
|
||||||
|
pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid error status block length!\n");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cper_estatus_check_header(estatus)) {
|
||||||
|
pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid CPER header!\n");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the CPER block, returning its address, and header in estatus. */
|
||||||
|
static int __ghes_peek_estatus(struct ghes *ghes,
|
||||||
|
struct acpi_hest_generic_status *estatus,
|
||||||
|
u64 *buf_paddr, enum fixed_addresses fixmap_idx)
|
||||||
{
|
{
|
||||||
struct acpi_hest_generic *g = ghes->generic;
|
struct acpi_hest_generic *g = ghes->generic;
|
||||||
u64 buf_paddr;
|
|
||||||
u32 len;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = apei_read(&buf_paddr, &g->error_status_address);
|
rc = apei_read(buf_paddr, &g->error_status_address);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
if (!silent && printk_ratelimit())
|
*buf_paddr = 0;
|
||||||
pr_warning(FW_WARN GHES_PFX
|
pr_warn_ratelimited(FW_WARN GHES_PFX
|
||||||
"Failed to read error status block address for hardware error source: %d.\n",
|
"Failed to read error status block address for hardware error source: %d.\n",
|
||||||
g->header.source_id);
|
g->header.source_id);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
if (!buf_paddr)
|
if (!*buf_paddr)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
ghes_copy_tofrom_phys(ghes->estatus, buf_paddr,
|
ghes_copy_tofrom_phys(estatus, *buf_paddr, sizeof(*estatus), 1,
|
||||||
sizeof(*ghes->estatus), 1);
|
fixmap_idx);
|
||||||
if (!ghes->estatus->block_status)
|
if (!estatus->block_status) {
|
||||||
|
*buf_paddr = 0;
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
ghes->buffer_paddr = buf_paddr;
|
return __ghes_check_estatus(ghes, estatus);
|
||||||
ghes->flags |= GHES_TO_CLEAR;
|
|
||||||
|
|
||||||
rc = -EIO;
|
|
||||||
len = cper_estatus_len(ghes->estatus);
|
|
||||||
if (len < sizeof(*ghes->estatus))
|
|
||||||
goto err_read_block;
|
|
||||||
if (len > ghes->generic->error_block_length)
|
|
||||||
goto err_read_block;
|
|
||||||
if (cper_estatus_check_header(ghes->estatus))
|
|
||||||
goto err_read_block;
|
|
||||||
ghes_copy_tofrom_phys(ghes->estatus + 1,
|
|
||||||
buf_paddr + sizeof(*ghes->estatus),
|
|
||||||
len - sizeof(*ghes->estatus), 1);
|
|
||||||
if (cper_estatus_check(ghes->estatus))
|
|
||||||
goto err_read_block;
|
|
||||||
rc = 0;
|
|
||||||
|
|
||||||
err_read_block:
|
|
||||||
if (rc && !silent && printk_ratelimit())
|
|
||||||
pr_warning(FW_WARN GHES_PFX
|
|
||||||
"Failed to read error status block!\n");
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ghes_clear_estatus(struct ghes *ghes)
|
static int __ghes_read_estatus(struct acpi_hest_generic_status *estatus,
|
||||||
|
u64 buf_paddr, enum fixed_addresses fixmap_idx,
|
||||||
|
size_t buf_len)
|
||||||
{
|
{
|
||||||
ghes->estatus->block_status = 0;
|
ghes_copy_tofrom_phys(estatus, buf_paddr, buf_len, 1, fixmap_idx);
|
||||||
if (!(ghes->flags & GHES_TO_CLEAR))
|
if (cper_estatus_check(estatus)) {
|
||||||
|
pr_warn_ratelimited(FW_WARN GHES_PFX
|
||||||
|
"Failed to read error status block!\n");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ghes_read_estatus(struct ghes *ghes,
|
||||||
|
struct acpi_hest_generic_status *estatus,
|
||||||
|
u64 *buf_paddr, enum fixed_addresses fixmap_idx)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = __ghes_peek_estatus(ghes, estatus, buf_paddr, fixmap_idx);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
rc = __ghes_check_estatus(ghes, estatus);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
return __ghes_read_estatus(estatus, *buf_paddr, fixmap_idx,
|
||||||
|
cper_estatus_len(estatus));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ghes_clear_estatus(struct ghes *ghes,
|
||||||
|
struct acpi_hest_generic_status *estatus,
|
||||||
|
u64 buf_paddr, enum fixed_addresses fixmap_idx)
|
||||||
|
{
|
||||||
|
estatus->block_status = 0;
|
||||||
|
|
||||||
|
if (!buf_paddr)
|
||||||
return;
|
return;
|
||||||
ghes_copy_tofrom_phys(ghes->estatus, ghes->buffer_paddr,
|
|
||||||
sizeof(ghes->estatus->block_status), 0);
|
ghes_copy_tofrom_phys(estatus, buf_paddr,
|
||||||
ghes->flags &= ~GHES_TO_CLEAR;
|
sizeof(estatus->block_status), 0,
|
||||||
|
fixmap_idx);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GHESv2 type HEST entries introduce support for error acknowledgment,
|
||||||
|
* so only acknowledge the error if this support is present.
|
||||||
|
*/
|
||||||
|
if (is_hest_type_generic_v2(ghes))
|
||||||
|
ghes_ack_error(ghes->generic_v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int sev)
|
static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int sev)
|
||||||
|
@ -672,26 +698,13 @@ static void ghes_estatus_cache_add(
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ghes_ack_error(struct acpi_hest_generic_v2 *gv2)
|
static void __ghes_panic(struct ghes *ghes,
|
||||||
|
struct acpi_hest_generic_status *estatus,
|
||||||
|
u64 buf_paddr, enum fixed_addresses fixmap_idx)
|
||||||
{
|
{
|
||||||
int rc;
|
__ghes_print_estatus(KERN_EMERG, ghes->generic, estatus);
|
||||||
u64 val = 0;
|
|
||||||
|
|
||||||
rc = apei_read(&val, &gv2->read_ack_register);
|
ghes_clear_estatus(ghes, estatus, buf_paddr, fixmap_idx);
|
||||||
if (rc)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
val &= gv2->read_ack_preserve << gv2->read_ack_register.bit_offset;
|
|
||||||
val |= gv2->read_ack_write << gv2->read_ack_register.bit_offset;
|
|
||||||
|
|
||||||
return apei_write(val, &gv2->read_ack_register);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __ghes_panic(struct ghes *ghes)
|
|
||||||
{
|
|
||||||
__ghes_print_estatus(KERN_EMERG, ghes->generic, ghes->estatus);
|
|
||||||
|
|
||||||
ghes_clear_estatus(ghes);
|
|
||||||
|
|
||||||
/* reboot to log the error! */
|
/* reboot to log the error! */
|
||||||
if (!panic_timeout)
|
if (!panic_timeout)
|
||||||
|
@ -701,34 +714,25 @@ static void __ghes_panic(struct ghes *ghes)
|
||||||
|
|
||||||
static int ghes_proc(struct ghes *ghes)
|
static int ghes_proc(struct ghes *ghes)
|
||||||
{
|
{
|
||||||
|
struct acpi_hest_generic_status *estatus = ghes->estatus;
|
||||||
|
u64 buf_paddr;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ghes_read_estatus(ghes, 0);
|
rc = ghes_read_estatus(ghes, estatus, &buf_paddr, FIX_APEI_GHES_IRQ);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (ghes_severity(ghes->estatus->error_severity) >= GHES_SEV_PANIC) {
|
if (ghes_severity(estatus->error_severity) >= GHES_SEV_PANIC)
|
||||||
__ghes_panic(ghes);
|
__ghes_panic(ghes, estatus, buf_paddr, FIX_APEI_GHES_IRQ);
|
||||||
}
|
|
||||||
|
|
||||||
if (!ghes_estatus_cached(ghes->estatus)) {
|
if (!ghes_estatus_cached(estatus)) {
|
||||||
if (ghes_print_estatus(NULL, ghes->generic, ghes->estatus))
|
if (ghes_print_estatus(NULL, ghes->generic, estatus))
|
||||||
ghes_estatus_cache_add(ghes->generic, ghes->estatus);
|
ghes_estatus_cache_add(ghes->generic, estatus);
|
||||||
}
|
}
|
||||||
ghes_do_proc(ghes, ghes->estatus);
|
ghes_do_proc(ghes, estatus);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ghes_clear_estatus(ghes);
|
ghes_clear_estatus(ghes, estatus, buf_paddr, FIX_APEI_GHES_IRQ);
|
||||||
|
|
||||||
if (rc == -ENOENT)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* GHESv2 type HEST entries introduce support for error acknowledgment,
|
|
||||||
* so only acknowledge the error if this support is present.
|
|
||||||
*/
|
|
||||||
if (is_hest_type_generic_v2(ghes))
|
|
||||||
return ghes_ack_error(ghes->generic_v2);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -751,8 +755,11 @@ static void ghes_add_timer(struct ghes *ghes)
|
||||||
static void ghes_poll_func(struct timer_list *t)
|
static void ghes_poll_func(struct timer_list *t)
|
||||||
{
|
{
|
||||||
struct ghes *ghes = from_timer(ghes, t, timer);
|
struct ghes *ghes = from_timer(ghes, t, timer);
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&ghes_notify_lock_irq, flags);
|
||||||
ghes_proc(ghes);
|
ghes_proc(ghes);
|
||||||
|
spin_unlock_irqrestore(&ghes_notify_lock_irq, flags);
|
||||||
if (!(ghes->flags & GHES_EXITING))
|
if (!(ghes->flags & GHES_EXITING))
|
||||||
ghes_add_timer(ghes);
|
ghes_add_timer(ghes);
|
||||||
}
|
}
|
||||||
|
@ -760,9 +767,12 @@ static void ghes_poll_func(struct timer_list *t)
|
||||||
static irqreturn_t ghes_irq_func(int irq, void *data)
|
static irqreturn_t ghes_irq_func(int irq, void *data)
|
||||||
{
|
{
|
||||||
struct ghes *ghes = data;
|
struct ghes *ghes = data;
|
||||||
|
unsigned long flags;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&ghes_notify_lock_irq, flags);
|
||||||
rc = ghes_proc(ghes);
|
rc = ghes_proc(ghes);
|
||||||
|
spin_unlock_irqrestore(&ghes_notify_lock_irq, flags);
|
||||||
if (rc)
|
if (rc)
|
||||||
return IRQ_NONE;
|
return IRQ_NONE;
|
||||||
|
|
||||||
|
@ -773,14 +783,17 @@ static int ghes_notify_hed(struct notifier_block *this, unsigned long event,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct ghes *ghes;
|
struct ghes *ghes;
|
||||||
|
unsigned long flags;
|
||||||
int ret = NOTIFY_DONE;
|
int ret = NOTIFY_DONE;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&ghes_notify_lock_irq, flags);
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
list_for_each_entry_rcu(ghes, &ghes_hed, list) {
|
list_for_each_entry_rcu(ghes, &ghes_hed, list) {
|
||||||
if (!ghes_proc(ghes))
|
if (!ghes_proc(ghes))
|
||||||
ret = NOTIFY_OK;
|
ret = NOTIFY_OK;
|
||||||
}
|
}
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
spin_unlock_irqrestore(&ghes_notify_lock_irq, flags);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -789,66 +802,20 @@ static struct notifier_block ghes_notifier_hed = {
|
||||||
.notifier_call = ghes_notify_hed,
|
.notifier_call = ghes_notify_hed,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_ACPI_APEI_SEA
|
|
||||||
static LIST_HEAD(ghes_sea);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return 0 only if one of the SEA error sources successfully reported an error
|
* Handlers for CPER records may not be NMI safe. For example,
|
||||||
* record sent from the firmware.
|
* memory_failure_queue() takes spinlocks and calls schedule_work_on().
|
||||||
*/
|
* In any NMI-like handler, memory from ghes_estatus_pool is used to save
|
||||||
int ghes_notify_sea(void)
|
* estatus, and added to the ghes_estatus_llist. irq_work_queue() causes
|
||||||
{
|
* ghes_proc_in_irq() to run in IRQ context where each estatus in
|
||||||
struct ghes *ghes;
|
* ghes_estatus_llist is processed.
|
||||||
int ret = -ENOENT;
|
*
|
||||||
|
* Memory from the ghes_estatus_pool is also used with the ghes_estatus_cache
|
||||||
rcu_read_lock();
|
* to suppress frequent messages.
|
||||||
list_for_each_entry_rcu(ghes, &ghes_sea, list) {
|
|
||||||
if (!ghes_proc(ghes))
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
rcu_read_unlock();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ghes_sea_add(struct ghes *ghes)
|
|
||||||
{
|
|
||||||
mutex_lock(&ghes_list_mutex);
|
|
||||||
list_add_rcu(&ghes->list, &ghes_sea);
|
|
||||||
mutex_unlock(&ghes_list_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ghes_sea_remove(struct ghes *ghes)
|
|
||||||
{
|
|
||||||
mutex_lock(&ghes_list_mutex);
|
|
||||||
list_del_rcu(&ghes->list);
|
|
||||||
mutex_unlock(&ghes_list_mutex);
|
|
||||||
synchronize_rcu();
|
|
||||||
}
|
|
||||||
#else /* CONFIG_ACPI_APEI_SEA */
|
|
||||||
static inline void ghes_sea_add(struct ghes *ghes) { }
|
|
||||||
static inline void ghes_sea_remove(struct ghes *ghes) { }
|
|
||||||
#endif /* CONFIG_ACPI_APEI_SEA */
|
|
||||||
|
|
||||||
#ifdef CONFIG_HAVE_ACPI_APEI_NMI
|
|
||||||
/*
|
|
||||||
* printk is not safe in NMI context. So in NMI handler, we allocate
|
|
||||||
* required memory from lock-less memory allocator
|
|
||||||
* (ghes_estatus_pool), save estatus into it, put them into lock-less
|
|
||||||
* list (ghes_estatus_llist), then delay printk into IRQ context via
|
|
||||||
* irq_work (ghes_proc_irq_work). ghes_estatus_size_request record
|
|
||||||
* required pool size by all NMI error source.
|
|
||||||
*/
|
*/
|
||||||
static struct llist_head ghes_estatus_llist;
|
static struct llist_head ghes_estatus_llist;
|
||||||
static struct irq_work ghes_proc_irq_work;
|
static struct irq_work ghes_proc_irq_work;
|
||||||
|
|
||||||
/*
|
|
||||||
* NMI may be triggered on any CPU, so ghes_in_nmi is used for
|
|
||||||
* having only one concurrent reader.
|
|
||||||
*/
|
|
||||||
static atomic_t ghes_in_nmi = ATOMIC_INIT(0);
|
|
||||||
|
|
||||||
static LIST_HEAD(ghes_nmi);
|
|
||||||
|
|
||||||
static void ghes_proc_in_irq(struct irq_work *irq_work)
|
static void ghes_proc_in_irq(struct irq_work *irq_work)
|
||||||
{
|
{
|
||||||
struct llist_node *llnode, *next;
|
struct llist_node *llnode, *next;
|
||||||
|
@ -905,96 +872,154 @@ static void ghes_print_queued_estatus(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save estatus for further processing in IRQ context */
|
static int ghes_in_nmi_queue_one_entry(struct ghes *ghes,
|
||||||
static void __process_error(struct ghes *ghes)
|
enum fixed_addresses fixmap_idx)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
|
struct acpi_hest_generic_status *estatus, tmp_header;
|
||||||
u32 len, node_len;
|
|
||||||
struct ghes_estatus_node *estatus_node;
|
struct ghes_estatus_node *estatus_node;
|
||||||
struct acpi_hest_generic_status *estatus;
|
u32 len, node_len;
|
||||||
|
u64 buf_paddr;
|
||||||
|
int sev, rc;
|
||||||
|
|
||||||
if (ghes_estatus_cached(ghes->estatus))
|
if (!IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG))
|
||||||
return;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
len = cper_estatus_len(ghes->estatus);
|
rc = __ghes_peek_estatus(ghes, &tmp_header, &buf_paddr, fixmap_idx);
|
||||||
|
if (rc) {
|
||||||
|
ghes_clear_estatus(ghes, &tmp_header, buf_paddr, fixmap_idx);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = __ghes_check_estatus(ghes, &tmp_header);
|
||||||
|
if (rc) {
|
||||||
|
ghes_clear_estatus(ghes, &tmp_header, buf_paddr, fixmap_idx);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = cper_estatus_len(&tmp_header);
|
||||||
node_len = GHES_ESTATUS_NODE_LEN(len);
|
node_len = GHES_ESTATUS_NODE_LEN(len);
|
||||||
|
|
||||||
estatus_node = (void *)gen_pool_alloc(ghes_estatus_pool, node_len);
|
estatus_node = (void *)gen_pool_alloc(ghes_estatus_pool, node_len);
|
||||||
if (!estatus_node)
|
if (!estatus_node)
|
||||||
return;
|
return -ENOMEM;
|
||||||
|
|
||||||
estatus_node->ghes = ghes;
|
estatus_node->ghes = ghes;
|
||||||
estatus_node->generic = ghes->generic;
|
estatus_node->generic = ghes->generic;
|
||||||
estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
|
estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
|
||||||
memcpy(estatus, ghes->estatus, len);
|
|
||||||
|
if (__ghes_read_estatus(estatus, buf_paddr, fixmap_idx, len)) {
|
||||||
|
ghes_clear_estatus(ghes, estatus, buf_paddr, fixmap_idx);
|
||||||
|
rc = -ENOENT;
|
||||||
|
goto no_work;
|
||||||
|
}
|
||||||
|
|
||||||
|
sev = ghes_severity(estatus->error_severity);
|
||||||
|
if (sev >= GHES_SEV_PANIC) {
|
||||||
|
ghes_print_queued_estatus();
|
||||||
|
__ghes_panic(ghes, estatus, buf_paddr, fixmap_idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
ghes_clear_estatus(ghes, &tmp_header, buf_paddr, fixmap_idx);
|
||||||
|
|
||||||
|
/* This error has been reported before, don't process it again. */
|
||||||
|
if (ghes_estatus_cached(estatus))
|
||||||
|
goto no_work;
|
||||||
|
|
||||||
llist_add(&estatus_node->llnode, &ghes_estatus_llist);
|
llist_add(&estatus_node->llnode, &ghes_estatus_llist);
|
||||||
#endif
|
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
no_work:
|
||||||
|
gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node,
|
||||||
|
node_len);
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ghes_in_nmi_spool_from_list(struct list_head *rcu_list,
|
||||||
|
enum fixed_addresses fixmap_idx)
|
||||||
|
{
|
||||||
|
int ret = -ENOENT;
|
||||||
|
struct ghes *ghes;
|
||||||
|
|
||||||
|
rcu_read_lock();
|
||||||
|
list_for_each_entry_rcu(ghes, rcu_list, list) {
|
||||||
|
if (!ghes_in_nmi_queue_one_entry(ghes, fixmap_idx))
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
rcu_read_unlock();
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG) && !ret)
|
||||||
|
irq_work_queue(&ghes_proc_irq_work);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_ACPI_APEI_SEA
|
||||||
|
static LIST_HEAD(ghes_sea);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return 0 only if one of the SEA error sources successfully reported an error
|
||||||
|
* record sent from the firmware.
|
||||||
|
*/
|
||||||
|
int ghes_notify_sea(void)
|
||||||
|
{
|
||||||
|
static DEFINE_RAW_SPINLOCK(ghes_notify_lock_sea);
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
raw_spin_lock(&ghes_notify_lock_sea);
|
||||||
|
rv = ghes_in_nmi_spool_from_list(&ghes_sea, FIX_APEI_GHES_SEA);
|
||||||
|
raw_spin_unlock(&ghes_notify_lock_sea);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ghes_sea_add(struct ghes *ghes)
|
||||||
|
{
|
||||||
|
mutex_lock(&ghes_list_mutex);
|
||||||
|
list_add_rcu(&ghes->list, &ghes_sea);
|
||||||
|
mutex_unlock(&ghes_list_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ghes_sea_remove(struct ghes *ghes)
|
||||||
|
{
|
||||||
|
mutex_lock(&ghes_list_mutex);
|
||||||
|
list_del_rcu(&ghes->list);
|
||||||
|
mutex_unlock(&ghes_list_mutex);
|
||||||
|
synchronize_rcu();
|
||||||
|
}
|
||||||
|
#else /* CONFIG_ACPI_APEI_SEA */
|
||||||
|
static inline void ghes_sea_add(struct ghes *ghes) { }
|
||||||
|
static inline void ghes_sea_remove(struct ghes *ghes) { }
|
||||||
|
#endif /* CONFIG_ACPI_APEI_SEA */
|
||||||
|
|
||||||
|
#ifdef CONFIG_HAVE_ACPI_APEI_NMI
|
||||||
|
/*
|
||||||
|
* NMI may be triggered on any CPU, so ghes_in_nmi is used for
|
||||||
|
* having only one concurrent reader.
|
||||||
|
*/
|
||||||
|
static atomic_t ghes_in_nmi = ATOMIC_INIT(0);
|
||||||
|
|
||||||
|
static LIST_HEAD(ghes_nmi);
|
||||||
|
|
||||||
static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
|
static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
struct ghes *ghes;
|
static DEFINE_RAW_SPINLOCK(ghes_notify_lock_nmi);
|
||||||
int sev, ret = NMI_DONE;
|
int ret = NMI_DONE;
|
||||||
|
|
||||||
if (!atomic_add_unless(&ghes_in_nmi, 1, 1))
|
if (!atomic_add_unless(&ghes_in_nmi, 1, 1))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
list_for_each_entry_rcu(ghes, &ghes_nmi, list) {
|
raw_spin_lock(&ghes_notify_lock_nmi);
|
||||||
if (ghes_read_estatus(ghes, 1)) {
|
if (!ghes_in_nmi_spool_from_list(&ghes_nmi, FIX_APEI_GHES_NMI))
|
||||||
ghes_clear_estatus(ghes);
|
ret = NMI_HANDLED;
|
||||||
continue;
|
raw_spin_unlock(&ghes_notify_lock_nmi);
|
||||||
} else {
|
|
||||||
ret = NMI_HANDLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
sev = ghes_severity(ghes->estatus->error_severity);
|
|
||||||
if (sev >= GHES_SEV_PANIC) {
|
|
||||||
oops_begin();
|
|
||||||
ghes_print_queued_estatus();
|
|
||||||
__ghes_panic(ghes);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ghes->flags & GHES_TO_CLEAR))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
__process_error(ghes);
|
|
||||||
ghes_clear_estatus(ghes);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
|
|
||||||
if (ret == NMI_HANDLED)
|
|
||||||
irq_work_queue(&ghes_proc_irq_work);
|
|
||||||
#endif
|
|
||||||
atomic_dec(&ghes_in_nmi);
|
atomic_dec(&ghes_in_nmi);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long ghes_esource_prealloc_size(
|
|
||||||
const struct acpi_hest_generic *generic)
|
|
||||||
{
|
|
||||||
unsigned long block_length, prealloc_records, prealloc_size;
|
|
||||||
|
|
||||||
block_length = min_t(unsigned long, generic->error_block_length,
|
|
||||||
GHES_ESTATUS_MAX_SIZE);
|
|
||||||
prealloc_records = max_t(unsigned long,
|
|
||||||
generic->records_to_preallocate, 1);
|
|
||||||
prealloc_size = min_t(unsigned long, block_length * prealloc_records,
|
|
||||||
GHES_ESOURCE_PREALLOC_MAX_SIZE);
|
|
||||||
|
|
||||||
return prealloc_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ghes_estatus_pool_shrink(unsigned long len)
|
|
||||||
{
|
|
||||||
ghes_estatus_pool_size_request -= PAGE_ALIGN(len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ghes_nmi_add(struct ghes *ghes)
|
static void ghes_nmi_add(struct ghes *ghes)
|
||||||
{
|
{
|
||||||
unsigned long len;
|
|
||||||
|
|
||||||
len = ghes_esource_prealloc_size(ghes->generic);
|
|
||||||
ghes_estatus_pool_expand(len);
|
|
||||||
mutex_lock(&ghes_list_mutex);
|
mutex_lock(&ghes_list_mutex);
|
||||||
if (list_empty(&ghes_nmi))
|
if (list_empty(&ghes_nmi))
|
||||||
register_nmi_handler(NMI_LOCAL, ghes_notify_nmi, 0, "ghes");
|
register_nmi_handler(NMI_LOCAL, ghes_notify_nmi, 0, "ghes");
|
||||||
|
@ -1004,8 +1029,6 @@ static void ghes_nmi_add(struct ghes *ghes)
|
||||||
|
|
||||||
static void ghes_nmi_remove(struct ghes *ghes)
|
static void ghes_nmi_remove(struct ghes *ghes)
|
||||||
{
|
{
|
||||||
unsigned long len;
|
|
||||||
|
|
||||||
mutex_lock(&ghes_list_mutex);
|
mutex_lock(&ghes_list_mutex);
|
||||||
list_del_rcu(&ghes->list);
|
list_del_rcu(&ghes->list);
|
||||||
if (list_empty(&ghes_nmi))
|
if (list_empty(&ghes_nmi))
|
||||||
|
@ -1016,24 +1039,79 @@ static void ghes_nmi_remove(struct ghes *ghes)
|
||||||
* freed after NMI handler finishes.
|
* freed after NMI handler finishes.
|
||||||
*/
|
*/
|
||||||
synchronize_rcu();
|
synchronize_rcu();
|
||||||
len = ghes_esource_prealloc_size(ghes->generic);
|
|
||||||
ghes_estatus_pool_shrink(len);
|
|
||||||
}
|
}
|
||||||
|
#else /* CONFIG_HAVE_ACPI_APEI_NMI */
|
||||||
|
static inline void ghes_nmi_add(struct ghes *ghes) { }
|
||||||
|
static inline void ghes_nmi_remove(struct ghes *ghes) { }
|
||||||
|
#endif /* CONFIG_HAVE_ACPI_APEI_NMI */
|
||||||
|
|
||||||
static void ghes_nmi_init_cxt(void)
|
static void ghes_nmi_init_cxt(void)
|
||||||
{
|
{
|
||||||
init_irq_work(&ghes_proc_irq_work, ghes_proc_in_irq);
|
init_irq_work(&ghes_proc_irq_work, ghes_proc_in_irq);
|
||||||
}
|
}
|
||||||
#else /* CONFIG_HAVE_ACPI_APEI_NMI */
|
|
||||||
static inline void ghes_nmi_add(struct ghes *ghes) { }
|
static int __ghes_sdei_callback(struct ghes *ghes,
|
||||||
static inline void ghes_nmi_remove(struct ghes *ghes) { }
|
enum fixed_addresses fixmap_idx)
|
||||||
static inline void ghes_nmi_init_cxt(void) { }
|
{
|
||||||
#endif /* CONFIG_HAVE_ACPI_APEI_NMI */
|
if (!ghes_in_nmi_queue_one_entry(ghes, fixmap_idx)) {
|
||||||
|
irq_work_queue(&ghes_proc_irq_work);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ghes_sdei_normal_callback(u32 event_num, struct pt_regs *regs,
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
static DEFINE_RAW_SPINLOCK(ghes_notify_lock_sdei_normal);
|
||||||
|
struct ghes *ghes = arg;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
raw_spin_lock(&ghes_notify_lock_sdei_normal);
|
||||||
|
err = __ghes_sdei_callback(ghes, FIX_APEI_GHES_SDEI_NORMAL);
|
||||||
|
raw_spin_unlock(&ghes_notify_lock_sdei_normal);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ghes_sdei_critical_callback(u32 event_num, struct pt_regs *regs,
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
static DEFINE_RAW_SPINLOCK(ghes_notify_lock_sdei_critical);
|
||||||
|
struct ghes *ghes = arg;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
raw_spin_lock(&ghes_notify_lock_sdei_critical);
|
||||||
|
err = __ghes_sdei_callback(ghes, FIX_APEI_GHES_SDEI_CRITICAL);
|
||||||
|
raw_spin_unlock(&ghes_notify_lock_sdei_critical);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int apei_sdei_register_ghes(struct ghes *ghes)
|
||||||
|
{
|
||||||
|
if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE))
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
return sdei_register_ghes(ghes, ghes_sdei_normal_callback,
|
||||||
|
ghes_sdei_critical_callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int apei_sdei_unregister_ghes(struct ghes *ghes)
|
||||||
|
{
|
||||||
|
if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE))
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
return sdei_unregister_ghes(ghes);
|
||||||
|
}
|
||||||
|
|
||||||
static int ghes_probe(struct platform_device *ghes_dev)
|
static int ghes_probe(struct platform_device *ghes_dev)
|
||||||
{
|
{
|
||||||
struct acpi_hest_generic *generic;
|
struct acpi_hest_generic *generic;
|
||||||
struct ghes *ghes = NULL;
|
struct ghes *ghes = NULL;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
int rc = -EINVAL;
|
int rc = -EINVAL;
|
||||||
|
|
||||||
|
@ -1064,6 +1142,13 @@ static int ghes_probe(struct platform_device *ghes_dev)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED:
|
||||||
|
if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE)) {
|
||||||
|
pr_warn(GHES_PFX "Generic hardware error source: %d notified via SDE Interface is not supported!\n",
|
||||||
|
generic->header.source_id);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ACPI_HEST_NOTIFY_LOCAL:
|
case ACPI_HEST_NOTIFY_LOCAL:
|
||||||
pr_warning(GHES_PFX "Generic hardware error source: %d notified via local interrupt is not supported!\n",
|
pr_warning(GHES_PFX "Generic hardware error source: %d notified via local interrupt is not supported!\n",
|
||||||
generic->header.source_id);
|
generic->header.source_id);
|
||||||
|
@ -1127,6 +1212,11 @@ static int ghes_probe(struct platform_device *ghes_dev)
|
||||||
case ACPI_HEST_NOTIFY_NMI:
|
case ACPI_HEST_NOTIFY_NMI:
|
||||||
ghes_nmi_add(ghes);
|
ghes_nmi_add(ghes);
|
||||||
break;
|
break;
|
||||||
|
case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED:
|
||||||
|
rc = apei_sdei_register_ghes(ghes);
|
||||||
|
if (rc)
|
||||||
|
goto err;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
@ -1136,7 +1226,9 @@ static int ghes_probe(struct platform_device *ghes_dev)
|
||||||
ghes_edac_register(ghes, &ghes_dev->dev);
|
ghes_edac_register(ghes, &ghes_dev->dev);
|
||||||
|
|
||||||
/* Handle any pending errors right away */
|
/* Handle any pending errors right away */
|
||||||
|
spin_lock_irqsave(&ghes_notify_lock_irq, flags);
|
||||||
ghes_proc(ghes);
|
ghes_proc(ghes);
|
||||||
|
spin_unlock_irqrestore(&ghes_notify_lock_irq, flags);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1150,6 +1242,7 @@ err:
|
||||||
|
|
||||||
static int ghes_remove(struct platform_device *ghes_dev)
|
static int ghes_remove(struct platform_device *ghes_dev)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
struct ghes *ghes;
|
struct ghes *ghes;
|
||||||
struct acpi_hest_generic *generic;
|
struct acpi_hest_generic *generic;
|
||||||
|
|
||||||
|
@ -1182,6 +1275,11 @@ static int ghes_remove(struct platform_device *ghes_dev)
|
||||||
case ACPI_HEST_NOTIFY_NMI:
|
case ACPI_HEST_NOTIFY_NMI:
|
||||||
ghes_nmi_remove(ghes);
|
ghes_nmi_remove(ghes);
|
||||||
break;
|
break;
|
||||||
|
case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED:
|
||||||
|
rc = apei_sdei_unregister_ghes(ghes);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
break;
|
break;
|
||||||
|
@ -1230,18 +1328,9 @@ static int __init ghes_init(void)
|
||||||
|
|
||||||
ghes_nmi_init_cxt();
|
ghes_nmi_init_cxt();
|
||||||
|
|
||||||
rc = ghes_estatus_pool_init();
|
|
||||||
if (rc)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
rc = ghes_estatus_pool_expand(GHES_ESTATUS_CACHE_AVG_SIZE *
|
|
||||||
GHES_ESTATUS_CACHE_ALLOCED_MAX);
|
|
||||||
if (rc)
|
|
||||||
goto err_pool_exit;
|
|
||||||
|
|
||||||
rc = platform_driver_register(&ghes_platform_driver);
|
rc = platform_driver_register(&ghes_platform_driver);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err_pool_exit;
|
goto err;
|
||||||
|
|
||||||
rc = apei_osc_setup();
|
rc = apei_osc_setup();
|
||||||
if (rc == 0 && osc_sb_apei_support_acked)
|
if (rc == 0 && osc_sb_apei_support_acked)
|
||||||
|
@ -1254,8 +1343,6 @@ static int __init ghes_init(void)
|
||||||
pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n");
|
pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err_pool_exit:
|
|
||||||
ghes_estatus_pool_exit();
|
|
||||||
err:
|
err:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <acpi/apei.h>
|
#include <acpi/apei.h>
|
||||||
|
#include <acpi/ghes.h>
|
||||||
|
|
||||||
#include "apei-internal.h"
|
#include "apei-internal.h"
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ static const int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {
|
||||||
[ACPI_HEST_TYPE_AER_BRIDGE] = sizeof(struct acpi_hest_aer_bridge),
|
[ACPI_HEST_TYPE_AER_BRIDGE] = sizeof(struct acpi_hest_aer_bridge),
|
||||||
[ACPI_HEST_TYPE_GENERIC_ERROR] = sizeof(struct acpi_hest_generic),
|
[ACPI_HEST_TYPE_GENERIC_ERROR] = sizeof(struct acpi_hest_generic),
|
||||||
[ACPI_HEST_TYPE_GENERIC_ERROR_V2] = sizeof(struct acpi_hest_generic_v2),
|
[ACPI_HEST_TYPE_GENERIC_ERROR_V2] = sizeof(struct acpi_hest_generic_v2),
|
||||||
|
[ACPI_HEST_TYPE_IA32_DEFERRED_CHECK] = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int hest_esrc_len(struct acpi_hest_header *hest_hdr)
|
static int hest_esrc_len(struct acpi_hest_header *hest_hdr)
|
||||||
|
@ -75,6 +77,11 @@ static int hest_esrc_len(struct acpi_hest_header *hest_hdr)
|
||||||
mc = (struct acpi_hest_ia_machine_check *)hest_hdr;
|
mc = (struct acpi_hest_ia_machine_check *)hest_hdr;
|
||||||
len = sizeof(*mc) + mc->num_hardware_banks *
|
len = sizeof(*mc) + mc->num_hardware_banks *
|
||||||
sizeof(struct acpi_hest_ia_error_bank);
|
sizeof(struct acpi_hest_ia_error_bank);
|
||||||
|
} 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);
|
||||||
}
|
}
|
||||||
BUG_ON(len == -1);
|
BUG_ON(len == -1);
|
||||||
|
|
||||||
|
@ -203,6 +210,11 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count)
|
||||||
rc = apei_hest_parse(hest_parse_ghes, &ghes_arr);
|
rc = apei_hest_parse(hest_parse_ghes, &ghes_arr);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
rc = ghes_estatus_pool_init(ghes_count);
|
||||||
|
if (rc)
|
||||||
|
goto err;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
kfree(ghes_arr.ghes_devs);
|
kfree(ghes_arr.ghes_devs);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -251,7 +263,9 @@ void __init acpi_hest_init(void)
|
||||||
rc = apei_hest_parse(hest_parse_ghes_count, &ghes_count);
|
rc = apei_hest_parse(hest_parse_ghes_count, &ghes_count);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
rc = hest_ghes_dev_register(ghes_count);
|
|
||||||
|
if (ghes_count)
|
||||||
|
rc = hest_ghes_dev_register(ghes_count);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Copyright (C) 2017 Arm Ltd.
|
// Copyright (C) 2017 Arm Ltd.
|
||||||
#define pr_fmt(fmt) "sdei: " fmt
|
#define pr_fmt(fmt) "sdei: " fmt
|
||||||
|
|
||||||
|
#include <acpi/ghes.h>
|
||||||
#include <linux/acpi.h>
|
#include <linux/acpi.h>
|
||||||
#include <linux/arm_sdei.h>
|
#include <linux/arm_sdei.h>
|
||||||
#include <linux/arm-smccc.h>
|
#include <linux/arm-smccc.h>
|
||||||
|
@ -887,6 +888,73 @@ static void sdei_smccc_hvc(unsigned long function_id,
|
||||||
arm_smccc_hvc(function_id, arg0, arg1, arg2, arg3, arg4, 0, 0, res);
|
arm_smccc_hvc(function_id, arg0, arg1, arg2, arg3, arg4, 0, 0, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,
|
||||||
|
sdei_event_callback *critical_cb)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
u64 result;
|
||||||
|
u32 event_num;
|
||||||
|
sdei_event_callback *cb;
|
||||||
|
|
||||||
|
if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES))
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
event_num = ghes->generic->notify.vector;
|
||||||
|
if (event_num == 0) {
|
||||||
|
/*
|
||||||
|
* Event 0 is reserved by the specification for
|
||||||
|
* SDEI_EVENT_SIGNAL.
|
||||||
|
*/
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_PRIORITY,
|
||||||
|
&result);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
if (result == SDEI_EVENT_PRIORITY_CRITICAL)
|
||||||
|
cb = critical_cb;
|
||||||
|
else
|
||||||
|
cb = normal_cb;
|
||||||
|
|
||||||
|
err = sdei_event_register(event_num, cb, ghes);
|
||||||
|
if (!err)
|
||||||
|
err = sdei_event_enable(event_num);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sdei_unregister_ghes(struct ghes *ghes)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int err;
|
||||||
|
u32 event_num = ghes->generic->notify.vector;
|
||||||
|
|
||||||
|
might_sleep();
|
||||||
|
|
||||||
|
if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES))
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The event may be running on another CPU. Disable it
|
||||||
|
* to stop new events, then try to unregister a few times.
|
||||||
|
*/
|
||||||
|
err = sdei_event_disable(event_num);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
err = sdei_event_unregister(event_num);
|
||||||
|
if (err != -EINPROGRESS)
|
||||||
|
break;
|
||||||
|
|
||||||
|
schedule();
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static int sdei_get_conduit(struct platform_device *pdev)
|
static int sdei_get_conduit(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
const char *method;
|
const char *method;
|
||||||
|
|
|
@ -546,19 +546,24 @@ EXPORT_SYMBOL_GPL(cper_estatus_check_header);
|
||||||
int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
|
int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
|
||||||
{
|
{
|
||||||
struct acpi_hest_generic_data *gdata;
|
struct acpi_hest_generic_data *gdata;
|
||||||
unsigned int data_len, gedata_len;
|
unsigned int data_len, record_size;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = cper_estatus_check_header(estatus);
|
rc = cper_estatus_check_header(estatus);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
data_len = estatus->data_length;
|
data_len = estatus->data_length;
|
||||||
|
|
||||||
apei_estatus_for_each_section(estatus, gdata) {
|
apei_estatus_for_each_section(estatus, gdata) {
|
||||||
gedata_len = acpi_hest_get_error_length(gdata);
|
if (sizeof(struct acpi_hest_generic_data) > data_len)
|
||||||
if (gedata_len > data_len - acpi_hest_get_size(gdata))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
data_len -= acpi_hest_get_record_size(gdata);
|
|
||||||
|
record_size = acpi_hest_get_record_size(gdata);
|
||||||
|
if (record_size > data_len)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
data_len -= record_size;
|
||||||
}
|
}
|
||||||
if (data_len)
|
if (data_len)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
* estatus: memory buffer for error status block, allocated during
|
* estatus: memory buffer for error status block, allocated during
|
||||||
* HEST parsing.
|
* HEST parsing.
|
||||||
*/
|
*/
|
||||||
#define GHES_TO_CLEAR 0x0001
|
|
||||||
#define GHES_EXITING 0x0002
|
#define GHES_EXITING 0x0002
|
||||||
|
|
||||||
struct ghes {
|
struct ghes {
|
||||||
|
@ -22,7 +21,6 @@ struct ghes {
|
||||||
struct acpi_hest_generic_v2 *generic_v2;
|
struct acpi_hest_generic_v2 *generic_v2;
|
||||||
};
|
};
|
||||||
struct acpi_hest_generic_status *estatus;
|
struct acpi_hest_generic_status *estatus;
|
||||||
u64 buffer_paddr;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
union {
|
union {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
|
@ -52,6 +50,8 @@ enum {
|
||||||
GHES_SEV_PANIC = 0x3,
|
GHES_SEV_PANIC = 0x3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int ghes_estatus_pool_init(int num_ghes);
|
||||||
|
|
||||||
/* From drivers/edac/ghes_edac.c */
|
/* From drivers/edac/ghes_edac.c */
|
||||||
|
|
||||||
#ifdef CONFIG_EDAC_GHES
|
#ifdef CONFIG_EDAC_GHES
|
||||||
|
|
|
@ -11,7 +11,11 @@ enum sdei_conduit_types {
|
||||||
CONDUIT_HVC,
|
CONDUIT_HVC,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include <acpi/ghes.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARM_SDE_INTERFACE
|
||||||
#include <asm/sdei.h>
|
#include <asm/sdei.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Arch code should override this to set the entry point from firmware... */
|
/* Arch code should override this to set the entry point from firmware... */
|
||||||
#ifndef sdei_arch_get_entry_point
|
#ifndef sdei_arch_get_entry_point
|
||||||
|
@ -39,6 +43,11 @@ int sdei_event_unregister(u32 event_num);
|
||||||
int sdei_event_enable(u32 event_num);
|
int sdei_event_enable(u32 event_num);
|
||||||
int sdei_event_disable(u32 event_num);
|
int sdei_event_disable(u32 event_num);
|
||||||
|
|
||||||
|
/* GHES register/unregister helpers */
|
||||||
|
int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,
|
||||||
|
sdei_event_callback *critical_cb);
|
||||||
|
int sdei_unregister_ghes(struct ghes *ghes);
|
||||||
|
|
||||||
#ifdef CONFIG_ARM_SDE_INTERFACE
|
#ifdef CONFIG_ARM_SDE_INTERFACE
|
||||||
/* For use by arch code when CPU hotplug notifiers are not appropriate. */
|
/* For use by arch code when CPU hotplug notifiers are not appropriate. */
|
||||||
int sdei_mask_local_cpu(void);
|
int sdei_mask_local_cpu(void);
|
||||||
|
|
|
@ -27,10 +27,10 @@
|
||||||
#include <asm/kvm_arm.h>
|
#include <asm/kvm_arm.h>
|
||||||
#include <asm/kvm_mmu.h>
|
#include <asm/kvm_mmu.h>
|
||||||
#include <asm/kvm_mmio.h>
|
#include <asm/kvm_mmio.h>
|
||||||
|
#include <asm/kvm_ras.h>
|
||||||
#include <asm/kvm_asm.h>
|
#include <asm/kvm_asm.h>
|
||||||
#include <asm/kvm_emulate.h>
|
#include <asm/kvm_emulate.h>
|
||||||
#include <asm/virt.h>
|
#include <asm/virt.h>
|
||||||
#include <asm/system_misc.h>
|
|
||||||
|
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
|
@ -1906,7 +1906,7 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run)
|
||||||
* For RAS the host kernel may handle this abort.
|
* For RAS the host kernel may handle this abort.
|
||||||
* There is no need to pass the error into the guest.
|
* There is no need to pass the error into the guest.
|
||||||
*/
|
*/
|
||||||
if (!handle_guest_sea(fault_ipa, kvm_vcpu_get_hsr(vcpu)))
|
if (!kvm_handle_guest_sea(fault_ipa, kvm_vcpu_get_hsr(vcpu)))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (unlikely(!is_iabt)) {
|
if (unlikely(!is_iabt)) {
|
||||||
|
|
Loading…
Reference in New Issue