xref: /linux/include/linux/ptdump.h (revision 00c010e130e58301db2ea0cec1eadc931e1cb8cf)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef _LINUX_PTDUMP_H
4 #define _LINUX_PTDUMP_H
5 
6 #include <linux/mm_types.h>
7 
8 struct ptdump_range {
9 	unsigned long start;
10 	unsigned long end;
11 };
12 
13 struct ptdump_state {
14 	void (*note_page_pte)(struct ptdump_state *st, unsigned long addr, pte_t pte);
15 	void (*note_page_pmd)(struct ptdump_state *st, unsigned long addr, pmd_t pmd);
16 	void (*note_page_pud)(struct ptdump_state *st, unsigned long addr, pud_t pud);
17 	void (*note_page_p4d)(struct ptdump_state *st, unsigned long addr, p4d_t p4d);
18 	void (*note_page_pgd)(struct ptdump_state *st, unsigned long addr, pgd_t pgd);
19 	void (*note_page_flush)(struct ptdump_state *st);
20 	void (*effective_prot_pte)(struct ptdump_state *st, pte_t pte);
21 	void (*effective_prot_pmd)(struct ptdump_state *st, pmd_t pmd);
22 	void (*effective_prot_pud)(struct ptdump_state *st, pud_t pud);
23 	void (*effective_prot_p4d)(struct ptdump_state *st, p4d_t p4d);
24 	void (*effective_prot_pgd)(struct ptdump_state *st, pgd_t pgd);
25 	const struct ptdump_range *range;
26 };
27 
28 bool ptdump_walk_pgd_level_core(struct seq_file *m,
29 				struct mm_struct *mm, pgd_t *pgd,
30 				bool checkwx, bool dmesg);
31 void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm, pgd_t *pgd);
32 bool ptdump_check_wx(void);
33 
debug_checkwx(void)34 static inline void debug_checkwx(void)
35 {
36 	if (IS_ENABLED(CONFIG_DEBUG_WX))
37 		ptdump_check_wx();
38 }
39 
40 #endif /* _LINUX_PTDUMP_H */
41