]> git.proxmox.com Git - mirror_qemu.git/commit
target/riscv: move 'mmu' to riscv_cpu_properties[]
authorDaniel Henrique Barboza <dbarboza@ventanamicro.com>
Fri, 5 Jan 2024 23:05:33 +0000 (20:05 -0300)
committerAlistair Francis <alistair.francis@wdc.com>
Fri, 9 Feb 2024 00:45:33 +0000 (10:45 +1000)
commitd06f28db60c536b9d7f159adedca397979f6e5ca
tree097f0b69d0705e139d828224d643eac7ba3d0264
parentd167a2247edefc640e95497321e571721cd7952e
target/riscv: move 'mmu' to riscv_cpu_properties[]

Commit 7f0bdfb5bfc ("target/riscv/cpu.c: remove cfg setup from
riscv_cpu_init()") already did some of the work by making some
cpu_init() functions to explictly enable their own 'mmu' default.

The generic CPUs didn't get update by that commit, so they are still
relying on the defaults set by the 'mmu' option. But having 'mmu' and
'pmp' being default=true will force CPUs that doesn't implement these
options to set them to 'false' in their cpu_init(), which isn't ideal.

We'll move 'mmu' to riscv_cpu_properties[] without any defaults, i.e.
the default will be 'false'. Compensate it by manually setting 'mmu =
true' to the generic CPUs that requires it.

Implement a setter for it to forbid the 'mmu' setting to be changed for
vendor CPUs. This will allow the option to exist for all CPUs and, at
the same time, protect vendor CPUs from undesired changes:

$ ./build/qemu-system-riscv64 -M virt -cpu sifive-e51,mmu=true
qemu-system-riscv64: can't apply global sifive-e51-riscv-cpu.mmu=true:
   CPU 'sifive-e51' does not allow changing the value of 'mmu'

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
Message-ID: <20240105230546.265053-5-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
target/riscv/cpu.c