Unverified Commit c029e487 authored by Sunil V L's avatar Sunil V L Committed by Palmer Dabbelt
Browse files

riscv: spinwait: Fix hartid variable type



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: c78f94f3 ("RISC-V: Use __cpu_up_stack/task_pointer only for spinwait method")

Signed-off-by: default avatarSunil V L <sunilvl@ventanamicro.com>
Reviewed-by: default avatarAtish Patra <atishp@rivosinc.com>
Link: https://lore.kernel.org/r/20220527051743.2829940-3-sunilvl@ventanamicro.com


Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent 869d40bd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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 */