Now that the code is in place for KVM to support FPU in MIPS KVM guests, wire up the new KVM_CAP_MIPS_FPU capability. For backwards compatibility, the capability must be explicitly enabled in order to detect or make use of the FPU from the guest.
Unified · Split
| @@ -3312,6 +3312,19 @@ Parameters: none · 3311 unmodified lines | |||
| 3312 | This capability enables the in-kernel irqchip for s390. Please refer to | 3312 | This capability enables the in-kernel irqchip for s390. Please refer to |
| 3313 | "4.24 KVM_CREATE_IRQCHIP" for details. | 3313 | "4.24 KVM_CREATE_IRQCHIP" for details. |
| 3314 | 3314 | ||
| 3315 | 6.9 KVM_CAP_MIPS_FPU | ||
| 3316 | |||
| 3317 | Architectures: mips | ||
| 3318 | Target: vcpu | ||
| 3319 | Parameters: args[0] is reserved for future use (should be 0). | ||
| 3320 | |||
| 3321 | This capability allows the use of the host Floating Point Unit by the guest. It | ||
| 3322 | allows the Config1.FP bit to be set to enable the FPU in the guest. Once this is | ||
| 3323 | done the KVM_REG_MIPS_FPR_* and KVM_REG_MIPS_FCR_* registers can be accessed | ||
| 3324 | (depending on the current guest FPU register mode), and the Status.FR, | ||
| 3325 | Config5.FRE bits are accessible via the KVM API and also from the guest, | ||
| 3326 | depending on them being supported by the FPU. | ||
| 3327 | |||
| 3315 | 7. Capabilities that can be enabled on VMs | 3328 | 7. Capabilities that can be enabled on VMs |
| 3316 | ------------------------------------------ | 3329 | ------------------------------------------ |
| 3317 | 3330 | ||
| @@ -797,6 +797,30 @@ static int kvm_mips_set_reg(struct kvm_vcpu *vcpu, · 796 unmodified lines | |||
| 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, · 51 unmodified lines | |||
| 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) · 102 unmodified lines | |||
| 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; |
| @@ -802,6 +802,7 @@ struct kvm_ppc_smmu_info { · 801 unmodified lines | |||
| 802 | #define KVM_CAP_S390_MEM_OP 108 | 802 | #define KVM_CAP_S390_MEM_OP 108 |
| 803 | #define KVM_CAP_S390_USER_STSI 109 | 803 | #define KVM_CAP_S390_USER_STSI 109 |
| 804 | #define KVM_CAP_S390_SKEYS 110 | 804 | #define KVM_CAP_S390_SKEYS 110 |
| 805 | #define KVM_CAP_MIPS_FPU 111 | ||
| 805 | 806 | ||
| 806 | #ifdef KVM_CAP_IRQ_ROUTING | 807 | #ifdef KVM_CAP_IRQ_ROUTING |
| 807 | 808 | ||