Re: [PATCH 2/9] hugetlb/userfaultfd: Forbid huge pmd sharing when uffd enabled

From: Peter Xu
Date: Thu Jan 21 2021 - 14:00:20 EST


On Fri, Jan 15, 2021 at 11:04:44AM -0800, Axel Rasmussen wrote:

[...]

> @@ -947,4 +948,15 @@ static inline __init void hugetlb_cma_check(void)
> }
> #endif
>
> +static inline bool want_pmd_share(struct vm_area_struct *vma)
> +{
> +#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
> + if (uffd_disable_huge_pmd_share(vma))
> + return false;
> + return true;
> +#else
> + return false;
> +#endif
> +}

I got syzbot complains about this chunk when compile some other archs outside
x86, probably because CONFIG_ARCH_WANT_HUGE_PMD_SHARE can be defined without
CONFIG_USERFAULTFD. I don't know why it didn't complain here, so just a fyi
that I've pushed some new version to the online repo so that they should have
been fixed. For example, for this patch:

https://github.com/xzpeter/linux/commit/0fd01db2c9ac3ab8600f3f7df23cf28fddcfee1b

static inline bool want_pmd_share(struct vm_area_struct *vma)
{
#ifdef CONFIG_USERFAULTFD
if (uffd_disable_huge_pmd_share(vma))
return false;
#endif

#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
return true;
#else
return false;
#endif
}

Thanks,

--
Peter Xu