diff options
| -rw-r--r-- | drivers/kvm/kvm_main.c | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 981f5d3cfd94..6fb36c80e3e8 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
| @@ -599,57 +599,6 @@ void fx_init(struct kvm_vcpu *vcpu) | |||
| 599 | EXPORT_SYMBOL_GPL(fx_init); | 599 | EXPORT_SYMBOL_GPL(fx_init); |
| 600 | 600 | ||
| 601 | /* | 601 | /* |
| 602 | * Creates some virtual cpus. Good luck creating more than one. | ||
| 603 | */ | ||
| 604 | static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n) | ||
| 605 | { | ||
| 606 | int r; | ||
| 607 | struct kvm_vcpu *vcpu; | ||
| 608 | |||
| 609 | r = -EINVAL; | ||
| 610 | if (!valid_vcpu(n)) | ||
| 611 | goto out; | ||
| 612 | |||
| 613 | vcpu = &kvm->vcpus[n]; | ||
| 614 | |||
| 615 | mutex_lock(&vcpu->mutex); | ||
| 616 | |||
| 617 | if (vcpu->vmcs) { | ||
| 618 | mutex_unlock(&vcpu->mutex); | ||
| 619 | return -EEXIST; | ||
| 620 | } | ||
| 621 | |||
| 622 | vcpu->host_fx_image = (char*)ALIGN((hva_t)vcpu->fx_buf, | ||
| 623 | FX_IMAGE_ALIGN); | ||
| 624 | vcpu->guest_fx_image = vcpu->host_fx_image + FX_IMAGE_SIZE; | ||
| 625 | |||
| 626 | r = kvm_arch_ops->vcpu_create(vcpu); | ||
| 627 | if (r < 0) | ||
| 628 | goto out_free_vcpus; | ||
| 629 | |||
| 630 | r = kvm_mmu_create(vcpu); | ||
| 631 | if (r < 0) | ||
| 632 | goto out_free_vcpus; | ||
| 633 | |||
| 634 | kvm_arch_ops->vcpu_load(vcpu); | ||
| 635 | r = kvm_mmu_setup(vcpu); | ||
| 636 | if (r >= 0) | ||
| 637 | r = kvm_arch_ops->vcpu_setup(vcpu); | ||
| 638 | vcpu_put(vcpu); | ||
| 639 | |||
| 640 | if (r < 0) | ||
| 641 | goto out_free_vcpus; | ||
| 642 | |||
| 643 | return 0; | ||
| 644 | |||
| 645 | out_free_vcpus: | ||
| 646 | kvm_free_vcpu(vcpu); | ||
| 647 | mutex_unlock(&vcpu->mutex); | ||
| 648 | out: | ||
| 649 | return r; | ||
| 650 | } | ||
| 651 | |||
| 652 | /* | ||
| 653 | * Allocate some memory and give it an address in the guest physical address | 602 | * Allocate some memory and give it an address in the guest physical address |
| 654 | * space. | 603 | * space. |
| 655 | * | 604 | * |
| @@ -1964,6 +1913,57 @@ static int kvm_vm_ioctl_debug_guest(struct kvm *kvm, | |||
| 1964 | return r; | 1913 | return r; |
| 1965 | } | 1914 | } |
| 1966 | 1915 | ||
| 1916 | /* | ||
| 1917 | * Creates some virtual cpus. Good luck creating more than one. | ||
| 1918 | */ | ||
| 1919 | static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n) | ||
| 1920 | { | ||
| 1921 | int r; | ||
| 1922 | struct kvm_vcpu *vcpu; | ||
| 1923 | |||
| 1924 | r = -EINVAL; | ||
| 1925 | if (!valid_vcpu(n)) | ||
| 1926 | goto out; | ||
| 1927 | |||
| 1928 | vcpu = &kvm->vcpus[n]; | ||
| 1929 | |||
| 1930 | mutex_lock(&vcpu->mutex); | ||
| 1931 | |||
| 1932 | if (vcpu->vmcs) { | ||
| 1933 | mutex_unlock(&vcpu->mutex); | ||
| 1934 | return -EEXIST; | ||
| 1935 | } | ||
| 1936 | |||
| 1937 | vcpu->host_fx_image = (char*)ALIGN((hva_t)vcpu->fx_buf, | ||
| 1938 | FX_IMAGE_ALIGN); | ||
| 1939 | vcpu->guest_fx_image = vcpu->host_fx_image + FX_IMAGE_SIZE; | ||
| 1940 | |||
| 1941 | r = kvm_arch_ops->vcpu_create(vcpu); | ||
| 1942 | if (r < 0) | ||
| 1943 | goto out_free_vcpus; | ||
| 1944 | |||
| 1945 | r = kvm_mmu_create(vcpu); | ||
| 1946 | if (r < 0) | ||
| 1947 | goto out_free_vcpus; | ||
| 1948 | |||
| 1949 | kvm_arch_ops->vcpu_load(vcpu); | ||
| 1950 | r = kvm_mmu_setup(vcpu); | ||
| 1951 | if (r >= 0) | ||
| 1952 | r = kvm_arch_ops->vcpu_setup(vcpu); | ||
| 1953 | vcpu_put(vcpu); | ||
| 1954 | |||
| 1955 | if (r < 0) | ||
| 1956 | goto out_free_vcpus; | ||
| 1957 | |||
| 1958 | return 0; | ||
| 1959 | |||
| 1960 | out_free_vcpus: | ||
| 1961 | kvm_free_vcpu(vcpu); | ||
| 1962 | mutex_unlock(&vcpu->mutex); | ||
| 1963 | out: | ||
| 1964 | return r; | ||
| 1965 | } | ||
| 1966 | |||
| 1967 | static long kvm_vm_ioctl(struct file *filp, | 1967 | static long kvm_vm_ioctl(struct file *filp, |
| 1968 | unsigned int ioctl, unsigned long arg) | 1968 | unsigned int ioctl, unsigned long arg) |
| 1969 | { | 1969 | { |
