From 0237d375de5fe8912b9e4134f45f7774a155b977 Mon Sep 17 00:00:00 2001 From: Magdalena Pastula Date: Fri, 21 Jun 2024 16:06:03 +0200 Subject: [PATCH] arch: riscv: add an option for empty spurious interrupt handler Add the possibility to disable fault handling in spurious interrupt handler on RISCs and replacce it with an infinite loop. Signed-off-by: Magdalena Pastula --- arch/Kconfig | 12 ++++++++++++ arch/riscv/core/irq_manage.c | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/arch/Kconfig b/arch/Kconfig index 5a7ceae93917cc..f5e48eed69d605 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -113,6 +113,7 @@ config RISCV select ARCH_IS_SET select ARCH_SUPPORTS_COREDUMP select ARCH_SUPPORTS_ROM_START if !SOC_FAMILY_ESPRESSIF_ESP32 + select ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS select ARCH_HAS_CODE_DATA_RELOCATION select ARCH_HAS_THREAD_LOCAL_STORAGE select IRQ_OFFLOAD_NESTED if IRQ_OFFLOAD @@ -608,6 +609,14 @@ config SIMPLIFIED_EXCEPTION_CODES down to the generic K_ERR_CPU_EXCEPTION, which makes testing code much more portable. +config EMPTY_IRQ_SPURIOUS + bool "Create empty spurious interrupt handler" + depends on ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS + help + This option changes body of spurious interrupt handler. When enabled, + handler contains only an infinite while loop, when disabled, handler + contains the whole Zephyr fault handling procedure. + endmenu # Interrupt configuration config INIT_ARCH_HW_AT_BOOT @@ -673,6 +682,9 @@ config ARCH_SUPPORTS_ARCH_HW_INIT config ARCH_SUPPORTS_ROM_START bool +config ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS + bool + config ARCH_HAS_EXTRA_EXCEPTION_INFO bool diff --git a/arch/riscv/core/irq_manage.c b/arch/riscv/core/irq_manage.c index 358b07534be69b..8ba7b615b42260 100644 --- a/arch/riscv/core/irq_manage.c +++ b/arch/riscv/core/irq_manage.c @@ -19,6 +19,12 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); FUNC_NORETURN void z_irq_spurious(const void *unused) { +#ifdef CONFIG_EMPTY_IRQ_SPURIOUS + while (1) { + } + + CODE_UNREACHABLE; +#else unsigned long mcause; ARG_UNUSED(unused); @@ -37,6 +43,7 @@ FUNC_NORETURN void z_irq_spurious(const void *unused) } #endif z_riscv_fatal_error(K_ERR_SPURIOUS_IRQ, NULL); +#endif /* CONFIG_EMPTY_IRQ_SPURIOUS */ } #ifdef CONFIG_DYNAMIC_INTERRUPTS