• Daniel Henrique Barboza's avatar
    RISC-V: KVM: return ENOENT in *_one_reg() when reg is unknown · 2a88f38c
    Daniel Henrique Barboza authored
    get_one_reg() and set_one_reg() are returning EINVAL errors for almost
    everything: if a reg doesn't exist, if a reg ID is malformatted, if the
    associated CPU extension that implements the reg isn't present in the
    host, and for set_one_reg() if the value being written is invalid.
    
    This isn't wrong according to the existing KVM API docs (EINVAL can be
    used when there's no such register) but adding more ENOENT instances
    will make easier for userspace to understand what went wrong.
    
    Existing userspaces can be affected by this error code change. We
    checked a few. As of current upstream code, crosvm doesn't check for any
    particular errno code when using kvm_(get|set)_one_reg(). Neither does
    QEMU. rust-vmm doesn't have kvm-riscv support yet. Thus we have a good
    chance of changing these error codes now while the KVM RISC-V ecosystem
    is still new, minimizing user impact.
    
    Change all get_one_reg() and set_one_reg() implementations to return
    -ENOENT at all "no such register" cases.
    Signed-off-by: default avatarDaniel Henrique Barboza <dbarboza@ventanamicro.com>
    Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
    Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
    2a88f38c
vcpu_sbi.c 10.2 KB