]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/riscv/cpu.c: introduce cpu_cfg_ext_auto_update()
authorDaniel Henrique Barboza <dbarboza@ventanamicro.com>
Tue, 12 Sep 2023 13:24:18 +0000 (10:24 -0300)
committerAlistair Francis <alistair.francis@wdc.com>
Thu, 12 Oct 2023 01:45:53 +0000 (11:45 +1000)
commit997e71952d1eb8d60b0807d01cf3956d84728067
treea889d00ea9bb3ee7ff6e9cb94f7e6ef86e9a8e9b
parent238fd586e0bc06d104d2d095170945b97ea56e19
target/riscv/cpu.c: introduce cpu_cfg_ext_auto_update()

During realize() time we're activating a lot of extensions based on some
criteria, e.g.:

    if (cpu->cfg.ext_zk) {
        cpu->cfg.ext_zkn = true;
        cpu->cfg.ext_zkr = true;
        cpu->cfg.ext_zkt = true;
    }

This practice resulted in at least one case where we ended up enabling
something we shouldn't: RVC enabling zca/zcd/zcf when using a CPU that
has priv_spec older than 1.12.0.

We're also not considering user choice. There's no way of doing it now
but this is about to change in the next few patches.

cpu_cfg_ext_auto_update() will check for priv version mismatches before
enabling extensions. If we have a mismatch between the current priv
version and the extension we want to enable, do not enable it. In the
near future, this same function will also consider user choice when
deciding if we're going to enable/disable an extension or not.

For now let's use it to handle zca/zcd/zcf enablement if RVC is enabled.

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-16-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
target/riscv/cpu.c