Commit 58004f26 authored by Tsukasa OI's avatar Tsukasa OI Committed by Palmer Dabbelt

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: default avatarAnup Patel <anup@brainfault.org>
Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
Signed-off-by: default avatarTsukasa OI <research_trasio@irq.a4lg.com>
Signed-off-by: default avatarAtish Patra <atishp@rivosinc.com>
Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent e783362e
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include <asm/smp.h> #include <asm/smp.h>
#include <asm/switch_to.h> #include <asm/switch_to.h>
#define NUM_ALPHA_EXTS ('z' - 'a' + 1)
unsigned long elf_hwcap __read_mostly; unsigned long elf_hwcap __read_mostly;
/* Host ISA bitmap */ /* Host ISA bitmap */
...@@ -63,7 +65,7 @@ void __init riscv_fill_hwcap(void) ...@@ -63,7 +65,7 @@ void __init riscv_fill_hwcap(void)
{ {
struct device_node *node; struct device_node *node;
const char *isa; const char *isa;
char print_str[BITS_PER_LONG + 1]; char print_str[NUM_ALPHA_EXTS + 1];
size_t i, j, isa_len; size_t i, j, isa_len;
static unsigned long isa2hwcap[256] = {0}; static unsigned long isa2hwcap[256] = {0};
...@@ -133,13 +135,13 @@ void __init riscv_fill_hwcap(void) ...@@ -133,13 +135,13 @@ void __init riscv_fill_hwcap(void)
} }
memset(print_str, 0, sizeof(print_str)); memset(print_str, 0, sizeof(print_str));
for (i = 0, j = 0; i < BITS_PER_LONG; i++) for (i = 0, j = 0; i < NUM_ALPHA_EXTS; i++)
if (riscv_isa[0] & BIT_MASK(i)) if (riscv_isa[0] & BIT_MASK(i))
print_str[j++] = (char)('a' + i); print_str[j++] = (char)('a' + i);
pr_info("riscv: ISA extensions %s\n", print_str); pr_info("riscv: ISA extensions %s\n", print_str);
memset(print_str, 0, sizeof(print_str)); memset(print_str, 0, sizeof(print_str));
for (i = 0, j = 0; i < BITS_PER_LONG; i++) for (i = 0, j = 0; i < NUM_ALPHA_EXTS; i++)
if (elf_hwcap & BIT_MASK(i)) if (elf_hwcap & BIT_MASK(i))
print_str[j++] = (char)('a' + i); print_str[j++] = (char)('a' + i);
pr_info("riscv: ELF capabilities %s\n", print_str); pr_info("riscv: ELF capabilities %s\n", print_str);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment