History

MIPS: KVM: Wire up MSA capability

Now that the code is in place for KVM to support MIPS SIMD Architecutre (MSA) in MIPS guests, wire up the new KVM_CAP_MIPS_MSA capability. For backwards compatibility, the capability must be explicitly enabled in order to detect or make use of MSA from the guest. The capability is not supported if the hardware supports MSA vector partitioning, since the extra support cannot be tested yet and it extends the state that the userland program would have to save.

James Hogan committed 11 years ago

Commit d952bd01 parent ab86bd63 files · +31 −0Browse files

Unified · Split

3 files
  1. Documentation/virtual/kvm/api.txt +12 −0
  2. arch/mips/kvm/mips.c +18 −0
  3. include/uapi/linux/kvm.h +1 −0
Documentation/virtual/kvm/api.txt+12−0
@@ -3335,6 +3335,18 @@ done the KVM_REG_MIPS_FPR_* and KVM_REG_MIPS_FCR_* registers can be accessed · 3334 unmodified lines
33353335 Config5.FRE bits are accessible via the KVM API and also from the guest,
33363336 depending on them being supported by the FPU.
33373337
3338+6.10 KVM_CAP_MIPS_MSA
3339+
3340+Architectures: mips
3341+Target: vcpu
3342+Parameters: args[0] is reserved for future use (should be 0).
3343+
3344+This capability allows the use of the MIPS SIMD Architecture (MSA) by the guest.
3345+It allows the Config3.MSAP bit to be set to enable the use of MSA by the guest.
3346+Once this is done the KVM_REG_MIPS_VEC_* and KVM_REG_MIPS_MSA_* registers can be
3347+accessed, and the Config5.MSAEn bit is accessible via the KVM API and also from
3348+the guest.
3349+
33383350 7. Capabilities that can be enabled on VMs
33393351 ------------------------------------------
33403352
arch/mips/kvm/mips.c+18−0
@@ -880,6 +880,9 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, · 879 unmodified lines
880880 case KVM_CAP_MIPS_FPU:
881881 vcpu->arch.fpu_enabled = true;
882882 break;
883+ case KVM_CAP_MIPS_MSA:
884+ vcpu->arch.msa_enabled = true;
885+ break;
883886 default:
884887 r = -EINVAL;
885888 break;
@@ -1071,6 +1074,21 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) · 185 unmodified lines
10711074 case KVM_CAP_MIPS_FPU:
10721075 r = !!cpu_has_fpu;
10731076 break;
1077+ case KVM_CAP_MIPS_MSA:
1078+ /*
1079+ * We don't support MSA vector partitioning yet:
1080+ * 1) It would require explicit support which can't be tested
1081+ * yet due to lack of support in current hardware.
1082+ * 2) It extends the state that would need to be saved/restored
1083+ * by e.g. QEMU for migration.
1084+ *
1085+ * When vector partitioning hardware becomes available, support
1086+ * could be added by requiring a flag when enabling
1087+ * KVM_CAP_MIPS_MSA capability to indicate that userland knows
1088+ * to save/restore the appropriate extra state.
1089+ */
1090+ r = cpu_has_msa && !(boot_cpu_data.msa_id & MSA_IR_WRPF);
1091+ break;
10741092 default:
10751093 r = 0;
10761094 break;
include/uapi/linux/kvm.h+1−0
@@ -803,6 +803,7 @@ struct kvm_ppc_smmu_info { · 802 unmodified lines
803803 #define KVM_CAP_S390_USER_STSI 109
804804 #define KVM_CAP_S390_SKEYS 110
805805 #define KVM_CAP_MIPS_FPU 111
806+#define KVM_CAP_MIPS_MSA 112
806807
807808 #ifdef KVM_CAP_IRQ_ROUTING
808809

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