History

MIPS: KVM: Wire up FPU capability

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.

James Hogan committed 11 years ago

Commit 5fafd871 parent 379245c3 files · +51 −0Browse files

Unified · Split

3 files
  1. Documentation/virtual/kvm/api.txt +13 −0
  2. arch/mips/kvm/mips.c +37 −0
  3. include/uapi/linux/kvm.h +1 −0
Documentation/virtual/kvm/api.txt+13−0
@@ -3312,6 +3312,19 @@ Parameters: none · 3311 unmodified lines
33123312 This capability enables the in-kernel irqchip for s390. Please refer to
33133313 "4.24 KVM_CREATE_IRQCHIP" for details.
33143314
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+
33153328 7. Capabilities that can be enabled on VMs
33163329 ------------------------------------------
33173330
arch/mips/kvm/mips.c+37−0
@@ -797,6 +797,30 @@ static int kvm_mips_set_reg(struct kvm_vcpu *vcpu, · 796 unmodified lines
797797 return 0;
798798 }
799799
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+
800824 long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl,
801825 unsigned long arg)
802826 {
@@ -854,6 +878,15 @@ long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, · 51 unmodified lines
854878 r = kvm_vcpu_ioctl_interrupt(vcpu, &irq);
855879 break;
856880 }
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+ }
857890 default:
858891 r = -ENOIOCTLCMD;
859892 }
@@ -962,11 +995,15 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) · 102 unmodified lines
962995
963996 switch (ext) {
964997 case KVM_CAP_ONE_REG:
998+ case KVM_CAP_ENABLE_CAP:
965999 r = 1;
9661000 break;
9671001 case KVM_CAP_COALESCED_MMIO:
9681002 r = KVM_COALESCED_MMIO_PAGE_OFFSET;
9691003 break;
1004+ case KVM_CAP_MIPS_FPU:
1005+ r = !!cpu_has_fpu;
1006+ break;
9701007 default:
9711008 r = 0;
9721009 break;
include/uapi/linux/kvm.h+1−0
@@ -802,6 +802,7 @@ struct kvm_ppc_smmu_info { · 801 unmodified lines
802802 #define KVM_CAP_S390_MEM_OP 108
803803 #define KVM_CAP_S390_USER_STSI 109
804804 #define KVM_CAP_S390_SKEYS 110
805+#define KVM_CAP_MIPS_FPU 111
805806
806807 #ifdef KVM_CAP_IRQ_ROUTING
807808

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t