Index | Thread | Search

From:
Nick Owens <mischief@offblast.org>
Subject:
[PATCH] riscv64: make isa size bigger and terminate
To:
tech@openbsd.org
Cc:
Nick Owens <mischief@offblast.org>
Date:
Sun, 15 Jun 2025 00:21:35 -0700

Download raw body.

Thread
the buffer is too short for some riscv ISA values, such as
'rv64imafdc_zicntr_zicsr_zifencei_zihpm_zba_zbb'.
---
 sys/arch/riscv64/riscv64/cpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/arch/riscv64/riscv64/cpu.c b/sys/arch/riscv64/riscv64/cpu.c
index e8400d4eed3..9c71a4f9a4f 100644
--- a/sys/arch/riscv64/riscv64/cpu.c
+++ b/sys/arch/riscv64/riscv64/cpu.c
@@ -102,7 +102,7 @@ size_t	thead_dcache_line_size;
 void
 cpu_identify(struct cpu_info *ci)
 {
-	char isa[32];
+	char isa[64];
 	uint64_t marchid, mimpid;
 	uint32_t mvendorid;
 	const char *vendor_name = NULL;
@@ -141,6 +141,7 @@ cpu_identify(struct cpu_info *ci)
 
 	len = OF_getprop(ci->ci_node, "riscv,isa", isa, sizeof(isa));
 	if (len != -1) {
+		isa[len - 1] = 0;
 		printf(" %s", isa);
 		strlcpy(cpu_model, isa, sizeof(cpu_model));
 	}
-- 
2.49.0