KVM: arm64: Rely on index_to_param() for size checks on userspace access
authorMarc Zyngier <maz@kernel.org>
Mon, 4 Jul 2022 16:01:50 +0000 (17:01 +0100)
committerMarc Zyngier <maz@kernel.org>
Sun, 17 Jul 2022 10:55:33 +0000 (11:55 +0100)
index_to_param() already checks that we use 64bit accesses for all
registers accessed from userspace.

However, we have extra checks in other places (such as index_to_params),
which is pretty confusing. Get rid off these redundant checks.

Reviewed-by: Reiji Watanabe <reijiw@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/sys_regs.c

index 0fbdb21..5dbe0f4 100644 (file)
@@ -2871,9 +2871,6 @@ int kvm_arm_sys_reg_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg
        if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_DEMUX)
                return demux_c15_get(reg->id, uaddr);
 
-       if (KVM_REG_SIZE(reg->id) != sizeof(__u64))
-               return -ENOENT;
-
        err = get_invariant_sys_reg(reg->id, uaddr);
        if (err != -ENOENT)
                return err;
@@ -2906,9 +2903,6 @@ int kvm_arm_sys_reg_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg
        if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_DEMUX)
                return demux_c15_set(reg->id, uaddr);
 
-       if (KVM_REG_SIZE(reg->id) != sizeof(__u64))
-               return -ENOENT;
-
        err = set_invariant_sys_reg(reg->id, uaddr);
        if (err != -ENOENT)
                return err;