[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 01/26] target/riscv: assert argument to set_satp_mode_max_support
From: |
Paolo Bonzini |
Subject: |
[PATCH 01/26] target/riscv: assert argument to set_satp_mode_max_supported is valid |
Date: |
Mon, 12 May 2025 11:52:01 +0200 |
Check that the argument to set_satp_mode_max_supported is valid for
the MXL value of the CPU. It would be a bug in the CPU definition
if it weren't.
In fact, there is such a bug in riscv_bare_cpu_init(): not just
SV64 is not a valid VM mode for 32-bit CPUs, SV64 is not a
valid VM mode at all, not yet at least.
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/riscv/cpu.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index d92874baa06..0f7ce5305be 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -444,6 +444,8 @@ static void set_satp_mode_max_supported(RISCVCPU *cpu,
cpu->cfg.satp_mode.supported |= (1 << i);
}
}
+
+ assert(cpu->cfg.satp_mode.supported & (1 << satp_mode));
}
/* Set the satp mode to the max supported */
@@ -1497,7 +1499,9 @@ static void riscv_bare_cpu_init(Object *obj)
* satp_mode manually (see set_satp_mode_default()).
*/
#ifndef CONFIG_USER_ONLY
- set_satp_mode_max_supported(cpu, VM_1_10_SV64);
+ set_satp_mode_max_supported(RISCV_CPU(obj),
+ riscv_cpu_mxl(&RISCV_CPU(obj)->env) == MXL_RV32 ?
+ VM_1_10_SV32 : VM_1_10_SV57);
#endif
}
--
2.49.0
- [PATCH v5 00/26] target/riscv: SATP mode and CPU definition overhaul, Paolo Bonzini, 2025/05/12
- [PATCH 01/26] target/riscv: assert argument to set_satp_mode_max_supported is valid,
Paolo Bonzini <=
- [PATCH 02/26] target/riscv: cpu: store max SATP mode as a single integer, Paolo Bonzini, 2025/05/12
- [PATCH 03/26] target/riscv: update max_satp_mode based on QOM properties, Paolo Bonzini, 2025/05/12
- [PATCH 05/26] target/riscv: move satp_mode.{map, init} out of CPUConfig, Paolo Bonzini, 2025/05/12
- [PATCH 07/26] target/riscv: store RISCVCPUDef struct directly in the class, Paolo Bonzini, 2025/05/12
- [PATCH 09/26] target/riscv: move RISCVCPUConfig fields to a header file, Paolo Bonzini, 2025/05/12
- [PATCH 06/26] target/riscv: introduce RISCVCPUDef, Paolo Bonzini, 2025/05/12
- [PATCH 04/26] target/riscv: remove supported from RISCVSATPMap, Paolo Bonzini, 2025/05/12
- [PATCH 11/26] target/riscv: add more RISCVCPUDef fields, Paolo Bonzini, 2025/05/12