xref: /openbmc/linux/arch/x86/kvm/kvm_onhyperv.h (revision 7ce05074)
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_remote_flush_tlb_with_range(struct kvm *kvm,
11 		struct kvm_tlb_range *range);
12 int hv_remote_flush_tlb(struct kvm *kvm);
13 
14 static inline void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp)
15 {
16 	struct kvm_arch *kvm_arch = &vcpu->kvm->arch;
17 
18 	if (kvm_x86_ops.tlb_remote_flush == hv_remote_flush_tlb) {
19 		spin_lock(&kvm_arch->hv_root_tdp_lock);
20 		vcpu->arch.hv_root_tdp = root_tdp;
21 		if (root_tdp != kvm_arch->hv_root_tdp)
22 			kvm_arch->hv_root_tdp = INVALID_PAGE;
23 		spin_unlock(&kvm_arch->hv_root_tdp_lock);
24 	}
25 }
26 #else /* !CONFIG_HYPERV */
27 static inline void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp)
28 {
29 }
30 #endif /* !CONFIG_HYPERV */
31 
32 #endif
33