KVM
kvm_onhyperv.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * KVM L1 hypervisor optimizations on Hyper-V.
4  */
5 
6 #ifndef __ARCH_X86_KVM_KVM_ONHYPERV_H__
7 #define __ARCH_X86_KVM_KVM_ONHYPERV_H__
8 
9 #if IS_ENABLED(CONFIG_HYPERV)
10 int hv_flush_remote_tlbs_range(struct kvm *kvm, gfn_t gfn, gfn_t nr_pages);
11 int hv_flush_remote_tlbs(struct kvm *kvm);
12 void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp);
13 static inline hpa_t hv_get_partition_assist_page(struct kvm_vcpu *vcpu)
14 {
15  /*
16  * Partition assist page is something which Hyper-V running in L0
17  * requires from KVM running in L1 before direct TLB flush for L2
18  * guests can be enabled. KVM doesn't currently use the page but to
19  * comply with TLFS it still needs to be allocated. For now, this
20  * is a single page shared among all vCPUs.
21  */
22  struct hv_partition_assist_pg **p_hv_pa_pg =
23  &vcpu->kvm->arch.hv_pa_pg;
24 
25  if (!*p_hv_pa_pg)
26  *p_hv_pa_pg = kzalloc(PAGE_SIZE, GFP_KERNEL_ACCOUNT);
27 
28  if (!*p_hv_pa_pg)
29  return INVALID_PAGE;
30 
31  return __pa(*p_hv_pa_pg);
32 }
33 #else /* !CONFIG_HYPERV */
34 static inline int hv_flush_remote_tlbs(struct kvm *kvm)
35 {
36  return -EOPNOTSUPP;
37 }
38 
39 static inline void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp)
40 {
41 }
42 #endif /* !CONFIG_HYPERV */
43 
44 #endif
int hv_flush_remote_tlbs_range(struct kvm *kvm, gfn_t start_gfn, gfn_t nr_pages)
Definition: kvm_onhyperv.c:95
static void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp)
Definition: kvm_onhyperv.h:39
static int hv_flush_remote_tlbs(struct kvm *kvm)
Definition: kvm_onhyperv.h:34