aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/kvm_host.h2
-rw-r--r--arch/x86/kvm/svm.c7
-rw-r--r--arch/x86/kvm/vmx.c4
-rw-r--r--arch/x86/kvm/x86.c11
4 files changed, 19 insertions, 5 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index d08bb4a202de..0cd0f2923af5 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -624,7 +624,7 @@ int kvm_pic_set_irq(void *opaque, int irq, int level);
624 624
625void kvm_inject_nmi(struct kvm_vcpu *vcpu); 625void kvm_inject_nmi(struct kvm_vcpu *vcpu);
626 626
627void fx_init(struct kvm_vcpu *vcpu); 627int fx_init(struct kvm_vcpu *vcpu);
628 628
629void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu); 629void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu);
630void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, 630void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 9c68a650f57e..2ae0c3923293 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -904,13 +904,18 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
904 svm->asid_generation = 0; 904 svm->asid_generation = 0;
905 init_vmcb(svm); 905 init_vmcb(svm);
906 906
907 fx_init(&svm->vcpu); 907 err = fx_init(&svm->vcpu);
908 if (err)
909 goto free_page4;
910
908 svm->vcpu.arch.apic_base = 0xfee00000 | MSR_IA32_APICBASE_ENABLE; 911 svm->vcpu.arch.apic_base = 0xfee00000 | MSR_IA32_APICBASE_ENABLE;
909 if (kvm_vcpu_is_bsp(&svm->vcpu)) 912 if (kvm_vcpu_is_bsp(&svm->vcpu))
910 svm->vcpu.arch.apic_base |= MSR_IA32_APICBASE_BSP; 913 svm->vcpu.arch.apic_base |= MSR_IA32_APICBASE_BSP;
911 914
912 return &svm->vcpu; 915 return &svm->vcpu;
913 916
917free_page4:
918 __free_page(hsave_page);
914free_page3: 919free_page3:
915 __free_pages(nested_msrpm_pages, MSRPM_ALLOC_ORDER); 920 __free_pages(nested_msrpm_pages, MSRPM_ALLOC_ORDER);
916free_page2: 921free_page2:
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9c3ffc5fde44..e71c731433ee 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2659,7 +2659,9 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
2659 msr |= MSR_IA32_APICBASE_BSP; 2659 msr |= MSR_IA32_APICBASE_BSP;
2660 kvm_set_apic_base(&vmx->vcpu, msr); 2660 kvm_set_apic_base(&vmx->vcpu, msr);
2661 2661
2662 fx_init(&vmx->vcpu); 2662 ret = fx_init(&vmx->vcpu);
2663 if (ret != 0)
2664 goto out;
2663 2665
2664 seg_setup(VCPU_SREG_CS); 2666 seg_setup(VCPU_SREG_CS);
2665 /* 2667 /*
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 033b9c207f93..e6e0d7781af7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5114,12 +5114,19 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
5114 return 0; 5114 return 0;
5115} 5115}
5116 5116
5117void fx_init(struct kvm_vcpu *vcpu) 5117int fx_init(struct kvm_vcpu *vcpu)
5118{ 5118{
5119 fpu_alloc(&vcpu->arch.guest_fpu); 5119 int err;
5120
5121 err = fpu_alloc(&vcpu->arch.guest_fpu);
5122 if (err)
5123 return err;
5124
5120 fpu_finit(&vcpu->arch.guest_fpu); 5125 fpu_finit(&vcpu->arch.guest_fpu);
5121 5126
5122 vcpu->arch.cr0 |= X86_CR0_ET; 5127 vcpu->arch.cr0 |= X86_CR0_ET;
5128
5129 return 0;
5123} 5130}
5124EXPORT_SYMBOL_GPL(fx_init); 5131EXPORT_SYMBOL_GPL(fx_init);
5125 5132