All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zhanpeng Zhang" <zhangzhanpeng.jasper@bytedance.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v14 03/10] riscv: sse: mask events during shutdown and kexec
Date: Wed, 02 Dec 2026 07:29:10 +0000	[thread overview]
Message-ID: <sashiko-outbox-245064@kernel.org> (raw)
In-Reply-To: <20261202070003.42491-15-zhangzhanpeng.jasper@bytedance.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] riscv: sse: unreachable !CONFIG_SMP panic_smp_self_stop() in
  reset.c
--

commit 1050ac9e85d5880cbc8b2d13b7d3b8288284a504
Author: Zhanpeng Zhang <zhangzhanpeng.jasper@bytedance.com>

riscv: sse: mask events during shutdown and kexec

This commit masks SBI Supervisor Software Events (SSE) on the local hart
during panic stop, CPU stop, restart, poweroff, and crash shutdown paths,
and rejects normal kexec from a crash kernel when SSE is supported.

Link: https://lore.kernel.org/r/as7-3PbWDxygadnJ@hu-himchau-blr.qualcomm.com/
Link: https://lore.kernel.org/r/0305b6b3-8292-4a4d-a473-dc26a39beca1@linux.dev/

> diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c
> index 14eb08a6db855..55482404f6f76 100644
> --- a/arch/riscv/kernel/reset.c
> +++ b/arch/riscv/kernel/reset.c
> @@ -6,9 +6,26 @@
>  #include <linux/efi.h>
>  #include <linux/reboot.h>
>  #include <linux/pm.h>
> +#include <linux/smp.h>
>  
> -static void __noreturn default_power_off(void)
> +#include <asm/sse.h>
> +
> +#ifndef CONFIG_SMP
> +void __noreturn panic_smp_self_stop(void)
> +{
> +	riscv_sse_mask_current_hart();
> +	local_irq_disable();
> +
> +	for (;;)
> +		cpu_relax();
> +}
> +#endif

[Severity: Medium]
Is this !CONFIG_SMP definition of panic_smp_self_stop() ever reachable?

In kernel/panic.c, every call to panic_smp_self_stop() in vpanic() and
nmi_panic() is guarded by either panic_try_force_cpu() or
panic_on_other_cpu().  When !CONFIG_SMP, panic_try_force_cpu() is a stub
returning false, and panic_on_other_cpu() checks
panic_in_progress() && !panic_on_this_cpu(), which is always false because
raw_smp_processor_id() is 0 and panic_try_start() sets panic_cpu to 0.

Meanwhile, the panicking CPU runs panic_other_cpus_shutdown(), which calls
smp_send_stop() or the weak crash_smp_send_stop().  On !CONFIG_SMP,
arch/riscv/kernel/smp.c is not built and both functions resolve to the
empty smp_send_stop() stub in include/linux/smp.h, so
panic_other_cpus_shutdown() never masks SSE on the panicking hart.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202070003.42491-12-zhangzhanpeng.jasper@bytedance.com?part=3

  reply	other threads:[~2026-12-02  7:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  7:00 [PATCH v14 00/10] riscv: add SBI Supervisor Software Events support Zhanpeng Zhang
2026-12-02  7:00 ` Zhanpeng Zhang
2026-12-02  7:00 ` [PATCH v14 01/10] riscv: add SBI SSE extension definitions Zhanpeng Zhang
2026-12-02  7:00   ` Zhanpeng Zhang
2026-12-02  7:00 ` [PATCH v14 02/10] riscv: add support for SBI Supervisor Software Events extension Zhanpeng Zhang
2026-12-02  7:00   ` Zhanpeng Zhang
2026-12-02  7:21   ` sashiko-bot
2026-12-02  7:00 ` [PATCH v14 03/10] riscv: sse: mask events during shutdown and kexec Zhanpeng Zhang
2026-12-02  7:00   ` Zhanpeng Zhang
2026-12-02  7:29   ` sashiko-bot [this message]
2026-12-02  7:00 ` [PATCH v14 04/10] drivers: firmware: add riscv SSE support Zhanpeng Zhang
2026-12-02  7:00   ` Zhanpeng Zhang
2026-12-02  7:25   ` sashiko-bot
2026-12-02  7:00 ` [PATCH v14 05/10] riscv: mm: avoid enabling interrupts for nofault page faults Zhanpeng Zhang
2026-12-02  7:00   ` Zhanpeng Zhang
2026-12-02  7:00 ` [PATCH v14 06/10] perf: RISC-V: support callchains with SSE delivery Zhanpeng Zhang
2026-12-02  7:00   ` Zhanpeng Zhang
2026-12-02  7:47   ` sashiko-bot
2026-12-02  7:00 ` [PATCH v14 07/10] perf: RISC-V: add support for SSE event Zhanpeng Zhang
2026-12-02  7:00   ` Zhanpeng Zhang
2026-12-02  7:33   ` sashiko-bot
2026-12-02  7:00 ` [PATCH v14 08/10] MAINTAINERS: add RISC-V SSE maintainers and file coverage Zhanpeng Zhang
2026-12-02  7:00   ` Zhanpeng Zhang
2026-12-02  7:00 ` [PATCH v14 09/10] selftests/riscv: add SSE test module Zhanpeng Zhang
2026-12-02  7:00   ` Zhanpeng Zhang
2026-12-02  7:26   ` sashiko-bot
2026-12-02  7:00 ` [PATCH v14 10/10] selftests/riscv: add perf user-stack SSE copy regression test Zhanpeng Zhang
2026-12-02  7:00   ` Zhanpeng Zhang
2026-12-02  7:24   ` sashiko-bot
2026-12-02  7:47 ` [PATCH v14 00/10] riscv: add SBI Supervisor Software Events support sashiko-bot

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=sashiko-outbox-245064@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zhangzhanpeng.jasper@bytedance.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 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.