diff options
Diffstat (limited to 'arch/mips/kvm')
-rw-r--r-- | arch/mips/kvm/mips.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index 5e41afe15ae8..7f86cb73d05d 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c | |||
@@ -797,6 +797,30 @@ static int kvm_mips_set_reg(struct kvm_vcpu *vcpu, | |||
797 | return 0; | 797 | return 0; |
798 | } | 798 | } |
799 | 799 | ||
800 | static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, | ||
801 | struct kvm_enable_cap *cap) | ||
802 | { | ||
803 | int r = 0; | ||
804 | |||
805 | if (!kvm_vm_ioctl_check_extension(vcpu->kvm, cap->cap)) | ||
806 | return -EINVAL; | ||
807 | if (cap->flags) | ||
808 | return -EINVAL; | ||
809 | if (cap->args[0]) | ||
810 | return -EINVAL; | ||
811 | |||
812 | switch (cap->cap) { | ||
813 | case KVM_CAP_MIPS_FPU: | ||
814 | vcpu->arch.fpu_enabled = true; | ||
815 | break; | ||
816 | default: | ||
817 | r = -EINVAL; | ||
818 | break; | ||
819 | } | ||
820 | |||
821 | return r; | ||
822 | } | ||
823 | |||
800 | long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, | 824 | long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, |
801 | unsigned long arg) | 825 | unsigned long arg) |
802 | { | 826 | { |
@@ -854,6 +878,15 @@ long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, | |||
854 | r = kvm_vcpu_ioctl_interrupt(vcpu, &irq); | 878 | r = kvm_vcpu_ioctl_interrupt(vcpu, &irq); |
855 | break; | 879 | break; |
856 | } | 880 | } |
881 | case KVM_ENABLE_CAP: { | ||
882 | struct kvm_enable_cap cap; | ||
883 | |||
884 | r = -EFAULT; | ||
885 | if (copy_from_user(&cap, argp, sizeof(cap))) | ||
886 | goto out; | ||
887 | r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap); | ||
888 | break; | ||
889 | } | ||
857 | default: | 890 | default: |
858 | r = -ENOIOCTLCMD; | 891 | r = -ENOIOCTLCMD; |
859 | } | 892 | } |
@@ -962,11 +995,15 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) | |||
962 | 995 | ||
963 | switch (ext) { | 996 | switch (ext) { |
964 | case KVM_CAP_ONE_REG: | 997 | case KVM_CAP_ONE_REG: |
998 | case KVM_CAP_ENABLE_CAP: | ||
965 | r = 1; | 999 | r = 1; |
966 | break; | 1000 | break; |
967 | case KVM_CAP_COALESCED_MMIO: | 1001 | case KVM_CAP_COALESCED_MMIO: |
968 | r = KVM_COALESCED_MMIO_PAGE_OFFSET; | 1002 | r = KVM_COALESCED_MMIO_PAGE_OFFSET; |
969 | break; | 1003 | break; |
1004 | case KVM_CAP_MIPS_FPU: | ||
1005 | r = !!cpu_has_fpu; | ||
1006 | break; | ||
970 | default: | 1007 | default: |
971 | r = 0; | 1008 | r = 0; |
972 | break; | 1009 | break; |