]> git.baikalelectronics.ru Git - kernel.git/commit
RISC-V: Fix IPI/RFENCE hmask on non-monotonic hartid ordering
authorGeert Uytterhoeven <geert@linux-m68k.org>
Mon, 31 Jan 2022 13:26:22 +0000 (14:26 +0100)
committerPalmer Dabbelt <palmer@rivosinc.com>
Mon, 14 Feb 2022 20:27:45 +0000 (12:27 -0800)
commit54daa832b806298c254fb62f8ec8a032d0f95fa5
tree9ab6716e6c0be760c787c49717cf8aa00a4c7d53
parent69f8cf16e2fa3577d0b66e1032d6066a43de8501
RISC-V: Fix IPI/RFENCE hmask on non-monotonic hartid ordering

If the boot CPU does not have the lowest hartid, "hartid - hbase" can
become negative, leading to an incorrect hmask, causing userspace to
crash with SEGV.  This is observed on e.g. Starlight Beta, where cpuid 1
maps to hartid 0, and cpuid 0 maps to hartid 1.

Fix this by detecting this case, and shifting the accumulated mask and
updating hbase, if possible.

Fixes: db1f3f9a9b8c05f0 ("RISC-V: Do not use cpumask data structure for hartid bitmap")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Tested-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kernel/sbi.c