1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __KVM_X86_MMU_INTERNAL_H
3 #define __KVM_X86_MMU_INTERNAL_H
5 #include <linux/types.h>
7 #include <asm/kvm_host.h>
10 struct list_head link;
11 struct hlist_node hash_link;
12 struct list_head lpage_disallowed_link;
17 bool lpage_disallowed; /* Can't be replaced by an equiv large page */
20 * The following two entries are used to key the shadow page in the
23 union kvm_mmu_page_role role;
27 /* hold the gfn of each spte inside spt */
29 int root_count; /* Currently serving as active root */
30 unsigned int unsync_children;
31 struct kvm_rmap_head parent_ptes; /* rmap pointers to parent sptes */
32 DECLARE_BITMAP(unsync_child_bitmap, 512);
36 * Used out of the mmu-lock to avoid reading spte values while an
37 * update is in progress; see the comments in __get_spte_lockless().
42 /* Number of writes since the last time traversal visited this page. */
43 atomic_t write_flooding_count;
46 static inline struct kvm_mmu_page *to_shadow_page(hpa_t shadow_page)
48 struct page *page = pfn_to_page(shadow_page >> PAGE_SHIFT);
50 return (struct kvm_mmu_page *)page_private(page);
53 static inline struct kvm_mmu_page *sptep_to_sp(u64 *sptep)
55 return to_shadow_page(__pa(sptep));
58 void kvm_mmu_gfn_disallow_lpage(struct kvm_memory_slot *slot, gfn_t gfn);
59 void kvm_mmu_gfn_allow_lpage(struct kvm_memory_slot *slot, gfn_t gfn);
60 bool kvm_mmu_slot_gfn_write_protect(struct kvm *kvm,
61 struct kvm_memory_slot *slot, u64 gfn);
63 #endif /* __KVM_X86_MMU_INTERNAL_H */