From 8b03b571138897e9192ce69ef6bb86b90924978e Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Thu, 18 Mar 2021 17:01:47 +1100 Subject: [PATCH] FROMGIT: mm/hugetlb: fix build with !ARCH_WANT_HUGE_PMD_SHARE want_pmd_share() is undefined with !ARCH_WANT_HUGE_PMD_SHARE since it's put by accident into a "#ifdef ARCH_WANT_HUGE_PMD_SHARE" block. Moving it out won't work either since vma_shareable() is only defined within the block. Define it for !ARCH_WANT_HUGE_PMD_SHARE instead. Link: https://lkml.kernel.org/r/20210310185359.88297-1-peterx@redhat.com Fixes: 5b109cc1cdcc ("hugetlb/userfaultfd: forbid huge pmd sharing when uffd enabled") Signed-off-by: Peter Xu Reported-by: Naresh Kamboju Tested-by: Naresh Kamboju Reviewed-by: Mike Kravetz Cc: Axel Rasmussen Signed-off-by: Andrew Morton Signed-off-by: Stephen Rothwell (cherry picked from commit 5038f9dd8bbde13ff16435011bb3b0981acc5c1c https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git akpm) Link: https://lore.kernel.org/patchwork/patch/1393174/ Signed-off-by: Lokesh Gidra Bug: 160737021 Bug: 169683130 Change-Id: Id716afd43bff303f7eda2c4f70f18d9ea727c698 --- mm/hugetlb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 2bf06eb3a30a..799cbe7bc326 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5333,9 +5333,6 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr) bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr) { -#ifndef CONFIG_ARCH_WANT_HUGE_PMD_SHARE - return false; -#endif #ifdef CONFIG_USERFAULTFD if (uffd_disable_huge_pmd_share(vma)) return false; @@ -5480,6 +5477,11 @@ void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma, unsigned long *start, unsigned long *end) { } + +bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr) +{ + return false; +} #endif /* CONFIG_ARCH_WANT_HUGE_PMD_SHARE */ #ifdef CONFIG_ARCH_WANT_GENERAL_HUGETLB