Add RAS support for RISC-V architecture
Subsystems (5)
cover Add RAS support for RISC-V architecture
This series implements the RAS (Reliability, Availability and Serviceability) support for RISC-V architecture using RISC-V RERI specification. It is conformant to ACPI platform error interfaces (APEI). It uses the highest priority Supervisor Software Events (SSE)[2] to deliver the hardware error events to the kernel. The SSE implemetation has already been merged in OpenSBI. Clement has sent a patch series for its implemenation in Linux kernel.[5]
The GHES driver framework is used as is with the following changes for RISC-V:
1. Register each ghes entry with SSE layer. Ghes notification vector is SSE event.
2. Add RISC-V specific entries for processor type and ISA string
3. Add fixmap indices GHES SSE Low and High Priority to help map and read from physical addresses present in GHES entry.
4. Other changes to build/configure the RAS support
How to Use:
----------
This RAS stack consists of Qemu[3], OpenSBI, EDK2[4], Linux kernel and devmem utility to inject and trigger errors. Qemu [Ref.] has support to emulate RISC-V RERI. The RAS agent is implemented in OpenSBI which creates CPER records. EDK2 generates HEST table and populates it with GHES entries with the help of OpenSBI.
Qemu Command:
------------
<qemu-dir>/build/qemu-system-riscv64 \
-s -accel tcg -m 4096 -smp 2 \
-cpu rv64,smepmp=false \
-serial mon:stdio \
-d guest_errors -D ./qemu.log \
-bios <opensbi-dir>/build/platform/generic/firmware/fw_dynamic.bin \
-monitor telnet:127.0.0.1:55555,server,nowait \
-device virtio-gpu-pci -full-screen \
-device qemu-xhci \
-device usb-kbd \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=<edk2-build-dir>/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=<edk2-build-dir>/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_VARS.fd \
-M virt,pflash0=pflash0,pflash1=pflash1,rpmi=true,reri=true,aia=aplic-imsic \
-kernel <kernel image> \
-initrd <rootfs image> \
-append "root=/dev/ram rw console=ttyS0 earlycon=uart8250,mmio,0x10000000"Error Injection & Triggering:
----------------------------
devmem 0x4010040 32 0x2a1
devmem 0x4010048 32 0x9001404
devmem 0x4010044 8 1
The above commands injects a TLB error on CPU 0.
Sample Output (CPU 0):
---------------------
[ 34.370282] {1}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1
[ 34.371375] {1}[Hardware Error]: event severity: recoverable
[ 34.372149] {1}[Hardware Error]: Error 0, type: recoverable
[ 34.372756] {1}[Hardware Error]: section_type: general processor error
[ 34.373357] {1}[Hardware Error]: processor_type: 3, RISCV
[ 34.373806] {1}[Hardware Error]: processor_isa: 6, RISCV64
[ 34.374294] {1}[Hardware Error]: error_type: 0x02
[ 34.374845] {1}[Hardware Error]: TLB error
[ 34.375448] {1}[Hardware Error]: operation: 1, data read
[ 34.376100] {1}[Hardware Error]: target_address: 0x0000000000000000References:
----------
[1] RERI Specification: https://github.com/riscv-non-isa/riscv-ras-eri/releases/download/v1.0/riscv-reri.pdf
[2] SSE Section in OpenSBI v3.0: https://github.com/riscv-non-isa/riscv-sbi-doc/releases/download/v3.0-rc3/riscv-sbi.pdf
[3] Qemu source (with RERI emulation support): https://github.com/ventanamicro/qemu.git (branch: dev-upstream)
[4] EDK2: https://github.com/ventanamicro/edk2.git (branch: dev-upstream)
[5] SSE Kernel Patches: https://lore.kernel.org/linux-riscv/[email protected]/T/
Himanshu Chauhan (10):
riscv: Define ioremap_cache for RISC-V
riscv: Define arch_apei_get_mem_attribute for RISC-V
acpi: Introduce SSE in HEST notification types
riscv: Add fixmap indices for GHES IRQ and SSE contexts
riscv: conditionally compile GHES NMI spool function
riscv: Add functions to register ghes having SSE notification
riscv: Add RISC-V entries in processor type and ISA strings
riscv: Introduce HEST SSE notification handlers
riscv: Add config option to enable APEI SSE handler
riscv: Enable APEI and NMI safe cmpxchg options required for RAS
arch/riscv/Kconfig | 2 + arch/riscv/include/asm/acpi.h | 20 ++++ arch/riscv/include/asm/fixmap.h | 8 ++ arch/riscv/include/asm/io.h | 3 + drivers/acpi/apei/Kconfig | 5 + drivers/acpi/apei/ghes.c | 102 +++++++++++++++++--- drivers/firmware/efi/cper.c | 3 + drivers/firmware/riscv/riscv_sse.c | 147 +++++++++++++++++++++++++++++ include/acpi/actbl1.h | 3 +- include/linux/riscv_sse.h | 15 +++ 10 files changed, 296 insertions(+), 12 deletions(-)
Signature · 1 line
2.43.0
RFC PATCH 1/10 riscv: Define ioremap_cache for RISC-V
bert and einj drivers use ioremap_cache for mapping entries but ioremap_cache is not defined for RISC-V.
--- arch/riscv/include/asm/io.h | 3 +++ 1 file changed, 3 insertions(+)
arch/riscv/include/asm/io.h +3 -0
@@ -30,6 +30,9 @@#define PCI_IOBASE ((void __iomem *)PCI_IO_START)#endif /* CONFIG_MMU */ +#define ioremap_cache (addr, size) \ + ((__force void *)ioremap_prot((addr), (size), _PAGE_KERNEL)) +/* * Emulation routines for the port-mapped IO space used by some PCI drivers. * These are defined as being "fully synchronous", but also "not guaranteed to
Signature · 1 line
2.43.0
Re: [RFC PATCH v1 01/10] riscv: Define ioremap_cache for RISC-V
Quoted 14 lines · Himanshu Chauhan
bert and einj drivers use
ioremap_cachefor mapping entries butioremap_cacheis not defined for RISC-V.Signed-off-by Himanshu Chauhan <[email protected]>--- arch/riscv/include/asm/io.h | 3 +++ 1 file changed, 3 insertions(+)arch/riscv/include/asm/io.h +0
-0
arch/riscv/include/asm/io.h line 35
Quoted 6 lines
arch/riscv/include/asm/io.h +3
-0@@ -30,6 +30,9 @@#define PCI_IOBASE ((void __iomem *)PCI_IO_START)#endif /* CONFIG_MMU */ +#define ioremap_cache (addr, size) \ + ((__force void *)ioremap_prot((addr), (size), _PAGE_KERNEL)) +
There is a compile error observed with this patch applied on the latest Linux-6.15-rcX kernel.
To fix compile error, we need the following change:
s/_PAGE_KERNEL/PAGE_KERNEL/
Regards,
Anup
RFC PATCH 2/10 riscv: Define arch_apei_get_mem_attribute for RISC-V
In reply to Himanshu Chauhanghes_map function uses arch_apei_get_mem_attribute to get the protection bits for a given physical address. These protection bits are then used to map the physical address.
--- arch/riscv/include/asm/acpi.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/riscv/include/asm/acpi.h +20 -0
@@ -27,6 +27,26 @@ extern int acpi_disabled;extern int acpi_noirq;extern int acpi_pci_disabled; +#ifdef CONFIG_ACPI_APEI +/* +* acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling +* IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode +* with a kernel command line parameter "acpi=nocmcoff". But we don't +* have this IA-32 specific feature on ARM64, this definition is only +* for compatibility. +*/ +#define acpi_disable_cmcff 1 +static inline pgprot_t arch_apei_get_mem_attribute (phys_addr_t addr) +{ +/* +* Until we have a way to look for EFI memory attributes. +*/ +return PAGE_KERNEL ; +} +#else /* CONFIG_ACPI_APEI */ +#define acpi_disable_cmcff 0 +#endif /* !CONFIG_ACPI_APEI */ +static inline void disable_acpi (void ) { acpi_disabled =1 ;
Signature · 1 line
2.43.0
Re: [RFC PATCH v1 02/10] riscv: Define arch_apei_get_mem_attribute for RISC-V
Quoted 14 lines · Himanshu Chauhan
ghes_mapfunction usesarch_apei_get_mem_attributeto get the protection bits for a given physical address. These protection bits are then used to map the physical address.Signed-off-by Himanshu Chauhan <[email protected]>--- arch/riscv/include/asm/acpi.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)arch/riscv/include/asm/acpi.h +0
-0
arch/riscv/include/asm/acpi.h extern int acpi_disabled; · line 35
Quoted 9 lines
arch/riscv/include/asm/acpi.h +6
-0@@ -27,6 +27,26 @@ extern int acpi_disabled;extern int acpi_noirq;extern int acpi_pci_disabled; +#ifdef CONFIG_ACPI_APEI +/* +* acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling +* IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode +* with a kernel command line parameter "acpi=nocmcoff". But we don't +* have this IA-32 specific feature on ARM64, this definition is only
Hi Himanshu
s/ARM/RISC-V
Thanks,
Clément
Quoted 17 lines
arch/riscv/include/asm/acpi.h +14
-0+* for compatibility. +*/ +#define acpi_disable_cmcff 1 +static inline pgprot_t arch_apei_get_mem_attribute (phys_addr_t addr) +{ +/* +* Until we have a way to look for EFI memory attributes. +*/ +return PAGE_KERNEL ; +} +#else /* CONFIG_ACPI_APEI */ +#define acpi_disable_cmcff 0 +#endif /* !CONFIG_ACPI_APEI */ +static inline void disable_acpi (void ) { acpi_disabled =1 ;
RFC PATCH 3/10 acpi: Introduce SSE in HEST notification types
In reply to Himanshu ChauhanIntroduce a new HEST notification type for RISC-V SSE events. The GHES entry's notification structure contains the notification to be used for a given error source. For error sources delivering events over SSE, it should contain the new SSE notification type.
--- include/acpi/actbl1.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/acpi/actbl1.h +2 -1
@@ -1515,7 +1515,8 @@ enum acpi_hest_notify_types {ACPI_HEST_NOTIFY_SEI =9 ,/* ACPI 6.1 */ ACPI_HEST_NOTIFY_GSIV =10 ,/* ACPI 6.1 */ ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED =11 ,/* ACPI 6.2 */ - ACPI_HEST_NOTIFY_RESERVED = 12 /* 12 and greater are reserved */ +ACPI_HEST_NOTIFY_SSE =12 ,/* RISCV SSE */ + ACPI_HEST_NOTIFY_RESERVED = 13 /* 13 and greater are reserved */ };/* Values for config_write_enable bitfield above */
Signature · 1 line
2.43.0
RFC PATCH 4/10 riscv: Add fixmap indices for GHES IRQ and SSE contexts
In reply to Himanshu ChauhanGHES error handling requires fixmap entries for IRQ notifications. Add fixmap indices for IRQ, SSE Low and High priority notifications.
--- arch/riscv/include/asm/fixmap.h | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/riscv/include/asm/fixmap.h +8 -0
@@ -38,6 +38,14 @@ enum fixed_addresses {FIX_TEXT_POKE0 ,FIX_EARLYCON_MEM_BASE , +#ifdef CONFIG_ACPI_APEI_GHES +/* Used for GHES mapping from assorted contexts */ +FIX_APEI_GHES_IRQ , +#ifdef CONFIG_RISCV_SSE +FIX_APEI_GHES_SSE_LOW_PRIORITY , +FIX_APEI_GHES_SSE_HIGH_PRIORITY , +#endif /* CONFIG_RISCV_SSE */ +#endif /* CONFIG_ACPI_APEI_GHES */ __end_of_permanent_fixed_addresses,/* * Temporary boot-time mappings, used by early_ioremap(),
Signature · 1 line
2.43.0
RFC PATCH 5/10 riscv: conditionally compile GHES NMI spool function
In reply to Himanshu ChauhanCompile ghes_in_nmi_spool_from_list only when NMI and SEA is enabled. Otherwise compilation fails with "defined but not used" error.
--- drivers/acpi/apei/ghes.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/acpi/apei/ghes.c +2 -0
@@ -1231,6 +1231,7 @@ static int ghes_in_nmi_queue_one_entry(struct ghes *ghes,return rc; } +#if defined(CONFIG_HAVE_ACPI_APEI_NMI ) || defined(CONFIG_ACPI_APEI_SEA )static int ghes_in_nmi_spool_from_list (struct list_head *rcu_list,enum fixed_addresses fixmap_idx) {
@@ -1249,6 +1250,7 @@ static int ghes_in_nmi_spool_from_list(struct list_head *rcu_list, return ret; } +#endif #ifdef CONFIG_ACPI_APEI_SEA static LIST_HEAD (ghes_sea);
Signature · 1 line
2.43.0
RFC PATCH 6/10 riscv: Add functions to register ghes having SSE notification
In reply to Himanshu ChauhanAdd functions to register the ghes entries which have SSE as notification type. The vector inside the ghes is the SSE event ID that should be registered.
--- drivers/firmware/riscv/riscv_sse.c | 147 +++++++++++++++++++++++++++++ include/linux/riscv_sse.h | 15 +++ 2 files changed, 162 insertions(+)
drivers/firmware/riscv/riscv_sse.c +147 -0
@@ -5,6 +5,8 @@#define pr_fmt (fmt) "sse: " fmt +#include <acpi/ghes.h> +#include <linux/acpi.h> #include <linux/cpu.h> #include <linux/cpuhotplug.h> #include <linux/cpu_pm.h>
@@ -689,3 +691,148 @@ static int __init sse_init(void)return ret; }arch_initcall (sse_init); + +struct sse_ghes_callback { +struct list_head head; +struct ghes *ghes; +sse_event_handler *callback; +}; + +struct sse_ghes_event_data { +struct list_head head; +u32 event_num; +struct list_head callback_list; +struct sse_event *event; +}; + +static DEFINE_SPINLOCK (sse_ghes_event_list_lock); +static LIST_HEAD (sse_ghes_event_list); + +static int sse_ghes_handler (u32 event_num,void *arg,struct pt_regs *regs) +{ +struct sse_ghes_event_data *ev_data = arg; +struct sse_ghes_callback *cb =NULL ; + +list_for_each_entry (cb, &ev_data->callback_list, head) { +if (cb && cb->ghes && cb->callback) { + cb->callback (ev_data->event_num, cb->ghes, regs); + } + } + +return 0 ; +} + +int sse_register_ghes (struct ghes *ghes,sse_event_handler *lo_cb, +sse_event_handler *hi_cb) +{ +struct sse_ghes_event_data *ev_data, *evd; +struct sse_ghes_callback *cb; +u32 ev_num; +int err; + +if (!sse_available) +return -EOPNOTSUPP ; +if (!ghes || !lo_cb || !hi_cb) +return -EINVAL ; + + ev_num = ghes->generic->notify.vector; + + ev_data =NULL ; +spin_lock (&sse_ghes_event_list_lock); +list_for_each_entry (evd, &sse_ghes_event_list, head) { +if (evd->event_num == ev_num) { + ev_data = evd; +break ; + } + } +spin_unlock (&sse_ghes_event_list_lock); + +if (!ev_data) { + ev_data =kzalloc (sizeof (*ev_data),GFP_KERNEL ); +if (!ev_data) +return -ENOMEM ; + +INIT_LIST_HEAD (&ev_data->head); + ev_data->event_num = ev_num; + +INIT_LIST_HEAD (&ev_data->callback_list); + + ev_data->event =sse_event_register (ev_num, ev_num, + sse_ghes_handler, ev_data); +if (IS_ERR (ev_data->event)) { +pr_err ("%s: Couldn't register event 0x%x\n" , __func__, ev_num); +kfree (ev_data); +return -ENOMEM ; + } + + err =sse_event_enable (ev_data->event); +if (err) { +pr_err ("%s: Couldn't enable event 0x%x\n" , __func__, ev_num); +sse_event_unregister (ev_data->event); +kfree (ev_data); +return err; + } + +spin_lock (&sse_ghes_event_list_lock); +list_add_tail (&ev_data->head, &sse_ghes_event_list); +spin_unlock (&sse_ghes_event_list_lock); + } + +list_for_each_entry (cb, &ev_data->callback_list, head) { +if (cb->ghes == ghes) +return -EALREADY ; + } + + cb =kzalloc (sizeof (*cb),GFP_KERNEL ); +if (!cb) +return -ENOMEM ; +INIT_LIST_HEAD (&cb->head); + cb->ghes = ghes; + cb->callback = lo_cb; +list_add_tail (&cb->head, &ev_data->callback_list); + +return 0 ; +} + +int sse_unregister_ghes (struct ghes *ghes) +{ +struct sse_ghes_event_data *ev_data, *tmp; +struct sse_ghes_callback *cb; +int free_ev_data =0 ; + +if (!ghes) +return -EINVAL ; + +spin_lock (&sse_ghes_event_list_lock); + +list_for_each_entry_safe (ev_data, tmp, &sse_ghes_event_list, head) { +list_for_each_entry (cb, &ev_data->callback_list, head) { +if (cb->ghes != ghes) +continue ; + +list_del (&cb->head); +kfree (cb); +break ; + } + +if (list_empty (&ev_data->callback_list)) + free_ev_data =1 ; + +if (free_ev_data) { +spin_unlock (&sse_ghes_event_list_lock); + +sse_event_disable (ev_data->event); +sse_event_unregister (ev_data->event); + ev_data->event =NULL ; + +spin_lock (&sse_ghes_event_list_lock); + +list_del (&ev_data->head); +kfree (ev_data); + } + } + +spin_unlock (&sse_ghes_event_list_lock); + +return 0 ; +}
include/linux/riscv_sse.h +15 -0
@@ -12,6 +12,8 @@struct sse_event ;struct pt_regs ; +struct ghes ; +typedef int (sse_event_handler )(u32 event_num,void *arg,struct pt_regs *regs);#ifdef CONFIG_RISCV_SSE
@@ -27,6 +29,9 @@ int sse_event_enable(struct sse_event *sse_evt);void sse_event_disable (struct sse_event *sse_evt); +int sse_register_ghes (struct ghes *ghes,sse_event_handler *lo_cb, +sse_event_handler *hi_cb); +int sse_unregister_ghes (struct ghes *ghes);#else static inline struct sse_event *sse_event_register(u32 event_num, u32 priority, sse_event_handler *handler,
@@ -50,6 +55,16 @@ static inline int sse_event_enable(struct sse_event *sse_evt)static inline void sse_event_disable (struct sse_event *sse_evt) {} +static inline int sse_register_ghes (struct ghes *ghes,sse_event_handler *lo_cb, +sse_event_handler *hi_cb) +{ +return -EOPNOTSUPP ; +} + +static inline int sse_unregister_ghes (struct ghes *ghes) +{ +return -EOPNOTSUPP ; +}#endif
Signature · 1 line
2.43.0
RFC PATCH 7/10 riscv: Add RISC-V entries in processor type and ISA strings
In reply to Himanshu Chauhan- Add RISCV in processor type
- Add RISCV32/64 in ISA
--- drivers/firmware/efi/cper.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/firmware/efi/cper.c +3 -0
@@ -110,6 +110,7 @@ static const char * const proc_type_strs[] = {"IA32/X64" ,"IA64" ,"ARM" , + "RISCV", }; static const char * const proc_isa_strs[] = {
@@ -118,6 +119,8 @@ static const char * const proc_isa_strs[] = {"X64" ,"ARM A32/T32" ,"ARM A64" , +"RISCV32" , + "RISCV64", }; const char * const cper_proc_error_type_strs[] = {
Signature · 1 line
2.43.0
RFC PATCH 8/10 riscv: Introduce HEST SSE notification handlers
In reply to Himanshu Chauhan- Functions to register a ghes entry with SSE
- Add Handlers for low/high priority events
- Call ghes common handler to handle an error event
--- drivers/acpi/apei/ghes.c | 100 ++++++++++++++++++++++++++++++++++----- 1 file changed, 89 insertions(+), 11 deletions(-)
drivers/acpi/apei/ghes.c +89 -11
@@ -17,6 +17,7 @@* Author: Huang Ying <[email protected]> */ +#include <linux/riscv_sse.h> #include <linux/arm_sdei.h> #include <linux/kernel.h> #include <linux/moduleparam.h>
@@ -97,6 +98,11 @@#define FIX_APEI_GHES_SDEI_CRITICAL __end_of_fixed_addresses#endif +#ifndef CONFIG_RISCV_SSE +#define FIX_APEI_GHES_SSE_LOW_PRIORITY __end_of_fixed_addresses +#define FIX_APEI_GHES_SSE_HIGH_PRIORITY __end_of_fixed_addresses +#endif +static ATOMIC_NOTIFIER_HEAD (ghes_report_chain);static inline bool is_hest_type_generic_v2 (struct ghes *ghes)
@@ -1405,6 +1411,63 @@ static int apei_sdei_unregister_ghes(struct ghes *ghes)return sdei_unregister_ghes (ghes); } +#if defined(CONFIG_ACPI_APEI_SSE ) +/* SSE Handlers */ +static int __ghes_sse_callback (struct ghes *ghes, +enum fixed_addresses fixmap_idx) +{ +if (!ghes_in_nmi_queue_one_entry (ghes, fixmap_idx)) { +irq_work_queue (&ghes_proc_irq_work); + +return 0 ; + } + +return -ENOENT ; +} + +/* Low priority */ +static int ghes_sse_lo_callback (u32 event_num,void *arg,struct pt_regs *regs) +{ +static DEFINE_RAW_SPINLOCK (ghes_notify_lock_sse_lo); +struct ghes *ghes = arg; +int err; + +raw_spin_lock (&ghes_notify_lock_sse_lo); + err =__ghes_sse_callback (ghes,FIX_APEI_GHES_SSE_LOW_PRIORITY ); +raw_spin_unlock (&ghes_notify_lock_sse_lo); + +return err; +} + +/* High priority */ +static int ghes_sse_hi_callback (u32 event_num,void *arg,struct pt_regs *regs) +{ +static DEFINE_RAW_SPINLOCK (ghes_notify_lock_sse_hi); +struct ghes *ghes = arg; +int err; + +raw_spin_lock (&ghes_notify_lock_sse_hi); + err =__ghes_sse_callback (ghes,FIX_APEI_GHES_SSE_HIGH_PRIORITY ); +raw_spin_unlock (&ghes_notify_lock_sse_hi); + +return err; +} + +static int apei_sse_register_ghes (struct ghes *ghes) +{ +return sse_register_ghes (ghes, ghes_sse_lo_callback, + ghes_sse_hi_callback); +} + +static int apei_sse_unregister_ghes (struct ghes *ghes) +{ +return sse_unregister_ghes (ghes); +} +#else /* CONFIG_ACPI_APEI_SSE */ +static int apei_sse_register_ghes (struct ghes *ghes) {return -ENOTSUPP ; } +static int apei_sse_unregister_ghes (struct ghes *ghes) {return -ENOTSUPP ; } +#endif +static int ghes_probe (struct platform_device *ghes_dev) {struct acpi_hest_generic *generic;
@@ -1451,6 +1514,15 @@ static int ghes_probe(struct platform_device *ghes_dev)pr_warn (GHES_PFX "Generic hardware error source: %d notified via local interrupt is not supported!\n" , generic->header.source_id); goto err; +case ACPI_HEST_NOTIFY_SSE : +if (!IS_ENABLED (CONFIG_ACPI_APEI_SSE )) { +pr_warn (GHES_PFX "Generic hardware error source: %d " +"notified via SSE is not supported\n" , + generic->header.source_id); + rc = -ENOTSUPP ; + goto err; + } +break ;default : pr_warn(FW_WARN GHES_PFX "Unknown notification type: %u for generic hardware error source: %d\n", generic->notify.type, generic->header.source_id);
@@ -1514,6 +1586,18 @@ static int ghes_probe(struct platform_device *ghes_dev)if (rc) goto err;break ; + +case ACPI_HEST_NOTIFY_SSE : + rc =apei_sse_register_ghes (ghes); +if (rc) { +pr_err (GHES_PFX "Failed to register for SSE notification" +" on vector %d\n" , + generic->notify.vector); + goto err; + } +pr_err (GHES_PFX "Registered SSE notification on vector %d\n" , + generic->notify.vector); +break ;default :BUG (); }
@@ -1543,7 +1627,6 @@ static int ghes_probe(struct platform_device *ghes_dev)static void ghes_remove (struct platform_device *ghes_dev) { -int rc;struct ghes *ghes;struct acpi_hest_generic *generic;
@@ -1577,16 +1660,11 @@ static void ghes_remove(struct platform_device *ghes_dev)ghes_nmi_remove (ghes);break ;case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED : - rc =apei_sdei_unregister_ghes (ghes); -if (rc) { -/* -* Returning early results in a resource leak, but we're -* only here if stopping the hardware failed. -*/ -dev_err (&ghes_dev->dev,"Failed to unregister ghes (%pe)\n" , -ERR_PTR (rc)); -return ; - } +apei_sdei_unregister_ghes (ghes); +break ; + +case ACPI_HEST_NOTIFY_SSE : +apei_sse_unregister_ghes (ghes);break ;default :BUG ();
Signature · 1 line
2.43.0
RFC PATCH 9/10 riscv: Add config option to enable APEI SSE handler
In reply to Himanshu ChauhanAPEI SSE handlers can be enabled/disabled with this config option. When enabled, the SSE registration is done for GHES entries having notification type set to SSE. When disabled, registration function return not supported error.
--- drivers/acpi/apei/Kconfig | 5 +++++ 1 file changed, 5 insertions(+)
drivers/acpi/apei/Kconfig +5 -0
@@ -45,6 +45,11 @@ config ACPI_APEI_SEA depends on ARM64 && ACPI_APEI_GHES default y +config ACPI_APEI_SSE + bool + depends on RISCV && RISCV_SSE && ACPI_APEI_GHES + default y + config ACPI_APEI_MEMORY_FAILURE bool "APEI memory error recovering support" depends on ACPI_APEI && MEMORY_FAILURE
Signature · 1 line
2.43.0
RFC PATCH 10/10 riscv: Enable APEI and NMI safe cmpxchg options required for RAS
In reply to Himanshu ChauhanEnable the APEI option so that APEI GHES options are visible. Enable SAFE_CMPXCHG option required for GHES error handling.
--- arch/riscv/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/riscv/Kconfig +2 -0
@@ -54,6 +54,7 @@ config RISCV select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_UBSAN select ARCH_HAS_VDSO_TIME_DATA + select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_KEEP_MEMBLOCK if ACPI select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if 64BIT && MMU select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
@@ -175,6 +176,7 @@ config RISCV select HAVE_MOVE_PUD select HAVE_PAGE_SIZE_4KB select HAVE_PCI + select HAVE_ACPI_APEI if ACPI select HAVE_PERF_EVENTS select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP
Signature · 1 line
2.43.0
Quoted 61 lines · Himanshu Chauhan
This series implements the RAS (Reliability, Availability and Serviceability) support for RISC-V architecture using RISC-V RERI specification. It is conformant to ACPI platform error interfaces (APEI). It uses the highest priority Supervisor Software Events (SSE)[2] to deliver the hardware error events to the kernel. The SSE implemetation has already been merged in OpenSBI. Clement has sent a patch series for its implemenation in Linux kernel.[5]
The GHES driver framework is used as is with the following changes for RISC-V:
1. Register each ghes entry with SSE layer. Ghes notification vector is SSE event.
2. Add RISC-V specific entries for processor type and ISA string
3. Add fixmap indices GHES SSE Low and High Priority to help map and read from physical addresses present in GHES entry.
4. Other changes to build/configure the RAS supportHow to Use:
----------
This RAS stack consists of Qemu[3], OpenSBI, EDK2[4], Linux kernel and devmem utility to inject and trigger errors. Qemu [Ref.] has support to emulate RISC-V RERI. The RAS agent is implemented in OpenSBI which creates CPER records. EDK2 generates HEST table and populates it with GHES entries with the help of OpenSBI.Qemu Command:
------------<qemu-dir>/build/qemu-system-riscv64 \ -s -accel tcg -m 4096 -smp 2 \ -cpu rv64,smepmp=false \ -serial mon:stdio \ -d guest_errors -D ./qemu.log \ -bios <opensbi-dir>/build/platform/generic/firmware/fw_dynamic.bin \ -monitor telnet:127.0.0.1:55555,server,nowait \ -device virtio-gpu-pci -full-screen \ -device qemu-xhci \ -device usb-kbd \ -blockdev node-name=pflash0,driver=file,read-only=on,filename=<edk2-build-dir>/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_CODE.fd \ -blockdev node-name=pflash1,driver=file,filename=<edk2-build-dir>/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_VARS.fd \ -M virt,pflash0=pflash0,pflash1=pflash1,rpmi=true,reri=true,aia=aplic-imsic \ -kernel <kernel image> \ -initrd <rootfs image> \ -append "root=/dev/ram rw console=ttyS0 earlycon=uart8250,mmio,0x10000000"Error Injection & Triggering:
----------------------------
devmem0x4010040320x2a1
devmem0x4010048320x9001404
devmem0x40100448 1The above commands injects a TLB error on CPU 0.
Sample Output (CPU 0):
---------------------[ 34.370282] {1}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1 [ 34.371375] {1}[Hardware Error]: event severity: recoverable [ 34.372149] {1}[Hardware Error]: Error 0, type: recoverable [ 34.372756] {1}[Hardware Error]: section_type: general processor error [ 34.373357] {1}[Hardware Error]: processor_type: 3, RISCV [ 34.373806] {1}[Hardware Error]: processor_isa: 6, RISCV64 [ 34.374294] {1}[Hardware Error]: error_type: 0x02 [ 34.374845] {1}[Hardware Error]: TLB error [ 34.375448] {1}[Hardware Error]: operation: 1, data read [ 34.376100] {1}[Hardware Error]: target_address: 0x0000000000000000
Quoted 7 lines
References:
----------
[1] RERI Specification: https://github.com/riscv-non-isa/riscv-ras-eri/releases/download/v1.0/riscv-reri.pdf
[2] SSE Section in OpenSBI v3.0: https://github.com/riscv-non-isa/riscv-sbi-doc/releases/download/v3.0-rc3/riscv-sbi.pdf
[3] Qemu source (with RERI emulation support): https://github.com/ventanamicro/qemu.git (branch: dev-upstream)
[4] EDK2: https://github.com/ventanamicro/edk2.git (branch: dev-upstream)
[5] SSE Kernel Patches: https://lore.kernel.org/linux-riscv/[email protected]/T/
Hi,
Thanks for this series.
I'm doing some work related to your patch. Besides SSE, I'm working on support for another notification type for synchronous hardware errors (e.g., on a poison read), which called Hardware Error Exception (HEE) in Dhaval Sharma's UEFI proposal[0] in PRS-TG. I have a patch for HEE support which I've sent out separately[1].
Perhaps we could merge my work into your patchset to bringing a complete RAS solution to the RISC-V architecture? Or, I'm also happy to wait for your patches to land and then continue my work on top.
Let me know what you think would be best.
Cheers,
Ruidong Tian
[0]: https://lists.riscv.org/g/tech-prs/topic/risc_v_ras_related_ecrs/113685653
[1]: https://lore.kernel.org/all/[email protected]/
Quoted 24 lines
Himanshu Chauhan (10):
riscv: Defineioremap_cachefor RISC-V
riscv: Definearch_apei_get_mem_attributefor RISC-V
acpi: Introduce SSE in HEST notification types
riscv: Add fixmap indices for GHES IRQ and SSE contexts
riscv: conditionally compile GHES NMI spool function
riscv: Add functions to register ghes having SSE notification
riscv: Add RISC-V entries in processor type and ISA strings
riscv: Introduce HEST SSE notification handlers
riscv: Add config option to enable APEI SSE handler
riscv: Enable APEI and NMI safe cmpxchg options required for RASarch/riscv/Kconfig | 2 + arch/riscv/include/asm/acpi.h | 20 ++++ arch/riscv/include/asm/fixmap.h | 8 ++ arch/riscv/include/asm/io.h | 3 + drivers/acpi/apei/Kconfig | 5 + drivers/acpi/apei/ghes.c | 102 +++++++++++++++++--- drivers/firmware/efi/cper.c | 3 + drivers/firmware/riscv/riscv_sse.c | 147 +++++++++++++++++++++++++++++ include/acpi/actbl1.h | 3 +- include/linux/riscv_sse.h | 15 +++ 10 files changed, 296 insertions(+), 12 deletions(-)