TYPE_RISCV_CPU_BASE is used only to initialize the correct default machine for 2 machines. Replace it with a runtime check.
Reviewed-by: Pierrick Bouvier <[email protected]> Reviewed-by: Chao Liu <[email protected]> Signed-off-by: Anton Johansson <[email protected]> -- Note, this patch is to be replaced by: [email protected] --- target/riscv/cpu.h | 6 ------ hw/riscv/microblaze-v-generic.c | 4 +++- hw/riscv/virt.c | 4 +++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index c2138dbd4b..aee1dcaaf9 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -39,12 +39,6 @@ typedef struct CPUArchState CPURISCVState; #define CPU_RESOLVING_TYPE TYPE_RISCV_CPU -#if defined(TARGET_RISCV32) -# define TYPE_RISCV_CPU_BASE TYPE_RISCV_CPU_BASE32 -#elif defined(TARGET_RISCV64) -# define TYPE_RISCV_CPU_BASE TYPE_RISCV_CPU_BASE64 -#endif - /* * b0: Whether a instruction always raise a store AMO or not. */ diff --git a/hw/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c index b0494b1ac5..3f07ab2132 100644 --- a/hw/riscv/microblaze-v-generic.c +++ b/hw/riscv/microblaze-v-generic.c @@ -15,6 +15,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/target-info.h" #include "qapi/error.h" #include "target/riscv/cpu.h" #include "hw/core/sysbus.h" @@ -182,7 +183,8 @@ static void mb_v_generic_machine_init(MachineClass *mc) mc->init = mb_v_generic_init; mc->min_cpus = 1; mc->max_cpus = 1; - mc->default_cpu_type = TYPE_RISCV_CPU_BASE; + mc->default_cpu_type = (target_riscv64()) ? TYPE_RISCV_CPU_BASE64 + : TYPE_RISCV_CPU_BASE32; mc->default_cpus = 1; } diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index d4b501802f..4da11db8b9 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -22,6 +22,7 @@ #include "qemu/units.h" #include "qemu/error-report.h" #include "qemu/guest-random.h" +#include "qemu/target-info.h" #include "qapi/error.h" #include "hw/core/boards.h" #include "hw/core/loader.h" @@ -1136,7 +1137,8 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data) mc->desc = "RISC-V VirtIO board"; mc->init = virt_machine_init; mc->max_cpus = VIRT_CPUS_MAX; - mc->default_cpu_type = TYPE_RISCV_CPU_BASE; + mc->default_cpu_type = (target_riscv64()) ? TYPE_RISCV_CPU_BASE64 + : TYPE_RISCV_CPU_BASE32; mc->block_default_type = IF_VIRTIO; mc->no_cdrom = 1; mc->pci_allow_0_address = true; -- 2.52.0
