mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 20:20:50 +07:00
KVM: Move kvm_vm_ioctl_create_vcpu() around
In preparation of some hacking. Signed-off-by: Avi Kivity <avi@qumranet.com>
This commit is contained in:
parent
2c6f5df979
commit
c5ea766006
@ -598,57 +598,6 @@ void fx_init(struct kvm_vcpu *vcpu)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(fx_init);
|
||||
|
||||
/*
|
||||
* Creates some virtual cpus. Good luck creating more than one.
|
||||
*/
|
||||
static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
|
||||
{
|
||||
int r;
|
||||
struct kvm_vcpu *vcpu;
|
||||
|
||||
r = -EINVAL;
|
||||
if (!valid_vcpu(n))
|
||||
goto out;
|
||||
|
||||
vcpu = &kvm->vcpus[n];
|
||||
|
||||
mutex_lock(&vcpu->mutex);
|
||||
|
||||
if (vcpu->vmcs) {
|
||||
mutex_unlock(&vcpu->mutex);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
vcpu->host_fx_image = (char*)ALIGN((hva_t)vcpu->fx_buf,
|
||||
FX_IMAGE_ALIGN);
|
||||
vcpu->guest_fx_image = vcpu->host_fx_image + FX_IMAGE_SIZE;
|
||||
|
||||
r = kvm_arch_ops->vcpu_create(vcpu);
|
||||
if (r < 0)
|
||||
goto out_free_vcpus;
|
||||
|
||||
r = kvm_mmu_create(vcpu);
|
||||
if (r < 0)
|
||||
goto out_free_vcpus;
|
||||
|
||||
kvm_arch_ops->vcpu_load(vcpu);
|
||||
r = kvm_mmu_setup(vcpu);
|
||||
if (r >= 0)
|
||||
r = kvm_arch_ops->vcpu_setup(vcpu);
|
||||
vcpu_put(vcpu);
|
||||
|
||||
if (r < 0)
|
||||
goto out_free_vcpus;
|
||||
|
||||
return 0;
|
||||
|
||||
out_free_vcpus:
|
||||
kvm_free_vcpu(vcpu);
|
||||
mutex_unlock(&vcpu->mutex);
|
||||
out:
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate some memory and give it an address in the guest physical address
|
||||
* space.
|
||||
@ -1964,6 +1913,57 @@ static int kvm_vm_ioctl_debug_guest(struct kvm *kvm,
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates some virtual cpus. Good luck creating more than one.
|
||||
*/
|
||||
static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
|
||||
{
|
||||
int r;
|
||||
struct kvm_vcpu *vcpu;
|
||||
|
||||
r = -EINVAL;
|
||||
if (!valid_vcpu(n))
|
||||
goto out;
|
||||
|
||||
vcpu = &kvm->vcpus[n];
|
||||
|
||||
mutex_lock(&vcpu->mutex);
|
||||
|
||||
if (vcpu->vmcs) {
|
||||
mutex_unlock(&vcpu->mutex);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
vcpu->host_fx_image = (char*)ALIGN((hva_t)vcpu->fx_buf,
|
||||
FX_IMAGE_ALIGN);
|
||||
vcpu->guest_fx_image = vcpu->host_fx_image + FX_IMAGE_SIZE;
|
||||
|
||||
r = kvm_arch_ops->vcpu_create(vcpu);
|
||||
if (r < 0)
|
||||
goto out_free_vcpus;
|
||||
|
||||
r = kvm_mmu_create(vcpu);
|
||||
if (r < 0)
|
||||
goto out_free_vcpus;
|
||||
|
||||
kvm_arch_ops->vcpu_load(vcpu);
|
||||
r = kvm_mmu_setup(vcpu);
|
||||
if (r >= 0)
|
||||
r = kvm_arch_ops->vcpu_setup(vcpu);
|
||||
vcpu_put(vcpu);
|
||||
|
||||
if (r < 0)
|
||||
goto out_free_vcpus;
|
||||
|
||||
return 0;
|
||||
|
||||
out_free_vcpus:
|
||||
kvm_free_vcpu(vcpu);
|
||||
mutex_unlock(&vcpu->mutex);
|
||||
out:
|
||||
return r;
|
||||
}
|
||||
|
||||
static long kvm_vm_ioctl(struct file *filp,
|
||||
unsigned int ioctl, unsigned long arg)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user