[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230704164003.GB83892@hirez.programming.kicks-ass.net>
Date: Tue, 4 Jul 2023 18:40:03 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: guoren@...nel.org
Cc: arnd@...db.de, palmer@...osinc.com, tglx@...utronix.de,
luto@...nel.org, conor.dooley@...rochip.com, heiko@...ech.de,
jszhang@...nel.org, lazyparser@...il.com, falcon@...ylab.org,
chenhuacai@...nel.org, apatel@...tanamicro.com,
atishp@...shpatra.org, mark.rutland@....com, bjorn@...nel.org,
palmer@...belt.com, bjorn@...osinc.com, daniel.thompson@...aro.org,
linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-riscv@...ts.infradead.org, stable@...r.kernel.org,
Guo Ren <guoren@...ux.alibaba.com>
Subject: Re: [PATCH] riscv: entry: Fixup do_trap_break from kernel side
On Sat, Jul 01, 2023 at 10:57:07PM -0400, guoren@...nel.org wrote:
> From: Guo Ren <guoren@...ux.alibaba.com>
>
> The irqentry_nmi_enter/exit would force the current context into in_interrupt.
> That would trigger the kernel to dead panic, but the kdb still needs "ebreak" to
> debug the kernel.
>
> Move irqentry_nmi_enter/exit to exception_enter/exit could correct handle_break
> of the kernel side.
This doesn't explain much if anything :/
I'm confused (probably because I don't know RISC-V very well), what's
EBREAK and how does it happen?
Specifically, if EBREAK can happen inside an local_irq_disable() region,
then the below change is actively wrong. Any exception/interrupt that
can happen while local_irq_disable() must be treated like an NMI.
If that makes kdb unhappy, fix kdb.
> Fixes: f0bddf50586d ("riscv: entry: Convert to generic entry")
> Reported-by: Daniel Thompson <daniel.thompson@...aro.org>
> Signed-off-by: Guo Ren <guoren@...ux.alibaba.com>
> Signed-off-by: Guo Ren <guoren@...nel.org>
> Cc: stable@...r.kernel.org
> ---
> arch/riscv/kernel/traps.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> index efc6b649985a..ed0eb9452f9e 100644
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -18,6 +18,7 @@
> #include <linux/irq.h>
> #include <linux/kexec.h>
> #include <linux/entry-common.h>
> +#include <linux/context_tracking.h>
>
> #include <asm/asm-prototypes.h>
> #include <asm/bug.h>
> @@ -257,11 +258,11 @@ 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);
> + enum ctx_state prev_state = exception_enter();
>
> handle_break(regs);
>
> - irqentry_nmi_exit(regs, state);
> + exception_exit(prev_state);
> }
> }
>
> --
> 2.36.1
>
Powered by blists - more mailing lists