11183646aSVineeth Pillai // SPDX-License-Identifier: GPL-2.0-only 21183646aSVineeth Pillai /* 31183646aSVineeth Pillai * KVM L1 hypervisor optimizations on Hyper-V for SVM. 41183646aSVineeth Pillai */ 51183646aSVineeth Pillai 61183646aSVineeth Pillai #include <linux/kvm_host.h> 71183646aSVineeth Pillai 81183646aSVineeth Pillai #include <asm/mshyperv.h> 91183646aSVineeth Pillai 101183646aSVineeth Pillai #include "svm.h" 111183646aSVineeth Pillai #include "svm_ops.h" 121183646aSVineeth Pillai 131183646aSVineeth Pillai #include "hyperv.h" 141183646aSVineeth Pillai #include "kvm_onhyperv.h" 151183646aSVineeth Pillai #include "svm_onhyperv.h" 161183646aSVineeth Pillai 171183646aSVineeth Pillai int svm_hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu) 181183646aSVineeth Pillai { 191183646aSVineeth Pillai struct hv_enlightenments *hve; 201183646aSVineeth Pillai struct hv_partition_assist_pg **p_hv_pa_pg = 211183646aSVineeth Pillai &to_kvm_hv(vcpu->kvm)->hv_pa_pg; 221183646aSVineeth Pillai 231183646aSVineeth Pillai if (!*p_hv_pa_pg) 241183646aSVineeth Pillai *p_hv_pa_pg = kzalloc(PAGE_SIZE, GFP_KERNEL); 251183646aSVineeth Pillai 261183646aSVineeth Pillai if (!*p_hv_pa_pg) 271183646aSVineeth Pillai return -ENOMEM; 281183646aSVineeth Pillai 29*68ae7c7bSSean Christopherson hve = &to_svm(vcpu)->vmcb->control.hv_enlightenments; 301183646aSVineeth Pillai 311183646aSVineeth Pillai hve->partition_assist_page = __pa(*p_hv_pa_pg); 321183646aSVineeth Pillai hve->hv_vm_id = (unsigned long)vcpu->kvm; 331183646aSVineeth Pillai if (!hve->hv_enlightenments_control.nested_flush_hypercall) { 341183646aSVineeth Pillai hve->hv_enlightenments_control.nested_flush_hypercall = 1; 35089fe572SSean Christopherson vmcb_mark_dirty(to_svm(vcpu)->vmcb, HV_VMCB_NESTED_ENLIGHTENMENTS); 361183646aSVineeth Pillai } 371183646aSVineeth Pillai 381183646aSVineeth Pillai return 0; 391183646aSVineeth Pillai } 401183646aSVineeth Pillai 41