Skip to content

Commit 3f96db1

Browse files
atishp04palmer-dabbelt
authored andcommitted
RISC-V: Do no continue isa string parsing without correct XLEN
The isa string should begin with either rv64 or rv32. Otherwise, it is an incorrect isa string. Currently, the string parsing continues even if it doesnot begin with current XLEN. Fix this by checking if it found "rv64" or "rv32" in the beginning. Tested-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 02d52fb commit 3f96db1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

arch/riscv/kernel/cpufeature.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void __init riscv_fill_hwcap(void)
8484
for_each_of_cpu_node(node) {
8585
unsigned long this_hwcap = 0;
8686
DECLARE_BITMAP(this_isa, RISCV_ISA_EXT_MAX);
87+
const char *temp;
8788

8889
if (riscv_of_processor_hartid(node) < 0)
8990
continue;
@@ -93,13 +94,17 @@ void __init riscv_fill_hwcap(void)
9394
continue;
9495
}
9596

97+
temp = isa;
9698
#if IS_ENABLED(CONFIG_32BIT)
9799
if (!strncmp(isa, "rv32", 4))
98100
isa += 4;
99101
#elif IS_ENABLED(CONFIG_64BIT)
100102
if (!strncmp(isa, "rv64", 4))
101103
isa += 4;
102104
#endif
105+
/* The riscv,isa DT property must start with rv64 or rv32 */
106+
if (temp == isa)
107+
continue;
103108
bitmap_zero(this_isa, RISCV_ISA_EXT_MAX);
104109
for (; *isa; ++isa) {
105110
const char *ext = isa++;

0 commit comments

Comments
 (0)