Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * KVM L1 hypervisor optimizations on Hyper-V for SVM.
0004  */
0005 
0006 #include <linux/kvm_host.h>
0007 
0008 #include <asm/mshyperv.h>
0009 
0010 #include "svm.h"
0011 #include "svm_ops.h"
0012 
0013 #include "hyperv.h"
0014 #include "kvm_onhyperv.h"
0015 #include "svm_onhyperv.h"
0016 
0017 int svm_hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu)
0018 {
0019     struct hv_enlightenments *hve;
0020     struct hv_partition_assist_pg **p_hv_pa_pg =
0021             &to_kvm_hv(vcpu->kvm)->hv_pa_pg;
0022 
0023     if (!*p_hv_pa_pg)
0024         *p_hv_pa_pg = kzalloc(PAGE_SIZE, GFP_KERNEL);
0025 
0026     if (!*p_hv_pa_pg)
0027         return -ENOMEM;
0028 
0029     hve = (struct hv_enlightenments *)to_svm(vcpu)->vmcb->control.reserved_sw;
0030 
0031     hve->partition_assist_page = __pa(*p_hv_pa_pg);
0032     hve->hv_vm_id = (unsigned long)vcpu->kvm;
0033     if (!hve->hv_enlightenments_control.nested_flush_hypercall) {
0034         hve->hv_enlightenments_control.nested_flush_hypercall = 1;
0035         vmcb_mark_dirty(to_svm(vcpu)->vmcb, VMCB_HV_NESTED_ENLIGHTENMENTS);
0036     }
0037 
0038     return 0;
0039 }
0040