* [RFC PATCH 1/3] riscv: Correctly print supported extensions
@ 2021-11-20 8:53 Tsukasa OI
2021-11-22 12:14 ` Ben Dooks
2021-11-22 12:35 ` Andreas Schwab
0 siblings, 2 replies; 5+ messages in thread
From: Tsukasa OI @ 2021-11-20 8:53 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou; +Cc: linux-riscv
This commit replaces BITS_PER_LONG with magic number 26.
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.
Signed-off-by: Tsukasa OI <research_trasio@irq.a4lg.com>
---
arch/riscv/kernel/cpufeature.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index d959d207a40d..6f2bf6ae4ae2 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -63,7 +63,7 @@ void __init riscv_fill_hwcap(void)
{
struct device_node *node;
const char *isa;
- char print_str[BITS_PER_LONG + 1];
+ char print_str[26 + 1];
size_t i, j, isa_len;
static unsigned long isa2hwcap[256] = {0};
@@ -133,13 +133,13 @@ void __init riscv_fill_hwcap(void)
}
memset(print_str, 0, sizeof(print_str));
- for (i = 0, j = 0; i < BITS_PER_LONG; i++)
+ for (i = 0, j = 0; i < 26; i++)
if (riscv_isa[0] & BIT_MASK(i))
print_str[j++] = (char)('a' + i);
pr_info("riscv: ISA extensions %s\n", 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 < 26; i++)
if (elf_hwcap & BIT_MASK(i))
print_str[j++] = (char)('a' + i);
pr_info("riscv: ELF capabilities %s\n", print_str);
--
2.32.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [RFC PATCH 1/3] riscv: Correctly print supported extensions
2021-11-20 8:53 [RFC PATCH 1/3] riscv: Correctly print supported extensions Tsukasa OI
@ 2021-11-22 12:14 ` Ben Dooks
2021-11-23 1:32 ` Tsukasa OI
2021-11-22 12:35 ` Andreas Schwab
1 sibling, 1 reply; 5+ messages in thread
From: Ben Dooks @ 2021-11-22 12:14 UTC (permalink / raw)
To: Tsukasa OI, Paul Walmsley, Palmer Dabbelt, Albert Ou; +Cc: linux-riscv
On 20/11/2021 08:53, Tsukasa OI wrote:
> This commit replaces BITS_PER_LONG with magic number 26.
>
> 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.
>
> Signed-off-by: Tsukasa OI <research_trasio@irq.a4lg.com>
> ---
> arch/riscv/kernel/cpufeature.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
> index d959d207a40d..6f2bf6ae4ae2 100644
> --- a/arch/riscv/kernel/cpufeature.c
> +++ b/arch/riscv/kernel/cpufeature.c
> @@ -63,7 +63,7 @@ void __init riscv_fill_hwcap(void)
> {
> struct device_node *node;
> const char *isa;
> - char print_str[BITS_PER_LONG + 1];
> + char print_str[26 + 1];
> size_t i, j, isa_len;
> static unsigned long isa2hwcap[256] = {0};
>
> @@ -133,13 +133,13 @@ void __init riscv_fill_hwcap(void)
> }
>
> memset(print_str, 0, sizeof(print_str));
> - for (i = 0, j = 0; i < BITS_PER_LONG; i++)
> + for (i = 0, j = 0; i < 26; i++)
> if (riscv_isa[0] & BIT_MASK(i))
> print_str[j++] = (char)('a' + i);
> pr_info("riscv: ISA extensions %s\n", 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 < 26; i++)
> if (elf_hwcap & BIT_MASK(i))
> print_str[j++] = (char)('a' + i);
> pr_info("riscv: ELF capabilities %s\n", print_str);
>
Maybe add a warn on if there are bits set between 26 and BITS_PER_LONG ?
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC PATCH 1/3] riscv: Correctly print supported extensions
2021-11-20 8:53 [RFC PATCH 1/3] riscv: Correctly print supported extensions Tsukasa OI
2021-11-22 12:14 ` Ben Dooks
@ 2021-11-22 12:35 ` Andreas Schwab
2021-11-23 1:25 ` Tsukasa OI
1 sibling, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2021-11-22 12:35 UTC (permalink / raw)
To: Tsukasa OI; +Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv
On Nov 20 2021, Tsukasa OI wrote:
> This commit replaces BITS_PER_LONG with magic number 26.
>
> 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.
Perhaps replace 26 by 'z' - 'a' + 1?
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 1/3] riscv: Correctly print supported extensions
2021-11-22 12:35 ` Andreas Schwab
@ 2021-11-23 1:25 ` Tsukasa OI
0 siblings, 0 replies; 5+ messages in thread
From: Tsukasa OI @ 2021-11-23 1:25 UTC (permalink / raw)
To: Andreas Schwab; +Cc: linux-riscv
On 2021/11/22 21:35, Andreas Schwab wrote:
> On Nov 20 2021, Tsukasa OI wrote:
>
>> This commit replaces BITS_PER_LONG with magic number 26.
>>
>> 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.
>
> Perhaps replace 26 by 'z' - 'a' + 1?
That's not bad. Possibly I can define:
#define NUM_ALPHA_EXTS ('z' - 'a' + 1)
I will submit RFC PATCH v2 by end of this week (I found several minor bugs in
"riscv,isa" parser [patch 2,3] anyway) so I'll rewrite it.
Thanks!
Tsukasa,
>
> Andreas.
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-23 1:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-20 8:53 [RFC PATCH 1/3] riscv: Correctly print supported extensions Tsukasa OI
2021-11-22 12:14 ` Ben Dooks
2021-11-23 1:32 ` Tsukasa OI
2021-11-22 12:35 ` Andreas Schwab
2021-11-23 1:25 ` Tsukasa OI
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.