target/riscv/cpu.c: honor user choice in cpu_cfg_ext_auto_update()
commit0a9eb9b497f3d349da77073e704c1a010cb788e5
authorDaniel Henrique Barboza <dbarboza@ventanamicro.com>
Tue, 12 Sep 2023 13:24:22 +0000 (12 10:24 -0300)
committerAlistair Francis <alistair.francis@wdc.com>
Thu, 12 Oct 2023 01:50:23 +0000 (12 11:50 +1000)
treef36b91d0a69c0c60a1eeb4333ad75c158d19b0c8
parent25aa6f7202d5403ac123abe5cd5ff08f2e003f77
target/riscv/cpu.c: honor user choice in cpu_cfg_ext_auto_update()

Add a new cpu_cfg_ext_is_user_set() helper to check if an extension was
set by the user in the command line. Use it inside
cpu_cfg_ext_auto_update() to verify if the user set a certain extension
and, if that's the case, do not change its value.

This will make us honor user choice instead of overwriting the values.
Users will then be informed whether they're using an incompatible set of
extensions instead of QEMU setting a magic value that works.

The reason why we're not implementing user choice for MISA extensions
right now is because, today, we do not silently change any MISA bit
during realize() time (we do warn when enabling bits if RVG is enabled).
We do that - a lot - with multi-letter extensions though, so we're
handling the most immediate concern first.

After this patch, we'll now error out if the user explicitly set 'zce' to true
and 'zca' to false:

$ ./build/qemu-system-riscv64 -M virt -cpu rv64,zce=true,zca=false -nographic
qemu-system-riscv64: Zcf/Zcd/Zcb/Zcmp/Zcmt extensions require Zca extension

This didn't happen before because we were enabling 'zca' if 'zce' was enabled
regardless if the user set 'zca' to false.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Message-ID: <20230912132423.268494-20-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
target/riscv/cpu.c