1 // SPDX-License-Identifier: GPL-2.0
3 #ifndef __KVM_X86_MMU_TDP_MMU_H
4 #define __KVM_X86_MMU_TDP_MMU_H
6 #include <linux/kvm_host.h>
8 hpa_t kvm_tdp_mmu_get_vcpu_root_hpa(struct kvm_vcpu *vcpu);
9 void kvm_tdp_mmu_free_root(struct kvm *kvm, struct kvm_mmu_page *root);
11 bool kvm_tdp_mmu_zap_gfn_range(struct kvm *kvm, gfn_t start, gfn_t end);
12 void kvm_tdp_mmu_zap_all(struct kvm *kvm);
14 int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
15 int map_writable, int max_level, kvm_pfn_t pfn,
18 int kvm_tdp_mmu_zap_hva_range(struct kvm *kvm, unsigned long start,
21 int kvm_tdp_mmu_age_hva_range(struct kvm *kvm, unsigned long start,
23 int kvm_tdp_mmu_test_age_hva(struct kvm *kvm, unsigned long hva);
25 int kvm_tdp_mmu_set_spte_hva(struct kvm *kvm, unsigned long address,
28 bool kvm_tdp_mmu_wrprot_slot(struct kvm *kvm, struct kvm_memory_slot *slot,
30 bool kvm_tdp_mmu_clear_dirty_slot(struct kvm *kvm,
31 struct kvm_memory_slot *slot);
32 void kvm_tdp_mmu_clear_dirty_pt_masked(struct kvm *kvm,
33 struct kvm_memory_slot *slot,
34 gfn_t gfn, unsigned long mask,
36 bool kvm_tdp_mmu_slot_set_dirty(struct kvm *kvm, struct kvm_memory_slot *slot);
37 void kvm_tdp_mmu_zap_collapsible_sptes(struct kvm *kvm,
38 const struct kvm_memory_slot *slot);
40 bool kvm_tdp_mmu_write_protect_gfn(struct kvm *kvm,
41 struct kvm_memory_slot *slot, gfn_t gfn);
43 int kvm_tdp_mmu_get_walk(struct kvm_vcpu *vcpu, u64 addr, u64 *sptes,
47 void kvm_mmu_init_tdp_mmu(struct kvm *kvm);
48 void kvm_mmu_uninit_tdp_mmu(struct kvm *kvm);
49 static inline bool is_tdp_mmu_enabled(struct kvm *kvm) { return kvm->arch.tdp_mmu_enabled; }
50 static inline bool is_tdp_mmu_page(struct kvm_mmu_page *sp) { return sp->tdp_mmu_page; }
52 static inline void kvm_mmu_init_tdp_mmu(struct kvm *kvm) {}
53 static inline void kvm_mmu_uninit_tdp_mmu(struct kvm *kvm) {}
54 static inline bool is_tdp_mmu_enabled(struct kvm *kvm) { return false; }
55 static inline bool is_tdp_mmu_page(struct kvm_mmu_page *sp) { return false; }
58 static inline bool is_tdp_mmu_root(struct kvm *kvm, hpa_t hpa)
60 struct kvm_mmu_page *sp;
62 if (!is_tdp_mmu_enabled(kvm))
64 if (WARN_ON(!VALID_PAGE(hpa)))
67 sp = to_shadow_page(hpa);
71 return is_tdp_mmu_page(sp) && sp->root_count;
74 #endif /* __KVM_X86_MMU_TDP_MMU_H */