@samitouri / QOSamiQemu / commits / 601c8494c6

target/riscv/tcg: disable svnapot if satp_mode < sv39

We did a recent change to disable svpbmt if satp_mode < sv39 that was discovered via a gitlab report. This time we don't have an opened bug but the problem is similar: RISC-V privileged ISA, chapter '"Svnapot" Extension for NAPOT Translation Contiguity, Version 1.0' states: "The Svnapot extension depends on the Sv39 extension." Do the same thing with svnapot, including the user warning in case we try to enable it without the required satp_mode: $ ./build/qemu-system-riscv64 -M virt,dumpdtb=fdt.dtb \ -cpu max,sv39=off,sv48=off,sv57=off,sv64=off,svnapot=on qemu-system-riscv64: warning: svnapot requires at least satp sv39, current satp mode: none Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20260527213034.2094103-1-daniel.barboza@oss.qualcomm.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Daniel Henrique Barboza committed May 27, 2026 at 18:30 UTC 601c8494c6c7e73f5b3f30b5823de2c13c003990
1 file changed +10
target/riscv/tcg/tcg-cpu.c
+10
@@ -848,6 +848,16 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
848 riscv_cpu_is_32bit(cpu)));
849 }
850 }
851 +
852 + if (cpu->cfg.ext_svnapot && cpu->cfg.max_satp_mode < VM_1_10_SV39) {
853 + cpu->cfg.ext_svnapot = false;
854 + if (cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_svnapot))) {
855 + warn_report("svnapot requires at least satp sv39, "
856 + "current satp mode: %s",
857 + satp_mode_str(cpu->cfg.max_satp_mode,
858 + riscv_cpu_is_32bit(cpu)));
859 + }
860 + }
861 #endif
862 /*
863 * Disable isa extensions based on priv spec after we