# Base git commit: 1613e604df0c
# (Linux 6.10-rc1)
# 
# Author:    Russell King (Oracle) (Mon 10 Jun 12:01:50 BST 2024)
# Committer: Russell King (Oracle) (Mon 10 Jun 12:01:50 BST 2024)
# 
#   Merge branches 'clkdev', 'fixes' and 'misc' into for-next
# 
# Author:    Yuntao Liu (Mon  3 Jun 16:37:50 BST 2024)
# Committer: Russell King (Oracle) (Mon 10 Jun 12:01:33 BST 2024)
# 
#   ARM: 9404/1: arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION
# 
#   The current arm32 architecture does not yet support the
#   HAVE_LD_DEAD_CODE_DATA_ELIMINATION feature. arm32 is widely used in
#   embedded scenarios, and enabling this feature would be beneficial for
#   reducing the size of the kernel image.
# 
#   In order to make this work, we keep the necessary tables by annotating
#   them with KEEP, also it requires further changes to linker script to KEEP
#   some tables and wildcard compiler generated sections into the right place.
#   When using ld.lld for linking, KEEP is not recognized within the OVERLAY
#   command, and Ard proposed a concise method to solve this problem.
# 
#   It boots normally with defconfig, vexpress_defconfig and tinyconfig.
# 
#   The size comparison of zImage is as follows:
#   defconfig       vexpress_defconfig      tinyconfig
#   5137712         5138024                 424192          no dce
#   5032560         4997824                 298384          dce
#   2.0%            2.7%                    29.7%           shrink
# 
#   When using smaller config file, there is a significant reduction in the
#   size of the zImage.
# 
#   We also tested this patch on a commercially available single-board
#   computer, and the comparison is as follows:
#   a15eb_config
#   2161384         no dce
#   2092240         dce
#   3.2%            shrink
# 
#   The zImage size has been reduced by approximately 3.2%, which is 70KB on
#   2.1M.
# 
#   Signed-off-by: Yuntao Liu
#   Tested-by: Arnd Bergmann
#   Reviewed-by: Arnd Bergmann
#   Reviewed-by: Linus Walleij
#   Signed-off-by: Russell King (Oracle)
# 
#   ed0f941022515ff40473ea5335769a5dc2524a3f
#    arch/arm/Kconfig                       | 1 +
#    arch/arm/boot/compressed/vmlinux.lds.S | 2 +-
#    arch/arm/include/asm/vmlinux.lds.h     | 2 +-
#    arch/arm/kernel/entry-armv.S           | 3 +++
#    arch/arm/kernel/vmlinux-xip.lds.S      | 4 ++--
#    arch/arm/kernel/vmlinux.lds.S          | 6 +++---
#    drivers/firmware/efi/libstub/Makefile  | 4 ++++
#    7 files changed, 15 insertions(+), 7 deletions(-)
# 
# Author:    Geert Uytterhoeven (Wed 29 May 13:09:24 BST 2024)
# Committer: Russell King (Oracle) (Mon 10 Jun 12:01:32 BST 2024)
# 
#   ARM: 9403/1: Alpine: Spelling s/initialiing/initializing/
# 
#   Fix a misspelling of "initializing".
# 
#   Signed-off-by: Geert Uytterhoeven
#   Signed-off-by: Russell King (Oracle)
# 
#   9ac7ba12d37b4c24f6db675ff7edb7e54f597a59
#    arch/arm/mach-alpine/alpine_cpu_pm.c | 2 +-
#    1 file changed, 1 insertion(+), 1 deletion(-)
# 
# Author:    Geert Uytterhoeven (Wed 29 May 13:07:42 BST 2024)
# Committer: Russell King (Oracle) (Mon 10 Jun 12:01:31 BST 2024)
# 
#   ARM: 9402/1: Kconfig: Spelling s/Cortex A-/Cortex-A/
# 
#   Fix a misspelling of "Cortex-A9", to make it easier to find which errata
#   are applicable to Cortex-A9 CPU cores.
# 
#   Signed-off-by: Geert Uytterhoeven
#   Signed-off-by: Russell King (Oracle)
# 
#   8ede71e1202011d8bfceeab4737e6d52d88688ab
#    arch/arm/Kconfig | 2 +-
#    1 file changed, 1 insertion(+), 1 deletion(-)
# 
# Author:    Dr. David Alan Gilbert (Mon 20 May 23:30:05 BST 2024)
# Committer: Russell King (Oracle) (Mon 10 Jun 12:01:30 BST 2024)
# 
#   ARM: 9400/1: Remove unused struct 'mod_unwind_map'
# 
#   I think this has been unused since
#   Commit b6f21d14f1ac ("ARM: 9204/2: module: Add all unwind tables when
#   load module")
# 
#   Signed-off-by: Dr. David Alan Gilbert
#   Signed-off-by: Russell King (Oracle)
# 
#   9b69b52cdde74a38c5ab4d89405b2bd384ec0155
#    arch/arm/kernel/module.c | 5 -----
#    1 file changed, 5 deletions(-)
# 
# Author:    Ard Biesheuvel (Tue  4 Jun 22:32:34 BST 2024)
# Committer: Russell King (Oracle) (Mon 10 Jun 12:00:27 BST 2024)
# 
#   ARM: 9405/1: ftrace: Don't assume stack frames are contiguous in memory
# 
#   The frame pointer unwinder relies on a standard layout of the stack
#   frame, consisting of (in downward order)
# 
#      Calling frame:
#        PC   <---------+
#        LR             |
#        SP             |
#        FP             |
#        .. locals ..   |
#      Callee frame:    |
#        PC             |
#        LR             |
#        SP             |
#        FP   ----------+
# 
#   where after storing its previous value on the stack, FP is made to point
#   at the location of PC in the callee stack frame, using the canonical
#   prologue:
# 
#      mov     ip, sp
#      stmdb   sp!, {fp, ip, lr, pc}
#      sub     fp, ip, #4
# 
#   The ftrace code assumes that this activation record is pushed first, and
#   that any stack space for locals is allocated below this. Strict
#   adherence to this would imply that the caller's value of SP at the time
#   of the function call can always be obtained by adding 4 to FP (which
#   points to PC in the callee frame).
# 
#   However, recent versions of GCC appear to deviate from this rule, and so
#   the only reliable way to obtain the caller's value of SP is to read it
#   from the activation record. Since this involves a read from memory
#   rather than simple arithmetic, we need to use the uaccess API here which
#   protects against inadvertent data aborts resulting from attempts to
#   dereference bogus FP values.
# 
#   The plain uaccess API is ftrace instrumented itself, so to avoid
#   unbounded recursion, use the __get_kernel_nofault() primitive directly.
# 
#   Closes: https://lore.kernel.org/all/alp44tukzo6mvcwl4ke4ehhmojrqnv6xfcdeuliybxfjfvgd3e@gpjvwj33cc76
# 
#   Closes: https://lore.kernel.org/all/d870c149-4363-43de-b0ea-7125dec5608e@broadcom.com/
# 
#   Reported-by: Uwe Kleine-König
#   Reported-by: Justin Chen
#   Tested-by: Thorsten Scherer
#   Reviewed-by: Linus Walleij
#   Signed-off-by: Ard Biesheuvel
#   Signed-off-by: Russell King (Oracle)
# 
#   e3cf20e5c68df604315ab30bdbe15dc8a5da556b
#    arch/arm/kernel/ftrace.c | 17 +++++++++++++++--
#    1 file changed, 15 insertions(+), 2 deletions(-)
# 
# Author:    Russell King (Oracle) (Mon 27 May 09:00:06 BST 2024)
# Committer: Russell King (Oracle) (Tue  4 Jun 17:12:01 BST 2024)
# 
#   clkdev: don't fail clkdev_alloc() if over-sized
# 
#   Don't fail clkdev_alloc() if the strings are over-sized. In this case,
#   the entry will not match during lookup, so its useless. However, since
#   code fails if we return NULL leading to boot failure, return a dummy
#   entry with the connection and device IDs set to "bad".
# 
#   Leave the warning so these problems can be found, and the useless
#   wasteful clkdev registrations removed.
# 
#   Reported-by: Ron Economos
#   Reported-by: Guenter Roeck
#   Fixes: 8d532528ff6a ("clkdev: report over-sized strings when creating clkdev entries")
#   Closes: https://lore.kernel.org/linux-clk/7eda7621-0dde-4153-89e4-172e4c095d01@roeck-us.net.
#   Link: https://lore.kernel.org/r/28114882-f8d7-21bf-4536-a186e8d7a22a@w6rz.net
#   Tested-by: Ron Economos
#   Signed-off-by: Russell King (Oracle)
# 
#   616501eccb58615f8f352a29239ea6c6fc5e6546
#    drivers/clk/clkdev.c | 11 +++++++++--
#    1 file changed, 9 insertions(+), 2 deletions(-)
# 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ee5115252aac..08572703d94d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -115,6 +115,7 @@ config ARM
 	select HAVE_KERNEL_XZ
 	select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M
 	select HAVE_KRETPROBES if HAVE_KPROBES
+	select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
 	select HAVE_MOD_ARCH_SPECIFIC
 	select HAVE_NMI
 	select HAVE_OPTPROBES if !THUMB2_KERNEL
@@ -735,7 +736,7 @@ config ARM_ERRATA_764319
 	bool "ARM errata: Read to DBGPRSR and DBGOSLSR may generate Undefined instruction"
 	depends on CPU_V7
 	help
-	  This option enables the workaround for the 764319 Cortex A-9 erratum.
+	  This option enables the workaround for the 764319 Cortex-A9 erratum.
 	  CP14 read accesses to the DBGPRSR and DBGOSLSR registers generate an
 	  unexpected Undefined Instruction exception when the DBGSWENABLE
 	  external pin is set to 0, even when the CP14 accesses are performed
diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S
index 3fcb3e62dc56..d411abd4310e 100644
--- a/arch/arm/boot/compressed/vmlinux.lds.S
+++ b/arch/arm/boot/compressed/vmlinux.lds.S
@@ -125,7 +125,7 @@ SECTIONS
 
   . = BSS_START;
   __bss_start = .;
-  .bss			: { *(.bss) }
+  .bss			: { *(.bss .bss.*) }
   _end = .;
 
   . = ALIGN(8);		/* the stack must be 64-bit aligned */
diff --git a/arch/arm/include/asm/vmlinux.lds.h b/arch/arm/include/asm/vmlinux.lds.h
index 4c8632d5c432..d60f6e83a9f7 100644
--- a/arch/arm/include/asm/vmlinux.lds.h
+++ b/arch/arm/include/asm/vmlinux.lds.h
@@ -42,7 +42,7 @@
 #define PROC_INFO							\
 		. = ALIGN(4);						\
 		__proc_info_begin = .;					\
-		*(.proc.info.init)					\
+		KEEP(*(.proc.info.init))				\
 		__proc_info_end = .;
 
 #define IDMAP_TEXT							\
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 6150a716828c..f01d23a220e6 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -1065,6 +1065,7 @@ ENDPROC(vector_bhb_loop8_\name)
 	.globl	vector_fiq
 
 	.section .vectors, "ax", %progbits
+	.reloc  .text, R_ARM_NONE, .
 	W(b)	vector_rst
 	W(b)	vector_und
 ARM(	.reloc	., R_ARM_LDR_PC_G0, .L__vector_swi		)
@@ -1078,6 +1079,7 @@ THUMB(	.reloc	., R_ARM_THM_PC12, .L__vector_swi		)
 
 #ifdef CONFIG_HARDEN_BRANCH_HISTORY
 	.section .vectors.bhb.loop8, "ax", %progbits
+	.reloc  .text, R_ARM_NONE, .
 	W(b)	vector_rst
 	W(b)	vector_bhb_loop8_und
 ARM(	.reloc	., R_ARM_LDR_PC_G0, .L__vector_bhb_loop8_swi	)
@@ -1090,6 +1092,7 @@ THUMB(	.reloc	., R_ARM_THM_PC12, .L__vector_bhb_loop8_swi	)
 	W(b)	vector_bhb_loop8_fiq
 
 	.section .vectors.bhb.bpiall, "ax", %progbits
+	.reloc  .text, R_ARM_NONE, .
 	W(b)	vector_rst
 	W(b)	vector_bhb_bpiall_und
 ARM(	.reloc	., R_ARM_LDR_PC_G0, .L__vector_bhb_bpiall_swi	)
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
index a0b6d1e3812f..e61591f33a6c 100644
--- a/arch/arm/kernel/ftrace.c
+++ b/arch/arm/kernel/ftrace.c
@@ -232,11 +232,24 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
 	unsigned long old;
 
 	if (unlikely(atomic_read(&current->tracing_graph_pause)))
+err_out:
 		return;
 
 	if (IS_ENABLED(CONFIG_UNWINDER_FRAME_POINTER)) {
-		/* FP points one word below parent's top of stack */
-		frame_pointer += 4;
+		/*
+		 * Usually, the stack frames are contiguous in memory but cases
+		 * have been observed where the next stack frame does not live
+		 * at 'frame_pointer + 4' as this code used to assume.
+		 *
+		 * Instead, dereference the field in the stack frame that
+		 * stores the SP of the calling frame: to avoid unbounded
+		 * recursion, this cannot involve any ftrace instrumented
+		 * functions, so use the __get_kernel_nofault() primitive
+		 * directly.
+		 */
+		__get_kernel_nofault(&frame_pointer,
+				     (unsigned long *)(frame_pointer - 8),
+				     unsigned long, err_out);
 	} else {
 		struct stackframe frame = {
 			.fp = frame_pointer,
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 677f218f7e84..da488d92e7a0 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -395,11 +395,6 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 	return 0;
 }
 
-struct mod_unwind_map {
-	const Elf_Shdr *unw_sec;
-	const Elf_Shdr *txt_sec;
-};
-
 static const Elf_Shdr *find_mod_section(const Elf32_Ehdr *hdr,
 	const Elf_Shdr *sechdrs, const char *name)
 {
diff --git a/arch/arm/kernel/vmlinux-xip.lds.S b/arch/arm/kernel/vmlinux-xip.lds.S
index c16d196b5aad..5eddb75a7174 100644
--- a/arch/arm/kernel/vmlinux-xip.lds.S
+++ b/arch/arm/kernel/vmlinux-xip.lds.S
@@ -63,7 +63,7 @@ SECTIONS
 	. = ALIGN(4);
 	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
 		__start___ex_table = .;
-		ARM_MMU_KEEP(*(__ex_table))
+		ARM_MMU_KEEP(KEEP(*(__ex_table)))
 		__stop___ex_table = .;
 	}
 
@@ -83,7 +83,7 @@ SECTIONS
 	}
 	.init.arch.info : {
 		__arch_info_begin = .;
-		*(.arch.info.init)
+		KEEP(*(.arch.info.init))
 		__arch_info_end = .;
 	}
 	.init.tagtable : {
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index bd9127c4b451..de373c6c2ae8 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -74,7 +74,7 @@ SECTIONS
 	. = ALIGN(4);
 	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
 		__start___ex_table = .;
-		ARM_MMU_KEEP(*(__ex_table))
+		ARM_MMU_KEEP(KEEP(*(__ex_table)))
 		__stop___ex_table = .;
 	}
 
@@ -99,7 +99,7 @@ SECTIONS
 	}
 	.init.arch.info : {
 		__arch_info_begin = .;
-		*(.arch.info.init)
+		KEEP(*(.arch.info.init))
 		__arch_info_end = .;
 	}
 	.init.tagtable : {
@@ -116,7 +116,7 @@ SECTIONS
 #endif
 	.init.pv_table : {
 		__pv_table_begin = .;
-		*(.pv_table)
+		KEEP(*(.pv_table))
 		__pv_table_end = .;
 	}
 
diff --git a/arch/arm/mach-alpine/alpine_cpu_pm.c b/arch/arm/mach-alpine/alpine_cpu_pm.c
index 13ae8412e9ce..b48da6f12b6c 100644
--- a/arch/arm/mach-alpine/alpine_cpu_pm.c
+++ b/arch/arm/mach-alpine/alpine_cpu_pm.c
@@ -29,7 +29,7 @@ int alpine_cpu_wakeup(unsigned int phys_cpu, uint32_t phys_resume_addr)
 	/*
 	 * Set CPU resume address -
 	 * secure firmware running on boot will jump to this address
-	 * after setting proper CPU mode, and initialiing e.g. secure
+	 * after setting proper CPU mode, and initializing e.g. secure
 	 * regs (the same mode all CPUs are booted to - usually HYP)
 	 */
 	writel(phys_resume_addr,
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 6a77d7e201a9..2f83fb97c6fb 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -204,8 +204,15 @@ vclkdev_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt,
 	pr_err("%pV:%s: %s ID is greater than %zu\n",
 	       &vaf, con_id, failure, max_size);
 	va_end(ap_copy);
-	kfree(cla);
-	return NULL;
+
+	/*
+	 * Don't fail in this case, but as the entry won't ever match just
+	 * fill it with something that also won't match.
+	 */
+	strscpy(cla->con_id, "bad", sizeof(cla->con_id));
+	strscpy(cla->dev_id, "bad", sizeof(cla->dev_id));
+
+	return &cla->cl;
 }
 
 static struct clk_lookup *
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 06f0428a723c..5a8a9b3429b5 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -56,6 +56,10 @@ KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_CFI), $(KBUILD_CFLAGS))
 # disable LTO
 KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
 
+# The .data section would be renamed to .data.efistub, therefore, remove
+# `-fdata-sections` flag from KBUILD_CFLAGS_KERNEL
+KBUILD_CFLAGS_KERNEL := $(filter-out -fdata-sections, $(KBUILD_CFLAGS_KERNEL))
+
 lib-y				:= efi-stub-helper.o gop.o secureboot.o tpm.o \
 				   file.o mem.o random.o randomalloc.o pci.o \
 				   skip_spaces.o lib-cmdline.o lib-ctype.o \
