xref: /linux-6.15/include/linux/ptdump.h (revision 6cdc82db)
130d621f6SSteven Price /* SPDX-License-Identifier: GPL-2.0 */
230d621f6SSteven Price 
330d621f6SSteven Price #ifndef _LINUX_PTDUMP_H
430d621f6SSteven Price #define _LINUX_PTDUMP_H
530d621f6SSteven Price 
630d621f6SSteven Price #include <linux/mm_types.h>
730d621f6SSteven Price 
830d621f6SSteven Price struct ptdump_range {
930d621f6SSteven Price 	unsigned long start;
1030d621f6SSteven Price 	unsigned long end;
1130d621f6SSteven Price };
1230d621f6SSteven Price 
1330d621f6SSteven Price struct ptdump_state {
14f8f0d0b6SSteven Price 	/* level is 0:PGD to 4:PTE, or -1 if unknown */
1530d621f6SSteven Price 	void (*note_page)(struct ptdump_state *st, unsigned long addr,
1699395ee3SSteven Price 			  int level, u64 val);
171494e0c3SSteven Price 	void (*effective_prot)(struct ptdump_state *st, int level, u64 val);
1830d621f6SSteven Price 	const struct ptdump_range *range;
1930d621f6SSteven Price };
2030d621f6SSteven Price 
21*6cdc82dbSChristophe Leroy bool ptdump_walk_pgd_level_core(struct seq_file *m,
22*6cdc82dbSChristophe Leroy 				struct mm_struct *mm, pgd_t *pgd,
23*6cdc82dbSChristophe Leroy 				bool checkwx, bool dmesg);
24e47690d7SSteven Price void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm, pgd_t *pgd);
25*6cdc82dbSChristophe Leroy bool ptdump_check_wx(void);
26a5e8131aSChristophe Leroy 
debug_checkwx(void)27a5e8131aSChristophe Leroy static inline void debug_checkwx(void)
28a5e8131aSChristophe Leroy {
29a5e8131aSChristophe Leroy 	if (IS_ENABLED(CONFIG_DEBUG_WX))
30a5e8131aSChristophe Leroy 		ptdump_check_wx();
31a5e8131aSChristophe Leroy }
3230d621f6SSteven Price 
3330d621f6SSteven Price #endif /* _LINUX_PTDUMP_H */
34