···599599EXPORT_SYMBOL_GPL(fx_init);600600601601/*602602- * Creates some virtual cpus. Good luck creating more than one.603603- */604604-static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)605605-{606606- int r;607607- struct kvm_vcpu *vcpu;608608-609609- r = -EINVAL;610610- if (!valid_vcpu(n))611611- goto out;612612-613613- vcpu = &kvm->vcpus[n];614614-615615- mutex_lock(&vcpu->mutex);616616-617617- if (vcpu->vmcs) {618618- mutex_unlock(&vcpu->mutex);619619- return -EEXIST;620620- }621621-622622- vcpu->host_fx_image = (char*)ALIGN((hva_t)vcpu->fx_buf,623623- FX_IMAGE_ALIGN);624624- vcpu->guest_fx_image = vcpu->host_fx_image + FX_IMAGE_SIZE;625625-626626- r = kvm_arch_ops->vcpu_create(vcpu);627627- if (r < 0)628628- goto out_free_vcpus;629629-630630- r = kvm_mmu_create(vcpu);631631- if (r < 0)632632- goto out_free_vcpus;633633-634634- kvm_arch_ops->vcpu_load(vcpu);635635- r = kvm_mmu_setup(vcpu);636636- if (r >= 0)637637- r = kvm_arch_ops->vcpu_setup(vcpu);638638- vcpu_put(vcpu);639639-640640- if (r < 0)641641- goto out_free_vcpus;642642-643643- return 0;644644-645645-out_free_vcpus:646646- kvm_free_vcpu(vcpu);647647- mutex_unlock(&vcpu->mutex);648648-out:649649- return r;650650-}651651-652652-/*653602 * Allocate some memory and give it an address in the guest physical address654603 * space.655604 *···1910196119111962 vcpu_put(vcpu);1912196319641964+ return r;19651965+}19661966+19671967+/*19681968+ * Creates some virtual cpus. Good luck creating more than one.19691969+ */19701970+static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)19711971+{19721972+ int r;19731973+ struct kvm_vcpu *vcpu;19741974+19751975+ r = -EINVAL;19761976+ if (!valid_vcpu(n))19771977+ goto out;19781978+19791979+ vcpu = &kvm->vcpus[n];19801980+19811981+ mutex_lock(&vcpu->mutex);19821982+19831983+ if (vcpu->vmcs) {19841984+ mutex_unlock(&vcpu->mutex);19851985+ return -EEXIST;19861986+ }19871987+19881988+ vcpu->host_fx_image = (char*)ALIGN((hva_t)vcpu->fx_buf,19891989+ FX_IMAGE_ALIGN);19901990+ vcpu->guest_fx_image = vcpu->host_fx_image + FX_IMAGE_SIZE;19911991+19921992+ r = kvm_arch_ops->vcpu_create(vcpu);19931993+ if (r < 0)19941994+ goto out_free_vcpus;19951995+19961996+ r = kvm_mmu_create(vcpu);19971997+ if (r < 0)19981998+ goto out_free_vcpus;19991999+20002000+ kvm_arch_ops->vcpu_load(vcpu);20012001+ r = kvm_mmu_setup(vcpu);20022002+ if (r >= 0)20032003+ r = kvm_arch_ops->vcpu_setup(vcpu);20042004+ vcpu_put(vcpu);20052005+20062006+ if (r < 0)20072007+ goto out_free_vcpus;20082008+20092009+ return 0;20102010+20112011+out_free_vcpus:20122012+ kvm_free_vcpu(vcpu);20132013+ mutex_unlock(&vcpu->mutex);20142014+out:19132015 return r;19142016}19152017