]> asedeno.scripts.mit.edu Git - linux.git/commit
KVM: arm64/sve: Make register ioctl access errors more consistent
authorDave Martin <Dave.Martin@arm.com>
Thu, 11 Apr 2019 15:13:39 +0000 (16:13 +0100)
committerMarc Zyngier <marc.zyngier@arm.com>
Thu, 18 Apr 2019 16:14:01 +0000 (17:14 +0100)
commit52110aa95948deba724739fc9933070c3e2c7239
treea0e3df04fb0a3e0933262fb30b583c51db516f30
parentf8d4635aff7e2e46beedaf61517a1caa4a06ee42
KVM: arm64/sve: Make register ioctl access errors more consistent

Currently, the way error codes are generated when processing the
SVE register access ioctls in a bit haphazard.

This patch refactors the code so that the behaviour is more
consistent: now, -EINVAL should be returned only for unrecognised
register IDs or when some other runtime error occurs.  -ENOENT is
returned for register IDs that are recognised, but whose
corresponding register (or slice) does not exist for the vcpu.

To this end, in {get,set}_sve_reg() we now delegate the
vcpu_has_sve() check down into {get,set}_sve_vls() and
sve_reg_to_region().  The KVM_REG_ARM64_SVE_VLS special case is
picked off first, then sve_reg_to_region() plays the role of
exhaustively validating or rejecting the register ID and (where
accepted) computing the applicable register region as before.

sve_reg_to_region() is rearranged so that -ENOENT or -EPERM is not
returned prematurely, before checking whether reg->id is in a
recognised range.

-EPERM is now only returned when an attempt is made to access an
actually existing register slice on an unfinalized vcpu.

Fixes: e1c9c98345b3 ("KVM: arm64/sve: Add SVE support to register access ioctl interface")
Fixes: 9033bba4b535 ("KVM: arm64/sve: Add pseudo-register for the guest's vector lengths")
Suggested-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm64/kvm/guest.c