fefc294baa
'priv_spec' and 'vext_spec' are two string options used as a fancy way of setting integers in the CPU state (cpu->env.priv_ver and cpu->env.vext_ver). It requires us to deal with string parsing and to store them in cpu_cfg. We must support these string options, but we don't need to store them. We have a precedence for this kind of arrangement in target/ppc/compat.c, ppc_compat_prop_get|set, getters and setters used for the 'max-cpu-compat' class property of the pseries ppc64 machine. We'll do the same with both 'priv_spec' and 'vext_spec'. For 'priv_spec', the validation from riscv_cpu_validate_priv_spec() will be done by the prop_priv_spec_set() setter, while also preventing it to be changed for vendor CPUs. Add two helpers that converts env->priv_ver back and forth to its string representation. These helpers allow us to get a string and set 'env->priv_ver' and return a string giving the current env->priv_ver value. In other words, make the cpu->cfg.priv_spec string obsolete. Last but not the least, move the reworked 'priv_spec' option to riscv_cpu_properties[]. After all said and done, we don't need to store the 'priv_spec' string in the CPU state, and we're now protecting vendor CPUs from priv_ver changes: $ ./build/qemu-system-riscv64 -M virt -cpu sifive-e51,priv_spec="v1.12.0" qemu-system-riscv64: can't apply global sifive-e51-riscv-cpu.priv_spec=v1.12.0: CPU 'sifive-e51' does not allow changing the value of 'priv_spec' Current 'priv_spec' val: v1.10.0 $ 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-7-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
||
---|---|---|
.. | ||
insn_trans | ||
kvm | ||
tcg | ||
arch_dump.c | ||
bitmanip_helper.c | ||
common-semi-target.h | ||
cpu_bits.h | ||
cpu_cfg.h | ||
cpu_helper.c | ||
cpu_user.h | ||
cpu_vendorid.h | ||
cpu-param.h | ||
cpu-qom.h | ||
cpu.c | ||
cpu.h | ||
crypto_helper.c | ||
csr.c | ||
debug.c | ||
debug.h | ||
fpu_helper.c | ||
gdbstub.c | ||
helper.h | ||
insn16.decode | ||
insn32.decode | ||
instmap.h | ||
internals.h | ||
Kconfig | ||
m128_helper.c | ||
machine.c | ||
meson.build | ||
monitor.c | ||
op_helper.c | ||
pmp.c | ||
pmp.h | ||
pmu.c | ||
pmu.h | ||
riscv-qmp-cmds.c | ||
sbi_ecall_interface.h | ||
time_helper.c | ||
time_helper.h | ||
trace-events | ||
trace.h | ||
translate.c | ||
vcrypto_helper.c | ||
vector_helper.c | ||
vector_internals.c | ||
vector_internals.h | ||
xthead.decode | ||
XVentanaCondOps.decode | ||
zce_helper.c |