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 void kvm_mmu_init_tdp_mmu(struct kvm *kvm);
9 void kvm_mmu_uninit_tdp_mmu(struct kvm *kvm);
11 bool is_tdp_mmu_root(struct kvm *kvm, hpa_t root);
12 hpa_t kvm_tdp_mmu_get_vcpu_root_hpa(struct kvm_vcpu *vcpu);
13 void kvm_tdp_mmu_free_root(struct kvm *kvm, struct kvm_mmu_page *root);
15 bool __kvm_tdp_mmu_zap_gfn_range(struct kvm *kvm, gfn_t start, gfn_t end,
17 static inline bool kvm_tdp_mmu_zap_gfn_range(struct kvm *kvm, gfn_t start,
20 return __kvm_tdp_mmu_zap_gfn_range(kvm, start, end, true);
22 static inline bool kvm_tdp_mmu_zap_sp(struct kvm *kvm, struct kvm_mmu_page *sp)
24 gfn_t end = sp->gfn + KVM_PAGES_PER_HPAGE(sp->role.level);
27 * Don't allow yielding, as the caller may have pending pages to zap
30 return __kvm_tdp_mmu_zap_gfn_range(kvm, sp->gfn, end, false);
32 void kvm_tdp_mmu_zap_all(struct kvm *kvm);
34 int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
35 int map_writable, int max_level, kvm_pfn_t pfn,
38 int kvm_tdp_mmu_zap_hva_range(struct kvm *kvm, unsigned long start,
41 int kvm_tdp_mmu_age_hva_range(struct kvm *kvm, unsigned long start,
43 int kvm_tdp_mmu_test_age_hva(struct kvm *kvm, unsigned long hva);
45 int kvm_tdp_mmu_set_spte_hva(struct kvm *kvm, unsigned long address,
48 bool kvm_tdp_mmu_wrprot_slot(struct kvm *kvm, struct kvm_memory_slot *slot,
50 bool kvm_tdp_mmu_clear_dirty_slot(struct kvm *kvm,
51 struct kvm_memory_slot *slot);
52 void kvm_tdp_mmu_clear_dirty_pt_masked(struct kvm *kvm,
53 struct kvm_memory_slot *slot,
54 gfn_t gfn, unsigned long mask,
56 bool kvm_tdp_mmu_slot_set_dirty(struct kvm *kvm, struct kvm_memory_slot *slot);
57 void kvm_tdp_mmu_zap_collapsible_sptes(struct kvm *kvm,
58 const struct kvm_memory_slot *slot);
60 bool kvm_tdp_mmu_write_protect_gfn(struct kvm *kvm,
61 struct kvm_memory_slot *slot, gfn_t gfn);
63 int kvm_tdp_mmu_get_walk(struct kvm_vcpu *vcpu, u64 addr, u64 *sptes,
66 #endif /* __KVM_X86_MMU_TDP_MMU_H */