1 // SPDX-License-Identifier: GPL-2.0
3 #ifndef __KVM_X86_MMU_TDP_ITER_H
4 #define __KVM_X86_MMU_TDP_ITER_H
6 #include <linux/kvm_host.h>
11 * A TDP iterator performs a pre-order walk over a TDP paging structure.
15 * The iterator will traverse the paging structure towards the mapping
18 gfn_t next_last_level_gfn;
20 * The next_last_level_gfn at the time when the thread last
21 * yielded. Only yielding when the next_last_level_gfn !=
22 * yielded_gfn helps ensure forward progress.
25 /* Pointers to the page tables traversed to reach the current SPTE */
26 u64 *pt_path[PT64_ROOT_MAX_LEVEL];
27 /* A pointer to the current SPTE */
29 /* The lowest GFN mapped by the current SPTE */
31 /* The level of the root page given to the iterator */
33 /* The lowest level the iterator should traverse to */
35 /* The iterator's current level within the paging structure */
37 /* A snapshot of the value at sptep */
40 * Whether the iterator has a valid state. This will be false if the
41 * iterator walks off the end of the paging structure.
47 * Iterates over every SPTE mapping the GFN range [start, end) in a
50 #define for_each_tdp_pte_min_level(iter, root, root_level, min_level, start, end) \
51 for (tdp_iter_start(&iter, root, root_level, min_level, start); \
52 iter.valid && iter.gfn < end; \
55 #define for_each_tdp_pte(iter, root, root_level, start, end) \
56 for_each_tdp_pte_min_level(iter, root, root_level, PG_LEVEL_4K, start, end)
58 u64 *spte_to_child_pt(u64 pte, int level);
60 void tdp_iter_start(struct tdp_iter *iter, u64 *root_pt, int root_level,
61 int min_level, gfn_t next_last_level_gfn);
62 void tdp_iter_next(struct tdp_iter *iter);
63 u64 *tdp_iter_root_pt(struct tdp_iter *iter);
65 #endif /* __KVM_X86_MMU_TDP_ITER_H */