]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/riscv/kvm: add kvm_csr_cfgs[]
authorDaniel Henrique Barboza <dbarboza@ventanamicro.com>
Tue, 29 Apr 2025 12:44:17 +0000 (09:44 -0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 20 May 2025 07:03:56 +0000 (10:03 +0300)
commit6ba14ba513a4fef01f5e49e48230c1dffaa9115d
treee6df0646479a0c75289e52e97dd681b9e49d6dbe
parent90f7e23cb7baa6f836723c3ae44039e46fee2a6d
target/riscv/kvm: add kvm_csr_cfgs[]

At this moment we're not checking if the host has support for any
specific CSR before doing get/put regs. This will cause problems if the
host KVM doesn't support it (see [1] as an example).

We'll use the same approach done with the CPU extensions: read all known
KVM CSRs during init() to check for availability, then read/write them
if they are present. This will be made by either using get-reglist or by
directly reading the CSRs.

For now we'll just convert the CSRs to use a kvm_csr_cfg[] array,
reusing the same KVMCPUConfig abstraction we use for extensions, and use
the array in (get|put)_csr_regs() instead of manually listing them. A
lot of boilerplate will be added but at least we'll automate the get/put
procedure for CSRs, i.e. adding a new CSR in the future will be a matter
of adding it in kvm_csr_regs[] and everything else will be taken care
of.

Despite all the code changes no behavioral change is made.

[1] https://lore.kernel.org/qemu-riscv/CABJz62OfUDHYkQ0T3rGHStQprf1c7_E0qBLbLKhfv=+jb0SYAw@mail.gmail.com/

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20250429124421.223883-6-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Cc: qemu-stable@nongnu.org
(cherry picked from commit d3b6f1742c36e3a3c1e74cb60646ee98a4e39ea3)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
target/riscv/cpu.h
target/riscv/kvm/kvm-cpu.c