Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

userfaultfd: wp: add pmd_swp_*uffd_wp() helpers

Adding these missing helpers for uffd-wp operations with pmd
swap/migration entries.

Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Bobby Powers <bobbypowers@gmail.com>
Cc: Brian Geffon <bgeffon@google.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Denis Plotnikov <dplotnikov@virtuozzo.com>
Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: "Kirill A . Shutemov" <kirill@shutemov.name>
Cc: Martin Cracauer <cracauer@cons.org>
Cc: Marty McFadden <mcfadden8@llnl.gov>
Cc: Maya Gokhale <gokhale2@llnl.gov>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Shaohua Li <shli@fb.com>
Link: http://lkml.kernel.org/r/20200220163112.11409-10-peterx@redhat.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Peter Xu and committed by
Linus Torvalds
2e3d5dc5 b569a176

+30
+15
arch/x86/include/asm/pgtable.h
··· 1424 1424 { 1425 1425 return pte_clear_flags(pte, _PAGE_SWP_UFFD_WP); 1426 1426 } 1427 + 1428 + static inline pmd_t pmd_swp_mkuffd_wp(pmd_t pmd) 1429 + { 1430 + return pmd_set_flags(pmd, _PAGE_SWP_UFFD_WP); 1431 + } 1432 + 1433 + static inline int pmd_swp_uffd_wp(pmd_t pmd) 1434 + { 1435 + return pmd_flags(pmd) & _PAGE_SWP_UFFD_WP; 1436 + } 1437 + 1438 + static inline pmd_t pmd_swp_clear_uffd_wp(pmd_t pmd) 1439 + { 1440 + return pmd_clear_flags(pmd, _PAGE_SWP_UFFD_WP); 1441 + } 1427 1442 #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_WP */ 1428 1443 1429 1444 #define PKRU_AD_BIT 0x1
+15
include/asm-generic/pgtable_uffd.h
··· 46 46 { 47 47 return pte; 48 48 } 49 + 50 + static inline pmd_t pmd_swp_mkuffd_wp(pmd_t pmd) 51 + { 52 + return pmd; 53 + } 54 + 55 + static inline int pmd_swp_uffd_wp(pmd_t pmd) 56 + { 57 + return 0; 58 + } 59 + 60 + static inline pmd_t pmd_swp_clear_uffd_wp(pmd_t pmd) 61 + { 62 + return pmd; 63 + } 49 64 #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_WP */ 50 65 51 66 #endif /* _ASM_GENERIC_PGTABLE_UFFD_H */