]> xenbits.xensource.com Git - people/pauldu/linux.git/commitdiff
RISC-V: KVM: set 'vlenb' in kvm_riscv_vcpu_alloc_vector_context()
authorDaniel Henrique Barboza <dbarboza@ventanamicro.com>
Tue, 5 Dec 2023 17:45:07 +0000 (14:45 -0300)
committerAnup Patel <anup@brainfault.org>
Fri, 29 Dec 2023 07:01:53 +0000 (12:31 +0530)
'vlenb', added to riscv_v_ext_state by commit c35f3aa34509 ("RISC-V:
vector: export VLENB csr in __sc_riscv_v_state"), isn't being
initialized in guest_context. If we export 'vlenb' as a KVM CSR,
something we want to do in the next patch, it'll always return 0.

Set 'vlenb' to riscv_v_size/32.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/vcpu_vector.c

index b339a2682f252bb8c0ac6d3803a8eab46e1e1443..530e49c588d6c6e1db700cac8e87f4a032d48d26 100644 (file)
@@ -76,6 +76,7 @@ int kvm_riscv_vcpu_alloc_vector_context(struct kvm_vcpu *vcpu,
        cntx->vector.datap = kmalloc(riscv_v_vsize, GFP_KERNEL);
        if (!cntx->vector.datap)
                return -ENOMEM;
+       cntx->vector.vlenb = riscv_v_vsize / 32;
 
        vcpu->arch.host_context.vector.datap = kzalloc(riscv_v_vsize, GFP_KERNEL);
        if (!vcpu->arch.host_context.vector.datap)