diff options
author | Daniel Henrique Barboza <dbarboza@ventanamicro.com> | 2025-04-29 09:44:18 -0300 |
---|---|---|
committer | Alistair Francis <alistair.francis@wdc.com> | 2025-05-19 13:42:34 +1000 |
commit | f396c217a53d9b7960dd002fbb07cfe1d46b27aa (patch) | |
tree | be4ce2fca8ed375bda039e163dfa29622d39c0da /python | |
parent | d3b6f1742c36e3a3c1e74cb60646ee98a4e39ea3 (diff) | |
download | qemu-f396c217a53d9b7960dd002fbb07cfe1d46b27aa.zip qemu-f396c217a53d9b7960dd002fbb07cfe1d46b27aa.tar.gz qemu-f396c217a53d9b7960dd002fbb07cfe1d46b27aa.tar.bz2 |
target/riscv/kvm: do not read unavailable CSRs
[1] reports that commit 4db19d5b21 broke a KVM guest running kernel 6.6.
This happens because the kernel does not know 'senvcfg', making it
unable to boot because QEMU is reading/wriiting it without any checks.
After converting the CSRs to do "automated" get/put reg procedures in
the previous patch we can now scan for availability. Two functions are
created:
- kvm_riscv_read_csr_cfg_legacy() will check if the CSR exists by brute
forcing KVM_GET_ONE_REG in each one of them, interpreting an EINVAL
return as indication that the CSR isn't available. This will be use in
absence of KVM_GET_REG_LIST;
- kvm_riscv_read_csr_cfg() will use the existing result of get_reg_list
to check if the CSRs ids are present.
kvm_riscv_init_multiext_cfg() is now kvm_riscv_init_cfg() to reflect that
the function is also dealing with CSRs.
[1] https://lore.kernel.org/qemu-riscv/CABJz62OfUDHYkQ0T3rGHStQprf1c7_E0qBLbLKhfv=+jb0SYAw@mail.gmail.com/
Fixes: 4db19d5b21 ("target/riscv/kvm: add missing KVM CSRs")
Reported-by: Andrea Bolognani <abologna@redhat.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-7-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Cc: qemu-stable@nongnu.org
Diffstat (limited to 'python')
0 files changed, 0 insertions, 0 deletions