Skip to contentSkip to conversation

riscv: Establish entry state for kernel software-check exceptions

PATCH Superseded Jisheng Zhang 1 participant 1 message Nov 7 RISC-V

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Establish entry state for kernel software-check exceptions

The kernel-mode software-check exception path calls die() without performing the entry bookkeeping used by other kernel trap handlers. die() invokes diagnostics and notifiers which need the corresponding RCU and tracing state established.

Wrap the kernel fault handling with irqentry_nmi_enter() and irqentry_nmi_exit(), following the existing kernel trap paths.

Assisted-by LLM
---
 arch/riscv/kernel/traps.c | 3 +++
 1 file changed, 3 insertions(+)
arch/riscv/kernel/traps.c +3 -0
index f8292adda099..f28e03f98af0 100644
@@ -402,8 +402,11 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
 
 		irqentry_exit_to_user_mode(regs);
 	} else {
+		irqentry_state_t state = irqentry_nmi_enter(regs);
+
 		/* sw check exception coming from kernel is a bug in kernel */
 		die(regs, "Kernel BUG");
+		irqentry_nmi_exit(regs, state);
 	}
 }
 
Signature · 1 line
2.55.0