]> 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>
Sun, 25 May 2025 10:14:52 +0000 (13:14 +0300)
commit289dcab554eddb536055e1ddc058d7d838f299af
tree5d8411e756c37e779da557e24e56fcade6cbd0ae
parente2d4d3c2ac9e01bad0a734f3c51c93815eda9ffb
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