public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 2/5] riscv: spinwait: Fix hartid variable type
       [not found] <20220526101131.2340729-1-sunilvl@ventanamicro.com>
@ 2022-05-26 10:11 ` Sunil V L
  2022-05-26 22:56   ` Atish Patra
  0 siblings, 1 reply; 2+ messages in thread
From: Sunil V L @ 2022-05-26 10:11 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Daniel Lezcano,
	Thomas Gleixner, Ard Biesheuvel, Marc Zyngier, Atish Patra,
	Heinrich Schuchardt, Anup Patel
  Cc: linux-riscv, linux-kernel, linux-efi, Sunil V L, Sunil V L,
	stable

The hartid variable is of type int but compared with
ULONG_MAX(INVALID_HARTID). This issue is fixed by changing
the hartid variable type to unsigned long.

Fixes: c78f94f35cf6 ("RISC-V: Use __cpu_up_stack/task_pointer only for spinwait method")
Cc: stable@vger.kernel.org

Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
---
 arch/riscv/kernel/cpu_ops_spinwait.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/cpu_ops_spinwait.c b/arch/riscv/kernel/cpu_ops_spinwait.c
index 346847f6c41c..3ade9152a3c7 100644
--- a/arch/riscv/kernel/cpu_ops_spinwait.c
+++ b/arch/riscv/kernel/cpu_ops_spinwait.c
@@ -18,7 +18,7 @@ void *__cpu_spinwait_task_pointer[NR_CPUS] __section(".data");
 static void cpu_update_secondary_bootdata(unsigned int cpuid,
 				   struct task_struct *tidle)
 {
-	int hartid = cpuid_to_hartid_map(cpuid);
+	unsigned long hartid = cpuid_to_hartid_map(cpuid);
 
 	/*
 	 * The hartid must be less than NR_CPUS to avoid out-of-bound access
@@ -27,7 +27,7 @@ static void cpu_update_secondary_bootdata(unsigned int cpuid,
 	 * spinwait booting is not the recommended approach for any platforms
 	 * booting Linux in S-mode and can be disabled in the future.
 	 */
-	if (hartid == INVALID_HARTID || hartid >= NR_CPUS)
+	if (hartid == INVALID_HARTID || hartid >= (unsigned long) NR_CPUS)
 		return;
 
 	/* Make sure tidle is updated */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2 2/5] riscv: spinwait: Fix hartid variable type
  2022-05-26 10:11 ` [PATCH V2 2/5] riscv: spinwait: Fix hartid variable type Sunil V L
@ 2022-05-26 22:56   ` Atish Patra
  0 siblings, 0 replies; 2+ messages in thread
From: Atish Patra @ 2022-05-26 22:56 UTC (permalink / raw)
  To: Sunil V L
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Daniel Lezcano,
	Thomas Gleixner, Ard Biesheuvel, Marc Zyngier, Atish Patra,
	Heinrich Schuchardt, Anup Patel, linux-riscv,
	linux-kernel@vger.kernel.org List, linux-efi, Sunil V L, stable

On Thu, May 26, 2022 at 3:12 AM Sunil V L <sunilvl@ventanamicro.com> wrote:
>
> The hartid variable is of type int but compared with
> ULONG_MAX(INVALID_HARTID). This issue is fixed by changing
> the hartid variable type to unsigned long.
>
> Fixes: c78f94f35cf6 ("RISC-V: Use __cpu_up_stack/task_pointer only for spinwait method")
> Cc: stable@vger.kernel.org
>
> Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
> ---
>  arch/riscv/kernel/cpu_ops_spinwait.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kernel/cpu_ops_spinwait.c b/arch/riscv/kernel/cpu_ops_spinwait.c
> index 346847f6c41c..3ade9152a3c7 100644
> --- a/arch/riscv/kernel/cpu_ops_spinwait.c
> +++ b/arch/riscv/kernel/cpu_ops_spinwait.c
> @@ -18,7 +18,7 @@ void *__cpu_spinwait_task_pointer[NR_CPUS] __section(".data");
>  static void cpu_update_secondary_bootdata(unsigned int cpuid,
>                                    struct task_struct *tidle)
>  {
> -       int hartid = cpuid_to_hartid_map(cpuid);
> +       unsigned long hartid = cpuid_to_hartid_map(cpuid);
>
>         /*
>          * The hartid must be less than NR_CPUS to avoid out-of-bound access
> @@ -27,7 +27,7 @@ static void cpu_update_secondary_bootdata(unsigned int cpuid,
>          * spinwait booting is not the recommended approach for any platforms
>          * booting Linux in S-mode and can be disabled in the future.
>          */
> -       if (hartid == INVALID_HARTID || hartid >= NR_CPUS)
> +       if (hartid == INVALID_HARTID || hartid >= (unsigned long) NR_CPUS)
>                 return;
>
>         /* Make sure tidle is updated */
> --
> 2.25.1
>

Reviewed-by: Atish Patra <atishp@rivosinc.com>

-- 
Regards,
Atish

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-26 22:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20220526101131.2340729-1-sunilvl@ventanamicro.com>
2022-05-26 10:11 ` [PATCH V2 2/5] riscv: spinwait: Fix hartid variable type Sunil V L
2022-05-26 22:56   ` Atish Patra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox