Merge tag 'mm-stable-2024-03-13-20-04' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / arch / x86 / mm / dump_pagetables.c
index b7b88c1..89079ea 100644 (file)
@@ -362,9 +362,9 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
        }
 }
 
-static void ptdump_walk_pgd_level_core(struct seq_file *m,
-                                      struct mm_struct *mm, pgd_t *pgd,
-                                      bool checkwx, bool dmesg)
+bool ptdump_walk_pgd_level_core(struct seq_file *m,
+                               struct mm_struct *mm, pgd_t *pgd,
+                               bool checkwx, bool dmesg)
 {
        const struct ptdump_range ptdump_ranges[] = {
 #ifdef CONFIG_X86_64
@@ -391,12 +391,17 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m,
        ptdump_walk_pgd(&st.ptdump, mm, pgd);
 
        if (!checkwx)
-               return;
-       if (st.wx_pages)
+               return true;
+       if (st.wx_pages) {
                pr_info("x86/mm: Checked W+X mappings: FAILED, %lu W+X pages found.\n",
                        st.wx_pages);
-       else
+
+               return false;
+       } else {
                pr_info("x86/mm: Checked W+X mappings: passed, no W+X pages found.\n");
+
+               return true;
+       }
 }
 
 void ptdump_walk_pgd_level(struct seq_file *m, struct mm_struct *mm)
@@ -431,9 +436,12 @@ void ptdump_walk_user_pgd_level_checkwx(void)
 #endif
 }
 
-void ptdump_walk_pgd_level_checkwx(void)
+bool ptdump_walk_pgd_level_checkwx(void)
 {
-       ptdump_walk_pgd_level_core(NULL, &init_mm, INIT_PGD, true, false);
+       if (!(__supported_pte_mask & _PAGE_NX))
+               return true;
+
+       return ptdump_walk_pgd_level_core(NULL, &init_mm, INIT_PGD, true, false);
 }
 
 static int __init pt_dump_init(void)