From: Nick Owens Subject: [PATCH] riscv64: make isa size bigger and terminate To: tech@openbsd.org Cc: Nick Owens Date: Sun, 15 Jun 2025 09:02:48 -0700 here is take two. after booting in QEMU, i discovered this rediculous isa string: rv64imafdch_zic64b_zicbom_zicbop_zicboz_ziccamoa_ziccif_zicclsm_ziccrse_zicntr_zicsr_zifencei_zihintntl_zihintpause_zihpm_zmmul_za64rs_zaamo_zalrsc_zawrs_zfa_zca_zcd_zba_zbb_zbc_zbs_shcounterenw_shgatpa_shtvala_shvsatpa_shvstvala_shvstvecd_ssccptr_sscounterenw_sstc_sstvala_sstvecd_ssu64xl_svadu_svvptc without this change, the kernel will just print mojibake, and hangs when booting secondary cores when the isa string overflows the buffer. i have swapped to using sizeof to terminate the buffer, instead of trusting OF_getprop's return value. --- sys/arch/riscv64/riscv64/cpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/arch/riscv64/riscv64/cpu.c b/sys/arch/riscv64/riscv64/cpu.c index e8400d4eed3..791ff2bfe15 100644 --- a/sys/arch/riscv64/riscv64/cpu.c +++ b/sys/arch/riscv64/riscv64/cpu.c @@ -73,7 +73,7 @@ const struct vendor { { 0, NULL } }; -char cpu_model[64]; +char cpu_model[512]; int cpu_node; struct cpu_info *cpu_info_list = &cpu_info_primary; @@ -102,7 +102,7 @@ size_t thead_dcache_line_size; void cpu_identify(struct cpu_info *ci) { - char isa[32]; + char isa[512]; 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[sizeof(isa) - 1] = 0; printf(" %s", isa); strlcpy(cpu_model, isa, sizeof(cpu_model)); } -- 2.49.0