All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anup Patel" <anup.patel@oss.qualcomm.com>
Cc: linux-clk@vger.kernel.org
Subject: Re: [PATCH v3 2/5] RISC-V: Prevent interrupt when accessing MPXY shared memory
Date: Fri, 04 Dec 2026 12:06:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-249753@kernel.org> (raw)
In-Reply-To: <20261204111504.3362889-3-anup.patel@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] riscv: wrong -ENOSPC errno in sbi_mpxy_send_message_*() when
  inactive
--

commit 364fd80b5b3da8f11006110b87538af023c33875
Author: Anup Patel <anup.patel@oss.qualcomm.com>

RISC-V: Prevent interrupt when accessing MPXY shared memory

This commit replaces get_cpu()/put_cpu() with guard(irqsave)() in the SBI
MPXY helpers so local interrupts cannot re-enter and clobber the per-CPU
shared memory buffer during an SBI call.

> diff --git a/arch/riscv/kernel/sbi_mpxy.c b/arch/riscv/kernel/sbi_mpxy.c
> index c1c5058d32525..4b25e5dc7fd62 100644
> --- a/arch/riscv/kernel/sbi_mpxy.c
> +++ b/arch/riscv/kernel/sbi_mpxy.c

[ ... ]

> @@ -166,18 +171,19 @@ int sbi_mpxy_send_message_with_resp(u32 channel_id, u32 msg_id,
>  				    void *rx, unsigned long max_rx_len,
>  				    unsigned long *rx_len)
>  {
> -	struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local);
> +	struct mpxy_local *mpxy;
>  	unsigned long rx_bytes;
>  	struct sbiret sret;
>  
> -	if (!mpxy->shmem_active)
> -		return -ENODEV;
>  	if (!tx && tx_len)
>  		return -EINVAL;
>  	if (mpxy_shmem_size < tx_len)
>  		return -ENOSPC;
>  
> -	get_cpu();
> +	guard(irqsave)();
> +	mpxy = this_cpu_ptr(&mpxy_local);
> +	if (!mpxy->shmem_active)
> +		return -ENODEV;

[Severity: Low]
Does moving the mpxy->shmem_active check after mpxy_shmem_size < tx_len
cause sbi_mpxy_send_message_with_resp() to return -ENOSPC instead of
-ENODEV when MPXY is inactive?

When SBI MPXY is unavailable or uninitialized, mpxy_shmem_size is 0 and
mpxy->shmem_active is false.  A call with a non-zero tx_len now hits
mpxy_shmem_size < tx_len first and returns -ENOSPC, inconsistent with the
tx_len == 0 path and the other sbi_mpxy_*() helpers.

sbi_mpxy_send_message_without_resp() has the same regression.  Moving the
mpxy_shmem_size < tx_len check after !mpxy->shmem_active in both functions
restores consistent -ENODEV reporting.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204111504.3362889-1-anup.patel@oss.qualcomm.com?part=2

  reply	other threads:[~2026-12-04 12:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 11:14 [PATCH v3 0/5] Parallel message send using SBI MPXY Anup Patel
2026-12-04 11:14 ` Anup Patel
2026-12-04 11:15 ` [PATCH v3 1/5] RISC-V: Move common MPXY helper routines to arch/riscv Anup Patel
2026-12-04 11:15   ` Anup Patel
2026-12-04 11:47   ` sashiko-bot
2026-12-04 11:15 ` [PATCH v3 2/5] RISC-V: Prevent interrupt when accessing MPXY shared memory Anup Patel
2026-12-04 11:15   ` Anup Patel
2026-12-04 12:06   ` sashiko-bot [this message]
2026-12-04 11:15 ` [PATCH v3 3/5] mailbox: add direct synchronous transmit API Anup Patel
2026-12-04 11:15   ` Anup Patel
2026-12-04 12:26   ` sashiko-bot
2026-12-04 11:15 ` [PATCH v3 4/5] mailbox: document direct synchronous transmit Anup Patel
2026-12-04 11:15   ` Anup Patel
2026-12-04 12:34   ` sashiko-bot
2026-12-04 11:15 ` [PATCH v3 5/5] mailbox: convert RISC-V SBI MPXY to direct transmit Anup Patel
2026-12-04 11:15   ` Anup Patel
2026-12-04 13:30   ` 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-249753@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=anup.patel@oss.qualcomm.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.