[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 04/19] target/riscv/cpu.c: set satp_mode_max MBARE during satp
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH v8 04/19] target/riscv/cpu.c: set satp_mode_max MBARE during satp_finalize() |
Date: |
Wed, 1 Nov 2023 17:41:49 -0300 |
KVM CPUs can handle "cpu->cfg.satp_mode.supported == 0" because KVM will
make it do internally, not requiring the current SATP support from TCG.
But other TCG CPUs doesn't deal well with it. We'll assert out before
OpenSBI if the CPU doesn't set a default:
ERROR:../target/riscv/cpu.c:317:satp_mode_max_from_map: assertion failed: (map
> 0)
Bail out! ERROR:../target/riscv/cpu.c:317:satp_mode_max_from_map: assertion
failed: (map > 0)
This will be thrown by target/riscv/csr.c, write_satp(), when stepping
in validate_vm().
There's no current CPUs affected by it, but next patch will add a new
CPU that doesn't have defaults and this assert will be hit.
Change riscv_cpu_satp_mode_finalize() to set satp_mode_max_supported()
to MBARE if the CPU happens to not have a max mode set yet.
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
target/riscv/cpu.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 9f6837ecb7..f7c1989d14 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -942,9 +942,19 @@ static void riscv_cpu_satp_mode_finalize(RISCVCPU *cpu,
Error **errp)
bool rv32 = riscv_cpu_mxl(&cpu->env) == MXL_RV32;
uint8_t satp_mode_map_max, satp_mode_supported_max;
- /* The CPU wants the OS to decide which satp mode to use */
if (cpu->cfg.satp_mode.supported == 0) {
- return;
+ if (kvm_enabled()) {
+ /* The CPU wants the OS to decide which satp mode to use */
+ return;
+ }
+
+ /*
+ * We do not handle cpu->cfg.satp_mode.supported == 0
+ * with TCG yet. Set to MBARE.
+ */
+ if (tcg_enabled()) {
+ set_satp_mode_max_supported(cpu, VM_1_10_MBARE);
+ }
}
satp_mode_supported_max =
--
2.41.0
[PATCH v8 06/19] target/riscv: add rv64i CPU, Daniel Henrique Barboza, 2023/11/01
[PATCH v8 07/19] target/riscv: add zicbop extension flag, Daniel Henrique Barboza, 2023/11/01
[PATCH v8 08/19] target/riscv/tcg: add 'zic64b' support, Daniel Henrique Barboza, 2023/11/01