target/riscv/kvm: initialize 'vlenb' via get-reg-list
authorDaniel Henrique Barboza <dbarboza@ventanamicro.com>
Tue, 23 Jan 2024 16:17:13 +0000 (13:17 -0300)
committerAlistair Francis <alistair.francis@wdc.com>
Fri, 9 Feb 2024 10:43:14 +0000 (20:43 +1000)
commitd4ff3da8f45c52670941c6e1b94e771d69d887e9
tree72765f75c3d787806616b26384c04cc4f93cea02
parentfafb0dc4d4805da596b0ad39281fa6df504d05b3
target/riscv/kvm: initialize 'vlenb' via get-reg-list

KVM will check for the correct 'reg_size' when accessing the vector
registers, erroring with EINVAL if we encode the wrong size in reg ID.
Vector registers varies in size with the vector length in bytes, or
'vlenb'. This means that we need the current 'vlenb' being used by the
host, otherwise we won't be able to fetch all vector regs.

We'll deal with 'vlenb' first. Its support was added in Linux 6.8 as a
get-reg-list register. We'll read 'vlenb' via get-reg-list and mark the
register as 'supported'. All 'vlenb' ops via kvm_arch_get_registers()
and kvm_arch_put_registers() will only be done if the reg is supported,
i.e. we fetched it in get-reg-list during init.

If the user sets a new vlenb value using the 'vlen' property, throw an
error if the user value differs from the host.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20240123161714.160149-3-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
target/riscv/kvm/kvm-cpu.c