linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@dabbelt.com>
To: Anup Patel <Anup.Patel@wdc.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	aou@eecs.berkeley.edu, Atish Patra <Atish.Patra@wdc.com>,
	Alistair Francis <Alistair.Francis@wdc.com>,
	anup@brainfault.org,  linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org, Anup Patel <Anup.Patel@wdc.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] RISC-V: Fix error code returned by riscv_hartid_to_cpuid()
Date: Fri, 23 Apr 2021 00:15:55 -0700 (PDT)	[thread overview]
Message-ID: <mhng-b5a84423-0884-4378-9a8c-86c1d00a302c@palmerdabbelt-glaptop> (raw)
In-Reply-To: <20210415085522.108624-1-anup.patel@wdc.com>

On Thu, 15 Apr 2021 01:55:22 PDT (-0700), Anup Patel wrote:
> We should return a negative error code upon failure in

Not just should: the PLIC driver assumed this was the return flavor and 
will overflow a per_cpu because it doesn't detect the error.  IIUC this 
will manifest if we have more harts that NR_CPUS, which is a possible 
configuration.

That said, it's gone unnoticed for ~3 years so I'm inclined to leave it 
out of fixes because I have nothing else and this late in the cycle is 
always a bit touchy.  It's kind of splitting hairs as it'll just get 
backported, but post-rc8 is an odd spot to be in.

Is this actually manifesting as a crash for you?

Sorry I missed this last week.

> riscv_hartid_to_cpuid() instead of NR_CPUS. This is also
> aligned with all uses of riscv_hartid_to_cpuid() which
> expect negative error code upon failure.
>
> Fixes: 6825c7a80f18 ("RISC-V: Add logical CPU indexing for RISC-V")

Also

Fixes: f99fb607fb2b ("RISC-V: Use Linux logical CPU number instead of hartid")

which is what actually manifests the bug -- again, kind of splitting 
hairs as it's the patch after.

> Cc: stable@vger.kernel.org
> Signed-off-by: Anup Patel <anup.patel@wdc.com>
> ---
>  arch/riscv/kernel/smp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c
> index ea028d9e0d24..d44567490d91 100644
> --- a/arch/riscv/kernel/smp.c
> +++ b/arch/riscv/kernel/smp.c
> @@ -54,7 +54,7 @@ int riscv_hartid_to_cpuid(int hartid)
>  			return i;
>
>  	pr_err("Couldn't find cpu id for hartid [%d]\n", hartid);
> -	return i;
> +	return -ENOENT;
>  }
>
>  void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out)

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

      reply	other threads:[~2021-04-23  7:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15  8:55 [PATCH] RISC-V: Fix error code returned by riscv_hartid_to_cpuid() Anup Patel
2021-04-23  7:15 ` Palmer Dabbelt [this message]

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=mhng-b5a84423-0884-4378-9a8c-86c1d00a302c@palmerdabbelt-glaptop \
    --to=palmer@dabbelt.com \
    --cc=Alistair.Francis@wdc.com \
    --cc=Anup.Patel@wdc.com \
    --cc=Atish.Patra@wdc.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=paul.walmsley@sifive.com \
    --cc=stable@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).