[PATCH 3/5] mm: add vaddr param to pmd_populate_kernel

2024-04-16 Thread Maxwell Bland
This patch affords each architecture the ability to condition the
population of page middle directory entries on the virtual address being
allocated, matching existing PTE infrastructure, easing the necessity of
performing a reverse page table walk in cases where the population
context is not readily accessible, i.e. dynamic vmalloc calls on arm64.

To achieve this goal, it modifies every call and implementation of the
pmd_populate_kernel function across architectures, ensuring uniform
adoption across all kernel deployments.

Signed-off-by: Maxwell Bland 

---

Hi all,

Thank you for taking the time to review this change. This effects many
subarchitectures so the maintainers list is large. Apologies in advance
if there is a specific maintainer I should have spoken with directly for
deployment across subprojects.

The reason for such a sweeping change is from 
lore.kernel.org/all/cf5409c3-254a-459b-8969-429db2ec6...@redhat.com

It is my understanding as well that some subarchitectures may have
separate "next" or development branches ahead of the main upstream
linux. Please let me know if a cherry-pick to that branch is desired and
I will do my best to check out and deploy it as possible.

 arch/alpha/include/asm/pgalloc.h |  5 +++--
 arch/arc/include/asm/pgalloc.h   |  3 ++-
 arch/arc/mm/highmem.c|  2 +-
 arch/arm/include/asm/kfence.h|  2 +-
 arch/arm/include/asm/pgalloc.h   |  3 ++-
 arch/arm/mm/kasan_init.c |  2 +-
 arch/arm/mm/mmu.c|  2 +-
 arch/arm64/include/asm/pgalloc.h |  3 ++-
 arch/arm64/mm/trans_pgd.c|  2 +-
 arch/csky/include/asm/pgalloc.h  |  2 +-
 arch/hexagon/include/asm/pgalloc.h   |  2 +-
 arch/loongarch/include/asm/pgalloc.h |  3 ++-
 arch/loongarch/mm/init.c |  2 +-
 arch/loongarch/mm/kasan_init.c   |  2 +-
 arch/m68k/include/asm/mcf_pgalloc.h  |  2 +-
 arch/m68k/include/asm/motorola_pgalloc.h |  3 ++-
 arch/m68k/include/asm/sun3_pgalloc.h |  3 ++-
 arch/microblaze/include/asm/pgalloc.h|  2 +-
 arch/mips/include/asm/pgalloc.h  |  2 +-
 arch/mips/kvm/mmu.c  |  2 +-
 arch/nios2/include/asm/pgalloc.h |  2 +-
 arch/openrisc/include/asm/pgalloc.h  |  2 +-
 arch/parisc/include/asm/pgalloc.h|  5 +++--
 arch/parisc/mm/init.c|  6 +++---
 arch/powerpc/include/asm/book3s/32/pgalloc.h |  2 +-
 arch/powerpc/include/asm/book3s/64/pgalloc.h |  2 +-
 arch/powerpc/include/asm/nohash/32/pgalloc.h |  2 +-
 arch/powerpc/include/asm/nohash/64/pgalloc.h |  2 +-
 arch/powerpc/mm/book3s64/radix_pgtable.c |  2 +-
 arch/powerpc/mm/kasan/init_32.c  |  4 ++--
 arch/powerpc/mm/kasan/init_book3e_64.c   |  9 ++---
 arch/powerpc/mm/kasan/init_book3s_64.c   |  7 +--
 arch/powerpc/mm/nohash/book3e_pgtable.c  |  2 +-
 arch/powerpc/mm/pgtable_32.c |  4 ++--
 arch/riscv/include/asm/pgalloc.h |  2 +-
 arch/riscv/kernel/hibernate.c|  2 +-
 arch/s390/include/asm/pgalloc.h  |  2 +-
 arch/sh/include/asm/pgalloc.h|  2 +-
 arch/sh/mm/init.c|  2 +-
 arch/sparc/include/asm/pgalloc_32.h  |  3 ++-
 arch/sparc/include/asm/pgalloc_64.h  |  4 ++--
 arch/sparc/mm/init_64.c  |  8 
 arch/um/include/asm/pgalloc.h|  4 ++--
 arch/x86/include/asm/pgalloc.h   |  3 ++-
 arch/x86/mm/init_64.c| 14 +++---
 arch/x86/mm/ioremap.c|  2 +-
 arch/x86/mm/kasan_init_64.c  |  2 +-
 arch/xtensa/include/asm/pgalloc.h|  2 +-
 include/linux/mm.h   |  4 ++--
 mm/hugetlb_vmemmap.c |  4 ++--
 mm/kasan/init.c  | 14 +-
 mm/memory.c  |  4 ++--
 mm/percpu.c  |  2 +-
 mm/pgalloc-track.h   |  3 ++-
 mm/sparse-vmemmap.c  |  2 +-
 55 files changed, 107 insertions(+), 78 deletions(-)

diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
index 68be7adbfe58..1d3d86cad3cc 100644
--- a/arch/alpha/include/asm/pgalloc.h
+++ b/arch/alpha/include/asm/pgalloc.h
@@ -7,7 +7,7 @@
 
 #include 
 
-/*  
+/*
  * Allocate and free page tables. The xxx_kernel() versions are
  * used to allocate a kernel page table - this turns on ASN bits
  * if any.
@@ -20,7 +20,8 @@ pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t pte)
 }
 
 static inline void
-pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
+pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte,
+   unsigned long vaddr)
 {
pmd_set(pmd, p

[linux-next:master] BUILD REGRESSION 66e4190e92ce0e4a50b2f6be0e5f5b2e47e072f4

2024-04-16 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
branch HEAD: 66e4190e92ce0e4a50b2f6be0e5f5b2e47e072f4  Add linux-next specific 
files for 20240416

Error/Warning reports:

https://lore.kernel.org/oe-kbuild-all/202404161933.izfqz32k-...@intel.com
https://lore.kernel.org/oe-kbuild-all/202404170348.thxrbof1-...@intel.com

Error/Warning: (recently discovered and may have been fixed)

arch/arc/include/asm/cmpxchg.h:50:26: error: implicit declaration of function 
'cmpxchg_emu_u8' [-Werror=implicit-function-declaration]
arch/mips/sgi-ip27/ip27-irq.c:280:13: warning: unused variable 'i' 
[-Wunused-variable]
netdev.c:(.text+0x2288): undefined reference to `page_pool_create'
netdev.c:(.text+0x378): undefined reference to `page_pool_alloc_pages'

Error/Warning ids grouped by kconfigs:

gcc_recent_errors
|-- alpha-allyesconfig
|   |-- 
drivers-gpu-drm-imx-ipuv3-imx-ldb.c:error:_sel-directive-output-may-be-truncated-writing-bytes-into-a-region-of-size-between-and
|   `-- 
drivers-gpu-drm-nouveau-nouveau_backlight.c:error:d-directive-output-may-be-truncated-writing-between-and-bytes-into-a-region-of-size
|-- alpha-randconfig-r112-20240416
|   `-- 
kernel-bpf-verifier.c:sparse:sparse:cast-truncates-bits-from-constant-value-(fffc-becomes-)
|-- arc-allmodconfig
|   `-- 
arch-arc-include-asm-cmpxchg.h:error:implicit-declaration-of-function-cmpxchg_emu_u8
|-- arc-allnoconfig
|   `-- 
arch-arc-include-asm-cmpxchg.h:error:implicit-declaration-of-function-cmpxchg_emu_u8
|-- arc-allyesconfig
|   `-- 
arch-arc-include-asm-cmpxchg.h:error:implicit-declaration-of-function-cmpxchg_emu_u8
|-- arc-defconfig
|   `-- 
arch-arc-include-asm-cmpxchg.h:error:implicit-declaration-of-function-cmpxchg_emu_u8
|-- arc-nsimosci_hs_smp_defconfig
|   `-- 
arch-arc-include-asm-cmpxchg.h:error:implicit-declaration-of-function-cmpxchg_emu_u8
|-- arc-randconfig-001-20240416
|   `-- 
arch-arc-include-asm-cmpxchg.h:error:implicit-declaration-of-function-cmpxchg_emu_u8
|-- arc-randconfig-002-20240416
|   `-- 
arch-arc-include-asm-cmpxchg.h:error:implicit-declaration-of-function-cmpxchg_emu_u8
|-- arm-allmodconfig
|   |-- 
drivers-gpu-drm-imx-ipuv3-imx-ldb.c:error:_sel-directive-output-may-be-truncated-writing-bytes-into-a-region-of-size-between-and
|   `-- 
drivers-gpu-drm-nouveau-nouveau_backlight.c:error:d-directive-output-may-be-truncated-writing-between-and-bytes-into-a-region-of-size
|-- arm-allyesconfig
|   |-- 
drivers-gpu-drm-imx-ipuv3-imx-ldb.c:error:_sel-directive-output-may-be-truncated-writing-bytes-into-a-region-of-size-between-and
|   `-- 
drivers-gpu-drm-nouveau-nouveau_backlight.c:error:d-directive-output-may-be-truncated-writing-between-and-bytes-into-a-region-of-size
|-- csky-allmodconfig
|   |-- 
drivers-gpu-drm-imx-ipuv3-imx-ldb.c:error:_sel-directive-output-may-be-truncated-writing-bytes-into-a-region-of-size-between-and
|   `-- 
drivers-gpu-drm-nouveau-nouveau_backlight.c:error:d-directive-output-may-be-truncated-writing-between-and-bytes-into-a-region-of-size
|-- csky-allyesconfig
|   |-- 
drivers-gpu-drm-imx-ipuv3-imx-ldb.c:error:_sel-directive-output-may-be-truncated-writing-bytes-into-a-region-of-size-between-and
|   `-- 
drivers-gpu-drm-nouveau-nouveau_backlight.c:error:d-directive-output-may-be-truncated-writing-between-and-bytes-into-a-region-of-size
|-- i386-randconfig-141-20240416
|   |-- 
drivers-pwm-core.c-pwm_cdev_ioctl()-warn:possible-spectre-second-half.-pwm
|   `-- 
drivers-pwm-core.c-pwm_cdev_ioctl()-warn:potential-spectre-issue-cdata-pwm-r
|-- loongarch-allmodconfig
|   |-- 
drivers-gpu-drm-imx-ipuv3-imx-ldb.c:error:_sel-directive-output-may-be-truncated-writing-bytes-into-a-region-of-size-between-and
|   `-- 
drivers-gpu-drm-nouveau-nouveau_backlight.c:error:d-directive-output-may-be-truncated-writing-between-and-bytes-into-a-region-of-size
|-- loongarch-allyesconfig
|   |-- 
drivers-gpu-drm-imx-ipuv3-imx-ldb.c:error:_sel-directive-output-may-be-truncated-writing-bytes-into-a-region-of-size-between-and
|   `-- 
drivers-gpu-drm-nouveau-nouveau_backlight.c:error:d-directive-output-may-be-truncated-writing-between-and-bytes-into-a-region-of-size
|-- microblaze-allmodconfig
|   |-- 
drivers-gpu-drm-imx-ipuv3-imx-ldb.c:error:_sel-directive-output-may-be-truncated-writing-bytes-into-a-region-of-size-between-and
|   `-- 
drivers-gpu-drm-nouveau-nouveau_backlight.c:error:d-directive-output-may-be-truncated-writing-between-and-bytes-into-a-region-of-size
|-- microblaze-allyesconfig
|   |-- 
drivers-gpu-drm-imx-ipuv3-imx-ldb.c:error:_sel-directive-output-may-be-truncated-writing-bytes-into-a-region-of-size-between-and
|   `-- 
drivers-gpu-drm-nouveau-nouveau_backlight.c:error:d-directive-output-may-be-truncated-writing-between-and-bytes-into-a-region-of-size
|-- mips-ip27_defconfig
|   `-- arch-mips-sgi-ip27-ip27-irq.c:warning:unused-variable-i
|-- openrisc-allyesconfig
|   |-- 
drivers-gpu-drm-imx-ipuv3-imx-ldb.c:error:_sel-directive-output-

Re: sh: arc: cmpxchg.h:50:12: error: implicit declaration of function 'cmpxchg_emu_u8' [-Werror=implicit-function-declaration]

2024-04-16 Thread Paul E. McKenney
On Mon, Apr 15, 2024 at 04:17:01PM +0530, Naresh Kamboju wrote:
> The arc and sh defconfig builds failed due to following build warnings / 
> errors
> on the Linux next-20240415 with gcc-9 and gcc-11.
> 
> Reported-by: Linux Kernel Functional Testing 
> 
> Following builds failed.
> sh:
> arc:
>  - defconfig
>  - tinyconfig
>  - allnoconfig
>  - vdk_hs38_smp_defconfig
> 
> Build log:
> 
> In file included from arch/arc/include/asm/atomic.h:13,
>  from include/linux/atomic.h:7,
>  from include/asm-generic/bitops/lock.h:5,
>  from arch/arc/include/asm/bitops.h:188,
>  from include/linux/bitops.h:70,
>  from include/linux/log2.h:12,
>  from kernel/bounds.c:13:
> include/linux/atomic/atomic-arch-fallback.h: In function 'raw_atomic_cmpxchg':
> arch/arc/include/asm/cmpxchg.h:50:12: error: implicit declaration of
> function 'cmpxchg_emu_u8' [-Werror=implicit-function-declaration]
>50 |   _prev_ = cmpxchg_emu_u8((volatile u8 *)_p_, _o_, _n_); \
>   |^~
> 
> Steps to reproduce:
> ---
> # tuxmake --runtime podman --target-arch arc --toolchain gcc-9
> --kconfig defconfig
> # tuxmake --runtime podman --target-arch sh --toolchain gcc-11
> --kconfig defconfig
> 
> 
> Links:
> ---
>  - 
> https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20240415/testrun/23463978/suite/build/test/gcc-9-defconfig/details/
>  - 
> https://storage.tuxsuite.com/public/linaro/lkft/builds/2f7sIl2MlKB5Fgq7JtTpYQ9lnXw/
>  - 
> https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20240415/testrun/23463981/suite/build/test/gcc-11-defconfig/details/

Thank you for testing this!  Does the following diff (to be folded into
the originals with attribution) help?

Thanx, Paul



diff --git a/arch/arc/include/asm/cmpxchg.h b/arch/arc/include/asm/cmpxchg.h
index c3833e18389f4..40101f9d88d45 100644
--- a/arch/arc/include/asm/cmpxchg.h
+++ b/arch/arc/include/asm/cmpxchg.h
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/arch/sh/include/asm/cmpxchg.h b/arch/sh/include/asm/cmpxchg.h
index 27a9040983cfe..726b3ad9c8703 100644
--- a/arch/sh/include/asm/cmpxchg.h
+++ b/arch/sh/include/asm/cmpxchg.h
@@ -9,6 +9,7 @@
 
 #include 
 #include 
+#include 
 
 #if defined(CONFIG_GUSA_RB)
 #include 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc