@samitouri / QOSamiQemu / commits / 05f9c29e8d

target/riscv: move valid_vm_* satp arrays to cpu.c

These satp arrays are used internally in both csr.c and in cpu.c. csr.c is going to be moved to the TCG subdir in the next patch, and we want the satp logic to be available for KVM with --disable-tcg builds. Move these arrays to cpu.c to keep them available for KVM with --disable-tcg. Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Message-ID: <20260703180538.3346781-3-daniel.barboza@oss.qualcomm.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Daniel Henrique Barboza committed Jul 3, 2026 at 15:05 UTC 05f9c29e8d73aa5e0b1ce673733b74a59d0c76c6
4 files changed +16 -14
target/riscv/cpu.c
+13
@@ -65,6 +65,19 @@ const uint32_t misa_bits[] = {RVI, RVE, RVM, RVA, RVF, RVD, RVV,
65 #define BYTE(x) (x)
66 #endif
67
68 +/* SATP bits that are shared between TCG and KVM */
69 +const bool valid_vm_1_10_32[16] = {
70 + [VM_1_10_MBARE] = true,
71 + [VM_1_10_SV32] = true
72 +};
73 +
74 +const bool valid_vm_1_10_64[16] = {
75 + [VM_1_10_MBARE] = true,
76 + [VM_1_10_SV39] = true,
77 + [VM_1_10_SV48] = true,
78 + [VM_1_10_SV57] = true
79 +};
80 +
81 bool riscv_cpu_is_32bit(RISCVCPU *cpu)
82 {
83 return riscv_cpu_mxl(&cpu->env) == MXL_RV32;
target/riscv/cpu.h
-2
@@ -968,8 +968,6 @@ void riscv_cpu_finalize_features(RISCVCPU *cpu, Error **errp);
968 void riscv_add_satp_mode_properties(Object *obj);
969 bool riscv_cpu_accelerator_compatible(RISCVCPU *cpu);
970
971 -extern const bool valid_vm_1_10_32[], valid_vm_1_10_64[];
972 -
971 void riscv_cpu_register_gdb_regs_for_features(CPUState *cs);
972
973 const char *satp_mode_str(uint8_t satp_mode, bool is_32_bit);
target/riscv/csr.c
-12
@@ -1875,18 +1875,6 @@ static const uint64_t hvien_writable_mask = LOCAL_INTERRUPTS;
1875
1876 static const uint64_t vsip_writable_mask = MIP_VSSIP | LOCAL_INTERRUPTS;
1877
1878 -const bool valid_vm_1_10_32[16] = {
1879 - [VM_1_10_MBARE] = true,
1880 - [VM_1_10_SV32] = true
1881 -};
1882 -
1883 -const bool valid_vm_1_10_64[16] = {
1884 - [VM_1_10_MBARE] = true,
1885 - [VM_1_10_SV39] = true,
1886 - [VM_1_10_SV48] = true,
1887 - [VM_1_10_SV57] = true
1888 -};
1889 -
1878 /* Machine Information Registers */
1879 static RISCVException read_zero(CPURISCVState *env, int csrno,
1880 target_ulong *val)
target/riscv/csr.h
+3
@@ -72,6 +72,9 @@ enum {
72 CSR_TABLE_SIZE = 0x1000
73 };
74
75 +/* valid_vm_* arrays are shared with KVM via cpu.c */
76 +extern const bool valid_vm_1_10_32[], valid_vm_1_10_64[];
77 +
78 /* CSR function table */
79 extern riscv_csr_operations csr_ops[CSR_TABLE_SIZE];
80