[PATCH v2 0/3] mm: Care about shadow stack guard gap when getting an unmapped area

2024-09-04 Thread Mark Brown
As covered in the commit log for c44357c2e76b ("x86/mm: care about shadow
stack guard gap during placement") our current mmap() implementation does
not take care to ensure that a new mapping isn't placed with existing
mappings inside it's own guard gaps. This is particularly important for
shadow stacks since if two shadow stacks end up getting placed adjacent to
each other then they can overflow into each other which weakens the
protection offered by the feature.

On x86 there is a custom arch_get_unmapped_area() which was updated by the
above commit to cover this case by specifying a start_gap for allocations
with VM_SHADOW_STACK. Both arm64 and RISC-V have equivalent features and
use the generic implementation of arch_get_unmapped_area() so let's make
the equivalent change there so they also don't get shadow stack pages
placed without guard pages. The arm64 and RISC-V shadow stack
implementations are currently on the list:

   https://lore.kernel.org/r/20240829-arm64-gcs-v12-0-42fec94743
   https://lore.kernel.org/lkml/20240403234054.2020347-1-de...@rivosinc.com/

Given the addition of the use of vm_flags in the generic implementation
we also simplify the set of possibilities that have to be dealt with in
the core code by making arch_get_unmapped_area() take vm_flags as
standard. This is a bit invasive since the prototype change touches
quite a few architectures but since the parameter is ignored the change
is straightforward, the simplification for the generic code seems worth
it.

Changes in v2:
- Add comment to stack_guard_placement()
- Build fixes for xtensa and MIPS.
- Link to v1: 
https://lore.kernel.org/r/20240902-mm-generic-shadow-stack-guard-v1-0-9acda38b3...@kernel.org

---
Mark Brown (3):
  mm: Make arch_get_unmapped_area() take vm_flags by default
  mm: Pass vm_flags to generic_get_unmapped_area()
  mm: Care about shadow stack guard gap when getting an unmapped area

 arch/alpha/kernel/osf_sys.c   |  2 +-
 arch/arc/mm/mmap.c|  3 ++-
 arch/arm/mm/mmap.c|  7 ++---
 arch/csky/abiv1/mmap.c|  3 ++-
 arch/loongarch/mm/mmap.c  |  5 ++--
 arch/mips/mm/mmap.c   |  5 ++--
 arch/parisc/kernel/sys_parisc.c   |  5 ++--
 arch/parisc/mm/hugetlbpage.c  |  2 +-
 arch/powerpc/mm/book3s64/slice.c  | 10 ---
 arch/s390/mm/mmap.c   |  4 +--
 arch/sh/mm/mmap.c |  5 ++--
 arch/sparc/kernel/sys_sparc_32.c  |  2 +-
 arch/sparc/kernel/sys_sparc_64.c  |  4 +--
 arch/x86/include/asm/pgtable_64.h |  1 -
 arch/x86/kernel/sys_x86_64.c  | 21 +++
 arch/xtensa/kernel/syscall.c  |  3 ++-
 include/linux/sched/mm.h  | 27 +++
 mm/mmap.c | 55 +++
 18 files changed, 75 insertions(+), 89 deletions(-)
---
base-commit: 7c626ce4bae1ac14f60076d00eafe71af30450ba
change-id: 20240830-mm-generic-shadow-stack-guard-5bc5b8d0e95d

Best regards,
-- 
Mark Brown 


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


[PATCH v2 1/3] mm: Make arch_get_unmapped_area() take vm_flags by default

2024-09-04 Thread Mark Brown
When we introduced arch_get_unmapped_area_vmflags() in 961148704acd
("mm: introduce arch_get_unmapped_area_vmflags()") we did so as part of
properly supporting guard pages for shadow stacks on x86_64, which uses
a custom arch_get_unmapped_area(). Equivalent features are also present
on both arm64 and RISC-V, both of which use the generic implementation
of arch_get_unmapped_area() and will require equivalent modification
there. Rather than continue to deal with having two versions of the
functions let's bite the bullet and have all implementations of
arch_get_unmapped_area() take vm_flags as a parameter.

The new parameter is currently ignored by all implementations other than
x86. The only caller that doesn't have a vm_flags available is
mm_get_unmapped_area(), as for the x86 implementation and the wrapper used
on other architectures this is modified to supply no flags.

No functional changes.

Acked-by: Lorenzo Stoakes 
Reviewed-by: Liam R. Howlett 
Acked-by: Helge Deller   # parisc
Signed-off-by: Mark Brown 
---
 arch/alpha/kernel/osf_sys.c   |  2 +-
 arch/arc/mm/mmap.c|  3 ++-
 arch/arm/mm/mmap.c|  7 ---
 arch/csky/abiv1/mmap.c|  3 ++-
 arch/loongarch/mm/mmap.c  |  5 +++--
 arch/mips/mm/mmap.c   |  5 +++--
 arch/parisc/kernel/sys_parisc.c   |  5 +++--
 arch/parisc/mm/hugetlbpage.c  |  2 +-
 arch/powerpc/mm/book3s64/slice.c  |  6 --
 arch/s390/mm/mmap.c   |  4 ++--
 arch/sh/mm/mmap.c |  5 +++--
 arch/sparc/kernel/sys_sparc_32.c  |  2 +-
 arch/sparc/kernel/sys_sparc_64.c  |  4 ++--
 arch/x86/include/asm/pgtable_64.h |  1 -
 arch/x86/kernel/sys_x86_64.c  | 21 +++--
 arch/xtensa/kernel/syscall.c  |  3 ++-
 include/linux/sched/mm.h  | 23 ---
 mm/mmap.c | 31 +++
 18 files changed, 51 insertions(+), 81 deletions(-)

diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index e5f881bc8288..8886ab539273 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -1229,7 +1229,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned 
long len,
 unsigned long
 arch_get_unmapped_area(struct file *filp, unsigned long addr,
   unsigned long len, unsigned long pgoff,
-  unsigned long flags)
+  unsigned long flags, vm_flags_t vm_flags)
 {
unsigned long limit;
 
diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c
index 69a915297155..2185afe8d59f 100644
--- a/arch/arc/mm/mmap.c
+++ b/arch/arc/mm/mmap.c
@@ -23,7 +23,8 @@
  */
 unsigned long
 arch_get_unmapped_area(struct file *filp, unsigned long addr,
-   unsigned long len, unsigned long pgoff, unsigned long flags)
+   unsigned long len, unsigned long pgoff,
+   unsigned long flags, vm_flags_t vm_flags)
 {
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index d65d0e6ed10a..3dbb383c26d5 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -28,7 +28,8 @@
  */
 unsigned long
 arch_get_unmapped_area(struct file *filp, unsigned long addr,
-   unsigned long len, unsigned long pgoff, unsigned long flags)
+   unsigned long len, unsigned long pgoff,
+   unsigned long flags, vm_flags_t vm_flags)
 {
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
@@ -78,8 +79,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 
 unsigned long
 arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
-   const unsigned long len, const unsigned long pgoff,
-   const unsigned long flags)
+   const unsigned long len, const unsigned long pgoff,
+   const unsigned long flags, vm_flags_t vm_flags)
 {
struct vm_area_struct *vma;
struct mm_struct *mm = current->mm;
diff --git a/arch/csky/abiv1/mmap.c b/arch/csky/abiv1/mmap.c
index 7f826331d409..1047865e82a9 100644
--- a/arch/csky/abiv1/mmap.c
+++ b/arch/csky/abiv1/mmap.c
@@ -23,7 +23,8 @@
  */
 unsigned long
 arch_get_unmapped_area(struct file *filp, unsigned long addr,
-   unsigned long len, unsigned long pgoff, unsigned long flags)
+   unsigned long len, unsigned long pgoff,
+   unsigned long flags, vm_flags_t vm_flags)
 {
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
diff --git a/arch/loongarch/mm/mmap.c b/arch/loongarch/mm/mmap.c
index 889030985135..914e82ff3f65 100644
--- a/arch/loongarch/mm/mmap.c
+++ b/arch/loongarch/mm/mmap.c
@@ -89,7 +89,8 @@ static unsigned long arch_get_unmapped_area_common(struct 
file *filp,
 }
 
 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr0,
-   unsigned long len, unsigned long pgoff, unsig

[PATCH v2 2/3] mm: Pass vm_flags to generic_get_unmapped_area()

2024-09-04 Thread Mark Brown
In preparation for using vm_flags to ensure guard pages for shadow stacks
supply them as an argument to generic_get_unmapped_area(). The only user
outside of the core code is the PowerPC book3s64 implementation which is
trivially wrapping the generic implementation in the radix_enabled() case.

No functional changes.

Acked-by: Lorenzo Stoakes 
Reviewed-by: Liam R. Howlett 
Acked-by: Michael Ellerman 
Signed-off-by: Mark Brown 
---
 arch/powerpc/mm/book3s64/slice.c |  4 ++--
 include/linux/sched/mm.h |  4 ++--
 mm/mmap.c| 10 ++
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c
index ada6bf896ef8..87307d0fc3b8 100644
--- a/arch/powerpc/mm/book3s64/slice.c
+++ b/arch/powerpc/mm/book3s64/slice.c
@@ -641,7 +641,7 @@ unsigned long arch_get_unmapped_area(struct file *filp,
 vm_flags_t vm_flags)
 {
if (radix_enabled())
-   return generic_get_unmapped_area(filp, addr, len, pgoff, flags);
+   return generic_get_unmapped_area(filp, addr, len, pgoff, flags, 
vm_flags);
 
return slice_get_unmapped_area(addr, len, flags,
   
mm_ctx_user_psize(¤t->mm->context), 0);
@@ -655,7 +655,7 @@ unsigned long arch_get_unmapped_area_topdown(struct file 
*filp,
 vm_flags_t vm_flags)
 {
if (radix_enabled())
-   return generic_get_unmapped_area_topdown(filp, addr0, len, 
pgoff, flags);
+   return generic_get_unmapped_area_topdown(filp, addr0, len, 
pgoff, flags, vm_flags);
 
return slice_get_unmapped_area(addr0, len, flags,
   
mm_ctx_user_psize(¤t->mm->context), 1);
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index c4d34abc45d4..07bb8d4181d7 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -204,11 +204,11 @@ unsigned long mm_get_unmapped_area_vmflags(struct 
mm_struct *mm,
 unsigned long
 generic_get_unmapped_area(struct file *filp, unsigned long addr,
  unsigned long len, unsigned long pgoff,
- unsigned long flags);
+ unsigned long flags, vm_flags_t vm_flags);
 unsigned long
 generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
  unsigned long len, unsigned long pgoff,
- unsigned long flags);
+ unsigned long flags, vm_flags_t vm_flags);
 #else
 static inline void arch_pick_mmap_layout(struct mm_struct *mm,
 struct rlimit *rlim_stack) {}
diff --git a/mm/mmap.c b/mm/mmap.c
index 7528146f886f..b06ba847c96e 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1789,7 +1789,7 @@ unsigned long vm_unmapped_area(struct 
vm_unmapped_area_info *info)
 unsigned long
 generic_get_unmapped_area(struct file *filp, unsigned long addr,
  unsigned long len, unsigned long pgoff,
- unsigned long flags)
+ unsigned long flags, vm_flags_t vm_flags)
 {
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma, *prev;
@@ -1823,7 +1823,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long 
addr,
   unsigned long len, unsigned long pgoff,
   unsigned long flags, vm_flags_t vm_flags)
 {
-   return generic_get_unmapped_area(filp, addr, len, pgoff, flags);
+   return generic_get_unmapped_area(filp, addr, len, pgoff, flags,
+vm_flags);
 }
 #endif
 
@@ -1834,7 +1835,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long 
addr,
 unsigned long
 generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
  unsigned long len, unsigned long pgoff,
- unsigned long flags)
+ unsigned long flags, vm_flags_t vm_flags)
 {
struct vm_area_struct *vma, *prev;
struct mm_struct *mm = current->mm;
@@ -1887,7 +1888,8 @@ arch_get_unmapped_area_topdown(struct file *filp, 
unsigned long addr,
   unsigned long len, unsigned long pgoff,
   unsigned long flags, vm_flags_t vm_flags)
 {
-   return generic_get_unmapped_area_topdown(filp, addr, len, pgoff, flags);
+   return generic_get_unmapped_area_topdown(filp, addr, len, pgoff, flags,
+vm_flags);
 }
 #endif
 

-- 
2.39.2


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


[PATCH v2 3/3] mm: Care about shadow stack guard gap when getting an unmapped area

2024-09-04 Thread Mark Brown
As covered in the commit log for c44357c2e76b ("x86/mm: care about shadow
stack guard gap during placement") our current mmap() implementation does
not take care to ensure that a new mapping isn't placed with existing
mappings inside it's own guard gaps. This is particularly important for
shadow stacks since if two shadow stacks end up getting placed adjacent to
each other then they can overflow into each other which weakens the
protection offered by the feature.

On x86 there is a custom arch_get_unmapped_area() which was updated by the
above commit to cover this case by specifying a start_gap for allocations
with VM_SHADOW_STACK. Both arm64 and RISC-V have equivalent features and
use the generic implementation of arch_get_unmapped_area() so let's make
the equivalent change there so they also don't get shadow stack pages
placed without guard pages. x86 uses a single page guard, this is also
sufficient for arm64 where we either do single word pops and pushes or
unconstrained writes.

Architectures which do not have this feature will define VM_SHADOW_STACK
to VM_NONE and hence be unaffected.

Suggested-by: Rick Edgecombe 
Acked-by: Lorenzo Stoakes 
Signed-off-by: Mark Brown 
---
 mm/mmap.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/mm/mmap.c b/mm/mmap.c
index b06ba847c96e..050c5ae2f80f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1753,6 +1753,18 @@ static unsigned long unmapped_area_topdown(struct 
vm_unmapped_area_info *info)
return gap;
 }
 
+/*
+ * Determine if the allocation needs to ensure that there is no
+ * existing mapping within it's guard gaps, for use as start_gap.
+ */
+static inline unsigned long stack_guard_placement(vm_flags_t vm_flags)
+{
+   if (vm_flags & VM_SHADOW_STACK)
+   return PAGE_SIZE;
+
+   return 0;
+}
+
 /*
  * Search for an unmapped address range.
  *
@@ -1814,6 +1826,7 @@ generic_get_unmapped_area(struct file *filp, unsigned 
long addr,
info.length = len;
info.low_limit = mm->mmap_base;
info.high_limit = mmap_end;
+   info.start_gap = stack_guard_placement(vm_flags);
return vm_unmapped_area(&info);
 }
 
@@ -1863,6 +1876,7 @@ generic_get_unmapped_area_topdown(struct file *filp, 
unsigned long addr,
info.length = len;
info.low_limit = PAGE_SIZE;
info.high_limit = arch_get_mmap_base(addr, mm->mmap_base);
+   info.start_gap = stack_guard_placement(vm_flags);
addr = vm_unmapped_area(&info);
 
/*

-- 
2.39.2


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


Re: [PATCH 3/3] mm: Care about shadow stack guard gap when getting an unmapped area

2024-09-04 Thread Deepak Gupta

On Mon, Sep 02, 2024 at 08:08:15PM +0100, Mark Brown wrote:

As covered in the commit log for c44357c2e76b ("x86/mm: care about shadow
stack guard gap during placement") our current mmap() implementation does
not take care to ensure that a new mapping isn't placed with existing
mappings inside it's own guard gaps. This is particularly important for
shadow stacks since if two shadow stacks end up getting placed adjacent to
each other then they can overflow into each other which weakens the
protection offered by the feature.

On x86 there is a custom arch_get_unmapped_area() which was updated by the
above commit to cover this case by specifying a start_gap for allocations
with VM_SHADOW_STACK. Both arm64 and RISC-V have equivalent features and
use the generic implementation of arch_get_unmapped_area() so let's make
the equivalent change there so they also don't get shadow stack pages
placed without guard pages.

Architectures which do not have this feature will define VM_SHADOW_STACK
to VM_NONE and hence be unaffected.

Suggested-by: Rick Edgecombe 
Signed-off-by: Mark Brown 
---
mm/mmap.c | 10 ++
1 file changed, 10 insertions(+)

diff --git a/mm/mmap.c b/mm/mmap.c
index b06ba847c96e..902c482b6084 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1753,6 +1753,14 @@ static unsigned long unmapped_area_topdown(struct 
vm_unmapped_area_info *info)
return gap;
}

+static inline unsigned long stack_guard_placement(vm_flags_t vm_flags)
+{
+   if (vm_flags & VM_SHADOW_STACK)
+   return PAGE_SIZE;
+
+   return 0;
+}
+
/*
 * Search for an unmapped address range.
 *
@@ -1814,6 +1822,7 @@ generic_get_unmapped_area(struct file *filp, unsigned 
long addr,
info.length = len;
info.low_limit = mm->mmap_base;
info.high_limit = mmap_end;
+   info.start_gap = stack_guard_placement(vm_flags);
return vm_unmapped_area(&info);
}

@@ -1863,6 +1872,7 @@ generic_get_unmapped_area_topdown(struct file *filp, 
unsigned long addr,
info.length = len;
info.low_limit = PAGE_SIZE;
info.high_limit = arch_get_mmap_base(addr, mm->mmap_base);
+   info.start_gap = stack_guard_placement(vm_flags);
addr = vm_unmapped_area(&info);

/*



lgtm

Reviewed-by: Deepak Gupta 


--
2.39.2



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


Re: [PATCH 2/3] mm: Pass vm_flags to generic_get_unmapped_area()

2024-09-04 Thread Deepak Gupta

On Mon, Sep 02, 2024 at 08:08:14PM +0100, Mark Brown wrote:

In preparation for using vm_flags to ensure guard pages for shadow stacks
supply them as an argument to generic_get_unmapped_area(). The only user
outside of the core code is the PowerPC book3s64 implementation which is
trivially wrapping the generic implementation in the radix_enabled() case.

Signed-off-by: Mark Brown 


Reviewed-by: Deepak Gupta 


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


Re: [PATCH 3/3] mm: Care about shadow stack guard gap when getting an unmapped area

2024-09-04 Thread Deepak Gupta

On Tue, Sep 03, 2024 at 08:57:20PM +0100, Mark Brown wrote:

On Tue, Sep 03, 2024 at 03:41:49PM -0400, Liam R. Howlett wrote:

* Mark Brown  [240902 15:09]:



> +static inline unsigned long stack_guard_placement(vm_flags_t vm_flags)
> +{
> +  if (vm_flags & VM_SHADOW_STACK)
> +  return PAGE_SIZE;



Is PAGE_SIZE is enough?


It's what x86 currently uses so it'll be no worse off if it gets moved
to the generic code (there's a comment in the arch code explaing what's
needed there) and it's enough for arm64, we only do single record
pushes/pops or (optionally) writes to unconstrained addresses.


It's enough for RISC-V too.


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


[PATCH 03/15] kbuild: move non-boot builtin DTBs to .init.rodata section

2024-09-04 Thread Masahiro Yamada
Some architectures support embedding boot DTB(s) in vmlinux. These
architectures, except MIPS and MicroBlaze, expect a single DTB in
the .dtb.init.rodata section. MIPS embeds multiple DTBs in vmlinux.
MicroBlaze embeds a DTB in its own __fdt_blob section instead of the
.dtb.init.rodata section.

For example, RISC-V previously allowed embedding multiple DTBs, but
only the first DTB in the .dtb.init.rodata section was used. Commit
2672031b20f6 ("riscv: dts: Move BUILTIN_DTB_SOURCE to common Kconfig")
ensured only one boot DTB is embedded.

Meanwhile, commit 7b937cc243e5 ("of: Create of_root if no dtb provided
by firmware") introduced another DTB into the .dtb.init.rodata section.

The symbol dump (sorted by address) for ARCH=riscv nommu_k210_defconfig
is now as follows:

801290e0 D __dtb_start
801290e0 D __dtb_k210_generic_begin
8012b571 D __dtb_k210_generic_end
8012b580 D __dtb_empty_root_begin
8012b5c8 D __dtb_empty_root_end
8012b5e0 D __dtb_end

The .dtb.init.rodata section contains the following two DTB files:

arch/riscv/boot/dts/canaan/k210_generic.dtb
drivers/of/empty_root.dtb

This is not an immediate problem because the boot code chooses the
first DTB, k210_generic.dtb. The second one, empty_root.dtb is ignored.
However, relying on the link order (i.e., the order in Makefiles) is
fragile.

Only the boot DTB should be placed in the .dtb.init.rodata because the
arch boot code generally does not know the DT name, thus it uses the
__dtb_start symbol to find it.

empty_root.dtb is looked up by name, so it can be moved to the generic
.init.rodata section.

When CONFIG_OF_UNITTEST is enabled, more unittest DTBOs are embedded in
the .dtb.init.rodata section. These are also looked up by name, so can
be moved to the .init.rodata section.

I added the __initdata annotation to the overlay_info data array because
modpost knows the .init.rodata section is discarded, and would otherwise
warn about it.

The implementation is kind of cheesy; the section is .dtb.init.rodata
under the arch/ directory, and .init.rodata section otherwise. This will
be refactored later.

Signed-off-by: Masahiro Yamada 
---

 drivers/of/unittest.c | 2 +-
 scripts/Makefile.dtbs | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index fd8cb931b1cc..f5d18ae01c90 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -3585,7 +3585,7 @@ OVERLAY_INFO_EXTERN(overlay_bad_symbol);
 OVERLAY_INFO_EXTERN(overlay_bad_unresolved);
 
 /* entries found by name */
-static struct overlay_info overlays[] = {
+static __initdata struct overlay_info overlays[] = {
OVERLAY_INFO(overlay_base, -, 0),
OVERLAY_INFO(overlay, 0, 0),
OVERLAY_INFO(overlay_0, 0, 0),
diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
index 46009d5f1486..55998b878e54 100644
--- a/scripts/Makefile.dtbs
+++ b/scripts/Makefile.dtbs
@@ -34,12 +34,14 @@ $(obj)/dtbs-list: $(dtb-y) FORCE
 # Assembly file to wrap dtb(o)
 # ---
 
+builtin-dtb-section = $(if $(filter arch/%, 
$(obj)),.dtb.init.rodata,.init.rodata)
+
 # Generate an assembly file to wrap the output of the device tree compiler
 quiet_cmd_wrap_S_dtb = WRAP$@
   cmd_wrap_S_dtb = {   
\
symbase=__$(patsubst .%,%,$(suffix $<))_$(subst -,_,$(notdir 
$*));  \
echo '\#include ';   
\
-   echo '.section .dtb.init.rodata,"a"';   
\
+   echo '.section $(builtin-dtb-section),"a"'; 
\
echo '.balign STRUCT_ALIGNMENT';
\
echo ".global $${symbase}_begin";   
\
echo "$${symbase}_begin:";  
\
-- 
2.43.0


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


[PATCH 02/15] kbuild: split device tree build rules into scripts/Makefile.dtbs

2024-09-04 Thread Masahiro Yamada
scripts/Makefile.lib is included not only from scripts/Makefile.build
but also from scripts/Makefile.{modfinal,package,vmlinux,vmlinux_o},
where DT build rules are not required.

Split the DT build rules out to scripts/Makefile.dtbs, and include it
only when necessary.

Signed-off-by: Masahiro Yamada 
---

 drivers/of/fdt.c   |   2 +-
 drivers/of/unittest.c  |   4 +-
 scripts/Makefile.build |  25 +++-
 scripts/Makefile.dtbs  | 142 +
 scripts/Makefile.lib   | 115 -
 5 files changed, 153 insertions(+), 135 deletions(-)
 create mode 100644 scripts/Makefile.dtbs

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 68103ad230ee..4d528c10df3a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -34,7 +34,7 @@
 
 /*
  * __dtb_empty_root_begin[] and __dtb_empty_root_end[] magically created by
- * cmd_dt_S_dtb in scripts/Makefile.lib
+ * cmd_wrap_S_dtb in scripts/Makefile.dtbs
  */
 extern uint8_t __dtb_empty_root_begin[];
 extern uint8_t __dtb_empty_root_end[];
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index c830f346df45..fd8cb931b1cc 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1861,7 +1861,7 @@ static int __init unittest_data_add(void)
struct device_node *unittest_data_node = NULL, *np;
/*
 * __dtbo_testcases_begin[] and __dtbo_testcases_end[] are magically
-* created by cmd_dt_S_dtbo in scripts/Makefile.lib
+* created by cmd_wrap_S_dtbo in scripts/Makefile.dtbs
 */
extern uint8_t __dtbo_testcases_begin[];
extern uint8_t __dtbo_testcases_end[];
@@ -3525,7 +3525,7 @@ static void __init of_unittest_lifecycle(void)
 
 /*
  * __dtbo_##overlay_name##_begin[] and __dtbo_##overlay_name##_end[] are
- * created by cmd_dt_S_dtbo in scripts/Makefile.lib
+ * created by cmd_wrap_S_dtbo in scripts/Makefile.dtbs
  */
 
 #define OVERLAY_INFO_EXTERN(overlay_name) \
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 4b6942653093..6385e7aa5dbb 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -57,7 +57,6 @@ endif
 # subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
 subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
 subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
-subdir-dtbslist := $(sort $(filter %/dtbs-list, $(dtb-y)))
 
 targets-for-builtin := $(extra-y)
 
@@ -349,7 +348,7 @@ $(obj)/%.o: $(obj)/%.S FORCE
 
 targets += $(filter-out $(subdir-builtin), $(real-obj-y))
 targets += $(filter-out $(subdir-modorder), $(real-obj-m))
-targets += $(real-dtb-y) $(lib-y) $(always-y)
+targets += $(lib-y) $(always-y)
 
 # Linker scripts preprocessor (.lds.S -> .lds)
 # ---
@@ -375,7 +374,6 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 
$(objtree)/scripts/asn1_compiler
 # To build objects in subdirs, we need to descend into the directories
 $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
 $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
-$(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj)/% ;
 
 #
 # Rule to compile a set of .o files into one .a file (without symbol table)
@@ -391,12 +389,8 @@ quiet_cmd_ar_builtin = AR  $@
 $(obj)/built-in.a: $(real-obj-y) FORCE
$(call if_changed,ar_builtin)
 
-#
-# Rule to create modules.order and dtbs-list
-#
-# This is a list of build artifacts (module or dtb) from the current Makefile
-# and its sub-directories. The timestamp should be updated when any of the
-# member files.
+# This is a list of build artifacts from the current Makefile and its
+# sub-directories. The timestamp should be updated when any of the member 
files.
 
 cmd_gen_order = { $(foreach m, $(real-prereqs), \
$(if $(filter %/$(notdir $@), $m), cat $m, echo $m);) :; } \
@@ -405,9 +399,6 @@ cmd_gen_order = { $(foreach m, $(real-prereqs), \
 $(obj)/modules.order: $(obj-m) FORCE
$(call if_changed,gen_order)
 
-$(obj)/dtbs-list: $(dtb-y) FORCE
-   $(call if_changed,gen_order)
-
 #
 # Rule to compile a set of .o files into one .a file (with symbol table)
 #
@@ -436,11 +427,7 @@ intermediate_targets = $(foreach sfx, $(2), \
$(patsubst %$(strip $(1)),%$(sfx), \
$(filter %$(strip $(1)), $(targets
 # %.asn1.o <- %.asn1.[ch] <- %.asn1
-# %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
-# %.dtbo.o <- %.dtbo.S <- %.dtbo <- %.dtso
-targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
-  $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \
-  $(call intermediate_targets, .dtbo.o, .dtbo.S .dtbo)
+targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h)
 
 # Include additional build rules when necessary
 # ---
@@ -457,6 +444,10 @@ ifneq ($(userprogs),)
 include $(srctree)/scripts/Makefile.userprog

[PATCH 00/15] kbuild: refactor DTB build rules, introduce a generic built-in boot DTB support

2024-09-04 Thread Masahiro Yamada


01 and 02 are kbuild cleanups.
03 and 04 parepare to wrap boot DTBs in scripts/Makefile.vmlinux.

My plan is to 05-13 to each arch ML in the next cycle, but they are included
in this patch set so that reviewers can understand what will happen in
the future.



Masahiro Yamada (15):
  kbuild: add intermediate targets for Flex/Bison in
scripts/Makefile.host
  kbuild: split device tree build rules into scripts/Makefile.dtbs
  kbuild: move non-boot builtin DTBs to .init.rodata section
  kbuild: add generic support for built-in boot DTBs
  MIPS: migrate to generic rule for built-in DTBs
  riscv: migrate to the generic rule for built-in DTB
  LoongArch:  migrate to the generic rule for built-in DTB
  ARC: migrate to the generic rule for built-in DTB
  openrisc: migrate to the generic rule for built-in DTB
  xtensa: migrate to the generic rule for built-in DTB
  nios2: migrate to the generic rule for built-in DTB
  sh: migrate to the generic rule for built-in DTB
  microblaze: migrate to the generic rule for built-in DTB
  kbuild: rename CONFIG_GENERIC_BUILTIN_DTB to CONFIG_BUILTIN_DTB
  kbuild: use .init.rodata section unconditionally for cmd_wrap_S_dtb

 Makefile  |   7 +-
 arch/arc/Kconfig  |   7 +-
 arch/arc/Makefile |   3 -
 arch/arc/boot/dts/Makefile|   9 +-
 arch/arc/configs/axs101_defconfig |   2 +-
 arch/arc/configs/axs103_defconfig |   2 +-
 arch/arc/configs/axs103_smp_defconfig |   2 +-
 arch/arc/configs/haps_hs_defconfig|   2 +-
 arch/arc/configs/haps_hs_smp_defconfig|   2 +-
 arch/arc/configs/hsdk_defconfig   |   2 +-
 arch/arc/configs/nsim_700_defconfig   |   2 +-
 arch/arc/configs/nsimosci_defconfig   |   2 +-
 arch/arc/configs/nsimosci_hs_defconfig|   2 +-
 arch/arc/configs/nsimosci_hs_smp_defconfig|   2 +-
 arch/arc/configs/tb10x_defconfig  |   2 +-
 arch/arc/configs/vdk_hs38_defconfig   |   2 +-
 arch/arc/configs/vdk_hs38_smp_defconfig   |   2 +-
 arch/loongarch/Kbuild |   1 -
 arch/loongarch/boot/dts/Makefile  |   2 -
 arch/microblaze/Kbuild|   1 -
 arch/microblaze/Kconfig   |   5 +
 arch/microblaze/boot/dts/Makefile |   5 -
 arch/microblaze/boot/dts/linked_dtb.S |   2 -
 arch/microblaze/kernel/vmlinux.lds.S  |   2 +-
 arch/mips/Kconfig |   1 +
 arch/mips/Makefile|   3 -
 arch/mips/boot/dts/Makefile   |   2 -
 arch/mips/boot/dts/brcm/Makefile  |   2 -
 arch/mips/boot/dts/cavium-octeon/Makefile |   2 -
 arch/mips/boot/dts/ingenic/Makefile   |   2 -
 arch/mips/boot/dts/lantiq/Makefile|   2 -
 arch/mips/boot/dts/loongson/Makefile  |   2 -
 arch/mips/boot/dts/mscc/Makefile  |   3 -
 arch/mips/boot/dts/mti/Makefile   |   2 -
 arch/mips/boot/dts/pic32/Makefile |   2 -
 arch/mips/boot/dts/ralink/Makefile|   2 -
 arch/nios2/Kbuild |   2 +-
 arch/nios2/boot/dts/Makefile  |   4 +-
 arch/nios2/kernel/prom.c  |   2 +-
 arch/nios2/platform/Kconfig.platform  |  10 +-
 arch/openrisc/Kbuild  |   1 -
 arch/openrisc/Kconfig |   3 +-
 arch/openrisc/boot/dts/Makefile   |   2 +-
 arch/openrisc/configs/or1klitex_defconfig |   2 +-
 arch/openrisc/configs/or1ksim_defconfig   |   2 +-
 arch/openrisc/configs/simple_smp_defconfig|   2 +-
 arch/riscv/Kbuild |   1 -
 arch/riscv/Kconfig|   2 +-
 arch/riscv/boot/dts/Makefile  |   2 -
 arch/riscv/configs/nommu_k210_defconfig   |   2 +-
 .../riscv/configs/nommu_k210_sdcard_defconfig |   2 +-
 arch/sh/Kbuild|   1 -
 arch/sh/Kconfig   |   6 +-
 arch/sh/boot/dts/Makefile |   2 +-
 arch/sh/kernel/setup.c|   4 +-
 arch/xtensa/Kbuild|   2 +-
 arch/xtensa/Kconfig   |   3 +-
 arch/xtensa/boot/dts/Makefile |   2 +-
 arch/xtensa/configs/audio_kc705_defconfig |   2 +-
 arch/xtensa/configs/cadence_csp_defconfig |   2 +-
 arch/xtensa/configs/generic_kc705_defconfig   |   2 +-
 arch/xtensa/configs/nommu_kc705_defconfig |   2 +-
 arch/xtensa/configs/smp_lx200_defconfig   |   2 +-
 arch/xtensa/configs/virt_defconfig|   2 +-
 arch/xtensa/configs/xip_kc705_defconfig   |   2 +-
 drivers/of/Kconfig|   6 +
 drivers/of/fdt.c  |   2 +-
 drivers/of/unittest.c |   6 +-
 scripts/Makefile.build   

[PATCH 01/15] kbuild: add intermediate targets for Flex/Bison in scripts/Makefile.host

2024-09-04 Thread Masahiro Yamada
Flex and Bison are used only for host programs. Move their intermediate
target processing from scripts/Makefile.build to scripts/Makefile.host.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.build | 35 ---
 scripts/Makefile.host  |  5 +
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index a5ac8ed1936f..4b6942653093 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -41,20 +41,6 @@ include $(srctree)/scripts/Makefile.compiler
 include $(kbuild-file)
 include $(srctree)/scripts/Makefile.lib
 
-# Do not include hostprogs rules unless needed.
-# $(sort ...) is used here to remove duplicated words and excessive spaces.
-hostprogs := $(sort $(hostprogs))
-ifneq ($(hostprogs),)
-include $(srctree)/scripts/Makefile.host
-endif
-
-# Do not include userprogs rules unless needed.
-# $(sort ...) is used here to remove duplicated words and excessive spaces.
-userprogs := $(sort $(userprogs))
-ifneq ($(userprogs),)
-include $(srctree)/scripts/Makefile.userprogs
-endif
-
 ifndef obj
 $(warning kbuild: Makefile.build is included improperly)
 endif
@@ -452,13 +438,24 @@ intermediate_targets = $(foreach sfx, $(2), \
 # %.asn1.o <- %.asn1.[ch] <- %.asn1
 # %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
 # %.dtbo.o <- %.dtbo.S <- %.dtbo <- %.dtso
-# %.lex.o <- %.lex.c <- %.l
-# %.tab.o <- %.tab.[ch] <- %.y
 targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
   $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \
-  $(call intermediate_targets, .dtbo.o, .dtbo.S .dtbo) \
-  $(call intermediate_targets, .lex.o, .lex.c) \
-  $(call intermediate_targets, .tab.o, .tab.c .tab.h)
+  $(call intermediate_targets, .dtbo.o, .dtbo.S .dtbo)
+
+# Include additional build rules when necessary
+# ---
+
+# $(sort ...) is used here to remove duplicated words and excessive spaces.
+hostprogs := $(sort $(hostprogs))
+ifneq ($(hostprogs),)
+include $(srctree)/scripts/Makefile.host
+endif
+
+# $(sort ...) is used here to remove duplicated words and excessive spaces.
+userprogs := $(sort $(userprogs))
+ifneq ($(userprogs),)
+include $(srctree)/scripts/Makefile.userprogs
+endif
 
 # Build
 # ---
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index e85be7721a48..e01c13a588dd 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -160,3 +160,8 @@ $(host-rust): $(obj)/%: $(src)/%.rs FORCE
 
 targets += $(host-csingle) $(host-cmulti) $(host-cobjs) \
   $(host-cxxmulti) $(host-cxxobjs) $(host-rust)
+
+# %.lex.o <- %.lex.c <- %.l
+# %.tab.o <- %.tab.[ch] <- %.y
+targets += $(call intermediate_targets, .lex.o, .lex.c) \
+   $(call intermediate_targets, .tab.o, .tab.c .tab.h)
-- 
2.43.0


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


[PATCH 04/15] kbuild: add generic support for built-in boot DTBs

2024-09-04 Thread Masahiro Yamada
Some architectures embed boot DTBs in vmlinux. A potential issue for
these architectures is a race condition during parallel builds because
Kbuild descends into arch/*/boot/dts/ twice.

One build thread is initiated by the 'dtbs' target, which is a
prerequisite of the 'all' target in the top-level Makefile:

  ifdef CONFIG_OF_EARLY_FLATTREE
  all: dtbs
  endif

For architectures that support the embedded boot dtb, arch/*/boot/dts/
is visited also during the ordinary directory traversal in order to
build obj-y objects that wrap DTBs.

Since these build threads are unaware of each other, they can run
simultaneously during parallel builds.

This commit introduces a generic build rule to scripts/Makefile.vmlinux
to support embedded boot DTBs in a race-free way. Architectures that
want to use this rule need to select CONFIG_GENERIC_BUILTIN_DTB.

After the migration, Makefiles under arch/*/boot/dts/ will be visited
only once to build only *.dtb files.

This change also aims to unify the CONFIG options used for embedded DTBs
support. Currently, different architectures use different CONFIG options
for the same purposes.

The CONFIG options are unified as follows:

 - CONFIG_GENERIC_BUILTIN_DTB

   This enables the generic rule for embedded boot DTBs. This will be
   renamed to CONFIG_BUILTIN_DTB after all architectures migrate to the
   generic rule.

 - CONFIG_BUILTIN_DTB_NAME

   This specifies the path to the embedded DTB.
   (relative to arch/*/boot/dts/)

 - CONFIG_BUILTIN_DTB_ALL

   If this is enabled, all DTB files compiled under arch/*/boot/dts/ are
   embedded into vmlinux. Only used by MIPS.

Signed-off-by: Masahiro Yamada 
---

 Makefile |  7 ++-
 drivers/of/Kconfig   |  6 ++
 scripts/Makefile.vmlinux | 44 
 scripts/link-vmlinux.sh  |  4 
 4 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 145112bf281a..1c765c12ab9e 100644
--- a/Makefile
+++ b/Makefile
@@ -1417,6 +1417,10 @@ ifdef CONFIG_OF_EARLY_FLATTREE
 all: dtbs
 endif
 
+ifdef CONFIG_GENERIC_BUILTIN_DTB
+vmlinux: dtbs
+endif
+
 endif
 
 PHONY += scripts_dtc
@@ -1483,7 +1487,8 @@ endif # CONFIG_MODULES
 CLEAN_FILES += vmlinux.symvers modules-only.symvers \
   modules.builtin modules.builtin.modinfo modules.nsdeps \
   compile_commands.json rust/test \
-  rust-project.json .vmlinux.objs .vmlinux.export.c
+  rust-project.json .vmlinux.objs .vmlinux.export.c \
+   .builtin-dtbs-list .builtin-dtb.S
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_FILES += include/config include/generated  \
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index dd726c7056bf..5142e7d7fef8 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -2,6 +2,12 @@
 config DTC
bool
 
+config GENERIC_BUILTIN_DTB
+   bool
+
+config BUILTIN_DTB_ALL
+   bool
+
 menuconfig OF
bool "Device Tree and Open Firmware support"
help
diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index 5ceecbed31eb..4626b472da49 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -17,6 +17,50 @@ quiet_cmd_cc_o_c = CC  $@
 %.o: %.c FORCE
$(call if_changed_dep,cc_o_c)
 
+quiet_cmd_as_o_S = AS  $@
+  cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
+
+%.o: %.S FORCE
+   $(call if_changed_dep,as_o_S)
+
+# Built-in dtb
+# ---
+
+quiet_cmd_wrap_dtbs = WRAP$@
+  cmd_wrap_dtbs = {
\
+   echo '\#include ';   \
+   echo '.section .dtb.init.rodata,"a"';   \
+   while read dtb; do  \
+   symbase=__dtb_$$(basename -s .dtb "$${dtb}" | tr - _);  \
+   echo '.balign STRUCT_ALIGNMENT';\
+   echo ".global $${symbase}_begin";   \
+   echo "$${symbase}_begin:";  \
+   echo '.incbin "'$$dtb'" ';  \
+   echo ".global $${symbase}_end"; \
+   echo "$${symbase}_end:";\
+   done < $<;  \
+   } > $@
+
+.builtin-dtbs.S: .builtin-dtbs-list FORCE
+   $(call if_changed,wrap_dtbs)
+
+quiet_cmd_gen_dtbs_list = GEN $@
+  cmd_gen_dtbs_list = \
+   $(if $(CONFIG_BUILTIN_DTB_NAME), echo 
"arch/$(SRCARCH)/boot/dts/$(CONFIG_BUILTIN_DTB_NAME).dtb",:) > $@
+
+.builtin-dtbs-list: arch/$(SRCARCH)/boot/dts/dtbs-list FORCE
+   $(call if_changed,$(if $(CONFIG_BUILTIN_DTB_ALL),copy,gen_dtbs_list))
+
+targets += .builtin-dtbs-list
+
+ifdef CONFIG_GENERIC_BUILTIN_DTB
+targets += .builtin-dtbs.S .builtin-dtbs.o
+vmlinux: .builtin-dtb

[PATCH 05/15] MIPS: migrate to generic rule for built-in DTBs

2024-09-04 Thread Masahiro Yamada
Select GENERIC_BUILTIN_DTB and BUILTIN_DTB_ALL when built-in DTB
support is enabled.

DTBs compiled under arch/mips/boot/dts/ will be wrapped and compiled
in scripts/Makefile.vmlinux.

Signed-off-by: Masahiro Yamada 
---

 arch/mips/Kconfig | 2 ++
 arch/mips/Makefile| 3 ---
 arch/mips/boot/dts/Makefile   | 2 --
 arch/mips/boot/dts/brcm/Makefile  | 2 --
 arch/mips/boot/dts/cavium-octeon/Makefile | 2 --
 arch/mips/boot/dts/ingenic/Makefile   | 2 --
 arch/mips/boot/dts/lantiq/Makefile| 2 --
 arch/mips/boot/dts/loongson/Makefile  | 2 --
 arch/mips/boot/dts/mscc/Makefile  | 3 ---
 arch/mips/boot/dts/mti/Makefile   | 2 --
 arch/mips/boot/dts/pic32/Makefile | 2 --
 arch/mips/boot/dts/ralink/Makefile| 2 --
 12 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 60077e576935..7bfe3fd011f4 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -28,10 +28,12 @@ config MIPS
select ARCH_WANT_IPC_PARSE_VERSION
select ARCH_WANT_LD_ORPHAN_WARN
select BUILDTIME_TABLE_SORT
+   select BUILTIN_DTB_ALL if BUILTIN_DTB
select CLONE_BACKWARDS
select CPU_NO_EFFICIENT_FFS if (TARGET_ISA_REV < 1)
select CPU_PM if CPU_IDLE || SUSPEND
select GENERIC_ATOMIC64 if !64BIT
+   select GENERIC_BUILTIN_DTB if BUILTIN_DTB
select GENERIC_CMOS_UPDATE
select GENERIC_CPU_AUTOPROBE
select GENERIC_GETTIMEOFDAY
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 5785a3d5ccfb..be8cb44a89fd 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -423,9 +423,6 @@ endif
 
 CLEAN_FILES += vmlinux.32 vmlinux.64
 
-# device-trees
-core-y += arch/mips/boot/dts/
-
 archprepare:
 ifdef CONFIG_MIPS32_N32
@$(kecho) '  Checking missing-syscalls for N32'
diff --git a/arch/mips/boot/dts/Makefile b/arch/mips/boot/dts/Makefile
index e2476b12bb0c..ff468439a8c4 100644
--- a/arch/mips/boot/dts/Makefile
+++ b/arch/mips/boot/dts/Makefile
@@ -16,5 +16,3 @@ subdir-$(CONFIG_ATH79)+= qca
 subdir-$(CONFIG_RALINK)+= ralink
 subdir-$(CONFIG_MACH_REALTEK_RTL)  += realtek
 subdir-$(CONFIG_FIT_IMAGE_FDT_XILFPGA) += xilfpga
-
-obj-$(CONFIG_BUILTIN_DTB)  := $(addsuffix /, $(subdir-y))
diff --git a/arch/mips/boot/dts/brcm/Makefile b/arch/mips/boot/dts/brcm/Makefile
index d85f446cc0ce..1798209697c6 100644
--- a/arch/mips/boot/dts/brcm/Makefile
+++ b/arch/mips/boot/dts/brcm/Makefile
@@ -33,5 +33,3 @@ dtb-$(CONFIG_DT_NONE) += \
bcm97420c.dtb \
bcm97425svmb.dtb \
bcm97435svmb.dtb
-
-obj-$(CONFIG_BUILTIN_DTB)  += $(addsuffix .o, $(dtb-y))
diff --git a/arch/mips/boot/dts/cavium-octeon/Makefile 
b/arch/mips/boot/dts/cavium-octeon/Makefile
index 17aef35f311b..48085bca666c 100644
--- a/arch/mips/boot/dts/cavium-octeon/Makefile
+++ b/arch/mips/boot/dts/cavium-octeon/Makefile
@@ -1,4 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0
 dtb-$(CONFIG_CAVIUM_OCTEON_SOC)+= octeon_3xxx.dtb octeon_68xx.dtb
-
-obj-$(CONFIG_BUILTIN_DTB)  += $(addsuffix .o, $(dtb-y))
diff --git a/arch/mips/boot/dts/ingenic/Makefile 
b/arch/mips/boot/dts/ingenic/Makefile
index 54aa0c4e6091..6e674f1a3aa3 100644
--- a/arch/mips/boot/dts/ingenic/Makefile
+++ b/arch/mips/boot/dts/ingenic/Makefile
@@ -5,5 +5,3 @@ dtb-$(CONFIG_JZ4770_GCW0)   += gcw0.dtb
 dtb-$(CONFIG_JZ4780_CI20)  += ci20.dtb
 dtb-$(CONFIG_X1000_CU1000_NEO) += cu1000-neo.dtb
 dtb-$(CONFIG_X1830_CU1830_NEO) += cu1830-neo.dtb
-
-obj-$(CONFIG_BUILTIN_DTB)  += $(addsuffix .o, $(dtb-y))
diff --git a/arch/mips/boot/dts/lantiq/Makefile 
b/arch/mips/boot/dts/lantiq/Makefile
index ae6e3e21ebeb..d8531b4653c0 100644
--- a/arch/mips/boot/dts/lantiq/Makefile
+++ b/arch/mips/boot/dts/lantiq/Makefile
@@ -1,4 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0
 dtb-$(CONFIG_DT_EASY50712) += danube_easy50712.dtb
-
-obj-$(CONFIG_BUILTIN_DTB)  += $(addsuffix .o, $(dtb-y))
diff --git a/arch/mips/boot/dts/loongson/Makefile 
b/arch/mips/boot/dts/loongson/Makefile
index 5c6433e441ee..5e3ab984d70f 100644
--- a/arch/mips/boot/dts/loongson/Makefile
+++ b/arch/mips/boot/dts/loongson/Makefile
@@ -5,5 +5,3 @@ dtb-$(CONFIG_MACH_LOONGSON64)   += loongson64c_4core_rs780e.dtb
 dtb-$(CONFIG_MACH_LOONGSON64)  += loongson64c_8core_rs780e.dtb
 dtb-$(CONFIG_MACH_LOONGSON64)  += loongson64g_4core_ls7a.dtb
 dtb-$(CONFIG_MACH_LOONGSON64)  += loongson64v_4core_virtio.dtb
-
-obj-$(CONFIG_BUILTIN_DTB)  += $(addsuffix .o, $(dtb-y))
diff --git a/arch/mips/boot/dts/mscc/Makefile b/arch/mips/boot/dts/mscc/Makefile
index eeb6b7aae83b..566dbec3c7fb 100644
--- a/arch/mips/boot/dts/mscc/Makefile
+++ b/arch/mips/boot/dts/mscc/Makefile
@@ -8,6 +8,3 @@ dtb-$(CONFIG_SOC_VCOREIII)  += \
ocelot_pcb123.dtb \
serval_pcb105.dtb \
serval_pcb106.dtb
-
-
-obj-$(CONFIG_BUILTIN_DTB)  += $(addsuffix .o, $(dtb-y))
diff 

[PATCH 07/15] LoongArch: migrate to the generic rule for built-in DTB

2024-09-04 Thread Masahiro Yamada
Select GENERIC_BUILTIN_DTB when built-in DTB support is enabled.

Signed-off-by: Masahiro Yamada 
---

 arch/loongarch/Kbuild| 1 -
 arch/loongarch/Kconfig   | 1 +
 arch/loongarch/boot/dts/Makefile | 2 --
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/loongarch/Kbuild b/arch/loongarch/Kbuild
index bfa21465d83a..beb8499dd8ed 100644
--- a/arch/loongarch/Kbuild
+++ b/arch/loongarch/Kbuild
@@ -4,7 +4,6 @@ obj-y += net/
 obj-y += vdso/
 
 obj-$(CONFIG_KVM) += kvm/
-obj-$(CONFIG_BUILTIN_DTB) += boot/dts/
 
 # for cleaning
 subdir- += boot
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index 70f169210b52..e1d3e5fb6fd2 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -388,6 +388,7 @@ endchoice
 config BUILTIN_DTB
bool "Enable built-in dtb in kernel"
depends on OF
+   select GENERIC_BUILTIN_DTB
help
  Some existing systems do not provide a canonical device tree to
  the kernel at boot time. Let's provide a device tree table in the
diff --git a/arch/loongarch/boot/dts/Makefile b/arch/loongarch/boot/dts/Makefile
index 747d0c3f6389..15d5e14fe418 100644
--- a/arch/loongarch/boot/dts/Makefile
+++ b/arch/loongarch/boot/dts/Makefile
@@ -1,5 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 dtb-y = loongson-2k0500-ref.dtb loongson-2k1000-ref.dtb loongson-2k2000-ref.dtb
-
-obj-$(CONFIG_BUILTIN_DTB)  += $(addsuffix .dtb.o, 
$(CONFIG_BUILTIN_DTB_NAME))
-- 
2.43.0


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


[PATCH 06/15] riscv: migrate to the generic rule for built-in DTB

2024-09-04 Thread Masahiro Yamada
Select GENERIC_BUILTIN_DTB when built-in DTB support is enabled.

To keep consistency across architectures, this commit also renames
CONFIG_BUILTIN_DTB_SOURCE to CONFIG_BUILTIN_DTB_NAME.

Signed-off-by: Masahiro Yamada 
---

 arch/riscv/Kbuild  | 1 -
 arch/riscv/Kconfig | 3 ++-
 arch/riscv/boot/dts/Makefile   | 2 --
 arch/riscv/configs/nommu_k210_defconfig| 2 +-
 arch/riscv/configs/nommu_k210_sdcard_defconfig | 2 +-
 5 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/riscv/Kbuild b/arch/riscv/Kbuild
index 2c585f7a0b6e..126fb738fc44 100644
--- a/arch/riscv/Kbuild
+++ b/arch/riscv/Kbuild
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 obj-y += kernel/ mm/ net/
-obj-$(CONFIG_BUILTIN_DTB) += boot/dts/
 obj-$(CONFIG_CRYPTO) += crypto/
 obj-y += errata/
 obj-$(CONFIG_KVM) += kvm/
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 0f3cd7c3a436..019c64ef0826 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -1110,13 +1110,14 @@ config RISCV_ISA_FALLBACK
 config BUILTIN_DTB
bool "Built-in device tree"
depends on OF && NONPORTABLE
+   select GENERIC_BUILTIN_DTB
help
  Build a device tree into the Linux image.
  This option should be selected if no bootloader is being used.
  If unsure, say N.
 
 
-config BUILTIN_DTB_SOURCE
+config BUILTIN_DTB_NAME
string "Built-in device tree source"
depends on BUILTIN_DTB
help
diff --git a/arch/riscv/boot/dts/Makefile b/arch/riscv/boot/dts/Makefile
index fdae05bbf556..b09678f9badc 100644
--- a/arch/riscv/boot/dts/Makefile
+++ b/arch/riscv/boot/dts/Makefile
@@ -7,5 +7,3 @@ subdir-y += sifive
 subdir-y += sophgo
 subdir-y += starfive
 subdir-y += thead
-
-obj-$(CONFIG_BUILTIN_DTB) := $(addsuffix .dtb.o, $(CONFIG_BUILTIN_DTB_SOURCE))
diff --git a/arch/riscv/configs/nommu_k210_defconfig 
b/arch/riscv/configs/nommu_k210_defconfig
index af9601da4643..41a025f927ba 100644
--- a/arch/riscv/configs/nommu_k210_defconfig
+++ b/arch/riscv/configs/nommu_k210_defconfig
@@ -35,7 +35,7 @@ CONFIG_NR_CPUS=2
 CONFIG_CMDLINE="earlycon console=ttySIF0"
 CONFIG_CMDLINE_FORCE=y
 CONFIG_BUILTIN_DTB=y
-CONFIG_BUILTIN_DTB_SOURCE="canaan/k210_generic"
+CONFIG_BUILTIN_DTB_NAME="canaan/k210_generic"
 # CONFIG_SECCOMP is not set
 # CONFIG_STACKPROTECTOR is not set
 # CONFIG_GCC_PLUGINS is not set
diff --git a/arch/riscv/configs/nommu_k210_sdcard_defconfig 
b/arch/riscv/configs/nommu_k210_sdcard_defconfig
index dd460c649152..ab4b22f1c91a 100644
--- a/arch/riscv/configs/nommu_k210_sdcard_defconfig
+++ b/arch/riscv/configs/nommu_k210_sdcard_defconfig
@@ -27,7 +27,7 @@ CONFIG_NR_CPUS=2
 CONFIG_CMDLINE="earlycon console=ttySIF0 root=/dev/mmcblk0p1 rootwait ro"
 CONFIG_CMDLINE_FORCE=y
 CONFIG_BUILTIN_DTB=y
-CONFIG_BUILTIN_DTB_SOURCE="canaan/k210_generic"
+CONFIG_BUILTIN_DTB_NAME="canaan/k210_generic"
 # CONFIG_SECCOMP is not set
 # CONFIG_STACKPROTECTOR is not set
 # CONFIG_GCC_PLUGINS is not set
-- 
2.43.0


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


[PATCH 09/15] openrisc: migrate to the generic rule for built-in DTB

2024-09-04 Thread Masahiro Yamada
Select GENERIC_BUILTIN_DTB to use the generic rule to support built-in
DTB.

To keep consistency across architectures, this commit also renames
CONFIG_OPENRISC_BUILTIN_DTB_NAME to CONFIG_BUILTIN_DTB_NAME.

Signed-off-by: Masahiro Yamada 
---

 arch/openrisc/Kbuild   | 1 -
 arch/openrisc/Kconfig  | 3 ++-
 arch/openrisc/boot/dts/Makefile| 2 +-
 arch/openrisc/configs/or1klitex_defconfig  | 2 +-
 arch/openrisc/configs/or1ksim_defconfig| 2 +-
 arch/openrisc/configs/simple_smp_defconfig | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/openrisc/Kbuild b/arch/openrisc/Kbuild
index b0b0f2b03f87..70bdb24ff204 100644
--- a/arch/openrisc/Kbuild
+++ b/arch/openrisc/Kbuild
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-y += lib/ kernel/ mm/
-obj-y += boot/dts/
 
 # for cleaning
 subdir- += boot
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 69c0258700b2..11ffcf33652c 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -10,6 +10,7 @@ config OPENRISC
select ARCH_HAS_DMA_SET_UNCACHED
select ARCH_HAS_DMA_CLEAR_UNCACHED
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
+   select GENERIC_BUILTIN_DTB
select COMMON_CLK
select OF
select OF_EARLY_FLATTREE
@@ -89,7 +90,7 @@ config DCACHE_WRITETHROUGH
 
  If unsure say N here
 
-config OPENRISC_BUILTIN_DTB
+config BUILTIN_DTB_NAME
string "Builtin DTB"
default ""
 
diff --git a/arch/openrisc/boot/dts/Makefile b/arch/openrisc/boot/dts/Makefile
index 13db5a2aab52..3a66e0ef3985 100644
--- a/arch/openrisc/boot/dts/Makefile
+++ b/arch/openrisc/boot/dts/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-y += $(addsuffix .dtb.o, $(CONFIG_OPENRISC_BUILTIN_DTB))
+dtb-y += $(addsuffix .dtb, $(CONFIG_BUILTIN_DTB_NAME))
 
 #DTC_FLAGS ?= -p 1024
diff --git a/arch/openrisc/configs/or1klitex_defconfig 
b/arch/openrisc/configs/or1klitex_defconfig
index 466f31a091be..3e849d25838a 100644
--- a/arch/openrisc/configs/or1klitex_defconfig
+++ b/arch/openrisc/configs/or1klitex_defconfig
@@ -7,7 +7,7 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SGETMASK_SYSCALL=y
 CONFIG_EXPERT=y
-CONFIG_OPENRISC_BUILTIN_DTB="or1klitex"
+CONFIG_BUILTIN_DTB_NAME="or1klitex"
 CONFIG_HZ_100=y
 CONFIG_OPENRISC_HAVE_SHADOW_GPRS=y
 CONFIG_NET=y
diff --git a/arch/openrisc/configs/or1ksim_defconfig 
b/arch/openrisc/configs/or1ksim_defconfig
index 0116e465238f..59fe33cefba2 100644
--- a/arch/openrisc/configs/or1ksim_defconfig
+++ b/arch/openrisc/configs/or1ksim_defconfig
@@ -14,7 +14,7 @@ CONFIG_SLUB=y
 CONFIG_SLUB_TINY=y
 CONFIG_MODULES=y
 # CONFIG_BLOCK is not set
-CONFIG_OPENRISC_BUILTIN_DTB="or1ksim"
+CONFIG_BUILTIN_DTB_NAME="or1ksim"
 CONFIG_HZ_100=y
 CONFIG_NET=y
 CONFIG_PACKET=y
diff --git a/arch/openrisc/configs/simple_smp_defconfig 
b/arch/openrisc/configs/simple_smp_defconfig
index b990cb6c9309..6008e824d31c 100644
--- a/arch/openrisc/configs/simple_smp_defconfig
+++ b/arch/openrisc/configs/simple_smp_defconfig
@@ -20,7 +20,7 @@ CONFIG_SLUB=y
 CONFIG_SLUB_TINY=y
 CONFIG_MODULES=y
 # CONFIG_BLOCK is not set
-CONFIG_OPENRISC_BUILTIN_DTB="simple_smp"
+CONFIG_BUILTIN_DTB_NAME="simple_smp"
 CONFIG_SMP=y
 CONFIG_HZ_100=y
 CONFIG_OPENRISC_HAVE_SHADOW_GPRS=y
-- 
2.43.0


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


[PATCH 08/15] ARC: migrate to the generic rule for built-in DTB

2024-09-04 Thread Masahiro Yamada
Select GENERIC_BUILTIN_DTB to use the generic rule to support built-in
DTB.

To keep consistency across architectures, this commit also renames
CONFIG_ARC_BUILTIN_DTB_NAME to CONFIG_BUILTIN_DTB_NAME.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/Kconfig   | 7 ---
 arch/arc/Makefile  | 3 ---
 arch/arc/boot/dts/Makefile | 9 +
 arch/arc/configs/axs101_defconfig  | 2 +-
 arch/arc/configs/axs103_defconfig  | 2 +-
 arch/arc/configs/axs103_smp_defconfig  | 2 +-
 arch/arc/configs/haps_hs_defconfig | 2 +-
 arch/arc/configs/haps_hs_smp_defconfig | 2 +-
 arch/arc/configs/hsdk_defconfig| 2 +-
 arch/arc/configs/nsim_700_defconfig| 2 +-
 arch/arc/configs/nsimosci_defconfig| 2 +-
 arch/arc/configs/nsimosci_hs_defconfig | 2 +-
 arch/arc/configs/nsimosci_hs_smp_defconfig | 2 +-
 arch/arc/configs/tb10x_defconfig   | 2 +-
 arch/arc/configs/vdk_hs38_defconfig| 2 +-
 arch/arc/configs/vdk_hs38_smp_defconfig| 2 +-
 16 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index d01e69a29b69..11fe4f497571 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -16,6 +16,7 @@ config ARC
select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
select ARCH_32BIT_OFF_T
select BUILDTIME_TABLE_SORT
+   select GENERIC_BUILTIN_DTB
select CLONE_BACKWARDS
select COMMON_CLK
select DMA_DIRECT_REMAP
@@ -549,11 +550,11 @@ config ARC_DBG_JUMP_LABEL
  part of static keys (jump labels) related code.
 endif
 
-config ARC_BUILTIN_DTB_NAME
+config BUILTIN_DTB_NAME
string "Built in DTB"
+   default "nsim_700"
help
- Set the name of the DTB to embed in the vmlinux binary
- Leaving it blank selects the "nsim_700" dtb.
+ Set the name of the DTB to embed in the vmlinux binary.
 
 endmenu # "ARC Architecture Configuration"
 
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 2390dd042e36..deb830bdeaa0 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -82,9 +82,6 @@ KBUILD_CFLAGS += $(cflags-y)
 KBUILD_AFLAGS  += $(KBUILD_CFLAGS)
 KBUILD_LDFLAGS += $(ldflags-y)
 
-# w/o this dtb won't embed into kernel binary
-core-y += arch/arc/boot/dts/
-
 core-y += arch/arc/plat-sim/
 core-$(CONFIG_ARC_PLAT_TB10X)  += arch/arc/plat-tb10x/
 core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/
diff --git a/arch/arc/boot/dts/Makefile b/arch/arc/boot/dts/Makefile
index 48704dfdf75c..ee5664f0640d 100644
--- a/arch/arc/boot/dts/Makefile
+++ b/arch/arc/boot/dts/Makefile
@@ -1,13 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
-# Built-in dtb
-builtindtb-y   := nsim_700
 
-ifneq ($(CONFIG_ARC_BUILTIN_DTB_NAME),)
-   builtindtb-y:= $(CONFIG_ARC_BUILTIN_DTB_NAME)
-endif
-
-obj-y   += $(builtindtb-y).dtb.o
-dtb-y := $(builtindtb-y).dtb
+dtb-y  := $(addsuffix .dtb, $(CONFIG_BUILTIN_DTB_NAME))
 
 # for CONFIG_OF_ALL_DTBS test
 dtb-   := $(patsubst $(src)/%.dts,%.dtb, $(wildcard $(src)/*.dts))
diff --git a/arch/arc/configs/axs101_defconfig 
b/arch/arc/configs/axs101_defconfig
index 89720d6d7e0d..628d55057cde 100644
--- a/arch/arc/configs/axs101_defconfig
+++ b/arch/arc/configs/axs101_defconfig
@@ -23,7 +23,7 @@ CONFIG_PARTITION_ADVANCED=y
 CONFIG_ARC_PLAT_AXS10X=y
 CONFIG_AXS101=y
 CONFIG_ARC_CACHE_LINE_SHIFT=5
-CONFIG_ARC_BUILTIN_DTB_NAME="axs101"
+CONFIG_BUILTIN_DTB_NAME="axs101"
 CONFIG_PREEMPT=y
 # CONFIG_COMPACTION is not set
 CONFIG_NET=y
diff --git a/arch/arc/configs/axs103_defconfig 
b/arch/arc/configs/axs103_defconfig
index 73ec01ed0492..7e4d4cbf1fb7 100644
--- a/arch/arc/configs/axs103_defconfig
+++ b/arch/arc/configs/axs103_defconfig
@@ -22,7 +22,7 @@ CONFIG_PARTITION_ADVANCED=y
 CONFIG_ARC_PLAT_AXS10X=y
 CONFIG_AXS103=y
 CONFIG_ISA_ARCV2=y
-CONFIG_ARC_BUILTIN_DTB_NAME="axs103"
+CONFIG_BUILTIN_DTB_NAME="axs103"
 CONFIG_PREEMPT=y
 # CONFIG_COMPACTION is not set
 CONFIG_NET=y
diff --git a/arch/arc/configs/axs103_smp_defconfig 
b/arch/arc/configs/axs103_smp_defconfig
index 4da0f626fa9d..764cbc781a7d 100644
--- a/arch/arc/configs/axs103_smp_defconfig
+++ b/arch/arc/configs/axs103_smp_defconfig
@@ -22,7 +22,7 @@ CONFIG_ARC_PLAT_AXS10X=y
 CONFIG_AXS103=y
 CONFIG_ISA_ARCV2=y
 CONFIG_SMP=y
-CONFIG_ARC_BUILTIN_DTB_NAME="axs103_idu"
+CONFIG_BUILTIN_DTB_NAME="axs103_idu"
 CONFIG_PREEMPT=y
 # CONFIG_COMPACTION is not set
 CONFIG_NET=y
diff --git a/arch/arc/configs/haps_hs_defconfig 
b/arch/arc/configs/haps_hs_defconfig
index 8c3ed5d6e6c3..3a1577112078 100644
--- a/arch/arc/configs/haps_hs_defconfig
+++ b/arch/arc/configs/haps_hs_defconfig
@@ -14,7 +14,7 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 CONFIG_PERF_EVENTS=y
 # CONFIG_COMPAT_BRK is not set
-CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs"
+CONFIG_BUILTIN_DTB_NAME="haps_hs"
 CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_COMPACTION is not set
diff --git a/arch/

[PATCH 10/15] xtensa: migrate to the generic rule for built-in DTB

2024-09-04 Thread Masahiro Yamada
Select GENERIC_BUILTIN_DTB to use the generic rule to support built-in
DTB.

To keep consistency across architectures, this commit also renames
CONFIG_BUILTIN_DTB_SOURCE to CONFIG_BUILTIN_DTB_NAME.

Signed-off-by: Masahiro Yamada 
---

 arch/xtensa/Kbuild  | 2 +-
 arch/xtensa/Kconfig | 3 ++-
 arch/xtensa/boot/dts/Makefile   | 2 +-
 arch/xtensa/configs/audio_kc705_defconfig   | 2 +-
 arch/xtensa/configs/cadence_csp_defconfig   | 2 +-
 arch/xtensa/configs/generic_kc705_defconfig | 2 +-
 arch/xtensa/configs/nommu_kc705_defconfig   | 2 +-
 arch/xtensa/configs/smp_lx200_defconfig | 2 +-
 arch/xtensa/configs/virt_defconfig  | 2 +-
 arch/xtensa/configs/xip_kc705_defconfig | 2 +-
 10 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/xtensa/Kbuild b/arch/xtensa/Kbuild
index fd12f61745ba..015baeb765b9 100644
--- a/arch/xtensa/Kbuild
+++ b/arch/xtensa/Kbuild
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-y += kernel/ mm/ platforms/ boot/dts/
+obj-y += kernel/ mm/ platforms/
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index f200a4ec044e..5fd1d248e147 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -19,6 +19,7 @@ config XTENSA
select ARCH_USE_QUEUED_SPINLOCKS
select ARCH_WANT_IPC_PARSE_VERSION
select BUILDTIME_TABLE_SORT
+   select GENERIC_BUILTIN_DTB
select CLONE_BACKWARDS
select COMMON_CLK
select DMA_NONCOHERENT_MMAP if MMU
@@ -461,7 +462,7 @@ config USE_OF
help
  Include support for flattened device tree machine descriptions.
 
-config BUILTIN_DTB_SOURCE
+config BUILTIN_DTB_NAME
string "DTB to build into the kernel image"
depends on OF
 
diff --git a/arch/xtensa/boot/dts/Makefile b/arch/xtensa/boot/dts/Makefile
index d6408c16d74e..7271294ce523 100644
--- a/arch/xtensa/boot/dts/Makefile
+++ b/arch/xtensa/boot/dts/Makefile
@@ -7,7 +7,7 @@
 #
 #
 
-obj-$(CONFIG_OF) += $(addsuffix .dtb.o, $(CONFIG_BUILTIN_DTB_SOURCE))
+dtb-$(CONFIG_OF) += $(addsuffix .dtb, $(CONFIG_BUILTIN_DTB_NAME))
 
 # for CONFIG_OF_ALL_DTBS test
 dtb-   := $(patsubst $(src)/%.dts,%.dtb, $(wildcard $(src)/*.dts))
diff --git a/arch/xtensa/configs/audio_kc705_defconfig 
b/arch/xtensa/configs/audio_kc705_defconfig
index 436b7cac9694..f2af1a32c9c7 100644
--- a/arch/xtensa/configs/audio_kc705_defconfig
+++ b/arch/xtensa/configs/audio_kc705_defconfig
@@ -30,7 +30,7 @@ CONFIG_XTENSA_PLATFORM_XTFPGA=y
 CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 
console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x3800@0"
 CONFIG_USE_OF=y
-CONFIG_BUILTIN_DTB_SOURCE="kc705"
+CONFIG_BUILTIN_DTB_NAME="kc705"
 # CONFIG_COMPACTION is not set
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 CONFIG_PM=y
diff --git a/arch/xtensa/configs/cadence_csp_defconfig 
b/arch/xtensa/configs/cadence_csp_defconfig
index 91c4c4cae8a7..5a272a278740 100644
--- a/arch/xtensa/configs/cadence_csp_defconfig
+++ b/arch/xtensa/configs/cadence_csp_defconfig
@@ -35,7 +35,7 @@ CONFIG_HIGHMEM=y
 # CONFIG_PCI is not set
 CONFIG_XTENSA_PLATFORM_XTFPGA=y
 CONFIG_USE_OF=y
-CONFIG_BUILTIN_DTB_SOURCE="csp"
+CONFIG_BUILTIN_DTB_NAME="csp"
 # CONFIG_COMPACTION is not set
 CONFIG_XTFPGA_LCD=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
diff --git a/arch/xtensa/configs/generic_kc705_defconfig 
b/arch/xtensa/configs/generic_kc705_defconfig
index e376238bc5ca..4427907becca 100644
--- a/arch/xtensa/configs/generic_kc705_defconfig
+++ b/arch/xtensa/configs/generic_kc705_defconfig
@@ -29,7 +29,7 @@ CONFIG_XTENSA_PLATFORM_XTFPGA=y
 CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 
console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x3800@0"
 CONFIG_USE_OF=y
-CONFIG_BUILTIN_DTB_SOURCE="kc705"
+CONFIG_BUILTIN_DTB_NAME="kc705"
 # CONFIG_COMPACTION is not set
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 CONFIG_NET=y
diff --git a/arch/xtensa/configs/nommu_kc705_defconfig 
b/arch/xtensa/configs/nommu_kc705_defconfig
index c2ab4306ee20..5828228522ba 100644
--- a/arch/xtensa/configs/nommu_kc705_defconfig
+++ b/arch/xtensa/configs/nommu_kc705_defconfig
@@ -36,7 +36,7 @@ CONFIG_XTENSA_PLATFORM_XTFPGA=y
 CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0x9d050020,115200n8 
console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=256M@0x6000"
 CONFIG_USE_OF=y
-CONFIG_BUILTIN_DTB_SOURCE="kc705_nommu"
+CONFIG_BUILTIN_DTB_NAME="kc705_nommu"
 CONFIG_BINFMT_FLAT=y
 CONFIG_NET=y
 CONFIG_PACKET=y
diff --git a/arch/xtensa/configs/smp_lx200_defconfig 
b/arch/xtensa/configs/smp_lx200_defconfig
index 63b56ce79f83..326966ca7831 100644
--- a/arch/xtensa/configs/smp_lx200_defconfig
+++ b/arch/xtensa/configs/smp_lx200_defconfig
@@ -33,7 +33,7 @@ CONFIG_XTENSA_PLATFORM_XTFPGA=y
 CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 
console=tt

[PATCH 12/15] sh: migrate to the generic rule for built-in DTB

2024-09-04 Thread Masahiro Yamada
Select GENERIC_BUILTIN_DTB when built-in DTB support is enabled.

To keep consistency across architectures, this commit also renames
CONFIG_USE_BUILTIN_DTB to CONFIG_BUILTIN_DTB, and
CONFIG_BUILTIN_DTB_SOURCE to CONFIG_BUILTIN_DTB_NAME.

Signed-off-by: Masahiro Yamada 
---

 arch/sh/Kbuild| 1 -
 arch/sh/Kconfig   | 7 ---
 arch/sh/boot/dts/Makefile | 2 +-
 arch/sh/kernel/setup.c| 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/sh/Kbuild b/arch/sh/Kbuild
index 056efec72c2a..0da6c6d6821a 100644
--- a/arch/sh/Kbuild
+++ b/arch/sh/Kbuild
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-y  += kernel/ mm/ boards/
 obj-$(CONFIG_SH_FPU_EMU)   += math-emu/
-obj-$(CONFIG_USE_BUILTIN_DTB)  += boot/dts/
 
 obj-$(CONFIG_HD6446X_SERIES)   += cchips/hd6446x/
 
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 1aa3c4a0c5b2..3b772378773f 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -644,10 +644,11 @@ endmenu
 
 menu "Boot options"
 
-config USE_BUILTIN_DTB
+config BUILTIN_DTB
bool "Use builtin DTB"
default n
depends on SH_DEVICE_TREE
+   select GENERIC_BUILTIN_DTB
help
  Link a device tree blob for particular hardware into the kernel,
  suppressing use of the DTB pointer provided by the bootloader.
@@ -655,10 +656,10 @@ config USE_BUILTIN_DTB
  not capable of providing a DTB to the kernel, or for experimental
  hardware without stable device tree bindings.
 
-config BUILTIN_DTB_SOURCE
+config BUILTIN_DTB_NAME
string "Source file for builtin DTB"
default ""
-   depends on USE_BUILTIN_DTB
+   depends on BUILTIN_DTB
help
  Base name (without suffix, relative to arch/sh/boot/dts) for the
  a DTS file that will be used to produce the DTB linked into the
diff --git a/arch/sh/boot/dts/Makefile b/arch/sh/boot/dts/Makefile
index 4a6dec9714a9..d109978a5eb9 100644
--- a/arch/sh/boot/dts/Makefile
+++ b/arch/sh/boot/dts/Makefile
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_USE_BUILTIN_DTB) += $(addsuffix .dtb.o, 
$(CONFIG_BUILTIN_DTB_SOURCE))
+obj-$(CONFIG_BUILTIN_DTB) += $(addsuffix .dtb.o, $(CONFIG_BUILTIN_DTB_NAME))
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 620e5cf8ae1e..aaca94a88dad 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -249,7 +249,7 @@ void __ref sh_fdt_init(phys_addr_t dt_phys)
/* Avoid calling an __init function on secondary cpus. */
if (done) return;
 
-#ifdef CONFIG_USE_BUILTIN_DTB
+#ifdef CONFIG_BUILTIN_DTB
dt_virt = __dtb_start;
 #else
dt_virt = phys_to_virt(dt_phys);
@@ -323,7 +323,7 @@ void __init setup_arch(char **cmdline_p)
sh_early_platform_driver_probe("earlyprintk", 1, 1);
 
 #ifdef CONFIG_OF_EARLY_FLATTREE
-#ifdef CONFIG_USE_BUILTIN_DTB
+#ifdef CONFIG_BUILTIN_DTB
unflatten_and_copy_device_tree();
 #else
unflatten_device_tree();
-- 
2.43.0


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


[PATCH 11/15] nios2: migrate to the generic rule for built-in DTB

2024-09-04 Thread Masahiro Yamada
Select GENERIC_BUILTIN_DTB when built-in DTB support is enabled.

To keep consistency across architectures, this commit also renames
CONFIG_NIOS2_DTB_SOURCE_BOOL to CONFIG_BUILTIN_DTB, and
CONFIG_NIOS2_DTB_SOURCE to CONFIG_BUILTIN_DTB_NAME.

Signed-off-by: Masahiro Yamada 
---

 arch/nios2/Kbuild|  2 +-
 arch/nios2/boot/dts/Makefile |  4 ++--
 arch/nios2/kernel/prom.c |  2 +-
 arch/nios2/platform/Kconfig.platform | 11 ++-
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/nios2/Kbuild b/arch/nios2/Kbuild
index fc2952edd2de..fa64c5954b20 100644
--- a/arch/nios2/Kbuild
+++ b/arch/nios2/Kbuild
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
-obj-y += kernel/ mm/ platform/ boot/dts/
+obj-y += kernel/ mm/ platform/
 
 # for cleaning
 subdir- += boot
diff --git a/arch/nios2/boot/dts/Makefile b/arch/nios2/boot/dts/Makefile
index 1a2e8996bec7..1b8f41c4154f 100644
--- a/arch/nios2/boot/dts/Makefile
+++ b/arch/nios2/boot/dts/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-y := $(patsubst %.dts,%.dtb.o,$(CONFIG_NIOS2_DTB_SOURCE))
+dtb-y := $(addsuffix .dtb, $(CONFIG_BUILTIN_DTB_NAME))
 
-dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(src)/%.dts,%.dtb, $(wildcard 
$(src)/*.dts))
+dtb-$(CONFIG_OF_ALL_DTBS) += $(patsubst $(src)/%.dts,%.dtb, $(wildcard 
$(src)/*.dts))
diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c
index 9a8393e6b4a8..f703056885c9 100644
--- a/arch/nios2/kernel/prom.c
+++ b/arch/nios2/kernel/prom.c
@@ -32,7 +32,7 @@ void __init early_init_devtree(void *params)
}
 #endif
 
-#ifdef CONFIG_NIOS2_DTB_SOURCE_BOOL
+#ifdef CONFIG_BUILTIN_DTB
if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER)
params = (void *)__dtb_start;
 #endif
diff --git a/arch/nios2/platform/Kconfig.platform 
b/arch/nios2/platform/Kconfig.platform
index e849daff6fd1..c75cadd92388 100644
--- a/arch/nios2/platform/Kconfig.platform
+++ b/arch/nios2/platform/Kconfig.platform
@@ -35,19 +35,20 @@ config NIOS2_DTB_PHYS_ADDR
help
  Physical address of a dtb blob.
 
-config NIOS2_DTB_SOURCE_BOOL
+config BUILTIN_DTB
bool "Compile and link device tree into kernel image"
depends on !COMPILE_TEST
+   select GENERIC_BUILTIN_DTB
help
  This allows you to specify a dts (device tree source) file
  which will be compiled and linked into the kernel image.
 
-config NIOS2_DTB_SOURCE
-   string "Device tree source file"
-   depends on NIOS2_DTB_SOURCE_BOOL
+config BUILTIN_DTB_NAME
+   string "Built-in device tree name"
+   depends on BUILTIN_DTB
default ""
help
- Absolute path to the device tree source (dts) file describing your
+ Relative path to the device tree without suffix describing your
  system.
 
 comment "Nios II instructions"
-- 
2.43.0


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


[PATCH 13/15] microblaze: migrate to the generic rule for built-in DTB

2024-09-04 Thread Masahiro Yamada
Select GENERIC_BUILTIN_DTB to use the generic rule to support built-in
DTB.

MicroBlaze is the only architecture that embeds the boot DTB into its
own section, __fdt_blob, and hard-codes the section size to 64kB.

All other architectures that support embedded DTBs use the
.dtb.init.rodata handled by include/asm-generic/vmlinux.lds.h.

For safety, arch/microblaze/boot/dts/system.dtb is still placed in the
__fdt_blob section, but removing the MicroBlaze-specific section should
be considered.

Signed-off-by: Masahiro Yamada 
---

 arch/microblaze/Kbuild| 1 -
 arch/microblaze/Kconfig   | 5 +
 arch/microblaze/boot/dts/Makefile | 5 -
 arch/microblaze/boot/dts/linked_dtb.S | 2 --
 arch/microblaze/kernel/vmlinux.lds.S  | 2 +-
 5 files changed, 6 insertions(+), 9 deletions(-)
 delete mode 100644 arch/microblaze/boot/dts/linked_dtb.S

diff --git a/arch/microblaze/Kbuild b/arch/microblaze/Kbuild
index 077a0b8e9615..70510389eb92 100644
--- a/arch/microblaze/Kbuild
+++ b/arch/microblaze/Kbuild
@@ -2,7 +2,6 @@
 obj-y  += kernel/
 obj-y  += mm/
 obj-$(CONFIG_PCI)  += pci/
-obj-y  += boot/dts/
 
 # for cleaning
 subdir- += boot
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index f18ec02ddeb2..4ed8ca89f0c9 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -10,6 +10,7 @@ config MICROBLAZE
select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_WANT_IPC_PARSE_VERSION
select BUILDTIME_TABLE_SORT
+   select GENERIC_BUILTIN_DTB
select TIMER_OF
select CLONE_BACKWARDS3
select COMMON_CLK
@@ -47,6 +48,10 @@ config MICROBLAZE
select TRACE_IRQFLAGS_SUPPORT
select GENERIC_IRQ_MULTI_HANDLER
 
+config BUILTIN_DTB_NAME
+   string
+   default "system"
+
 # Endianness selection
 choice
prompt "Endianness selection"
diff --git a/arch/microblaze/boot/dts/Makefile 
b/arch/microblaze/boot/dts/Makefile
index b84e2cbb20ee..87c1d25ff096 100644
--- a/arch/microblaze/boot/dts/Makefile
+++ b/arch/microblaze/boot/dts/Makefile
@@ -4,11 +4,6 @@
 dtb-y := system.dtb
 
 ifneq ($(DTB),)
-obj-y += linked_dtb.o
-
-# Ensure system.dtb exists
-$(obj)/linked_dtb.o: $(obj)/system.dtb
-
 # Generate system.dtb from $(DTB).dtb
 ifneq ($(DTB),system)
 $(obj)/system.dtb: $(obj)/$(DTB).dtb
diff --git a/arch/microblaze/boot/dts/linked_dtb.S 
b/arch/microblaze/boot/dts/linked_dtb.S
deleted file mode 100644
index 23345af3721f..
--- a/arch/microblaze/boot/dts/linked_dtb.S
+++ /dev/null
@@ -1,2 +0,0 @@
-.section __fdt_blob,"a"
-.incbin "arch/microblaze/boot/dts/system.dtb"
diff --git a/arch/microblaze/kernel/vmlinux.lds.S 
b/arch/microblaze/kernel/vmlinux.lds.S
index ae50d3d04a7d..e86f9ca8e979 100644
--- a/arch/microblaze/kernel/vmlinux.lds.S
+++ b/arch/microblaze/kernel/vmlinux.lds.S
@@ -47,7 +47,7 @@ SECTIONS {
. = ALIGN (8) ;
__fdt_blob : AT(ADDR(__fdt_blob) - LOAD_OFFSET) {
_fdt_start = . ;/* place for fdt blob */
-   *(__fdt_blob) ; /* Any link-placed DTB */
+   *(.dtb.init.rodata) ;   /* Any link-placed DTB */
. = _fdt_start + 0x1;   /* Pad up to 64kbyte */
_fdt_end = . ;
}
-- 
2.43.0


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


[PATCH 14/15] kbuild: rename CONFIG_GENERIC_BUILTIN_DTB to CONFIG_BUILTIN_DTB

2024-09-04 Thread Masahiro Yamada
Now that all architectures have migrated to the generic built-in
DTB support, the GENERIC_ prefix is no longer necessary.

Signed-off-by: Masahiro Yamada 
---

 Makefile | 2 +-
 arch/arc/Kconfig | 2 +-
 arch/loongarch/Kconfig   | 1 -
 arch/microblaze/Kconfig  | 2 +-
 arch/mips/Kconfig| 1 -
 arch/nios2/platform/Kconfig.platform | 1 -
 arch/openrisc/Kconfig| 2 +-
 arch/riscv/Kconfig   | 1 -
 arch/sh/Kconfig  | 1 -
 arch/xtensa/Kconfig  | 2 +-
 drivers/of/Kconfig   | 2 +-
 scripts/Makefile.vmlinux | 2 +-
 scripts/link-vmlinux.sh  | 2 +-
 13 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index 1c765c12ab9e..a83edbdbc79c 100644
--- a/Makefile
+++ b/Makefile
@@ -1417,7 +1417,7 @@ ifdef CONFIG_OF_EARLY_FLATTREE
 all: dtbs
 endif
 
-ifdef CONFIG_GENERIC_BUILTIN_DTB
+ifdef CONFIG_BUILTIN_DTB
 vmlinux: dtbs
 endif
 
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 11fe4f497571..05fed3cd8b29 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -16,7 +16,7 @@ config ARC
select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
select ARCH_32BIT_OFF_T
select BUILDTIME_TABLE_SORT
-   select GENERIC_BUILTIN_DTB
+   select BUILTIN_DTB
select CLONE_BACKWARDS
select COMMON_CLK
select DMA_DIRECT_REMAP
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index e1d3e5fb6fd2..70f169210b52 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -388,7 +388,6 @@ endchoice
 config BUILTIN_DTB
bool "Enable built-in dtb in kernel"
depends on OF
-   select GENERIC_BUILTIN_DTB
help
  Some existing systems do not provide a canonical device tree to
  the kernel at boot time. Let's provide a device tree table in the
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 4ed8ca89f0c9..e1a3b5f4d97e 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -10,7 +10,7 @@ config MICROBLAZE
select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_WANT_IPC_PARSE_VERSION
select BUILDTIME_TABLE_SORT
-   select GENERIC_BUILTIN_DTB
+   select BUILTIN_DTB
select TIMER_OF
select CLONE_BACKWARDS3
select COMMON_CLK
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 7bfe3fd011f4..fda96e4f2187 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -33,7 +33,6 @@ config MIPS
select CPU_NO_EFFICIENT_FFS if (TARGET_ISA_REV < 1)
select CPU_PM if CPU_IDLE || SUSPEND
select GENERIC_ATOMIC64 if !64BIT
-   select GENERIC_BUILTIN_DTB if BUILTIN_DTB
select GENERIC_CMOS_UPDATE
select GENERIC_CPU_AUTOPROBE
select GENERIC_GETTIMEOFDAY
diff --git a/arch/nios2/platform/Kconfig.platform 
b/arch/nios2/platform/Kconfig.platform
index c75cadd92388..5f0cf551b5ca 100644
--- a/arch/nios2/platform/Kconfig.platform
+++ b/arch/nios2/platform/Kconfig.platform
@@ -38,7 +38,6 @@ config NIOS2_DTB_PHYS_ADDR
 config BUILTIN_DTB
bool "Compile and link device tree into kernel image"
depends on !COMPILE_TEST
-   select GENERIC_BUILTIN_DTB
help
  This allows you to specify a dts (device tree source) file
  which will be compiled and linked into the kernel image.
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 11ffcf33652c..f55e66be4112 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -10,7 +10,7 @@ config OPENRISC
select ARCH_HAS_DMA_SET_UNCACHED
select ARCH_HAS_DMA_CLEAR_UNCACHED
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
-   select GENERIC_BUILTIN_DTB
+   select BUILTIN_DTB
select COMMON_CLK
select OF
select OF_EARLY_FLATTREE
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 019c64ef0826..a63b66b32636 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -1110,7 +1110,6 @@ config RISCV_ISA_FALLBACK
 config BUILTIN_DTB
bool "Built-in device tree"
depends on OF && NONPORTABLE
-   select GENERIC_BUILTIN_DTB
help
  Build a device tree into the Linux image.
  This option should be selected if no bootloader is being used.
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 3b772378773f..b09019cd87d4 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -648,7 +648,6 @@ config BUILTIN_DTB
bool "Use builtin DTB"
default n
depends on SH_DEVICE_TREE
-   select GENERIC_BUILTIN_DTB
help
  Link a device tree blob for particular hardware into the kernel,
  suppressing use of the DTB pointer provided by the bootloader.
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 5fd1d248e147..cccfacb5848d 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -19,7 +19,7 @@ config X

[PATCH 15/15] kbuild: use .init.rodata section unconditionally for cmd_wrap_S_dtb

2024-09-04 Thread Masahiro Yamada
Boot DTBs are now wrapped and compiled in scripts/Makefile.vmlinux.

The cmd_wrap_S_dtb rule in scripts/Makefile.dtbs is now only used
for generic purposes, so the .init.rodata section should be used
unconditionally.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.dtbs | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
index 55998b878e54..436bfea85bb9 100644
--- a/scripts/Makefile.dtbs
+++ b/scripts/Makefile.dtbs
@@ -34,14 +34,12 @@ $(obj)/dtbs-list: $(dtb-y) FORCE
 # Assembly file to wrap dtb(o)
 # ---
 
-builtin-dtb-section = $(if $(filter arch/%, 
$(obj)),.dtb.init.rodata,.init.rodata)
-
 # Generate an assembly file to wrap the output of the device tree compiler
 quiet_cmd_wrap_S_dtb = WRAP$@
   cmd_wrap_S_dtb = {   
\
symbase=__$(patsubst .%,%,$(suffix $<))_$(subst -,_,$(notdir 
$*));  \
echo '\#include ';   
\
-   echo '.section $(builtin-dtb-section),"a"'; 
\
+   echo '.section .init.rodata,"a"';   
\
echo '.balign STRUCT_ALIGNMENT';
\
echo ".global $${symbase}_begin";   
\
echo "$${symbase}_begin:";  
\
-- 
2.43.0


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


Re: [PATCH RFC v2 0/4] mm: Introduce MAP_BELOW_HINT

2024-09-04 Thread Kirill A. Shutemov
On Thu, Aug 29, 2024 at 12:15:57AM -0700, Charlie Jenkins wrote:
> Some applications rely on placing data in free bits addresses allocated
> by mmap. Various architectures (eg. x86, arm64, powerpc) restrict the
> address returned by mmap to be less than the 48-bit address space,
> unless the hint address uses more than 47 bits (the 48th bit is reserved
> for the kernel address space).
> 
> The riscv architecture needs a way to similarly restrict the virtual
> address space. On the riscv port of OpenJDK an error is thrown if
> attempted to run on the 57-bit address space, called sv57 [1].  golang
> has a comment that sv57 support is not complete, but there are some
> workarounds to get it to mostly work [2].
> 
> These applications work on x86 because x86 does an implicit 47-bit
> restriction of mmap() address that contain a hint address that is less
> than 48 bits.
> 
> Instead of implicitly restricting the address space on riscv (or any
> current/future architecture), a flag would allow users to opt-in to this
> behavior rather than opt-out as is done on other architectures. This is
> desirable because it is a small class of applications that do pointer
> masking.

This argument looks broken to me.

The "small class of applications" is going to be broken unless they got
patched to use your new mmap() flag. You are asking for bugs.

Consider the case when you write, compile and validate a piece of software
on machine that has <=47bit VA. The binary got shipped to customers.
Later, customer gets a new shiny machine that supports larger address
space and your previously working software is broken. Such binaries might
exist today.

It is bad idea to use >47bit VA by default. Most of software got tested on
x86 with 47bit VA.

We can consider more options to opt-in into wider address space like
personality or prctl() handle. But opt-out is no-go from what I see.

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

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