diff options
author | Shannon Zhao <shannon.zhao@linaro.org> | 2016-01-11 07:56:17 -0500 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2016-02-29 13:34:21 -0500 |
commit | f577f6c2a6a5ccabe98061f256a1e2ff468d5e93 (patch) | |
tree | 278bd52115efb03e8d23ab4f80969a9bd1d6dab3 /arch/arm/kvm | |
parent | 808e738142e7086ef793ebf9797099c392894e65 (diff) |
arm64: KVM: Introduce per-vcpu kvm device controls
In some cases it needs to get/set attributes specific to a vcpu and so
needs something else than ONE_REG.
Let's copy the KVM_DEVICE approach, and define the respective ioctls
for the vcpu file descriptor.
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'arch/arm/kvm')
-rw-r--r-- | arch/arm/kvm/arm.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 9d133df2da53..166232356291 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c | |||
@@ -828,11 +828,51 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu, | |||
828 | return 0; | 828 | return 0; |
829 | } | 829 | } |
830 | 830 | ||
831 | static int kvm_arm_vcpu_set_attr(struct kvm_vcpu *vcpu, | ||
832 | struct kvm_device_attr *attr) | ||
833 | { | ||
834 | int ret = -ENXIO; | ||
835 | |||
836 | switch (attr->group) { | ||
837 | default: | ||
838 | break; | ||
839 | } | ||
840 | |||
841 | return ret; | ||
842 | } | ||
843 | |||
844 | static int kvm_arm_vcpu_get_attr(struct kvm_vcpu *vcpu, | ||
845 | struct kvm_device_attr *attr) | ||
846 | { | ||
847 | int ret = -ENXIO; | ||
848 | |||
849 | switch (attr->group) { | ||
850 | default: | ||
851 | break; | ||
852 | } | ||
853 | |||
854 | return ret; | ||
855 | } | ||
856 | |||
857 | static int kvm_arm_vcpu_has_attr(struct kvm_vcpu *vcpu, | ||
858 | struct kvm_device_attr *attr) | ||
859 | { | ||
860 | int ret = -ENXIO; | ||
861 | |||
862 | switch (attr->group) { | ||
863 | default: | ||
864 | break; | ||
865 | } | ||
866 | |||
867 | return ret; | ||
868 | } | ||
869 | |||
831 | long kvm_arch_vcpu_ioctl(struct file *filp, | 870 | long kvm_arch_vcpu_ioctl(struct file *filp, |
832 | unsigned int ioctl, unsigned long arg) | 871 | unsigned int ioctl, unsigned long arg) |
833 | { | 872 | { |
834 | struct kvm_vcpu *vcpu = filp->private_data; | 873 | struct kvm_vcpu *vcpu = filp->private_data; |
835 | void __user *argp = (void __user *)arg; | 874 | void __user *argp = (void __user *)arg; |
875 | struct kvm_device_attr attr; | ||
836 | 876 | ||
837 | switch (ioctl) { | 877 | switch (ioctl) { |
838 | case KVM_ARM_VCPU_INIT: { | 878 | case KVM_ARM_VCPU_INIT: { |
@@ -875,6 +915,21 @@ long kvm_arch_vcpu_ioctl(struct file *filp, | |||
875 | return -E2BIG; | 915 | return -E2BIG; |
876 | return kvm_arm_copy_reg_indices(vcpu, user_list->reg); | 916 | return kvm_arm_copy_reg_indices(vcpu, user_list->reg); |
877 | } | 917 | } |
918 | case KVM_SET_DEVICE_ATTR: { | ||
919 | if (copy_from_user(&attr, argp, sizeof(attr))) | ||
920 | return -EFAULT; | ||
921 | return kvm_arm_vcpu_set_attr(vcpu, &attr); | ||
922 | } | ||
923 | case KVM_GET_DEVICE_ATTR: { | ||
924 | if (copy_from_user(&attr, argp, sizeof(attr))) | ||
925 | return -EFAULT; | ||
926 | return kvm_arm_vcpu_get_attr(vcpu, &attr); | ||
927 | } | ||
928 | case KVM_HAS_DEVICE_ATTR: { | ||
929 | if (copy_from_user(&attr, argp, sizeof(attr))) | ||
930 | return -EFAULT; | ||
931 | return kvm_arm_vcpu_has_attr(vcpu, &attr); | ||
932 | } | ||
878 | default: | 933 | default: |
879 | return -EINVAL; | 934 | return -EINVAL; |
880 | } | 935 | } |