Skip to content

Commit 58004f2

Browse files
a4lgpalmer-dabbelt
authored andcommitted
RISC-V: Correctly print supported extensions
This commit replaces BITS_PER_LONG with number of alphabet letters. Current ISA pretty-printing code expects extension 'a' (bit 0) through 'z' (bit 25). Although bit 26 and higher is not currently used (thus never cause an issue in practice), it will be an annoying problem if we start to use those in the future. This commit disables printing high bits for now. Reviewed-by: Anup Patel <anup@brainfault.org> Tested-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Tsukasa OI <research_trasio@irq.a4lg.com> Signed-off-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent e783362 commit 58004f2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

arch/riscv/kernel/cpufeature.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <asm/smp.h>
1414
#include <asm/switch_to.h>
1515

16+
#define NUM_ALPHA_EXTS ('z' - 'a' + 1)
17+
1618
unsigned long elf_hwcap __read_mostly;
1719

1820
/* Host ISA bitmap */
@@ -63,7 +65,7 @@ void __init riscv_fill_hwcap(void)
6365
{
6466
struct device_node *node;
6567
const char *isa;
66-
char print_str[BITS_PER_LONG + 1];
68+
char print_str[NUM_ALPHA_EXTS + 1];
6769
size_t i, j, isa_len;
6870
static unsigned long isa2hwcap[256] = {0};
6971

@@ -133,13 +135,13 @@ void __init riscv_fill_hwcap(void)
133135
}
134136

135137
memset(print_str, 0, sizeof(print_str));
136-
for (i = 0, j = 0; i < BITS_PER_LONG; i++)
138+
for (i = 0, j = 0; i < NUM_ALPHA_EXTS; i++)
137139
if (riscv_isa[0] & BIT_MASK(i))
138140
print_str[j++] = (char)('a' + i);
139141
pr_info("riscv: ISA extensions %s\n", print_str);
140142

141143
memset(print_str, 0, sizeof(print_str));
142-
for (i = 0, j = 0; i < BITS_PER_LONG; i++)
144+
for (i = 0, j = 0; i < NUM_ALPHA_EXTS; i++)
143145
if (elf_hwcap & BIT_MASK(i))
144146
print_str[j++] = (char)('a' + i);
145147
pr_info("riscv: ELF capabilities %s\n", print_str);

0 commit comments

Comments
 (0)