arm64: KVM: Fix system register enumeration
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 2 Apr 2019 02:28:39 +0000 (03:28 +0100)
committerMarc Zyngier <marc.zyngier@arm.com>
Tue, 2 Apr 2019 04:13:40 +0000 (05:13 +0100)
The introduction of the SVE registers to userspace started with a
refactoring of the way we expose any register via the ONE_REG
interface.

Unfortunately, this change doesn't exactly behave as expected
if the number of registers is non-zero and consider everything
to be an error. The visible result is that QEMU barfs very early
when creating vcpus.

Make sure we only exit early in case there is an actual error, rather
than a positive number of registers...

Fixes: be25bbb392fa ("KVM: arm64: Factor out core register ID enumeration")
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm64/kvm/guest.c

index 086ab0508d694c0287b9a96048dc86ab33339719..4f7b26bbf671fd2c5e4c14f7523b5d2fe178a1c3 100644 (file)
@@ -604,22 +604,22 @@ int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices)
        int ret;
 
        ret = copy_core_reg_indices(vcpu, uindices);
-       if (ret)
+       if (ret < 0)
                return ret;
        uindices += ret;
 
        ret = copy_sve_reg_indices(vcpu, uindices);
-       if (ret)
+       if (ret < 0)
                return ret;
        uindices += ret;
 
        ret = kvm_arm_copy_fw_reg_indices(vcpu, uindices);
-       if (ret)
+       if (ret < 0)
                return ret;
        uindices += kvm_arm_get_fw_num_regs(vcpu);
 
        ret = copy_timer_indices(vcpu, uindices);
-       if (ret)
+       if (ret < 0)
                return ret;
        uindices += NUM_TIMER_REGS;