diff mbox series

[kvmtool,03/10] riscv: Make CPU_ISA_MAX_LEN depend upon isa_info_arr array size

Message ID 20231128145628.413414-4-apatel@ventanamicro.com (mailing list archive)
State New, archived
Headers show
Series SBI debug console and few ISA extensions | expand

Commit Message

Anup Patel Nov. 28, 2023, 2:56 p.m. UTC
Currently, the CPU_ISA_MAX_LEN is a fixed value so we will easily
run out of space when all possible ISA extensions supported by
KVM RISC-V are available.

Instead of above, let us make CPU_ISA_MAX_LEN depend upon the
isa_info_arr[] array size so that CPU_ISA_MAX_LEN automatically
adapts to growing number of ISA extensions.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 riscv/fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/riscv/fdt.c b/riscv/fdt.c
index b45f731..230d1f8 100644
--- a/riscv/fdt.c
+++ b/riscv/fdt.c
@@ -44,7 +44,6 @@  static void dump_fdt(const char *dtb_file, void *fdt)
 }
 
 #define CPU_NAME_MAX_LEN 15
-#define CPU_ISA_MAX_LEN 128
 static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
 {
 	int cpu, pos, i, index, valid_isa_len;
@@ -60,6 +59,7 @@  static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
 
 	for (cpu = 0; cpu < kvm->nrcpus; ++cpu) {
 		char cpu_name[CPU_NAME_MAX_LEN];
+#define CPU_ISA_MAX_LEN (ARRAY_SIZE(isa_info_arr) * 16)
 		char cpu_isa[CPU_ISA_MAX_LEN];
 		struct kvm_cpu *vcpu = kvm->cpus[cpu];
 		struct kvm_one_reg reg;