aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kvm/svm.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1d9b33843c80..d42e191b17fa 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -698,29 +698,28 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
698 if (err) 698 if (err)
699 goto free_svm; 699 goto free_svm;
700 700
701 err = -ENOMEM;
701 page = alloc_page(GFP_KERNEL); 702 page = alloc_page(GFP_KERNEL);
702 if (!page) { 703 if (!page)
703 err = -ENOMEM;
704 goto uninit; 704 goto uninit;
705 }
706 705
707 err = -ENOMEM;
708 msrpm_pages = alloc_pages(GFP_KERNEL, MSRPM_ALLOC_ORDER); 706 msrpm_pages = alloc_pages(GFP_KERNEL, MSRPM_ALLOC_ORDER);
709 if (!msrpm_pages) 707 if (!msrpm_pages)
710 goto uninit; 708 goto free_page1;
711 709
712 nested_msrpm_pages = alloc_pages(GFP_KERNEL, MSRPM_ALLOC_ORDER); 710 nested_msrpm_pages = alloc_pages(GFP_KERNEL, MSRPM_ALLOC_ORDER);
713 if (!nested_msrpm_pages) 711 if (!nested_msrpm_pages)
714 goto uninit; 712 goto free_page2;
715
716 svm->msrpm = page_address(msrpm_pages);
717 svm_vcpu_init_msrpm(svm->msrpm);
718 713
719 hsave_page = alloc_page(GFP_KERNEL); 714 hsave_page = alloc_page(GFP_KERNEL);
720 if (!hsave_page) 715 if (!hsave_page)
721 goto uninit; 716 goto free_page3;
717
722 svm->nested.hsave = page_address(hsave_page); 718 svm->nested.hsave = page_address(hsave_page);
723 719
720 svm->msrpm = page_address(msrpm_pages);
721 svm_vcpu_init_msrpm(svm->msrpm);
722
724 svm->nested.msrpm = page_address(nested_msrpm_pages); 723 svm->nested.msrpm = page_address(nested_msrpm_pages);
725 724
726 svm->vmcb = page_address(page); 725 svm->vmcb = page_address(page);
@@ -737,6 +736,12 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
737 736
738 return &svm->vcpu; 737 return &svm->vcpu;
739 738
739free_page3:
740 __free_pages(nested_msrpm_pages, MSRPM_ALLOC_ORDER);
741free_page2:
742 __free_pages(msrpm_pages, MSRPM_ALLOC_ORDER);
743free_page1:
744 __free_page(page);
740uninit: 745uninit:
741 kvm_vcpu_uninit(&svm->vcpu); 746 kvm_vcpu_uninit(&svm->vcpu);
742free_svm: 747free_svm: