Subject: linux-next: build failure after merge of the mm tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 25 Jan 2024 14:29:07 +1100

Hi all,

After merging the mm tree, today's linux-next build (powerpc allnoconfig)
failed like this:

WARNING: unmet direct dependencies detected for CRASH_DUMP
  Depends on [n]: ARCH_SUPPORTS_CRASH_DUMP [=y] && KEXEC_CORE [=n]
  Selected by [y]:
  - ARCH_SELECTS_KEXEC [=y]
arch/powerpc/kernel/crash_dump.c:101:6: error: redefinition of 'is_kdump_kernel'
  101 | bool is_kdump_kernel(void)
      |      ^~~~~~~~~~~~~~~
In file included from arch/powerpc/kernel/crash_dump.c:12:
include/linux/crash_dump.h:64:20: note: previous definition of 'is_kdump_kernel' with type 'bool(void)' {aka '_Bool(void)'}
   64 | static inline bool is_kdump_kernel(void)
      |                    ^~~~~~~~~~~~~~~
kernel/crash_core.c: In function 'kimage_crash_copy_vmcoreinfo':
kernel/crash_core.c:43:18: error: invalid use of undefined type 'struct kimage'
   43 |         if (image->type != KEXEC_TYPE_CRASH)
      |                  ^~
kernel/crash_core.c:43:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in this function); did you mean 'KEXEC_ON_CRASH'?
   43 |         if (image->type != KEXEC_TYPE_CRASH)
      |                            ^~~~~~~~~~~~~~~~
      |                            KEXEC_ON_CRASH
kernel/crash_core.c:43:28: note: each undeclared identifier is reported only once for each function it appears in
kernel/crash_core.c:55:27: error: implicit declaration of function 'kimage_alloc_control_pages' [-Werror=implicit-function-declaration]
   55 |         vmcoreinfo_page = kimage_alloc_control_pages(image, 0);
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/crash_core.c:55:25: warning: assignment to 'struct page *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   55 |         vmcoreinfo_page = kimage_alloc_control_pages(image, 0);
      |                         ^
kernel/crash_core.c:66:14: error: invalid use of undefined type 'struct kimage'
   66 |         image->vmcoreinfo_data_copy = safecopy;
      |              ^~
kernel/crash_core.c: At top level:
kernel/crash_core.c:74:5: error: redefinition of 'kexec_should_crash'
   74 | int kexec_should_crash(struct task_struct *p)
      |     ^~~~~~~~~~~~~~~~~~
In file included from kernel/crash_core.c:12:
include/linux/kexec.h:474:19: note: previous definition of 'kexec_should_crash' with type 'int(struct task_struct *)'
  474 | static inline int kexec_should_crash(struct task_struct *p) { return 0; }
      |                   ^~~~~~~~~~~~~~~~~~
kernel/crash_core.c:92:5: error: redefinition of 'kexec_crash_loaded'
   92 | int kexec_crash_loaded(void)
      |     ^~~~~~~~~~~~~~~~~~
include/linux/kexec.h:475:19: note: previous definition of 'kexec_crash_loaded' with type 'int(void)'
  475 | static inline int kexec_crash_loaded(void) { return 0; }
      |                   ^~~~~~~~~~~~~~~~~~
kernel/crash_core.c: In function 'kexec_crash_loaded':
kernel/crash_core.c:94:18: error: 'kexec_crash_image' undeclared (first use in this function); did you mean 'kexec_crash_loaded'?
   94 |         return !!kexec_crash_image;
      |                  ^~~~~~~~~~~~~~~~~
      |                  kexec_crash_loaded
kernel/crash_core.c: At top level:
kernel/crash_core.c:103:16: error: redefinition of '__crash_kexec'
  103 | void __noclone __crash_kexec(struct pt_regs *regs)
      |                ^~~~~~~~~~~~~
include/linux/kexec.h:472:20: note: previous definition of '__crash_kexec' with type 'void(struct pt_regs *)'
  472 | static inline void __crash_kexec(struct pt_regs *regs) { }
      |                    ^~~~~~~~~~~~~
kernel/crash_core.c: In function '__crash_kexec':
kernel/crash_core.c:114:21: error: 'kexec_crash_image' undeclared (first use in this function); did you mean 'kexec_crash_loaded'?
  114 |                 if (kexec_crash_image) {
      |                     ^~~~~~~~~~~~~~~~~
      |                     kexec_crash_loaded
kernel/crash_core.c:117:25: error: implicit declaration of function 'crash_setup_regs' [-Werror=implicit-function-declaration]
  117 |                         crash_setup_regs(&fixed_regs, regs);
      |                         ^~~~~~~~~~~~~~~~
kernel/crash_core.c:120:25: error: implicit declaration of function 'machine_kexec' [-Werror=implicit-function-declaration]
  120 |                         machine_kexec(kexec_crash_image);
      |                         ^~~~~~~~~~~~~
kernel/crash_core.c: At top level:
kernel/crash_core.c:128:1: warning: ignoring attribute 'noinline' because it conflicts with attribute 'gnu_inline' [-Wattributes]
  128 | {
      | ^
include/linux/kexec.h:473:20: note: previous declaration here
  473 | static inline void crash_kexec(struct pt_regs *regs) { }
      |                    ^~~~~~~~~~~
kernel/crash_core.c:127:18: error: redefinition of 'crash_kexec'
  127 | __bpf_kfunc void crash_kexec(struct pt_regs *regs)
      |                  ^~~~~~~~~~~
include/linux/kexec.h:473:20: note: previous definition of 'crash_kexec' with type 'void(struct pt_regs *)'
  473 | static inline void crash_kexec(struct pt_regs *regs) { }
      |                    ^~~~~~~~~~~
kernel/crash_core.c: In function '__crash_shrink_memory':
kernel/crash_core.c:356:9: error: implicit declaration of function 'crash_free_reserved_phys_range' [-Werror=implicit-function-declaration]
  356 |         crash_free_reserved_phys_range(ram_res->start, ram_res->end);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/crash_core.c: In function 'crash_shrink_memory':
kernel/crash_core.c:370:13: error: 'kexec_crash_image' undeclared (first use in this function); did you mean 'kexec_crash_loaded'?
  370 |         if (kexec_crash_image) {
      |             ^~~~~~~~~~~~~~~~~
      |             kexec_crash_loaded
In file included from include/linux/kernel.h:27,
                 from arch/powerpc/include/asm/page.h:11,
                 from arch/powerpc/include/asm/thread_info.h:13,
                 from include/linux/thread_info.h:60,
                 from arch/powerpc/include/asm/processor.h:41,
                 from include/linux/sched.h:13,
                 from include/linux/utsname.h:6,
                 from kernel/crash_core.c:9:
kernel/crash_core.c:377:38: error: 'KEXEC_CRASH_MEM_ALIGN' undeclared (first use in this function)
  377 |         new_size = roundup(new_size, KEXEC_CRASH_MEM_ALIGN);
      |                                      ^~~~~~~~~~~~~~~~~~~~~
include/linux/math.h:61:16: note: in definition of macro 'roundup'
   61 |         typeof(y) __y = y;                              \
      |                ^
kernel/crash_core.c: In function 'crash_save_cpu':
kernel/crash_core.c:437:36: error: 'KEXEC_CORE_NOTE_NAME' undeclared (first use in this function); did you mean 'CRASH_CORE_NOTE_NAME'?
  437 |         buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS,
      |                                    ^~~~~~~~~~~~~~~~~~~~
      |                                    CRASH_CORE_NOTE_NAME
kernel/crash_core.c: In function 'kexec_crash_loaded':
kernel/crash_core.c:95:1: error: control reaches end of non-void function [-Werror=return-type]
   95 | }
      | ^
cc1: some warnings being treated as errors

Caused by commit

  9dc830523e4e ("ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP")

I have applied the following patch:

From: Stephen Rothwell <[email-masked]>
Date: Thu, 25 Jan 2024 14:20:51 +1100
Subject: [PATCH] fix up for "ppc, crash: enforce KEXEC and KEXEC_FILE to
 select CRASH_DUMP"

Signed-off-by: Stephen Rothwell <[email-masked]>
---
 arch/powerpc/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 31f013e636e3..e7707bebc061 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -610,6 +610,8 @@ config ARCH_SUPPORTS_KEXEC
 
 config ARCH_SELECTS_KEXEC
 	def_bool y
+	depends on ARCH_SUPPORTS_CRASH_DUMP
+	depends on KEXEC_CORE
 	select CRASH_DUMP
 
 config ARCH_SUPPORTS_KEXEC_FILE
-- 
2.43.0

-- 
Cheers,
Stephen Rothwell