]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/pagemap: export uffd-wp protection information
authorPeter Xu <peterx@redhat.com>
Thu, 1 Jul 2021 01:49:09 +0000 (18:49 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Jul 2021 03:47:27 +0000 (20:47 -0700)
Export the PTE/PMD status of uffd-wp to pagemap too.

Link: https://lkml.kernel.org/r/20210428225030.9708-6-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Brian Geffon <bgeffon@google.com>
Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Oliver Upton <oupton@google.com>
Cc: Shaohua Li <shli@fb.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Wang Qing <wangqing@vivo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Documentation/admin-guide/mm/pagemap.rst
fs/proc/task_mmu.c

index 340a5aee9b80268cf5c3c0e05962a5df97f77bcd..fb578fbbb76ca99bfc9187c8a85c8ec90416f059 100644 (file)
@@ -21,6 +21,8 @@ There are four components to pagemap:
     * Bit  55    pte is soft-dirty (see
       :ref:`Documentation/admin-guide/mm/soft-dirty.rst <soft_dirty>`)
     * Bit  56    page exclusively mapped (since 4.2)
+    * Bit  57    pte is uffd-wp write-protected (since 5.13) (see
+      :ref:`Documentation/admin-guide/mm/userfaultfd.rst <userfaultfd>`)
     * Bits 57-60 zero
     * Bit  61    page is file-page or shared-anon (since 3.5)
     * Bit  62    page swapped
index 9feda779288211e620647cba4738c93d613d8e11..95c8f1e8fea6b67fec174527654e49d86dc73a20 100644 (file)
@@ -1302,6 +1302,7 @@ struct pagemapread {
 #define PM_PFRAME_MASK         GENMASK_ULL(PM_PFRAME_BITS - 1, 0)
 #define PM_SOFT_DIRTY          BIT_ULL(55)
 #define PM_MMAP_EXCLUSIVE      BIT_ULL(56)
+#define PM_UFFD_WP             BIT_ULL(57)
 #define PM_FILE                        BIT_ULL(61)
 #define PM_SWAP                        BIT_ULL(62)
 #define PM_PRESENT             BIT_ULL(63)
@@ -1375,10 +1376,14 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm,
                page = vm_normal_page(vma, addr, pte);
                if (pte_soft_dirty(pte))
                        flags |= PM_SOFT_DIRTY;
+               if (pte_uffd_wp(pte))
+                       flags |= PM_UFFD_WP;
        } else if (is_swap_pte(pte)) {
                swp_entry_t entry;
                if (pte_swp_soft_dirty(pte))
                        flags |= PM_SOFT_DIRTY;
+               if (pte_swp_uffd_wp(pte))
+                       flags |= PM_UFFD_WP;
                entry = pte_to_swp_entry(pte);
                if (pm->show_pfn)
                        frame = swp_type(entry) |
@@ -1426,6 +1431,8 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
                        flags |= PM_PRESENT;
                        if (pmd_soft_dirty(pmd))
                                flags |= PM_SOFT_DIRTY;
+                       if (pmd_uffd_wp(pmd))
+                               flags |= PM_UFFD_WP;
                        if (pm->show_pfn)
                                frame = pmd_pfn(pmd) +
                                        ((addr & ~PMD_MASK) >> PAGE_SHIFT);
@@ -1444,6 +1451,8 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
                        flags |= PM_SWAP;
                        if (pmd_swp_soft_dirty(pmd))
                                flags |= PM_SOFT_DIRTY;
+                       if (pmd_swp_uffd_wp(pmd))
+                               flags |= PM_UFFD_WP;
                        VM_BUG_ON(!is_pmd_migration_entry(pmd));
                        page = migration_entry_to_page(entry);
                }