public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rui Qi" <qirui.001@bytedance.com>
To: "Conor Dooley" <conor@kernel.org>
Cc: <paul.walmsley@sifive.com>, <palmer@dabbelt.com>,
	 <aou@eecs.berkeley.edu>, <alex@ghiti.fr>,
	<cyrilbur@tenstorrent.com>,  <tglx@kernel.org>,
	<peterz@infradead.org>, <debug@rivosinc.com>,
	 <andybnac@gmail.com>, <charlie@rivosinc.com>,
	<geomatsi@gmail.com>,  <thuth@redhat.com>, <bjorn@rivosinc.com>,
	<songshuaishuai@tinylab.org>,  <martin@kaiser.cx>,
	<masahiroy@kernel.org>, <kees@kernel.org>,
	 <linux-arch@vger.kernel.org>, <linux-riscv@lists.infradead.org>,
	 <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] riscv: add system error interrupt handler support
Date: Mon, 2 Mar 2026 10:41:39 +0800	[thread overview]
Message-ID: <f4d46b2a-6375-4e86-8dc8-65753c1ca6ac@bytedance.com> (raw)
In-Reply-To: <20260227-scanner-trembling-5e41445f9e93@spud>

On 2/27/26 6:08 PM, Conor Dooley wrote:
> On Fri, Feb 27, 2026 at 03:54:39PM +0800, Rui Qi wrote:
>> On 2/26/26 5:22 PM, Conor Dooley wrote:
>>> On Thu, Feb 26, 2026 at 04:27:35PM +0800, Rui Qi wrote:
>>>> Add a system error interrupt handler for RISC-V that panics
>>>> the system when hardware errors are detected. The implementation includes:
>>>>
>>>> - Add IRQ_SYS_ERROR (23) interrupt definition to CSR header
>>>> - Implement sys_error.c module with panic handler
>>>> - Register per-CPU interrupt handler for system error interrupts
>>>> - Add module to kernel build system
>>>>
>>>> When a system error interrupt occurs, the handler immediately panics
>>>> the system with a descriptive message to ensure the error is properly
>>>> captured and the system is halted safely.
>>>>
>>>> Signed-off-by: Rui Qi <qirui.001@bytedance.com>
>>>> ---
>>>>  arch/riscv/include/asm/csr.h  |  4 +-
>>>>  arch/riscv/kernel/Makefile    |  1 +
>>>>  arch/riscv/kernel/sys_error.c | 80 +++++++++++++++++++++++++++++++++++
>>>>  include/linux/cpuhotplug.h    |  1 +
>>>>  4 files changed, 85 insertions(+), 1 deletion(-)
>>>>  create mode 100644 arch/riscv/kernel/sys_error.c
>>>>
>>>> diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h
>>>> index 31b8988f4488..1f43c25b07ed 100644
>>>> --- a/arch/riscv/include/asm/csr.h
>>>> +++ b/arch/riscv/include/asm/csr.h
>>>> @@ -99,7 +99,8 @@
>>>>  #define IRQ_M_EXT		11
>>>>  #define IRQ_S_GEXT		12
>>>>  #define IRQ_PMU_OVF		13
>>>> -#define IRQ_LOCAL_MAX		(IRQ_PMU_OVF + 1)
>>>> +#define IRQ_SYS_ERROR		23
>>>
>>> Hmmm, two problems I think with this. 23 is one of the interrupts that
>>> has been reserved for use with AIA. I don't think they use it right now,
>>> but in the future it might see use there.
>>>
>>> The first problem is kind of moot though, because reserving 16-23 for
>>> AIA is a retcon, and previously these interrupts were available custom
>>> use on any platform (as you have done here), so while it might be a
>>> system error on your platform, it could be something completely innocuous
>>> on mine!
>>>
>>> With that in mind, does having this in arch code make sense at all?
>>> Can this just be a normal driver, that'll only probe on your specific
>>> platform?
>>
>> Thanks for the comment.
>>
>> I checked the latest RISC-V Interrupt Spec (2025-03-12). In that
>> version, interrupts 16–23 are defined as architectural local interrupts,
>> and interrupt 23 is tentatively proposed for a “Bus or system error”
> 
> Right, tentative is kinda no use to either of us though. Do you have
> hardware that does this?
> 
>> type condition. That suggests this interrupt number is no longer just a
>> free, platform-defined slot — it now carries architectural intent and a
>> potential standardized meaning.
> 
> Emphasis on "potential", of course ;) Still a platform defined slot for
> anyone that doesn't implement AIA, I think...
> I don't understand the interaction between extensions and the priv spec
> here, since the priv spec still says that 16 and higher are platform
> specific.
> 
>> Given this context, my current implementation treats interrupt 23 as a
>> local condition that matches the spec’s intent for a system-level error
>> signal, rather than an arbitrary, custom platform interrupt. This seemed
>> reasonable as long as it aligns with the architectural semantics for
>> local interrupts.
>>
>> That said, I’m open to the concern about placing this handling in
>> arch/riscv, and I’d like to understand your preference: do you think
>> this should be entirely moved into platform-specific code, or would a
>> conditional, spec-aware arch implementation (e.g., gated on the presence
>> of the relevant AIA/local interrupt support) be acceptable? Please let
> 
> It can't be gated on AIA, because AIA isn't the extension that says that
> this is what interrupt 23 does (it specifically says that new extensions
> are expected to define the use of the three interrupts "proposes"), and
> we don't permit extension related stuff that is not frozen. I couldn't
> find an extension at any stage that set the behaviour in stone, are you
> aware of one? If one exists, a spec-aware arch implementation would be
> okay. If one does not, you'll have to make this specific to your
> platform until that extension shows up.
> 
>> me know what approach you’d suggest.

Thanks for the clarification — that makes sense.

You're right that AIA itself does not normatively define the semantics
of interrupt 23, and that the wording there is explicitly provisional. I
also understand the policy around not merging extension-related behavior
unless it is tied to a frozen specification.

My reasoning was based on the architectural direction indicated in the
interrupt spec, but I agree that “tentative” does not constitute a
stable architectural contract, and therefore isn't sufficient to justify
arch-level handling at this point.

Given that, I can move this into platform-specific code for now. If and
when a ratified extension formally assigns defined semantics to
interrupt 23, we could then revisit a spec-aware arch implementation
gated on that extension.

Please let me know if that approach aligns better with your expectations.

  reply	other threads:[~2026-03-02  2:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26  8:27 [PATCH] riscv: add system error interrupt handler support Rui Qi
2026-02-26  9:22 ` Conor Dooley
2026-02-27  7:54   ` Rui Qi
2026-02-27 10:08     ` Conor Dooley
2026-03-02  2:41       ` Rui Qi [this message]
2026-02-26 19:09 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f4d46b2a-6375-4e86-8dc8-65753c1ca6ac@bytedance.com \
    --to=qirui.001@bytedance.com \
    --cc=alex@ghiti.fr \
    --cc=andybnac@gmail.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=bjorn@rivosinc.com \
    --cc=charlie@rivosinc.com \
    --cc=conor@kernel.org \
    --cc=cyrilbur@tenstorrent.com \
    --cc=debug@rivosinc.com \
    --cc=geomatsi@gmail.com \
    --cc=kees@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=martin@kaiser.cx \
    --cc=masahiroy@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.org \
    --cc=songshuaishuai@tinylab.org \
    --cc=tglx@kernel.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox