[PATCH V12 2/5] mm: userfaultfd: Add pgtable_supports_uffd_wp()
David Hildenbrand
david at redhat.com
Mon Sep 15 06:56:13 PDT 2025
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 at iscas.ac.cn>
> ---
[...]
LGTM, one not below, thanks!
Acked-by: David Hildenbrand <david at 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
More information about the linux-riscv
mailing list