mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-27 06:04:23 +08:00
RISC-V: KVM: add 'vlenb' Vector CSR
Userspace requires 'vlenb' to be able to encode it in reg ID. Otherwise it is not possible to retrieve any vector reg since we're returning EINVAL if reg_size isn't vlenb (see kvm_riscv_vcpu_vreg_addr()). Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
parent
197bd237b6
commit
2fa290372d
@ -116,6 +116,9 @@ static int kvm_riscv_vcpu_vreg_addr(struct kvm_vcpu *vcpu,
|
|||||||
case KVM_REG_RISCV_VECTOR_CSR_REG(vcsr):
|
case KVM_REG_RISCV_VECTOR_CSR_REG(vcsr):
|
||||||
*reg_addr = &cntx->vector.vcsr;
|
*reg_addr = &cntx->vector.vcsr;
|
||||||
break;
|
break;
|
||||||
|
case KVM_REG_RISCV_VECTOR_CSR_REG(vlenb):
|
||||||
|
*reg_addr = &cntx->vector.vlenb;
|
||||||
|
break;
|
||||||
case KVM_REG_RISCV_VECTOR_CSR_REG(datap):
|
case KVM_REG_RISCV_VECTOR_CSR_REG(datap):
|
||||||
default:
|
default:
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
@ -174,6 +177,18 @@ int kvm_riscv_vcpu_set_reg_vector(struct kvm_vcpu *vcpu,
|
|||||||
if (!riscv_isa_extension_available(isa, v))
|
if (!riscv_isa_extension_available(isa, v))
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
|
if (reg_num == KVM_REG_RISCV_VECTOR_CSR_REG(vlenb)) {
|
||||||
|
struct kvm_cpu_context *cntx = &vcpu->arch.guest_context;
|
||||||
|
unsigned long reg_val;
|
||||||
|
|
||||||
|
if (copy_from_user(®_val, uaddr, reg_size))
|
||||||
|
return -EFAULT;
|
||||||
|
if (reg_val != cntx->vector.vlenb)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
rc = kvm_riscv_vcpu_vreg_addr(vcpu, reg_num, reg_size, ®_addr);
|
rc = kvm_riscv_vcpu_vreg_addr(vcpu, reg_num, reg_size, ®_addr);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user