[PATCH V12 2/5] mm: userfaultfd: Add pgtable_supports_uffd_wp()

Chunyan Zhang posted 5 patches 2 weeks, 3 days ago
There is a newer version of this series
[PATCH V12 2/5] mm: userfaultfd: Add pgtable_supports_uffd_wp()
Posted by Chunyan Zhang 2 weeks, 3 days ago
Some platforms can customize the PTE/PMD entry uffd-wp bit making
it unavailable even if the architecture provides the resource.
This patch adds a macro API that allows architectures to define their
specific implementations to check if the uffd-wp bit is available
on which device the kernel is running.

Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
---
 fs/userfaultfd.c                   | 22 +++++++++++-----------
 include/asm-generic/pgtable_uffd.h | 17 +++++++++++++++++
 include/linux/mm_inline.h          | 10 ++++++++--
 include/linux/userfaultfd_k.h      | 27 +++++++++++++--------------
 mm/memory.c                        |  6 ++++--
 5 files changed, 53 insertions(+), 29 deletions(-)

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 54c6cc7fe9c6..e41736ffa202 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -1270,9 +1270,9 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
 	if (uffdio_register.mode & UFFDIO_REGISTER_MODE_MISSING)
 		vm_flags |= VM_UFFD_MISSING;
 	if (uffdio_register.mode & UFFDIO_REGISTER_MODE_WP) {
-#ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP
-		goto out;
-#endif
+		if (!pgtable_supports_uffd_wp())
+			goto out;
+
 		vm_flags |= VM_UFFD_WP;
 	}
 	if (uffdio_register.mode & UFFDIO_REGISTER_MODE_MINOR) {
@@ -1980,14 +1980,14 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
 	uffdio_api.features &=
 		~(UFFD_FEATURE_MINOR_HUGETLBFS | UFFD_FEATURE_MINOR_SHMEM);
 #endif
-#ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP
-	uffdio_api.features &= ~UFFD_FEATURE_PAGEFAULT_FLAG_WP;
-#endif
-#ifndef CONFIG_PTE_MARKER_UFFD_WP
-	uffdio_api.features &= ~UFFD_FEATURE_WP_HUGETLBFS_SHMEM;
-	uffdio_api.features &= ~UFFD_FEATURE_WP_UNPOPULATED;
-	uffdio_api.features &= ~UFFD_FEATURE_WP_ASYNC;
-#endif
+	if (!pgtable_supports_uffd_wp())
+		uffdio_api.features &= ~UFFD_FEATURE_PAGEFAULT_FLAG_WP;
+
+	if (!uffd_supports_wp_marker()) {
+		uffdio_api.features &= ~UFFD_FEATURE_WP_HUGETLBFS_SHMEM;
+		uffdio_api.features &= ~UFFD_FEATURE_WP_UNPOPULATED;
+		uffdio_api.features &= ~UFFD_FEATURE_WP_ASYNC;
+	}
 
 	ret = -EINVAL;
 	if (features & ~uffdio_api.features)
diff --git a/include/asm-generic/pgtable_uffd.h b/include/asm-generic/pgtable_uffd.h
index 828966d4c281..200da65262a8 100644
--- a/include/asm-generic/pgtable_uffd.h
+++ b/include/asm-generic/pgtable_uffd.h
@@ -1,6 +1,23 @@
 #ifndef _ASM_GENERIC_PGTABLE_UFFD_H
 #define _ASM_GENERIC_PGTABLE_UFFD_H
 
+/*
+ * Some platforms can customize the uffd-wp bit, making it unavailable
+ * even if the architecture provides the resource.
+ * Adding this API allows architectures to add their own checks for the
+ * devices on which the kernel is running.
+ * Note: When overriding it, please make sure the
+ * CONFIG_HAVE_ARCH_USERFAULTFD_WP is part of this macro.
+ */
+#ifndef pgtable_supports_uffd_wp
+#define pgtable_supports_uffd_wp()	IS_ENABLED(CONFIG_HAVE_ARCH_USERFAULTFD_WP)
+#endif
+
+static __always_inline bool uffd_supports_wp_marker(void)
+{
+	return pgtable_supports_uffd_wp() && IS_ENABLED(CONFIG_PTE_MARKER_UFFD_WP);
+}
+
 #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP
 static __always_inline int pte_uffd_wp(pte_t pte)
 {
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index 89b518ff097e..d6526a7f034b 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -570,9 +570,15 @@ static inline bool
 pte_install_uffd_wp_if_needed(struct vm_area_struct *vma, unsigned long addr,
 			      pte_t *pte, pte_t pteval)
 {
-#ifdef CONFIG_PTE_MARKER_UFFD_WP
 	bool arm_uffd_pte = false;
 
+	/*
+	 * Some platforms can customize the PTE uffd-wp bit, making it unavailable
+	 * even if the architecture allows providing the PTE resource.
+	 */
+	if (!uffd_supports_wp_marker())
+		return false;
+
 	/* The current status of the pte should be "cleared" before calling */
 	WARN_ON_ONCE(!pte_none(ptep_get(pte)));
 
@@ -601,7 +607,7 @@ pte_install_uffd_wp_if_needed(struct vm_area_struct *vma, unsigned long addr,
 			   make_pte_marker(PTE_MARKER_UFFD_WP));
 		return true;
 	}
-#endif
+
 	return false;
 }
 
diff --git a/include/linux/userfaultfd_k.h b/include/linux/userfaultfd_k.h
index c0e716aec26a..c19435863076 100644
--- a/include/linux/userfaultfd_k.h
+++ b/include/linux/userfaultfd_k.h
@@ -228,15 +228,14 @@ static inline bool vma_can_userfault(struct vm_area_struct *vma,
 	if (wp_async && (vm_flags == VM_UFFD_WP))
 		return true;
 
-#ifndef CONFIG_PTE_MARKER_UFFD_WP
 	/*
 	 * If user requested uffd-wp but not enabled pte markers for
 	 * uffd-wp, then shmem & hugetlbfs are not supported but only
 	 * anonymous.
 	 */
-	if ((vm_flags & VM_UFFD_WP) && !vma_is_anonymous(vma))
+	if (!uffd_supports_wp_marker() && (vm_flags & VM_UFFD_WP) &&
+	    !vma_is_anonymous(vma))
 		return false;
-#endif
 
 	/* By default, allow any of anon|shmem|hugetlb */
 	return vma_is_anonymous(vma) || is_vm_hugetlb_page(vma) ||
@@ -436,28 +435,26 @@ static inline bool userfaultfd_wp_use_markers(struct vm_area_struct *vma)
 
 static inline bool pte_marker_entry_uffd_wp(swp_entry_t entry)
 {
-#ifdef CONFIG_PTE_MARKER_UFFD_WP
+	if (!uffd_supports_wp_marker())
+		return false;
+
 	return is_pte_marker_entry(entry) &&
-	    (pte_marker_get(entry) & PTE_MARKER_UFFD_WP);
-#else
-	return false;
-#endif
+	       (pte_marker_get(entry) & PTE_MARKER_UFFD_WP);
 }
 
 static inline bool pte_marker_uffd_wp(pte_t pte)
 {
-#ifdef CONFIG_PTE_MARKER_UFFD_WP
 	swp_entry_t entry;
 
+	if (!uffd_supports_wp_marker())
+		return false;
+
 	if (!is_swap_pte(pte))
 		return false;
 
 	entry = pte_to_swp_entry(pte);
 
 	return pte_marker_entry_uffd_wp(entry);
-#else
-	return false;
-#endif
 }
 
 /*
@@ -466,7 +463,9 @@ static inline bool pte_marker_uffd_wp(pte_t pte)
  */
 static inline bool pte_swp_uffd_wp_any(pte_t pte)
 {
-#ifdef CONFIG_PTE_MARKER_UFFD_WP
+	if (!uffd_supports_wp_marker())
+		return false;
+
 	if (!is_swap_pte(pte))
 		return false;
 
@@ -475,7 +474,7 @@ static inline bool pte_swp_uffd_wp_any(pte_t pte)
 
 	if (pte_marker_uffd_wp(pte))
 		return true;
-#endif
+
 	return false;
 }
 
diff --git a/mm/memory.c b/mm/memory.c
index 0ba4f6b71847..607e14177412 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1465,7 +1465,9 @@ zap_install_uffd_wp_if_needed(struct vm_area_struct *vma,
 {
 	bool was_installed = false;
 
-#ifdef CONFIG_PTE_MARKER_UFFD_WP
+	if (!uffd_supports_wp_marker())
+		return false;
+
 	/* Zap on anonymous always means dropping everything */
 	if (vma_is_anonymous(vma))
 		return false;
@@ -1482,7 +1484,7 @@ zap_install_uffd_wp_if_needed(struct vm_area_struct *vma,
 		pte++;
 		addr += PAGE_SIZE;
 	}
-#endif
+
 	return was_installed;
 }
 
-- 
2.34.1
Re: [PATCH V12 2/5] mm: userfaultfd: Add pgtable_supports_uffd_wp()
Posted by kernel test robot 2 weeks, 2 days ago
Hi Chunyan,

kernel test robot noticed the following build errors:

[auto build test ERROR on brauner-vfs/vfs.all]
[also build test ERROR on kees/for-next/execve linus/master v6.17-rc6]
[cannot apply to akpm-mm/mm-everything next-20250915]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chunyan-Zhang/mm-softdirty-Add-pgtable_supports_soft_dirty/20250915-181826
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link:    https://lore.kernel.org/r/20250915101343.1449546-3-zhangchunyan%40iscas.ac.cn
patch subject: [PATCH V12 2/5] mm: userfaultfd: Add pgtable_supports_uffd_wp()
config: riscv-randconfig-002-20250916 (https://download.01.org/0day-ci/archive/20250916/202509161304.mQnxOxhS-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250916/202509161304.mQnxOxhS-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509161304.mQnxOxhS-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/mm_inline.h:10,
                    from mm/internal.h:13,
                    from mm/page_frag_cache.c:21:
   include/linux/userfaultfd_k.h: In function 'pte_marker_entry_uffd_wp':
>> include/linux/userfaultfd_k.h:441:9: error: implicit declaration of function 'is_pte_marker_entry' [-Werror=implicit-function-declaration]
     441 |  return is_pte_marker_entry(entry) &&
         |         ^~~~~~~~~~~~~~~~~~~
>> include/linux/userfaultfd_k.h:442:10: error: implicit declaration of function 'pte_marker_get' [-Werror=implicit-function-declaration]
     442 |         (pte_marker_get(entry) & PTE_MARKER_UFFD_WP);
         |          ^~~~~~~~~~~~~~
>> include/linux/userfaultfd_k.h:442:34: error: 'PTE_MARKER_UFFD_WP' undeclared (first use in this function)
     442 |         (pte_marker_get(entry) & PTE_MARKER_UFFD_WP);
         |                                  ^~~~~~~~~~~~~~~~~~
   include/linux/userfaultfd_k.h:442:34: note: each undeclared identifier is reported only once for each function it appears in
   include/linux/userfaultfd_k.h: In function 'pte_marker_uffd_wp':
>> include/linux/userfaultfd_k.h:452:7: error: implicit declaration of function 'is_swap_pte'; did you mean 'is_swap_pmd'? [-Werror=implicit-function-declaration]
     452 |  if (!is_swap_pte(pte))
         |       ^~~~~~~~~~~
         |       is_swap_pmd
>> include/linux/userfaultfd_k.h:455:10: error: implicit declaration of function 'pte_to_swp_entry' [-Werror=implicit-function-declaration]
     455 |  entry = pte_to_swp_entry(pte);
         |          ^~~~~~~~~~~~~~~~
>> include/linux/userfaultfd_k.h:455:10: error: incompatible types when assigning to type 'swp_entry_t' from type 'int'
   In file included from include/linux/mm_inline.h:11,
                    from mm/internal.h:13,
                    from mm/page_frag_cache.c:21:
   include/linux/swapops.h: At top level:
>> include/linux/swapops.h:124:19: error: static declaration of 'is_swap_pte' follows non-static declaration
     124 | static inline int is_swap_pte(pte_t pte)
         |                   ^~~~~~~~~~~
   In file included from include/linux/mm_inline.h:10,
                    from mm/internal.h:13,
                    from mm/page_frag_cache.c:21:
   include/linux/userfaultfd_k.h:452:7: note: previous implicit declaration of 'is_swap_pte' was here
     452 |  if (!is_swap_pte(pte))
         |       ^~~~~~~~~~~
   In file included from include/linux/mm_inline.h:11,
                    from mm/internal.h:13,
                    from mm/page_frag_cache.c:21:
>> include/linux/swapops.h:133:27: error: conflicting types for 'pte_to_swp_entry'
     133 | static inline swp_entry_t pte_to_swp_entry(pte_t pte)
         |                           ^~~~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:10,
                    from mm/internal.h:13,
                    from mm/page_frag_cache.c:21:
   include/linux/userfaultfd_k.h:455:10: note: previous implicit declaration of 'pte_to_swp_entry' was here
     455 |  entry = pte_to_swp_entry(pte);
         |          ^~~~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:11,
                    from mm/internal.h:13,
                    from mm/page_frag_cache.c:21:
>> include/linux/swapops.h:429:20: error: conflicting types for 'is_pte_marker_entry'
     429 | static inline bool is_pte_marker_entry(swp_entry_t entry)
         |                    ^~~~~~~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:10,
                    from mm/internal.h:13,
                    from mm/page_frag_cache.c:21:
   include/linux/userfaultfd_k.h:441:9: note: previous implicit declaration of 'is_pte_marker_entry' was here
     441 |  return is_pte_marker_entry(entry) &&
         |         ^~~~~~~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:11,
                    from mm/internal.h:13,
                    from mm/page_frag_cache.c:21:
>> include/linux/swapops.h:434:26: error: conflicting types for 'pte_marker_get'
     434 | static inline pte_marker pte_marker_get(swp_entry_t entry)
         |                          ^~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:10,
                    from mm/internal.h:13,
                    from mm/page_frag_cache.c:21:
   include/linux/userfaultfd_k.h:442:10: note: previous implicit declaration of 'pte_marker_get' was here
     442 |         (pte_marker_get(entry) & PTE_MARKER_UFFD_WP);
         |          ^~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
   In file included from include/linux/mm_inline.h:10,
                    from mm/mremap.c:12:
   include/linux/userfaultfd_k.h: In function 'pte_marker_entry_uffd_wp':
>> include/linux/userfaultfd_k.h:441:9: error: implicit declaration of function 'is_pte_marker_entry' [-Werror=implicit-function-declaration]
     441 |  return is_pte_marker_entry(entry) &&
         |         ^~~~~~~~~~~~~~~~~~~
>> include/linux/userfaultfd_k.h:442:10: error: implicit declaration of function 'pte_marker_get' [-Werror=implicit-function-declaration]
     442 |         (pte_marker_get(entry) & PTE_MARKER_UFFD_WP);
         |          ^~~~~~~~~~~~~~
>> include/linux/userfaultfd_k.h:442:34: error: 'PTE_MARKER_UFFD_WP' undeclared (first use in this function)
     442 |         (pte_marker_get(entry) & PTE_MARKER_UFFD_WP);
         |                                  ^~~~~~~~~~~~~~~~~~
   include/linux/userfaultfd_k.h:442:34: note: each undeclared identifier is reported only once for each function it appears in
   include/linux/userfaultfd_k.h: In function 'pte_marker_uffd_wp':
>> include/linux/userfaultfd_k.h:452:7: error: implicit declaration of function 'is_swap_pte'; did you mean 'is_swap_pmd'? [-Werror=implicit-function-declaration]
     452 |  if (!is_swap_pte(pte))
         |       ^~~~~~~~~~~
         |       is_swap_pmd
>> include/linux/userfaultfd_k.h:455:10: error: implicit declaration of function 'pte_to_swp_entry' [-Werror=implicit-function-declaration]
     455 |  entry = pte_to_swp_entry(pte);
         |          ^~~~~~~~~~~~~~~~
>> include/linux/userfaultfd_k.h:455:10: error: incompatible types when assigning to type 'swp_entry_t' from type 'int'
   In file included from include/linux/mm_inline.h:11,
                    from mm/mremap.c:12:
   include/linux/swapops.h: At top level:
>> include/linux/swapops.h:124:19: error: static declaration of 'is_swap_pte' follows non-static declaration
     124 | static inline int is_swap_pte(pte_t pte)
         |                   ^~~~~~~~~~~
   In file included from include/linux/mm_inline.h:10,
                    from mm/mremap.c:12:
   include/linux/userfaultfd_k.h:452:7: note: previous implicit declaration of 'is_swap_pte' was here
     452 |  if (!is_swap_pte(pte))
         |       ^~~~~~~~~~~
   In file included from include/linux/mm_inline.h:11,
                    from mm/mremap.c:12:
>> include/linux/swapops.h:133:27: error: conflicting types for 'pte_to_swp_entry'
     133 | static inline swp_entry_t pte_to_swp_entry(pte_t pte)
         |                           ^~~~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:10,
                    from mm/mremap.c:12:
   include/linux/userfaultfd_k.h:455:10: note: previous implicit declaration of 'pte_to_swp_entry' was here
     455 |  entry = pte_to_swp_entry(pte);
         |          ^~~~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:11,
                    from mm/mremap.c:12:
>> include/linux/swapops.h:429:20: error: conflicting types for 'is_pte_marker_entry'
     429 | static inline bool is_pte_marker_entry(swp_entry_t entry)
         |                    ^~~~~~~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:10,
                    from mm/mremap.c:12:
   include/linux/userfaultfd_k.h:441:9: note: previous implicit declaration of 'is_pte_marker_entry' was here
     441 |  return is_pte_marker_entry(entry) &&
         |         ^~~~~~~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:11,
                    from mm/mremap.c:12:
>> include/linux/swapops.h:434:26: error: conflicting types for 'pte_marker_get'
     434 | static inline pte_marker pte_marker_get(swp_entry_t entry)
         |                          ^~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:10,
                    from mm/mremap.c:12:
   include/linux/userfaultfd_k.h:442:10: note: previous implicit declaration of 'pte_marker_get' was here
     442 |         (pte_marker_get(entry) & PTE_MARKER_UFFD_WP);
         |          ^~~~~~~~~~~~~~
   In file included from include/linux/mm_inline.h:10,
                    from mm/mremap.c:12:
   include/linux/userfaultfd_k.h: In function 'pte_marker_entry_uffd_wp':
   include/linux/userfaultfd_k.h:443:1: warning: control reaches end of non-void function [-Wreturn-type]
     443 | }
         | ^
   cc1: some warnings being treated as errors


vim +/is_pte_marker_entry +441 include/linux/userfaultfd_k.h

2bad466cc9d9b4c Peter Xu      2023-03-09  435  
1db9dbc2ef05205 Peter Xu      2022-05-12  436  static inline bool pte_marker_entry_uffd_wp(swp_entry_t entry)
1db9dbc2ef05205 Peter Xu      2022-05-12  437  {
564509f441b4695 Chunyan Zhang 2025-09-15  438  	if (!uffd_supports_wp_marker())
564509f441b4695 Chunyan Zhang 2025-09-15  439  		return false;
564509f441b4695 Chunyan Zhang 2025-09-15  440  
1db9dbc2ef05205 Peter Xu      2022-05-12 @441  	return is_pte_marker_entry(entry) &&
1db9dbc2ef05205 Peter Xu      2022-05-12 @442  	       (pte_marker_get(entry) & PTE_MARKER_UFFD_WP);
1db9dbc2ef05205 Peter Xu      2022-05-12  443  }
1db9dbc2ef05205 Peter Xu      2022-05-12  444  
1db9dbc2ef05205 Peter Xu      2022-05-12  445  static inline bool pte_marker_uffd_wp(pte_t pte)
1db9dbc2ef05205 Peter Xu      2022-05-12  446  {
1db9dbc2ef05205 Peter Xu      2022-05-12  447  	swp_entry_t entry;
1db9dbc2ef05205 Peter Xu      2022-05-12  448  
564509f441b4695 Chunyan Zhang 2025-09-15  449  	if (!uffd_supports_wp_marker())
564509f441b4695 Chunyan Zhang 2025-09-15  450  		return false;
564509f441b4695 Chunyan Zhang 2025-09-15  451  
1db9dbc2ef05205 Peter Xu      2022-05-12 @452  	if (!is_swap_pte(pte))
1db9dbc2ef05205 Peter Xu      2022-05-12  453  		return false;
1db9dbc2ef05205 Peter Xu      2022-05-12  454  
1db9dbc2ef05205 Peter Xu      2022-05-12 @455  	entry = pte_to_swp_entry(pte);
1db9dbc2ef05205 Peter Xu      2022-05-12  456  
1db9dbc2ef05205 Peter Xu      2022-05-12  457  	return pte_marker_entry_uffd_wp(entry);
1db9dbc2ef05205 Peter Xu      2022-05-12  458  }
1db9dbc2ef05205 Peter Xu      2022-05-12  459  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH V12 2/5] mm: userfaultfd: Add pgtable_supports_uffd_wp()
Posted by Conor Dooley 2 weeks, 2 days ago
On Mon, Sep 15, 2025 at 06:13:40PM +0800, Chunyan Zhang wrote:
> Some platforms can customize the PTE/PMD entry uffd-wp bit making
> it unavailable even if the architecture provides the resource.
> This patch adds a macro API that allows architectures to define their
> specific implementations to check if the uffd-wp bit is available
> on which device the kernel is running.
> 
> Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>

According to patchwork CI for riscv, this doesn't build for 32-bit
defconfigs or the no-mmu defconfigs.
Re: [PATCH V12 2/5] mm: userfaultfd: Add pgtable_supports_uffd_wp()
Posted by David Hildenbrand 2 weeks, 3 days ago
On 15.09.25 12:13, Chunyan Zhang wrote:
> Some platforms can customize the PTE/PMD entry uffd-wp bit making
> it unavailable even if the architecture provides the resource.
> This patch adds a macro API that allows architectures to define their
> specific implementations to check if the uffd-wp bit is available
> on which device the kernel is running.
> 

Similar to my reply to #1, you should probably summarize what you do 
regarding ifdef and "No functional change expected".

> Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
> ---

[...]

LGTM, one not below, thanks!

Acked-by: David Hildenbrand <david@redhat.com>

> +/*
> + * Some platforms can customize the uffd-wp bit, making it unavailable
> + * even if the architecture provides the resource.
> + * Adding this API allows architectures to add their own checks for the
> + * devices on which the kernel is running.
> + * Note: When overriding it, please make sure the
> + * CONFIG_HAVE_ARCH_USERFAULTFD_WP is part of this macro.
> + */
> +#ifndef pgtable_supports_uffd_wp
> +#define pgtable_supports_uffd_wp()	IS_ENABLED(CONFIG_HAVE_ARCH_USERFAULTFD_WP)
> +#endif
> +
> +static __always_inline bool uffd_supports_wp_marker(void)
> +{
> +	return pgtable_supports_uffd_wp() && IS_ENABLED(CONFIG_PTE_MARKER_UFFD_WP);
> +}

Likely a simple "inline" should do the trick?

> +
>   #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP
>   static __always_inline int pte_uffd_wp(pte_t pte)
>   {
> diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
> index 89b518ff097e..d6526a7f034b 100644
> --- a/include/linux/mm_inline.h
> +++ b/include/linux/mm_inline.h
> @@ -570,9 +570,15 @@ static inline bool
>   pte_install_uffd_wp_if_needed(struct vm_area_struct *vma, unsigned long addr,
>   			      pte_t *pte, pte_t pteval)
>   {


-- 
Cheers

David / dhildenb