Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[linux-2.6-microblaze.git] / arch / x86 / kvm / svm / svm.c
index b9096bb..d1a9f99 100644 (file)
@@ -703,7 +703,7 @@ static int svm_cpu_init(int cpu)
        int ret = -ENOMEM;
 
        memset(sd, 0, sizeof(struct svm_cpu_data));
-       sd->save_area = alloc_page(GFP_KERNEL | __GFP_ZERO);
+       sd->save_area = snp_safe_alloc_page(NULL);
        if (!sd->save_area)
                return ret;
 
@@ -1421,7 +1421,7 @@ static int svm_vcpu_create(struct kvm_vcpu *vcpu)
        svm = to_svm(vcpu);
 
        err = -ENOMEM;
-       vmcb01_page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
+       vmcb01_page = snp_safe_alloc_page(vcpu);
        if (!vmcb01_page)
                goto out;
 
@@ -1430,7 +1430,7 @@ static int svm_vcpu_create(struct kvm_vcpu *vcpu)
                 * SEV-ES guests require a separate VMSA page used to contain
                 * the encrypted register state of the guest.
                 */
-               vmsa_page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
+               vmsa_page = snp_safe_alloc_page(vcpu);
                if (!vmsa_page)
                        goto error_free_vmcb_page;
 
@@ -3452,7 +3452,7 @@ int svm_invoke_exit_handler(struct kvm_vcpu *vcpu, u64 exit_code)
        if (!svm_check_exit_valid(exit_code))
                return svm_handle_invalid_exit(vcpu, exit_code);
 
-#ifdef CONFIG_RETPOLINE
+#ifdef CONFIG_MITIGATION_RETPOLINE
        if (exit_code == SVM_EXIT_MSR)
                return msr_interception(vcpu);
        else if (exit_code == SVM_EXIT_VINTR)
@@ -4901,6 +4901,16 @@ static int svm_vm_init(struct kvm *kvm)
        return 0;
 }
 
+static void *svm_alloc_apic_backing_page(struct kvm_vcpu *vcpu)
+{
+       struct page *page = snp_safe_alloc_page(vcpu);
+
+       if (!page)
+               return NULL;
+
+       return page_address(page);
+}
+
 static struct kvm_x86_ops svm_x86_ops __initdata = {
        .name = KBUILD_MODNAME,
 
@@ -5030,6 +5040,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
 
        .vcpu_deliver_sipi_vector = svm_vcpu_deliver_sipi_vector,
        .vcpu_get_apicv_inhibit_reasons = avic_vcpu_get_apicv_inhibit_reasons,
+       .alloc_apic_backing_page = svm_alloc_apic_backing_page,
 };
 
 /*