@samitouri / QOSamiQemu / commits / 1dbf46d97b

target/riscv/cpu.c: add 'svbare' satp-mode

Seems like we forgot to add a flag to set satp-mode=bare. What we're doing instead is to set the CPU default satp-mode to 'off' to set it to bare ... assuming we know the default satp-mode. Otherwise one needs to do -cpu X,sv39=off,sv48=off,sv57=off,sv64=off to get a bare-mode CPU. Add a flag to make this process easier. The name choice is based on the fact that I didn't find many references to 'mbare' in RISC-V docs, but 'svbare' is a flag name that toolchain uses to set satp-mode=bare. Might as well use the same name to help with cross project compat. After this patch: $ ./build/qemu-system-riscv64 -M virt,dumpdtb=fdt.dtb -cpu rv64 $ dtc -I dtb -O dts fdt.dtb | grep mmu-type mmu-type = "riscv,sv57"; $ ./build/qemu-system-riscv64 -M virt,dumpdtb=fdt.dtb -cpu rv64,svbare=on $ dtc -I dtb -O dts fdt.dtb | grep mmu-type mmu-type = "riscv,none"; Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com> Message-ID: <20260611162223.2361941-2-daniel.barboza@oss.qualcomm.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Daniel Henrique Barboza committed Jun 11, 2026 at 13:22 UTC 1dbf46d97b807639214ec6eede442fd91af2299d
1 file changed +4 -1
target/riscv/cpu.c
+4 -1
@@ -418,7 +418,7 @@ int riscv_cpu_max_xlen(RISCVCPUClass *mcc)
418 #ifndef CONFIG_USER_ONLY
419 static uint8_t satp_mode_from_str(const char *satp_mode_str)
420 {
421 - if (!strncmp(satp_mode_str, "mbare", 5)) {
421 + if (!strncmp(satp_mode_str, "svbare", 6)) {
422 return VM_1_10_MBARE;
423 }
424
@@ -1063,6 +1063,9 @@ void riscv_add_satp_mode_properties(Object *obj)
1063 {
1064 RISCVCPU *cpu = RISCV_CPU(obj);
1065
1066 + object_property_add(obj, "svbare", "bool", cpu_riscv_get_satp,
1067 + cpu_riscv_set_satp, NULL, &cpu->satp_modes);
1068 +
1069 if (cpu->env.misa_mxl == MXL_RV32) {
1070 object_property_add(obj, "sv32", "bool", cpu_riscv_get_satp,
1071 cpu_riscv_set_satp, NULL, &cpu->satp_modes);