qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] RISC-V: Fix riscv_isa_string, use popcount to count bits
@ 2018-03-09 21:01 Michael Clark
  2018-03-10 21:25 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Clark @ 2018-03-09 21:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Clark, Palmer Dabbelt, Peter Maydell, Eric Blake

Logic bug caused the string size calculation for the RISC-V
format ISA string to be small. This fix allows slack for rv128.

Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Clark <mjc@sifive.com>
---
 target/riscv/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 4851890..1456535 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -391,7 +391,7 @@ static const TypeInfo riscv_cpu_type_info = {
 char *riscv_isa_string(RISCVCPU *cpu)
 {
     int i;
-    size_t maxlen = 5 + ctz32(cpu->env.misa);
+    size_t maxlen = 8 + ctpop64(cpu->env.misa);
     char *isa_string = g_new0(char, maxlen);
     snprintf(isa_string, maxlen, "rv%d", TARGET_LONG_BITS);
     for (i = 0; i < sizeof(riscv_exts); i++) {
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-03-16 20:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-09 21:01 [Qemu-devel] [PATCH v2] RISC-V: Fix riscv_isa_string, use popcount to count bits Michael Clark
2018-03-10 21:25 ` Philippe Mathieu-Daudé
2018-03-11 11:46   ` Philippe Mathieu-Daudé
2018-03-15 19:27   ` Peter Maydell
2018-03-16 17:03     ` Michael Clark
2018-03-16 20:55       ` Michael Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).