xemu/target
Daniel Henrique Barboza faf3b5d86f target/riscv: rework write_misa()
write_misa() must use as much common logic as possible. We want to open
code just the bits that are exclusive to the CSR write operation and TCG
internals.

Our validation is done with riscv_cpu_validate_set_extensions(), but we
need a small tweak first. When enabling RVG we're doing:

        env->misa_ext |= RVI | RVM | RVA | RVF | RVD;
        env->misa_ext_mask = env->misa_ext;

This works fine for realize() time but this can potentially overwrite
env->misa_ext_mask if we reutilize the function for write_misa().

Instead of doing misa_ext_mask = misa_ext, sum up the RVG extensions in
misa_ext_mask as well. This won't change realize() time behavior
(misa_ext_mask will be == misa_ext) and will ensure that write_misa()
won't change misa_ext_mask by accident.

After that, rewrite write_misa() to work as follows:

- mask the write using misa_ext_mask to avoid enabling unsupported
  extensions;

- suppress RVC if the next insn isn't aligned;

- disable RVG if any of RVG dependencies are being disabled by the user;

- assign env->misa_ext and run riscv_cpu_validate_set_extensions(). On
  error, rollback env->misa_ext to its original value, logging a
  GUEST_ERROR to inform the user about the failed write;

- handle RVF and MSTATUS_FS and continue as usual.

Let's keep write_misa() as experimental for now until this logic gains
enough mileage.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Message-Id: <20230517135714.211809-12-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2023-06-13 17:05:42 +10:00
..
alpha accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
arm target/arm: Only include tcg/oversized-guest.h if CONFIG_TCG 2023-06-07 08:35:13 -07:00
avr accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
cris accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
hexagon target/*: Add missing includes of exec/translation-block.h 2023-06-05 12:04:29 -07:00
hppa accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
i386 hvf: add guest debugging handlers for Apple Silicon hosts 2023-06-06 10:19:30 +01:00
loongarch target/*: Add missing includes of exec/translation-block.h 2023-06-05 12:04:29 -07:00
m68k target/m68k/fpu_helper: Use FloatRelation enum to hold comparison result 2023-06-09 23:38:16 +03:00
microblaze accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
mips target/*: Add missing includes of exec/translation-block.h 2023-06-05 12:04:29 -07:00
nios2 accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
openrisc accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
ppc target/ppc: Implement gathering irq statistics 2023-06-10 10:19:24 -03:00
riscv target/riscv: rework write_misa() 2023-06-13 17:05:42 +10:00
rx accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
s390x * Fix emulated LCCB, LOCFHR, MXDB and MXDBR s390x instructions 2023-06-06 07:07:37 -07:00
sh4 accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
sparc accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
tricore target/tricore: Fix wrong PSW for call insns 2023-06-07 18:20:48 +02:00
xtensa accel/tcg: Introduce translator_io_start 2023-06-05 12:04:29 -07:00
Kconfig hw/loongarch: Add support loongson3 virt machine type. 2022-06-06 18:09:03 +00:00
meson.build target/loongarch: Add target build suport 2022-06-06 18:09:03 +00:00