svm_onhyperv.c 904 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * KVM L1 hypervisor optimizations on Hyper-V for SVM.
  4. */
  5. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  6. #include <linux/kvm_host.h>
  7. #include <asm/mshyperv.h>
  8. #include "svm.h"
  9. #include "svm_ops.h"
  10. #include "hyperv.h"
  11. #include "kvm_onhyperv.h"
  12. #include "svm_onhyperv.h"
  13. int svm_hv_enable_l2_tlb_flush(struct kvm_vcpu *vcpu)
  14. {
  15. struct hv_vmcb_enlightenments *hve;
  16. hpa_t partition_assist_page = hv_get_partition_assist_page(vcpu);
  17. if (partition_assist_page == INVALID_PAGE)
  18. return -ENOMEM;
  19. hve = &to_svm(vcpu)->vmcb->control.hv_enlightenments;
  20. hve->partition_assist_page = partition_assist_page;
  21. hve->hv_vm_id = (unsigned long)vcpu->kvm;
  22. if (!hve->hv_enlightenments_control.nested_flush_hypercall) {
  23. hve->hv_enlightenments_control.nested_flush_hypercall = 1;
  24. vmcb_mark_dirty(to_svm(vcpu)->vmcb, HV_VMCB_NESTED_ENLIGHTENMENTS);
  25. }
  26. return 0;
  27. }