All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH dovetail v2 0/4] riscv: dovetail: trap handling fixes
@ 2026-11-21 16:59 Tobias Schaffner
  2026-11-21 16:59 ` [PATCH dovetail v2 1/4] riscv: dovetail: do not notify traps again from do_trap() Tobias Schaffner
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Tobias Schaffner @ 2026-11-21 16:59 UTC (permalink / raw)
  To: xenomai; +Cc: rpm, jan.kiszka, florian.bezdeka, Tobias Schaffner

Hi all,

this series fixes the riscv trap handling of Dovetail.

Thanks to Jan for sharing his AI reviews on this which made me have
a look at this.

The bugs were verified by running a trap matrix test, which raises
every kind of trap from an out-of-band EVL thread, with a more detailed
oob_trap RV monitor from the Dovetail RV RFC enabled.

Testing was done on v7.3 with EVL under QEMU riscv64 and on a StarFive
VisionFive2: the trap matrix test, the libevl suite and kprobe tests
hitting out-of-band syscalls, IRQ handlers and nested faults all pass
with a clean kernel log and no monitor reaction. For 3/4, the oob_trap
monitor was extended to report an interrupt or a context switch while a
kernel trap over a context with hard irqs off runs, and the trap matrix
got kprobes whose fetch argument faults within the trap, in-band and
out-of-band, under timer interrupts: with v1 of that patch the monitor
reports every run, with v2 none.

Changes in v2:
 - Dropped "riscv: dovetail: do not nest the unknown trap handler in
   software checks": in favour of Jans changes that handle this for
   all architectures.
 - 3/4: Reworked. We inherit the hard irq state of the interrupted
   context from parents state instead of enabling hard irqs for kernel
   mode faults whenever in-band now. Thanks for the review @Florian

Thanks,
Tobias

Tobias Schaffner (4):
  riscv: dovetail: do not notify traps again from do_trap()
  riscv: dovetail: run kernel trap handlers the core did not demote for
  riscv: dovetail: inherit the hard irq state on kernel page faults
  riscv: dovetail: read the CFI trap value from the saved registers

 arch/riscv/kernel/traps.c | 51 ++++++++++++++++++---------------------
 arch/riscv/mm/fault.c     |  7 ++++--
 2 files changed, 28 insertions(+), 30 deletions(-)


base-commit: 2089e615c61844a111f5a09e80a6a7e2959e48f9
-- 
2.53.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH dovetail v2 1/4] riscv: dovetail: do not notify traps again from do_trap()
  2026-11-21 16:59 [PATCH dovetail v2 0/4] riscv: dovetail: trap handling fixes Tobias Schaffner
@ 2026-11-21 16:59 ` Tobias Schaffner
  2026-11-21 16:59 ` [PATCH dovetail v2 2/4] riscv: dovetail: run kernel trap handlers the core did not demote for Tobias Schaffner
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 15+ messages in thread
From: Tobias Schaffner @ 2026-11-21 16:59 UTC (permalink / raw)
  To: xenomai; +Cc: rpm, jan.kiszka, florian.bezdeka, Tobias Schaffner

do_trap() is called by trap handlers which already notified the
companion core. The nested mark_trap_exit() unwinds the trap before the
outer handler is done, which then runs with hard irqs off, or over the
out-of-band stage if the trap_exit handler switched back to it. Tracking
the owner frame of the notification does not catch this: do_trap() is
passed the frame of its caller.

Drop the nested notification.

Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
---
 arch/riscv/kernel/traps.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index 897fb63ff10b..e2d06cb87c6e 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -142,9 +142,6 @@ void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr)
 {
 	struct task_struct *tsk = current;
 
-	if (!mark_trap_entry(regs))
-		return;
-
 	if (show_unhandled_signals && unhandled_signal(tsk, signo)
 	    && printk_ratelimit()) {
 		pr_info("%s[%d]: unhandled signal %d code 0x%x at 0x" REG_FMT,
@@ -156,8 +153,6 @@ void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr)
 	}
 
 	force_sig_fault(signo, code, (void __user *)addr);
-
-	mark_trap_exit(regs);
 }
 
 static void do_trap_error(struct pt_regs *regs, int signo, int code,
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH dovetail v2 2/4] riscv: dovetail: run kernel trap handlers the core did not demote for
  2026-11-21 16:59 [PATCH dovetail v2 0/4] riscv: dovetail: trap handling fixes Tobias Schaffner
  2026-11-21 16:59 ` [PATCH dovetail v2 1/4] riscv: dovetail: do not notify traps again from do_trap() Tobias Schaffner
@ 2026-11-21 16:59 ` Tobias Schaffner
  2026-11-21 16:59 ` [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults Tobias Schaffner
  2026-11-21 16:59 ` [PATCH dovetail v2 4/4] riscv: dovetail: read the CFI trap value from the saved registers Tobias Schaffner
  3 siblings, 0 replies; 15+ messages in thread
From: Tobias Schaffner @ 2026-11-21 16:59 UTC (permalink / raw)
  To: xenomai; +Cc: rpm, jan.kiszka, florian.bezdeka, Tobias Schaffner

A kernel mode trap is skipped if the companion core leaves the current
context out-of-band. Kernel mode traps are notified from within
irqentry_nmi_enter(), where a core may not demote the current task (EVL
bails out on in_nmi()), so a kprobe, an access fault or a misaligned
access hit out-of-band in kernel mode is never handled and the faulting
instruction traps again forever.

Run the kernel handler regardless, as arm64 does. Only user mode traps
are still skipped, the core having to deal with those itself.

Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
---
 arch/riscv/kernel/traps.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index e2d06cb87c6e..a8e37ec27cc2 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -113,6 +113,11 @@ void die(struct pt_regs *regs, const char *str)
 		make_task_dead(SIGSEGV);
 }
 
+/*
+ * Kernel mode callers ignore the return value: skipping their handler
+ * would trap again on the same instruction, so it runs whether the
+ * core demoted us or not.
+ */
 static __always_inline
 bool mark_trap_entry(struct pt_regs *regs)
 {
@@ -183,10 +188,9 @@ asmlinkage __visible __trap_section void name(struct pt_regs *regs)		\
 		irqentry_exit_to_user_mode(regs);				\
 	} else {								\
 		irqentry_state_t state = irqentry_nmi_enter(regs);		\
-		if (mark_trap_entry(regs)) {					\
-			do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \
-			mark_trap_exit(regs);					\
-		}								\
+		mark_trap_entry(regs);						\
+		do_trap_error(regs, signo, code, regs->epc, "Oops - " str);	\
+		mark_trap_exit(regs);						\
 		irqentry_nmi_exit(regs, state);					\
 	}									\
 }
@@ -221,11 +225,11 @@ asmlinkage __visible __trap_section void do_trap_insn_illegal(struct pt_regs *re
 		irqentry_exit_to_user_mode(regs);
 	} else {
 		irqentry_state_t state = irqentry_nmi_enter(regs);
-		if (mark_trap_entry(regs)) {
-			do_trap_error(regs, SIGILL, ILL_ILLOPC, regs->epc,
-				      "Oops - illegal instruction");
-			mark_trap_exit(regs);
-		}
+
+		mark_trap_entry(regs);
+		do_trap_error(regs, SIGILL, ILL_ILLOPC, regs->epc,
+			      "Oops - illegal instruction");
+		mark_trap_exit(regs);
 		irqentry_nmi_exit(regs, state);
 	}
 }
@@ -262,8 +266,7 @@ static void do_trap_misaligned(struct pt_regs *regs, enum misaligned_access_type
 		local_irq_enable();
 	} else {
 		state = irqentry_nmi_enter(regs);
-		if (!mark_trap_entry(regs))
-			goto out;
+		mark_trap_entry(regs);
 	}
 
 	if (misaligned_handler[type].handler(regs))
@@ -366,10 +369,10 @@ asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs)
 		irqentry_exit_to_user_mode(regs);
 	} else {
 		irqentry_state_t state = irqentry_nmi_enter(regs);
-		if (mark_trap_entry(regs)) {
-			handle_break(regs);
-			mark_trap_exit(regs);
-		}
+
+		mark_trap_entry(regs);
+		handle_break(regs);
+		mark_trap_exit(regs);
 		irqentry_nmi_exit(regs, state);
 	}
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-21 16:59 [PATCH dovetail v2 0/4] riscv: dovetail: trap handling fixes Tobias Schaffner
  2026-11-21 16:59 ` [PATCH dovetail v2 1/4] riscv: dovetail: do not notify traps again from do_trap() Tobias Schaffner
  2026-11-21 16:59 ` [PATCH dovetail v2 2/4] riscv: dovetail: run kernel trap handlers the core did not demote for Tobias Schaffner
@ 2026-11-21 16:59 ` Tobias Schaffner
  2026-11-22 22:12   ` Florian Bezdeka
  2026-11-22 22:18   ` Florian Bezdeka
  2026-11-21 16:59 ` [PATCH dovetail v2 4/4] riscv: dovetail: read the CFI trap value from the saved registers Tobias Schaffner
  3 siblings, 2 replies; 15+ messages in thread
From: Tobias Schaffner @ 2026-11-21 16:59 UTC (permalink / raw)
  To: xenomai; +Cc: rpm, jan.kiszka, florian.bezdeka, Tobias Schaffner

A page fault may hit kernel code which runs with hard irqs off, e.g. a
kprobe whose fetch argument faults within the breakpoint trap. The fault
handler still enables hard irqs for every kernel mode fault, so an
interrupt may break into that code. If the fault is handled out-of-band,
the handler also unstalls the in-band stage over the out-of-band stage.

Enable hard irqs in handle_page_fault() only if the faulting code had
them on and we run in-band, and stall the in-band stage on exit only if
we run in-band.

Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
---
 arch/riscv/kernel/traps.c | 11 ++++-------
 arch/riscv/mm/fault.c     |  7 +++++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index a8e37ec27cc2..47799f18fa7d 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
 asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs)
 {
 	irqentry_state_t state = irqentry_enter(regs);
+	bool inband = mark_trap_entry(regs);
 
-	mark_trap_entry(regs);
-
-	BUG_ON(dovetail_debug() && !running_inband());
-
-	if (!user_mode(regs))
-		hard_cond_local_irq_enable();
+	BUG_ON(dovetail_debug() && !inband && user_mode(regs));
 
 	handle_page_fault(regs, state);
 
-	local_irq_disable();
+	if (inband)
+		local_irq_disable();
 
 	mark_trap_exit(regs);
 
diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index c5709112c346..f72b49d8f15a 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -317,8 +317,11 @@ void handle_page_fault(struct pt_regs *regs, irqentry_state_t state)
 
 	/* Enable interrupts if they were enabled in the parent context. */
 #ifdef CONFIG_IRQ_PIPELINE
-	if (state.stage_info != IRQENTRY_INBAND_STALLED)
-		local_irq_enable_full();
+	if (running_inband() && !regs_irqs_disabled(regs)) {
+		hard_local_irq_enable();
+		if (state.stage_info != IRQENTRY_INBAND_STALLED)
+			local_irq_enable();
+	}
 #else
 	if (!regs_irqs_disabled(regs))
 		local_irq_enable();
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH dovetail v2 4/4] riscv: dovetail: read the CFI trap value from the saved registers
  2026-11-21 16:59 [PATCH dovetail v2 0/4] riscv: dovetail: trap handling fixes Tobias Schaffner
                   ` (2 preceding siblings ...)
  2026-11-21 16:59 ` [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults Tobias Schaffner
@ 2026-11-21 16:59 ` Tobias Schaffner
  3 siblings, 0 replies; 15+ messages in thread
From: Tobias Schaffner @ 2026-11-21 16:59 UTC (permalink / raw)
  To: xenomai; +Cc: rpm, jan.kiszka, florian.bezdeka, Tobias Schaffner

handle_user_cfi_violation() reads CSR_TVAL after mark_trap_entry()
enabled hard irqs for the user mode trap. An interrupt taken in between
overwrites stval, so a CFI violation may be taken for an unknown
exception, or the other way around.

Use the trap value saved on exception entry.

Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
---
 arch/riscv/kernel/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index 47799f18fa7d..6de8a7ee04d9 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -433,7 +433,7 @@ void do_trap_ecall_u(struct pt_regs *regs)
 /* handle cfi violations */
 bool handle_user_cfi_violation(struct pt_regs *regs)
 {
-	unsigned long tval = csr_read(CSR_TVAL);
+	unsigned long tval = regs->badaddr;
 	bool is_fcfi = (tval == CFI_TVAL_FCFI_CODE && cpu_supports_indirect_br_lp_instr());
 	bool is_bcfi = (tval == CFI_TVAL_BCFI_CODE && cpu_supports_shadow_stack());
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-21 16:59 ` [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults Tobias Schaffner
@ 2026-11-22 22:12   ` Florian Bezdeka
  2026-11-22 22:18   ` Florian Bezdeka
  1 sibling, 0 replies; 15+ messages in thread
From: Florian Bezdeka @ 2026-11-22 22:12 UTC (permalink / raw)
  To: Tobias Schaffner, xenomai; +Cc: rpm, jan.kiszka

On Sat Nov 21, 2026 at 5:59 PM CET, Tobias Schaffner wrote:
> A page fault may hit kernel code which runs with hard irqs off, e.g. a
> kprobe whose fetch argument faults within the breakpoint trap. The fault
> handler still enables hard irqs for every kernel mode fault, so an
> interrupt may break into that code. If the fault is handled out-of-band,
> the handler also unstalls the in-band stage over the out-of-band stage.
>
> Enable hard irqs in handle_page_fault() only if the faulting code had
> them on and we run in-band, and stall the in-band stage on exit only if
> we run in-band.
>
> Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
> Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
> ---
>  arch/riscv/kernel/traps.c | 11 ++++-------
>  arch/riscv/mm/fault.c     |  7 +++++--
>  2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> index a8e37ec27cc2..47799f18fa7d 100644
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
>  asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs)
>  {
>  	irqentry_state_t state = irqentry_enter(regs);
> +	bool inband = mark_trap_entry(regs);
>  
> -	mark_trap_entry(regs);
> -
> -	BUG_ON(dovetail_debug() && !running_inband());
> -
> -	if (!user_mode(regs))
> -		hard_cond_local_irq_enable();
> +	BUG_ON(dovetail_debug() && !inband && user_mode(regs));
>  
>  	handle_page_fault(regs, state);
>  
> -	local_irq_disable();
> +	if (inband)
> +		local_irq_disable();
>  
>  	mark_trap_exit(regs);
>  
> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> index c5709112c346..f72b49d8f15a 100644
> --- a/arch/riscv/mm/fault.c
> +++ b/arch/riscv/mm/fault.c
> @@ -317,8 +317,11 @@ void handle_page_fault(struct pt_regs *regs, irqentry_state_t state)
>  
>  	/* Enable interrupts if they were enabled in the parent context. */
>  #ifdef CONFIG_IRQ_PIPELINE
> -	if (state.stage_info != IRQENTRY_INBAND_STALLED)
> -		local_irq_enable_full();
> +	if (running_inband() && !regs_irqs_disabled(regs)) {
> +		hard_local_irq_enable();
> +		if (state.stage_info != IRQENTRY_INBAND_STALLED)
> +			local_irq_enable();
> +	}

Is that aligned with any of the other architectures?

I'm asking because the pattern used here seems to have an ordering
problem.

Once hard_local_irq_enable() enabled the hard IRQs, hardware events
might come in, hitting a stalled inband stage. Means we log the events 
into the IRQ log.

Afterwards, we unstall the inband stage with local_irq_enable() call,
which will bring us full IRQ log synchronization.

local_irq_enable_full() would do it the other way around.
Unstall first, than IRQ enable at the hardware layer. That looks like
the proper ordering.

>  #else
>  	if (!regs_irqs_disabled(regs))
>  		local_irq_enable();


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-21 16:59 ` [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults Tobias Schaffner
  2026-11-22 22:12   ` Florian Bezdeka
@ 2026-11-22 22:18   ` Florian Bezdeka
  2026-11-23 11:39     ` Tobias Schaffner
  1 sibling, 1 reply; 15+ messages in thread
From: Florian Bezdeka @ 2026-11-22 22:18 UTC (permalink / raw)
  To: Tobias Schaffner, xenomai; +Cc: rpm, jan.kiszka

On Sat Nov 21, 2026 at 5:59 PM CET, Tobias Schaffner wrote:
> A page fault may hit kernel code which runs with hard irqs off, e.g. a
> kprobe whose fetch argument faults within the breakpoint trap. The fault
> handler still enables hard irqs for every kernel mode fault, so an
> interrupt may break into that code. If the fault is handled out-of-band,
> the handler also unstalls the in-band stage over the out-of-band stage.
>
> Enable hard irqs in handle_page_fault() only if the faulting code had
> them on and we run in-band, and stall the in-band stage on exit only if
> we run in-band.
>
> Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
> Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
> ---
>  arch/riscv/kernel/traps.c | 11 ++++-------
>  arch/riscv/mm/fault.c     |  7 +++++--
>  2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> index a8e37ec27cc2..47799f18fa7d 100644
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
>  asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs)
>  {
>  	irqentry_state_t state = irqentry_enter(regs);
> +	bool inband = mark_trap_entry(regs);
>  
> -	mark_trap_entry(regs);
> -
> -	BUG_ON(dovetail_debug() && !running_inband());
> -
> -	if (!user_mode(regs))
> -		hard_cond_local_irq_enable();
> +	BUG_ON(dovetail_debug() && !inband && user_mode(regs));
>  
>  	handle_page_fault(regs, state);
>  
> -	local_irq_disable();
> +	if (inband)
> +		local_irq_disable();
>  
>  	mark_trap_exit(regs);
>  
> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> index c5709112c346..f72b49d8f15a 100644
> --- a/arch/riscv/mm/fault.c
> +++ b/arch/riscv/mm/fault.c
> @@ -317,8 +317,11 @@ void handle_page_fault(struct pt_regs *regs, irqentry_state_t state)
>  
>  	/* Enable interrupts if they were enabled in the parent context. */
>  #ifdef CONFIG_IRQ_PIPELINE
> -	if (state.stage_info != IRQENTRY_INBAND_STALLED)
> -		local_irq_enable_full();
> +	if (running_inband() && !regs_irqs_disabled(regs)) {
> +		hard_local_irq_enable();
> +		if (state.stage_info != IRQENTRY_INBAND_STALLED)
> +			local_irq_enable();
> +	}

Is that part aligned with any of the other architectures?

I'm asking because it seems that the pattern used here has an ordering
problem.

Once we enabled hard IRQs with hard_local_irq_enable() hardware events
might come in, hitting an stalled inband stage. Means we log all the
events into the IRQ log.

When we unstall the inband stage with local_irq_enable(), that will
bring us a full IRQ log synchronization - over page fault handling.

As local_irq_enable_full() does it the other way around as well, I
think that the ordering is wrong.

If taken / aligned from/with an other arch: we should check that as well.

>  #else
>  	if (!regs_irqs_disabled(regs))
>  		local_irq_enable();


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-22 22:18   ` Florian Bezdeka
@ 2026-11-23 11:39     ` Tobias Schaffner
  2026-11-23 12:05       ` Florian Bezdeka
  0 siblings, 1 reply; 15+ messages in thread
From: Tobias Schaffner @ 2026-11-23 11:39 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai; +Cc: rpm, jan.kiszka

On 11/22/26 23:18, Florian Bezdeka wrote:
> On Sat Nov 21, 2026 at 5:59 PM CET, Tobias Schaffner wrote:
>> A page fault may hit kernel code which runs with hard irqs off, e.g. a
>> kprobe whose fetch argument faults within the breakpoint trap. The fault
>> handler still enables hard irqs for every kernel mode fault, so an
>> interrupt may break into that code. If the fault is handled out-of-band,
>> the handler also unstalls the in-band stage over the out-of-band stage.
>>
>> Enable hard irqs in handle_page_fault() only if the faulting code had
>> them on and we run in-band, and stall the in-band stage on exit only if
>> we run in-band.
>>
>> Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
>> Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
>> ---
>>   arch/riscv/kernel/traps.c | 11 ++++-------
>>   arch/riscv/mm/fault.c     |  7 +++++--
>>   2 files changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
>> index a8e37ec27cc2..47799f18fa7d 100644
>> --- a/arch/riscv/kernel/traps.c
>> +++ b/arch/riscv/kernel/traps.c
>> @@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
>>   asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs)
>>   {
>>   	irqentry_state_t state = irqentry_enter(regs);
>> +	bool inband = mark_trap_entry(regs);
>>   
>> -	mark_trap_entry(regs);
>> -
>> -	BUG_ON(dovetail_debug() && !running_inband());
>> -
>> -	if (!user_mode(regs))
>> -		hard_cond_local_irq_enable();
>> +	BUG_ON(dovetail_debug() && !inband && user_mode(regs));
>>   
>>   	handle_page_fault(regs, state);
>>   
>> -	local_irq_disable();
>> +	if (inband)
>> +		local_irq_disable();
>>   
>>   	mark_trap_exit(regs);
>>   
>> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
>> index c5709112c346..f72b49d8f15a 100644
>> --- a/arch/riscv/mm/fault.c
>> +++ b/arch/riscv/mm/fault.c
>> @@ -317,8 +317,11 @@ void handle_page_fault(struct pt_regs *regs, irqentry_state_t state)
>>   
>>   	/* Enable interrupts if they were enabled in the parent context. */
>>   #ifdef CONFIG_IRQ_PIPELINE
>> -	if (state.stage_info != IRQENTRY_INBAND_STALLED)
>> -		local_irq_enable_full();
>> +	if (running_inband() && !regs_irqs_disabled(regs)) {
>> +		hard_local_irq_enable();
>> +		if (state.stage_info != IRQENTRY_INBAND_STALLED)
>> +			local_irq_enable();
>> +	}
> 
> Is that part aligned with any of the other architectures?

Yes. This pattern is taken from cond_reenable_irqs_kernel() in
arch/x86/mm/fault.c

> I'm asking because it seems that the pattern used here has an ordering
> problem.
> 
> Once we enabled hard IRQs with hard_local_irq_enable() hardware events
> might come in, hitting an stalled inband stage. Means we log all the
> events into the IRQ log.
> 
> When we unstall the inband stage with local_irq_enable(), that will
> bring us a full IRQ log synchronization - over page fault handling.

Is this really a problem? We are handling the running_inband() case here.

Mainline is doing this at the same point to allow IRQ handlers to run
while page faulting. Why should we prevent handle this differently?
As long as hard IRQs have been enabled before this should be fine,
shouldn't it?

> As local_irq_enable_full() does it the other way around as well, I
> think that the ordering is wrong.
> 
> If taken / aligned from/with an other arch: we should check that as well.
> 
>>   #else
>>   	if (!regs_irqs_disabled(regs))
>>   		local_irq_enable();
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-23 11:39     ` Tobias Schaffner
@ 2026-11-23 12:05       ` Florian Bezdeka
  2026-11-23 12:26         ` Bezdeka, Florian
  2026-11-23 13:43         ` Tobias Schaffner
  0 siblings, 2 replies; 15+ messages in thread
From: Florian Bezdeka @ 2026-11-23 12:05 UTC (permalink / raw)
  To: Tobias Schaffner, xenomai; +Cc: rpm, jan.kiszka

On Mon, 2026-11-23 at 12:39 +0100, Tobias Schaffner wrote:
> On 11/22/26 23:18, Florian Bezdeka wrote:
> > On Sat Nov 21, 2026 at 5:59 PM CET, Tobias Schaffner wrote:
> > > A page fault may hit kernel code which runs with hard irqs off, e.g. a
> > > kprobe whose fetch argument faults within the breakpoint trap. The fault
> > > handler still enables hard irqs for every kernel mode fault, so an
> > > interrupt may break into that code. If the fault is handled out-of-band,
> > > the handler also unstalls the in-band stage over the out-of-band stage.
> > > 
> > > Enable hard irqs in handle_page_fault() only if the faulting code had
> > > them on and we run in-band, and stall the in-band stage on exit only if
> > > we run in-band.
> > > 
> > > Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
> > > Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
> > > ---
> > >   arch/riscv/kernel/traps.c | 11 ++++-------
> > >   arch/riscv/mm/fault.c     |  7 +++++--
> > >   2 files changed, 9 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> > > index a8e37ec27cc2..47799f18fa7d 100644
> > > --- a/arch/riscv/kernel/traps.c
> > > +++ b/arch/riscv/kernel/traps.c
> > > @@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
> > >   asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs)
> > >   {
> > >   	irqentry_state_t state = irqentry_enter(regs);
> > > +	bool inband = mark_trap_entry(regs);
> > >   
> > > -	mark_trap_entry(regs);
> > > -
> > > -	BUG_ON(dovetail_debug() && !running_inband());
> > > -
> > > -	if (!user_mode(regs))
> > > -		hard_cond_local_irq_enable();
> > > +	BUG_ON(dovetail_debug() && !inband && user_mode(regs));
> > >   
> > >   	handle_page_fault(regs, state);
> > >   
> > > -	local_irq_disable();
> > > +	if (inband)
> > > +		local_irq_disable();
> > >   
> > >   	mark_trap_exit(regs);

Below comes another hard_cond_local_irq_disable() call that is a
duplicate as already handled by mark_trap_exit(). => More code to be
removed.

> > >   
> > > diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> > > index c5709112c346..f72b49d8f15a 100644
> > > --- a/arch/riscv/mm/fault.c
> > > +++ b/arch/riscv/mm/fault.c
> > > @@ -317,8 +317,11 @@ void handle_page_fault(struct pt_regs *regs, irqentry_state_t state)
> > >   
> > >   	/* Enable interrupts if they were enabled in the parent context. */
> > >   #ifdef CONFIG_IRQ_PIPELINE
> > > -	if (state.stage_info != IRQENTRY_INBAND_STALLED)
> > > -		local_irq_enable_full();
> > > +	if (running_inband() && !regs_irqs_disabled(regs)) {
> > > +		hard_local_irq_enable();
> > > +		if (state.stage_info != IRQENTRY_INBAND_STALLED)
> > > +			local_irq_enable();
> > > +	}
> > 
> > Is that part aligned with any of the other architectures?
> 
> Yes. This pattern is taken from cond_reenable_irqs_kernel() in
> arch/x86/mm/fault.c

Let me check, but I think the entry code is a bit different on x86.

The original Linux code here is
 
	if (!regs_irqs_disabled(regs))
		local_irq_enable();

The question now is: Why do you still play around with hard IRQs? They
have already been enabled in mark_trap_entry(). => Remove the
hard_local_irq_enable() call, no? 

> 
> > I'm asking because it seems that the pattern used here has an ordering
> > problem.
> > 
> > Once we enabled hard IRQs with hard_local_irq_enable() hardware events
> > might come in, hitting an stalled inband stage. Means we log all the
> > events into the IRQ log.
> > 
> > When we unstall the inband stage with local_irq_enable(), that will
> > bring us a full IRQ log synchronization - over page fault handling.
> 
> Is this really a problem? We are handling the running_inband() case here.

In case of an IRQ storm we will not make any progress here. I remember a
discussion with Philippe, where I took the "hardware disablement first"
pattern with me. Let me search for it...

> 
> Mainline is doing this at the same point to allow IRQ handlers to run
> while page faulting. Why should we prevent handle this differently?
> As long as hard IRQs have been enabled before this should be fine,
> shouldn't it?
> 
> > As local_irq_enable_full() does it the other way around as well, I
> > think that the ordering is wrong.
> > 
> > If taken / aligned from/with an other arch: we should check that as well.
> > 
> > >   #else
> > >   	if (!regs_irqs_disabled(regs))
> > >   		local_irq_enable();
> > 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-23 12:05       ` Florian Bezdeka
@ 2026-11-23 12:26         ` Bezdeka, Florian
  2026-11-23 13:43         ` Tobias Schaffner
  1 sibling, 0 replies; 15+ messages in thread
From: Bezdeka, Florian @ 2026-11-23 12:26 UTC (permalink / raw)
  To: Schaffner, Tobias, xenomai@lists.linux.dev; +Cc: rpm@xenomai.org, Kiszka, Jan

On Mon, 2026-11-23 at 13:05 +0100, Florian Bezdeka wrote:
> > 
> > Yes. This pattern is taken from cond_reenable_irqs_kernel() in
> > arch/x86/mm/fault.c
> 
> Let me check, but I think the entry code is a bit different on x86.

Confirmed. cond_reenable_irqs_kernel() on x86 is called *before*
notifying the co-kernel. It's more or less the "replacement" for your
mark_trap_entry() on risc-v.

You copied it *after* the co-kernel notify, which breaks the ordering.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-23 12:05       ` Florian Bezdeka
  2026-11-23 12:26         ` Bezdeka, Florian
@ 2026-11-23 13:43         ` Tobias Schaffner
  2026-11-23 22:12           ` Florian Bezdeka
  1 sibling, 1 reply; 15+ messages in thread
From: Tobias Schaffner @ 2026-11-23 13:43 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai; +Cc: rpm, jan.kiszka

On 11/23/26 13:05, Florian Bezdeka wrote:
> On Mon, 2026-11-23 at 12:39 +0100, Tobias Schaffner wrote:
>> On 11/22/26 23:18, Florian Bezdeka wrote:
>>> On Sat Nov 21, 2026 at 5:59 PM CET, Tobias Schaffner wrote:
>>>> A page fault may hit kernel code which runs with hard irqs off, e.g. a
>>>> kprobe whose fetch argument faults within the breakpoint trap. The fault
>>>> handler still enables hard irqs for every kernel mode fault, so an
>>>> interrupt may break into that code. If the fault is handled out-of-band,
>>>> the handler also unstalls the in-band stage over the out-of-band stage.
>>>>
>>>> Enable hard irqs in handle_page_fault() only if the faulting code had
>>>> them on and we run in-band, and stall the in-band stage on exit only if
>>>> we run in-band.
>>>>
>>>> Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
>>>> Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
>>>> ---
>>>>    arch/riscv/kernel/traps.c | 11 ++++-------
>>>>    arch/riscv/mm/fault.c     |  7 +++++--
>>>>    2 files changed, 9 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
>>>> index a8e37ec27cc2..47799f18fa7d 100644
>>>> --- a/arch/riscv/kernel/traps.c
>>>> +++ b/arch/riscv/kernel/traps.c
>>>> @@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
>>>>    asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs)
>>>>    {
>>>>    	irqentry_state_t state = irqentry_enter(regs);
>>>> +	bool inband = mark_trap_entry(regs);
>>>>    
>>>> -	mark_trap_entry(regs);
>>>> -
>>>> -	BUG_ON(dovetail_debug() && !running_inband());
>>>> -
>>>> -	if (!user_mode(regs))
>>>> -		hard_cond_local_irq_enable();
>>>> +	BUG_ON(dovetail_debug() && !inband && user_mode(regs));
>>>>    
>>>>    	handle_page_fault(regs, state);
>>>>    
>>>> -	local_irq_disable();
>>>> +	if (inband)
>>>> +		local_irq_disable();
>>>>    
>>>>    	mark_trap_exit(regs);
> 
> Below comes another hard_cond_local_irq_disable() call that is a
> duplicate as already handled by mark_trap_exit(). => More code to be
> removed.

One is for user_mode and one for !user_mode().

>>>>    
>>>> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
>>>> index c5709112c346..f72b49d8f15a 100644
>>>> --- a/arch/riscv/mm/fault.c
>>>> +++ b/arch/riscv/mm/fault.c
>>>> @@ -317,8 +317,11 @@ void handle_page_fault(struct pt_regs *regs, irqentry_state_t state)
>>>>    
>>>>    	/* Enable interrupts if they were enabled in the parent context. */
>>>>    #ifdef CONFIG_IRQ_PIPELINE
>>>> -	if (state.stage_info != IRQENTRY_INBAND_STALLED)
>>>> -		local_irq_enable_full();
>>>> +	if (running_inband() && !regs_irqs_disabled(regs)) {
>>>> +		hard_local_irq_enable();
>>>> +		if (state.stage_info != IRQENTRY_INBAND_STALLED)
>>>> +			local_irq_enable();
>>>> +	}
>>>
>>> Is that part aligned with any of the other architectures?
>>
>> Yes. This pattern is taken from cond_reenable_irqs_kernel() in
>> arch/x86/mm/fault.c
> 
> Let me check, but I think the entry code is a bit different on x86.
> 
> The original Linux code here is
>   
> 	if (!regs_irqs_disabled(regs))
> 		local_irq_enable();
> 
> The question now is: Why do you still play around with hard IRQs? They
> have already been enabled in mark_trap_entry(). => Remove the
> hard_local_irq_enable() call, no?

Again: mark_trap_entry/exit only enables/disables hard IRQS if inband &&
user_mode. This covers kernel mode and is therefore similar to what x86
does. Ordering should not make that much of a difference here should it?
We just want to make sure that inband can handle its interrupts while
page faulting and that EVL is able to run even if inband is handling its
interrupts.

>>
>>> I'm asking because it seems that the pattern used here has an ordering
>>> problem.
>>>
>>> Once we enabled hard IRQs with hard_local_irq_enable() hardware events
>>> might come in, hitting an stalled inband stage. Means we log all the
>>> events into the IRQ log.
>>>
>>> When we unstall the inband stage with local_irq_enable(), that will
>>> bring us a full IRQ log synchronization - over page fault handling.
>>
>> Is this really a problem? We are handling the running_inband() case here.
> 
> In case of an IRQ storm we will not make any progress here. I remember a
> discussion with Philippe, where I took the "hardware disablement first"
> pattern with me. Let me search for it...
> 
>>
>> Mainline is doing this at the same point to allow IRQ handlers to run
>> while page faulting. Why should we prevent handle this differently?
>> As long as hard IRQs have been enabled before this should be fine,
>> shouldn't it?
>>
>>> As local_irq_enable_full() does it the other way around as well, I
>>> think that the ordering is wrong.
>>>
>>> If taken / aligned from/with an other arch: we should check that as well.
>>>
>>>>    #else
>>>>    	if (!regs_irqs_disabled(regs))
>>>>    		local_irq_enable();
>>>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-23 13:43         ` Tobias Schaffner
@ 2026-11-23 22:12           ` Florian Bezdeka
  2026-11-24 19:53             ` Tobias Schaffner
  0 siblings, 1 reply; 15+ messages in thread
From: Florian Bezdeka @ 2026-11-23 22:12 UTC (permalink / raw)
  To: Tobias Schaffner, xenomai; +Cc: rpm, jan.kiszka

On Mon, 2026-11-23 at 14:43 +0100, Tobias Schaffner wrote:
> On 11/23/26 13:05, Florian Bezdeka wrote:
> > On Mon, 2026-11-23 at 12:39 +0100, Tobias Schaffner wrote:
> > > On 11/22/26 23:18, Florian Bezdeka wrote:
> > > > On Sat Nov 21, 2026 at 5:59 PM CET, Tobias Schaffner wrote:
> > > > > A page fault may hit kernel code which runs with hard irqs off, e.g. a
> > > > > kprobe whose fetch argument faults within the breakpoint trap. The fault
> > > > > handler still enables hard irqs for every kernel mode fault, so an
> > > > > interrupt may break into that code. If the fault is handled out-of-band,
> > > > > the handler also unstalls the in-band stage over the out-of-band stage.
> > > > > 
> > > > > Enable hard irqs in handle_page_fault() only if the faulting code had
> > > > > them on and we run in-band, and stall the in-band stage on exit only if
> > > > > we run in-band.
> > > > > 
> > > > > Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
> > > > > Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
> > > > > ---
> > > > >    arch/riscv/kernel/traps.c | 11 ++++-------
> > > > >    arch/riscv/mm/fault.c     |  7 +++++--
> > > > >    2 files changed, 9 insertions(+), 9 deletions(-)
> > > > > 
> > > > > diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> > > > > index a8e37ec27cc2..47799f18fa7d 100644
> > > > > --- a/arch/riscv/kernel/traps.c
> > > > > +++ b/arch/riscv/kernel/traps.c
> > > > > @@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
> > > > >    asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs)
> > > > >    {
> > > > >    	irqentry_state_t state = irqentry_enter(regs);
> > > > > +	bool inband = mark_trap_entry(regs);
> > > > >    
> > > > > -	mark_trap_entry(regs);
> > > > > -
> > > > > -	BUG_ON(dovetail_debug() && !running_inband());
> > > > > -
> > > > > -	if (!user_mode(regs))
> > > > > -		hard_cond_local_irq_enable();
> > > > > +	BUG_ON(dovetail_debug() && !inband && user_mode(regs));
> > > > >    
> > > > >    	handle_page_fault(regs, state);
> > > > >    
> > > > > -	local_irq_disable();
> > > > > +	if (inband)
> > > > > +		local_irq_disable();
> > > > >    
> > > > >    	mark_trap_exit(regs);
> > 
> > Below comes another hard_cond_local_irq_disable() call that is a
> > duplicate as already handled by mark_trap_exit(). => More code to be
> > removed.
> 
> One is for user_mode and one for !user_mode().

Can't follow here, but I agree: Some on the confusion is/was on my side.
Let's bring back the complete sequence:

	mark_trap_entry(regs); [1]

	if (!user_mode(regs))
		hard_cond_local_irq_enable(); [2]

	handle_page_fault(regs, state); [3]

	local_irq_disable(); [4]

	mark_trap_exit(regs); [5]

	if (!user_mode(regs))
		hard_cond_local_irq_disable(); [6]

[1] and [5] open/close the trap handling section. Entry into this area
and exit from it should match. But: [2] is inside the section while it's
counterpart [6] is outside the section. That's a mismatch (even if the
code does the right thing, more later).

[2] and [6] must be in lock-step. In v2 only [2] has been removed on my
request, because it is a partial duplicate, right, but removal likely
leads to confusion.

[4] must only be called when running inband.

Now the most confusing part, at least on my end: My expectation was that
you follow the same pattern as x86 does. But that is not the case. The
page fault handler on x86 does not use mark_trap_entry/exit() at all.

That's why cond_reenable_irqs_{user,kernel} exist. That is - so to say -
the IRQ mask touching counterpart of mark_trap_{entry,exit}() on riscv.
The fault handler itself is directly calling oob_trap_notify() on x86.

hard IRQ enablement inside the page fault handler:
I went to x86 today and reviewed the code again, mostly to make sure
we're not following a broken pattern. Outcome: I consider the x86
implementation as correct.

The main logic (on x86):

1) Re-enable interrupts following the following rules:

   - Fault over user space: Enable hard IRQs and in addition,
     when running inband: enable inband IRQs 
     (see cond_reenable_irqs_user())

   - Fault over kernel space: Enable hard IRQs and in case the 
     inband stage was unstalled on fault entry: enable inband IRQs
     (see cond_reenable_irqs_kernel())

2) Notify the co-kernel, by calling oob_trap_notify()

3) Call the fault handler 

4) Restore IRQ state (see cond_disable_irqs())

Coming back to risc-v now: Starting in do_page_fault(), I see a
completely different order of things. Starting with mark_trap_entry()
being called which notifies the co-kernel first, without doing 1) as on
x86. At least the notification has to take place under the same
conditions as on other archs. Otherwise we might confuse the co-kernel.

I hope that helps (and makes sense).

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-23 22:12           ` Florian Bezdeka
@ 2026-11-24 19:53             ` Tobias Schaffner
  2026-11-25 11:13               ` Florian Bezdeka
  0 siblings, 1 reply; 15+ messages in thread
From: Tobias Schaffner @ 2026-11-24 19:53 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai; +Cc: rpm, jan.kiszka

On 11/23/26 23:12, Florian Bezdeka wrote:
> On Mon, 2026-11-23 at 14:43 +0100, Tobias Schaffner wrote:
>> On 11/23/26 13:05, Florian Bezdeka wrote:
>>> On Mon, 2026-11-23 at 12:39 +0100, Tobias Schaffner wrote:
>>>> On 11/22/26 23:18, Florian Bezdeka wrote:
>>>>> On Sat Nov 21, 2026 at 5:59 PM CET, Tobias Schaffner wrote:
>>>>>> A page fault may hit kernel code which runs with hard irqs off, e.g. a
>>>>>> kprobe whose fetch argument faults within the breakpoint trap. The fault
>>>>>> handler still enables hard irqs for every kernel mode fault, so an
>>>>>> interrupt may break into that code. If the fault is handled out-of-band,
>>>>>> the handler also unstalls the in-band stage over the out-of-band stage.
>>>>>>
>>>>>> Enable hard irqs in handle_page_fault() only if the faulting code had
>>>>>> them on and we run in-band, and stall the in-band stage on exit only if
>>>>>> we run in-band.
>>>>>>
>>>>>> Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
>>>>>> Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
>>>>>> ---
>>>>>>     arch/riscv/kernel/traps.c | 11 ++++-------
>>>>>>     arch/riscv/mm/fault.c     |  7 +++++--
>>>>>>     2 files changed, 9 insertions(+), 9 deletions(-)
>>>>>>
>>>>>> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
>>>>>> index a8e37ec27cc2..47799f18fa7d 100644
>>>>>> --- a/arch/riscv/kernel/traps.c
>>>>>> +++ b/arch/riscv/kernel/traps.c
>>>>>> @@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
>>>>>>     asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs)
>>>>>>     {
>>>>>>     	irqentry_state_t state = irqentry_enter(regs);
>>>>>> +	bool inband = mark_trap_entry(regs);
>>>>>>     
>>>>>> -	mark_trap_entry(regs);
>>>>>> -
>>>>>> -	BUG_ON(dovetail_debug() && !running_inband());
>>>>>> -
>>>>>> -	if (!user_mode(regs))
>>>>>> -		hard_cond_local_irq_enable();
>>>>>> +	BUG_ON(dovetail_debug() && !inband && user_mode(regs));
>>>>>>     
>>>>>>     	handle_page_fault(regs, state);
>>>>>>     
>>>>>> -	local_irq_disable();
>>>>>> +	if (inband)
>>>>>> +		local_irq_disable();
>>>>>>     
>>>>>>     	mark_trap_exit(regs);
>>>
>>> Below comes another hard_cond_local_irq_disable() call that is a
>>> duplicate as already handled by mark_trap_exit(). => More code to be
>>> removed.
>>
>> One is for user_mode and one for !user_mode().
> 
> Can't follow here, but I agree: Some on the confusion is/was on my side.
> Let's bring back the complete sequence:
> 
> 	mark_trap_entry(regs); [1]
> 
> 	if (!user_mode(regs))
> 		hard_cond_local_irq_enable(); [2]
> 
> 	handle_page_fault(regs, state); [3]
> 
> 	local_irq_disable(); [4]
> 
> 	mark_trap_exit(regs); [5]
> 
> 	if (!user_mode(regs))
> 		hard_cond_local_irq_disable(); [6]
> 
> [1] and [5] open/close the trap handling section. Entry into this area
> and exit from it should match. But: [2] is inside the section while it's
> counterpart [6] is outside the section. That's a mismatch (even if the
> code does the right thing, more later).
> 
> [2] and [6] must be in lock-step. In v2 only [2] has been removed on my
> request, because it is a partial duplicate, right, but removal likely
> leads to confusion.
> 
> [4] must only be called when running inband.
> 
> Now the most confusing part, at least on my end: My expectation was that
> you follow the same pattern as x86 does. But that is not the case. The
> page fault handler on x86 does not use mark_trap_entry/exit() at all.
> 
> That's why cond_reenable_irqs_{user,kernel} exist. That is - so to say -
> the IRQ mask touching counterpart of mark_trap_{entry,exit}() on riscv.
> The fault handler itself is directly calling oob_trap_notify() on x86.
> 
> hard IRQ enablement inside the page fault handler:
> I went to x86 today and reviewed the code again, mostly to make sure
> we're not following a broken pattern. Outcome: I consider the x86
> implementation as correct.
> 
> The main logic (on x86):
> 
> 1) Re-enable interrupts following the following rules:
> 
>     - Fault over user space: Enable hard IRQs and in addition,
>       when running inband: enable inband IRQs
>       (see cond_reenable_irqs_user())
> 
>     - Fault over kernel space: Enable hard IRQs and in case the
>       inband stage was unstalled on fault entry: enable inband IRQs
>       (see cond_reenable_irqs_kernel())
> 
> 2) Notify the co-kernel, by calling oob_trap_notify()
> 
> 3) Call the fault handler
> 
> 4) Restore IRQ state (see cond_disable_irqs())
> 
> Coming back to risc-v now: Starting in do_page_fault(), I see a
> completely different order of things. Starting with mark_trap_entry()
> being called which notifies the co-kernel first, without doing 1) as on
> x86. At least the notification has to take place under the same
> conditions as on other archs. Otherwise we might confuse the co-kernel.
> 
> I hope that helps (and makes sense).

You have a point regarding the ordering. Thanks for putting that much
effort in describing this in detail. That helped a lot.

I will have to spend some additional time to think this through.
When comparing both I also noticed that some kernel traps are not
notified at all in x86 and arm64. This will eventually make it a
bigger change than I expected it in the first place.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-24 19:53             ` Tobias Schaffner
@ 2026-11-25 11:13               ` Florian Bezdeka
  2026-11-27 12:25                 ` Tobias Schaffner
  0 siblings, 1 reply; 15+ messages in thread
From: Florian Bezdeka @ 2026-11-25 11:13 UTC (permalink / raw)
  To: Tobias Schaffner, xenomai; +Cc: rpm, jan.kiszka

On Tue, 2026-11-24 at 20:53 +0100, Tobias Schaffner wrote:
> On 11/23/26 23:12, Florian Bezdeka wrote:
> > On Mon, 2026-11-23 at 14:43 +0100, Tobias Schaffner wrote:
> > > On 11/23/26 13:05, Florian Bezdeka wrote:
> > > > On Mon, 2026-11-23 at 12:39 +0100, Tobias Schaffner wrote:
> > > > > On 11/22/26 23:18, Florian Bezdeka wrote:
> > > > > > On Sat Nov 21, 2026 at 5:59 PM CET, Tobias Schaffner wrote:
> > > > > > > A page fault may hit kernel code which runs with hard irqs off, e.g. a
> > > > > > > kprobe whose fetch argument faults within the breakpoint trap. The fault
> > > > > > > handler still enables hard irqs for every kernel mode fault, so an
> > > > > > > interrupt may break into that code. If the fault is handled out-of-band,
> > > > > > > the handler also unstalls the in-band stage over the out-of-band stage.
> > > > > > > 
> > > > > > > Enable hard irqs in handle_page_fault() only if the faulting code had
> > > > > > > them on and we run in-band, and stall the in-band stage on exit only if
> > > > > > > we run in-band.
> > > > > > > 
> > > > > > > Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
> > > > > > > Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
> > > > > > > ---
> > > > > > >     arch/riscv/kernel/traps.c | 11 ++++-------
> > > > > > >     arch/riscv/mm/fault.c     |  7 +++++--
> > > > > > >     2 files changed, 9 insertions(+), 9 deletions(-)
> > > > > > > 
> > > > > > > diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> > > > > > > index a8e37ec27cc2..47799f18fa7d 100644
> > > > > > > --- a/arch/riscv/kernel/traps.c
> > > > > > > +++ b/arch/riscv/kernel/traps.c
> > > > > > > @@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
> > > > > > >     asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs)
> > > > > > >     {
> > > > > > >     	irqentry_state_t state = irqentry_enter(regs);
> > > > > > > +	bool inband = mark_trap_entry(regs);
> > > > > > >     
> > > > > > > -	mark_trap_entry(regs);
> > > > > > > -
> > > > > > > -	BUG_ON(dovetail_debug() && !running_inband());
> > > > > > > -
> > > > > > > -	if (!user_mode(regs))
> > > > > > > -		hard_cond_local_irq_enable();
> > > > > > > +	BUG_ON(dovetail_debug() && !inband && user_mode(regs));
> > > > > > >     
> > > > > > >     	handle_page_fault(regs, state);
> > > > > > >     
> > > > > > > -	local_irq_disable();
> > > > > > > +	if (inband)
> > > > > > > +		local_irq_disable();
> > > > > > >     
> > > > > > >     	mark_trap_exit(regs);
> > > > 
> > > > Below comes another hard_cond_local_irq_disable() call that is a
> > > > duplicate as already handled by mark_trap_exit(). => More code to be
> > > > removed.
> > > 
> > > One is for user_mode and one for !user_mode().
> > 
> > Can't follow here, but I agree: Some on the confusion is/was on my side.
> > Let's bring back the complete sequence:
> > 
> > 	mark_trap_entry(regs); [1]
> > 
> > 	if (!user_mode(regs))
> > 		hard_cond_local_irq_enable(); [2]
> > 
> > 	handle_page_fault(regs, state); [3]
> > 
> > 	local_irq_disable(); [4]
> > 
> > 	mark_trap_exit(regs); [5]
> > 
> > 	if (!user_mode(regs))
> > 		hard_cond_local_irq_disable(); [6]
> > 
> > [1] and [5] open/close the trap handling section. Entry into this area
> > and exit from it should match. But: [2] is inside the section while it's
> > counterpart [6] is outside the section. That's a mismatch (even if the
> > code does the right thing, more later).
> > 
> > [2] and [6] must be in lock-step. In v2 only [2] has been removed on my
> > request, because it is a partial duplicate, right, but removal likely
> > leads to confusion.
> > 
> > [4] must only be called when running inband.
> > 
> > Now the most confusing part, at least on my end: My expectation was that
> > you follow the same pattern as x86 does. But that is not the case. The
> > page fault handler on x86 does not use mark_trap_entry/exit() at all.
> > 
> > That's why cond_reenable_irqs_{user,kernel} exist. That is - so to say -
> > the IRQ mask touching counterpart of mark_trap_{entry,exit}() on riscv.
> > The fault handler itself is directly calling oob_trap_notify() on x86.
> > 
> > hard IRQ enablement inside the page fault handler:
> > I went to x86 today and reviewed the code again, mostly to make sure
> > we're not following a broken pattern. Outcome: I consider the x86
> > implementation as correct.
> > 
> > The main logic (on x86):
> > 
> > 1) Re-enable interrupts following the following rules:
> > 
> >     - Fault over user space: Enable hard IRQs and in addition,
> >       when running inband: enable inband IRQs
> >       (see cond_reenable_irqs_user())
> > 
> >     - Fault over kernel space: Enable hard IRQs and in case the
> >       inband stage was unstalled on fault entry: enable inband IRQs
> >       (see cond_reenable_irqs_kernel())
> > 
> > 2) Notify the co-kernel, by calling oob_trap_notify()
> > 
> > 3) Call the fault handler
> > 
> > 4) Restore IRQ state (see cond_disable_irqs())
> > 
> > Coming back to risc-v now: Starting in do_page_fault(), I see a
> > completely different order of things. Starting with mark_trap_entry()
> > being called which notifies the co-kernel first, without doing 1) as on
> > x86. At least the notification has to take place under the same
> > conditions as on other archs. Otherwise we might confuse the co-kernel.
> > 
> > I hope that helps (and makes sense).
> 
> You have a point regarding the ordering. Thanks for putting that much
> effort in describing this in detail. That helped a lot.
> 
> I will have to spend some additional time to think this through.
> When comparing both I also noticed that some kernel traps are not
> notified at all in x86 and arm64. This will eventually make it a
> bigger change than I expected it in the first place.

Stay focused on riscv for the moment. I can have a look at the other
archs. What do you think is missing/odd? Any pointers?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults
  2026-11-25 11:13               ` Florian Bezdeka
@ 2026-11-27 12:25                 ` Tobias Schaffner
  0 siblings, 0 replies; 15+ messages in thread
From: Tobias Schaffner @ 2026-11-27 12:25 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai; +Cc: rpm, jan.kiszka

On 11/25/26 12:13, Florian Bezdeka wrote:
> On Tue, 2026-11-24 at 20:53 +0100, Tobias Schaffner wrote:
>> On 11/23/26 23:12, Florian Bezdeka wrote:
>>> On Mon, 2026-11-23 at 14:43 +0100, Tobias Schaffner wrote:
>>>> On 11/23/26 13:05, Florian Bezdeka wrote:
>>>>> On Mon, 2026-11-23 at 12:39 +0100, Tobias Schaffner wrote:
>>>>>> On 11/22/26 23:18, Florian Bezdeka wrote:
>>>>>>> On Sat Nov 21, 2026 at 5:59 PM CET, Tobias Schaffner wrote:
>>>>>>>> A page fault may hit kernel code which runs with hard irqs off, e.g. a
>>>>>>>> kprobe whose fetch argument faults within the breakpoint trap. The fault
>>>>>>>> handler still enables hard irqs for every kernel mode fault, so an
>>>>>>>> interrupt may break into that code. If the fault is handled out-of-band,
>>>>>>>> the handler also unstalls the in-band stage over the out-of-band stage.
>>>>>>>>
>>>>>>>> Enable hard irqs in handle_page_fault() only if the faulting code had
>>>>>>>> them on and we run in-band, and stall the in-band stage on exit only if
>>>>>>>> we run in-band.
>>>>>>>>
>>>>>>>> Fixes: 1d1fdeccecef ("riscv: dovetail: add core support")
>>>>>>>> Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
>>>>>>>> ---
>>>>>>>>      arch/riscv/kernel/traps.c | 11 ++++-------
>>>>>>>>      arch/riscv/mm/fault.c     |  7 +++++--
>>>>>>>>      2 files changed, 9 insertions(+), 9 deletions(-)
>>>>>>>>
>>>>>>>> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
>>>>>>>> index a8e37ec27cc2..47799f18fa7d 100644
>>>>>>>> --- a/arch/riscv/kernel/traps.c
>>>>>>>> +++ b/arch/riscv/kernel/traps.c
>>>>>>>> @@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *
>>>>>>>>      asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs)
>>>>>>>>      {
>>>>>>>>      	irqentry_state_t state = irqentry_enter(regs);
>>>>>>>> +	bool inband = mark_trap_entry(regs);
>>>>>>>>      
>>>>>>>> -	mark_trap_entry(regs);
>>>>>>>> -
>>>>>>>> -	BUG_ON(dovetail_debug() && !running_inband());
>>>>>>>> -
>>>>>>>> -	if (!user_mode(regs))
>>>>>>>> -		hard_cond_local_irq_enable();
>>>>>>>> +	BUG_ON(dovetail_debug() && !inband && user_mode(regs));
>>>>>>>>      
>>>>>>>>      	handle_page_fault(regs, state);
>>>>>>>>      
>>>>>>>> -	local_irq_disable();
>>>>>>>> +	if (inband)
>>>>>>>> +		local_irq_disable();
>>>>>>>>      
>>>>>>>>      	mark_trap_exit(regs);
>>>>>
>>>>> Below comes another hard_cond_local_irq_disable() call that is a
>>>>> duplicate as already handled by mark_trap_exit(). => More code to be
>>>>> removed.
>>>>
>>>> One is for user_mode and one for !user_mode().
>>>
>>> Can't follow here, but I agree: Some on the confusion is/was on my side.
>>> Let's bring back the complete sequence:
>>>
>>> 	mark_trap_entry(regs); [1]
>>>
>>> 	if (!user_mode(regs))
>>> 		hard_cond_local_irq_enable(); [2]
>>>
>>> 	handle_page_fault(regs, state); [3]
>>>
>>> 	local_irq_disable(); [4]
>>>
>>> 	mark_trap_exit(regs); [5]
>>>
>>> 	if (!user_mode(regs))
>>> 		hard_cond_local_irq_disable(); [6]
>>>
>>> [1] and [5] open/close the trap handling section. Entry into this area
>>> and exit from it should match. But: [2] is inside the section while it's
>>> counterpart [6] is outside the section. That's a mismatch (even if the
>>> code does the right thing, more later).
>>>
>>> [2] and [6] must be in lock-step. In v2 only [2] has been removed on my
>>> request, because it is a partial duplicate, right, but removal likely
>>> leads to confusion.
>>>
>>> [4] must only be called when running inband.
>>>
>>> Now the most confusing part, at least on my end: My expectation was that
>>> you follow the same pattern as x86 does. But that is not the case. The
>>> page fault handler on x86 does not use mark_trap_entry/exit() at all.
>>>
>>> That's why cond_reenable_irqs_{user,kernel} exist. That is - so to say -
>>> the IRQ mask touching counterpart of mark_trap_{entry,exit}() on riscv.
>>> The fault handler itself is directly calling oob_trap_notify() on x86.
>>>
>>> hard IRQ enablement inside the page fault handler:
>>> I went to x86 today and reviewed the code again, mostly to make sure
>>> we're not following a broken pattern. Outcome: I consider the x86
>>> implementation as correct.
>>>
>>> The main logic (on x86):
>>>
>>> 1) Re-enable interrupts following the following rules:
>>>
>>>      - Fault over user space: Enable hard IRQs and in addition,
>>>        when running inband: enable inband IRQs
>>>        (see cond_reenable_irqs_user())
>>>
>>>      - Fault over kernel space: Enable hard IRQs and in case the
>>>        inband stage was unstalled on fault entry: enable inband IRQs
>>>        (see cond_reenable_irqs_kernel())
>>>
>>> 2) Notify the co-kernel, by calling oob_trap_notify()
>>>
>>> 3) Call the fault handler
>>>
>>> 4) Restore IRQ state (see cond_disable_irqs())
>>>
>>> Coming back to risc-v now: Starting in do_page_fault(), I see a
>>> completely different order of things. Starting with mark_trap_entry()
>>> being called which notifies the co-kernel first, without doing 1) as on
>>> x86. At least the notification has to take place under the same
>>> conditions as on other archs. Otherwise we might confuse the co-kernel.
>>>
>>> I hope that helps (and makes sense).
>>
>> You have a point regarding the ordering. Thanks for putting that much
>> effort in describing this in detail. That helped a lot.
>>
>> I will have to spend some additional time to think this through.
>> When comparing both I also noticed that some kernel traps are not
>> notified at all in x86 and arm64. This will eventually make it a
>> bigger change than I expected it in the first place.
> 
> Stay focused on riscv for the moment. I can have a look at the other
> archs. What do you think is missing/odd? Any pointers?

Sorry for the late reply.

X86 and arm64 do not notify kernel pagefaults but tries to fix them
up and returns in this case. Seems I missed that and tried to handle
all page faults the same way.

Does the pattern below look good to you? This is nearer to the
implementations of the other architectures now.

It shows the overall Dovetail and EVL changes on top of vanilla
7.2 touching page faults. Thought this is easier to review and discuss
in this case but feel free to directly request the patches if this fits
your workflow better.

diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index 8c62c771a656..689861c7cf5e 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -413,14 +507,75 @@ asmlinkage __visible noinstr void 
do_page_fault(struct pt_regs *regs)
  {
         irqentry_state_t state = irqentry_enter(regs);

-       handle_page_fault(regs);
+       handle_page_fault(regs, state);

-       local_irq_disable();
+       /* Page fault handling might have reenabled interrupts. */
+       local_irq_disable_full();

         irqentry_exit(regs, state);
  }
  #endif


diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 04ed6f8acae4..483537214567 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -79,6 +79,7 @@ static void show_pte(unsigned long addr)
  static void die_kernel_fault(const char *msg, unsigned long addr,
  		struct pt_regs *regs)
  {
+	irq_pipeline_oops();
  	bust_spinlocks(1);

  	pr_alert("Unable to handle kernel %s at virtual address " REG_FMT 
"\n", msg,
@@ -111,6 +112,9 @@ static inline void no_context(struct pt_regs *regs, 
unsigned long addr)
  		msg = "paging request";
  	}

+	/* Dovetail: switch in-band for the oops. */
+	oob_trap_notify(regs->cause, regs);
+
  	die_kernel_fault(msg, addr, regs);
  }

@@ -275,7 +279,7 @@ static inline bool access_error(unsigned long cause, 
struct vm_area_struct *vma)
   * This routine handles page faults.  It determines the address and the
   * problem, and then passes it off to one of the appropriate routines.
   */
-void handle_page_fault(struct pt_regs *regs)
+void handle_page_fault(struct pt_regs *regs, irqentry_state_t state)
  {
  	struct task_struct *tsk;
  	struct vm_area_struct *vma;
@@ -314,9 +318,31 @@ void handle_page_fault(struct pt_regs *regs)
  		return;
  	}

+#ifdef CONFIG_IRQ_PIPELINE
+	/* Kernel addresses and hard irqs off code can only be fixed up. */
+	if (!user_mode(regs) &&
+	    (addr >= TASK_SIZE || regs_irqs_disabled(regs))) {
+		tsk->thread.bad_cause = cause;
+		no_context(regs, addr);
+		return;
+	}
+
+	/* Enable interrupts if they were enabled in the parent context. */
+	if (!regs_irqs_disabled(regs)) {
+		hard_local_irq_enable();
+		if (state.stage_info == IRQENTRY_INBAND_UNSTALLED)
+			local_irq_enable();
+	}
+
+	/* Unless it switches us in-band, the core handles the fault. */
+	oob_trap_notify(cause, regs);
+	if (!running_inband())
+		goto out;
+#else
  	/* Enable interrupts if they were enabled in the parent context. */
  	if (!regs_irqs_disabled(regs))
  		local_irq_enable();
+#endif

  	/*
  	 * If we're in an interrupt, have no user context, or are running
@@ -325,7 +351,7 @@ void handle_page_fault(struct pt_regs *regs)
  	if (unlikely(faulthandler_disabled() || !mm)) {
  		tsk->thread.bad_cause = cause;
  		no_context(regs, addr);
-		return;
+		goto out;
  	}

  	if (user_mode(regs))
@@ -333,7 +359,7 @@ void handle_page_fault(struct pt_regs *regs)

  	if (!user_mode(regs) && addr < TASK_SIZE && unlikely(!(regs->status & 
SR_SUM))) {
  		if (fixup_exception(regs))
-			return;
+			goto out;

  		die_kernel_fault("access to user memory without uaccess routines", 
addr, regs);
  	}
@@ -356,7 +382,7 @@ void handle_page_fault(struct pt_regs *regs)
  		count_vm_vma_lock_event(VMA_LOCK_SUCCESS);
  		tsk->thread.bad_cause = cause;
  		bad_area_nosemaphore(regs, SEGV_ACCERR, addr);
-		return;
+		goto out;
  	}

  	fault = handle_mm_fault(vma, addr, flags | FAULT_FLAG_VMA_LOCK, regs);
@@ -374,7 +400,7 @@ void handle_page_fault(struct pt_regs *regs)
  	if (fault_signal_pending(fault, regs)) {
  		if (!user_mode(regs))
  			no_context(regs, addr);
-		return;
+		goto out;
  	}
  lock_mmap:

@@ -383,7 +409,7 @@ void handle_page_fault(struct pt_regs *regs)
  	if (unlikely(!vma)) {
  		tsk->thread.bad_cause = cause;
  		bad_area_nosemaphore(regs, code, addr);
-		return;
+		goto out;
  	}

  	/*
@@ -395,7 +421,7 @@ void handle_page_fault(struct pt_regs *regs)
  	if (unlikely(access_error(cause, vma))) {
  		tsk->thread.bad_cause = cause;
  		bad_area(regs, mm, code, addr);
-		return;
+		goto out;
  	}

  	/*
@@ -413,12 +439,12 @@ void handle_page_fault(struct pt_regs *regs)
  	if (fault_signal_pending(fault, regs)) {
  		if (!user_mode(regs))
  			no_context(regs, addr);
-		return;
+		goto out;
  	}

  	/* The fault is fully completed (including releasing mmap lock) */
  	if (fault & VM_FAULT_COMPLETED)
-		return;
+		goto out;

  	if (unlikely(fault & VM_FAULT_RETRY)) {
  		flags |= FAULT_FLAG_TRIED;
@@ -437,7 +463,8 @@ void handle_page_fault(struct pt_regs *regs)
  	if (unlikely(fault & VM_FAULT_ERROR)) {
  		tsk->thread.bad_cause = cause;
  		mm_fault_error(regs, addr, fault);
-		return;
+		goto out;
  	}
-	return;
+out:
+	oob_trap_unwind(cause, regs);
  }

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-11-27 12:25 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21 16:59 [PATCH dovetail v2 0/4] riscv: dovetail: trap handling fixes Tobias Schaffner
2026-11-21 16:59 ` [PATCH dovetail v2 1/4] riscv: dovetail: do not notify traps again from do_trap() Tobias Schaffner
2026-11-21 16:59 ` [PATCH dovetail v2 2/4] riscv: dovetail: run kernel trap handlers the core did not demote for Tobias Schaffner
2026-11-21 16:59 ` [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults Tobias Schaffner
2026-11-22 22:12   ` Florian Bezdeka
2026-11-22 22:18   ` Florian Bezdeka
2026-11-23 11:39     ` Tobias Schaffner
2026-11-23 12:05       ` Florian Bezdeka
2026-11-23 12:26         ` Bezdeka, Florian
2026-11-23 13:43         ` Tobias Schaffner
2026-11-23 22:12           ` Florian Bezdeka
2026-11-24 19:53             ` Tobias Schaffner
2026-11-25 11:13               ` Florian Bezdeka
2026-11-27 12:25                 ` Tobias Schaffner
2026-11-21 16:59 ` [PATCH dovetail v2 4/4] riscv: dovetail: read the CFI trap value from the saved registers Tobias Schaffner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.