Skip to contentSkip to conversation

powerpc/kexec: split CONFIG_CRASH_DUMP out from CONFIG_KEXEC_CORE

PATCH Superseded Hari Bathini 3 participants 7 messages Feb 13, 2024 – Feb 26, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover powerpc/kexec: split CONFIG_CRASH_DUMP out from CONFIG_KEXEC_CORE

This patch series is a follow-up to [1] based on discussions at [2] about additional work needed to get it working on powerpc.

The first patch in the series makes struct crash_mem available with or without CONFIG_CRASH_DUMP enabled. The next patch moves kdump specific code for kexec_file_load syscall under CONFIG_CRASH_DUMP and the last patch splits other kdump specific code under CONFIG_CRASH_DUMP and removes dependency with CONFIG_CRASH_DUMP for CONFIG_KEXEC_CORE.

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Hari Bathini (3):
kexec/kdump: make struct crash_mem available without CONFIG_CRASH_DUMP powerpc/kexec: split CONFIG_KEXEC_FILE and CONFIG_CRASH_DUMP powerpc/kdump: Split KEXEC_CORE and CRASH_DUMP dependency

 arch/powerpc/Kconfig               |   9 +-
 arch/powerpc/include/asm/kexec.h   |  98 +++++------
 arch/powerpc/kernel/prom.c         |   2 +-
 arch/powerpc/kernel/setup-common.c |   2 +-
 arch/powerpc/kernel/smp.c          |   4 +-
 arch/powerpc/kexec/Makefile        |   3 +-
 arch/powerpc/kexec/core.c          |   4 +
 arch/powerpc/kexec/elf_64.c        |   4 +-
 arch/powerpc/kexec/file_load_64.c  | 269 +++++++++++++++--------------
 include/linux/crash_core.h         |  12 +-
 10 files changed, 208 insertions(+), 199 deletions(-)
Signature · 7 lines
2.43.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

PATCH 1/3 kexec/kdump: make struct crash_mem available without CONFIG_CRASH_DUMP

struct crash_mem defined under include/linux/crash_core.h represents a list of memory ranges. While it is used to represent memory ranges for kdump kernel, it can also be used for other kind of memory ranges. In fact, KEXEC_FILE_LOAD syscall in powerpc uses this structure to represent reserved memory ranges and exclude memory ranges needed to find the right memory regions to load kexec kernel. So, make the definition of crash_mem structure available for !CONFIG_CRASH_DUMP case too.

---
 include/linux/crash_core.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/crash_core.h +6 -6
index 23270b16e1db..d33352c2e386 100644
@@ -8,6 +8,12 @@
 
 struct kimage;
 
+struct crash_mem {
+	unsigned int max_nr_ranges;
+	unsigned int nr_ranges;
+	struct range ranges[] __counted_by(max_nr_ranges);
+};
+
 #ifdef CONFIG_CRASH_DUMP
 
 int crash_shrink_memory(unsigned long new_size);
@@ -51,12 +57,6 @@ static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; }
 /* Alignment required for elf header segment */
 #define ELF_CORE_HEADER_ALIGN   4096
 
-struct crash_mem {
-	unsigned int max_nr_ranges;
-	unsigned int nr_ranges;
-	struct range ranges[] __counted_by(max_nr_ranges);
-};
-
 extern int crash_exclude_mem_range(struct crash_mem *mem,
 				   unsigned long long mstart,
 				   unsigned long long mend);
Signature · 7 lines
2.43.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#3 lore raw

PATCH 2/3 powerpc/kexec: split CONFIG_KEXEC_FILE and CONFIG_CRASH_DUMP

In reply to Hari Bathini

CONFIG_KEXEC_FILE does not have to select CONFIG_CRASH_DUMP. Move some code under CONFIG_CRASH_DUMP to support CONFIG_KEXEC_FILE and !CONFIG_CRASH_DUMP case.

---
 arch/powerpc/kexec/elf_64.c       |   4 +-
 arch/powerpc/kexec/file_load_64.c | 269 ++++++++++++++++--------------
 2 files changed, 142 insertions(+), 131 deletions(-)
arch/powerpc/kexec/elf_64.c +2 -2
index 904016cf89ea..6d8951e8e966 100644
@@ -47,7 +47,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
 	if (ret)
 		return ERR_PTR(ret);
 
-	if (image->type == KEXEC_TYPE_CRASH) {
+	if (IS_ENABLED(CONFIG_CRASH_DUMP) && image->type == KEXEC_TYPE_CRASH) {
 		/* min & max buffer values for kdump case */
 		kbuf.buf_min = pbuf.buf_min = crashk_res.start;
 		kbuf.buf_max = pbuf.buf_max =
@@ -70,7 +70,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
 	kexec_dprintk("Loaded purgatory at 0x%lx\n", pbuf.mem);
 
 	/* Load additional segments needed for panic kernel */
-	if (image->type == KEXEC_TYPE_CRASH) {
+	if (IS_ENABLED(CONFIG_CRASH_DUMP) && image->type == KEXEC_TYPE_CRASH) {
 		ret = load_crashdump_segments_ppc64(image, &kbuf);
 		if (ret) {
 			pr_err("Failed to load kdump kernel segments\n");
arch/powerpc/kexec/file_load_64.c +140 -129

322 lines not on this page · raw message

Signature · 7 lines
2.43.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#4 lore raw

PATCH 3/3 powerpc/kdump: Split KEXEC_CORE and CRASH_DUMP dependency

In reply to Hari Bathini

Remove CONFIG_CRASH_DUMP dependency on CONFIG_KEXEC. CONFIG_KEXEC_CORE was used at places where CONFIG_CRASH_DUMP or CONFIG_CRASH_RESERVE was appropriate. Replace with appropriate #ifdefs to support CONFIG_KEXEC and !CONFIG_CRASH_DUMP configuration option. Also, make CONFIG_FA_DUMP dependent on CONFIG_CRASH_DUMP to avoid unmet dependencies for FA_DUMP with !CONFIG_KEXEC_CORE configuration option.

---
 arch/powerpc/Kconfig               |  9 +--
 arch/powerpc/include/asm/kexec.h   | 98 +++++++++++++++---------------
 arch/powerpc/kernel/prom.c         |  2 +-
 arch/powerpc/kernel/setup-common.c |  2 +-
 arch/powerpc/kernel/smp.c          |  4 +-
 arch/powerpc/kexec/Makefile        |  3 +-
 arch/powerpc/kexec/core.c          |  4 ++
 7 files changed, 60 insertions(+), 62 deletions(-)
arch/powerpc/Kconfig +1 -8
index 5cf8ad8d7e8e..e377deefa2dc 100644
@@ -607,11 +607,6 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
 config ARCH_SUPPORTS_KEXEC
 	def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
 
-config ARCH_SELECTS_KEXEC
-	def_bool y
-	depends on KEXEC
-	select CRASH_DUMP
-
 config ARCH_SUPPORTS_KEXEC_FILE
 	def_bool PPC64
 
@@ -622,7 +617,6 @@ config ARCH_SELECTS_KEXEC_FILE
 	def_bool y
 	depends on KEXEC_FILE
 	select KEXEC_ELF
-	select CRASH_DUMP
 	select HAVE_IMA_KEXEC if IMA
 
 config PPC64_BIG_ENDIAN_ELF_ABI_V2
@@ -694,8 +688,7 @@ config ARCH_SELECTS_CRASH_DUMP
 
 config FA_DUMP
 	bool "Firmware-assisted dump"
-	depends on PPC64 && (PPC_RTAS || PPC_POWERNV)
-	select CRASH_DUMP
+	depends on CRASH_DUMP && PPC64 && (PPC_RTAS || PPC_POWERNV)
 	help
 	  A robust mechanism to get reliable kernel crash dump with
 	  assistance from firmware. This approach does not use kexec,
arch/powerpc/include/asm/kexec.h +49 -49

130 lines not on this page · raw message

arch/powerpc/kernel/prom.c +1 -1
index 0b5878c3125b..1edc34b711ba 100644
@@ -453,7 +453,7 @@ static int __init early_init_dt_scan_chosen_ppc(unsigned long node,
 		tce_alloc_end = *lprop;
 #endif
 
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_RESERVE
 	lprop = of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
 	if (lprop)
 		crashk_res.start = *lprop;
arch/powerpc/kernel/setup-common.c +1 -1
index 733f210ffda1..35cac3eaaf75 100644
@@ -109,7 +109,7 @@ int ppc_do_canonicalize_irqs;
 EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
 #endif
 
-#ifdef CONFIG_VMCORE_INFO
+#ifdef CONFIG_CRASH_DUMP
 /* This keeps a track of which one is the crashing cpu. */
 int crashing_cpu = -1;
 #endif
arch/powerpc/kernel/smp.c +2 -2
index 693334c20d07..aa81c95c73a4 100644
@@ -588,7 +588,7 @@ void smp_send_debugger_break(void)
 }
 #endif
 
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_DUMP
 void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
 {
 	int cpu;
@@ -631,7 +631,7 @@ void crash_smp_send_stop(void)
 
 	stopped = true;
 
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_DUMP
 	if (kexec_crash_image) {
 		crash_kexec_prepare();
 		return;
arch/powerpc/kexec/Makefile +2 -1
index 91e96f5168b7..8e469c4da3f8 100644
@@ -3,12 +3,13 @@
 # Makefile for the linux kernel.
 #
 
-obj-y				+= core.o crash.o core_$(BITS).o
+obj-y				+= core.o core_$(BITS).o
 
 obj-$(CONFIG_PPC32)		+= relocate_32.o
 
 obj-$(CONFIG_KEXEC_FILE)	+= file_load.o ranges.o file_load_$(BITS).o elf_$(BITS).o
 obj-$(CONFIG_VMCORE_INFO)	+= vmcore_info.o
+obj-$(CONFIG_CRASH_DUMP)	+= crash.o
 
 # Disable GCOV, KCOV & sanitizers in odd or sensitive code
 GCOV_PROFILE_core_$(BITS).o := n
arch/powerpc/kexec/core.c +4 -0
index 3ff4411ed496..b8333a49ea5d 100644
@@ -44,10 +44,12 @@ void machine_kexec_mask_interrupts(void) {
 	}
 }
 
+#ifdef CONFIG_CRASH_DUMP
 void machine_crash_shutdown(struct pt_regs *regs)
 {
 	default_machine_crash_shutdown(regs);
 }
+#endif
 
 void machine_kexec_cleanup(struct kimage *image)
 {
@@ -77,6 +79,7 @@ void machine_kexec(struct kimage *image)
 	for(;;);
 }
 
+#ifdef CONFIG_CRASH_RESERVE
 void __init reserve_crashkernel(void)
 {
 	unsigned long long crash_size, crash_base, total_mem_sz;
@@ -251,3 +254,4 @@ static int __init kexec_setup(void)
 	return 0;
 }
 late_initcall(kexec_setup);
+#endif /* CONFIG_CRASH_RESERVE */
Signature · 7 lines
2.43.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#2 lore raw

Re: [PATCH linux-next 1/3] kexec/kdump: make struct crash_mem available without CONFIG_CRASH_DUMP

In reply to Hari Bathini
Quoted 2 lines · Hari Bathini

struct crash_mem defined under include/linux/crash_core.h represents a list of memory ranges. While it is used to represent memory ranges

From its name, it's not only representing memory ranges, it's representing crash memory ranges. Except of this, the whole series looks good to me. Thanks for the effort.

Quoted 45 lines

for kdump kernel, it can also be used for other kind of memory ranges. In fact, KEXEC_FILE_LOAD syscall in powerpc uses this structure to represent reserved memory ranges and exclude memory ranges needed to find the right memory regions to load kexec kernel. So, make the definition of crash_mem structure available for !CONFIG_CRASH_DUMP case too.

---
 include/linux/crash_core.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/crash_core.h +6 -6
index 23270b16e1db..d33352c2e386 100644
@@ -8,6 +8,12 @@
 
 struct kimage;
 
+struct crash_mem {
+	unsigned int max_nr_ranges;
+	unsigned int nr_ranges;
+	struct range ranges[] __counted_by(max_nr_ranges);
+};
+
 #ifdef CONFIG_CRASH_DUMP
 
 int crash_shrink_memory(unsigned long new_size);
@@ -51,12 +57,6 @@ static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; }
 /* Alignment required for elf header segment */
 #define ELF_CORE_HEADER_ALIGN   4096
 
-struct crash_mem {
-	unsigned int max_nr_ranges;
-	unsigned int nr_ranges;
-	struct range ranges[] __counted_by(max_nr_ranges);
-};
-
 extern int crash_exclude_mem_range(struct crash_mem *mem,
 				   unsigned long long mstart,
 				   unsigned long long mend);
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH linux-next 3/3] powerpc/kdump: Split KEXEC_CORE and CRASH_DUMP dependency

In reply to Hari Bathini

Hello Hari,

Build failure detected.

Quoted 243 lines · Hari Bathini

Remove CONFIG_CRASH_DUMP dependency on CONFIG_KEXEC. CONFIG_KEXEC_CORE was used at places where CONFIG_CRASH_DUMP or CONFIG_CRASH_RESERVE was appropriate. Replace with appropriate #ifdefs to support CONFIG_KEXEC and !CONFIG_CRASH_DUMP configuration option. Also, make CONFIG_FA_DUMP dependent on CONFIG_CRASH_DUMP to avoid unmet dependencies for FA_DUMP with !CONFIG_KEXEC_CORE configuration option.

---
  arch/powerpc/Kconfig               |  9 +--
  arch/powerpc/include/asm/kexec.h   | 98 +++++++++++++++---------------
  arch/powerpc/kernel/prom.c         |  2 +-
  arch/powerpc/kernel/setup-common.c |  2 +-
  arch/powerpc/kernel/smp.c          |  4 +-
  arch/powerpc/kexec/Makefile        |  3 +-
  arch/powerpc/kexec/core.c          |  4 ++
  7 files changed, 60 insertions(+), 62 deletions(-)
arch/powerpc/Kconfig +1 -8
index 5cf8ad8d7e8e..e377deefa2dc 100644
@@ -607,11 +607,6 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
  config ARCH_SUPPORTS_KEXEC
  	def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
 
-config ARCH_SELECTS_KEXEC
-	def_bool y
-	depends on KEXEC
-	select CRASH_DUMP
-
  config ARCH_SUPPORTS_KEXEC_FILE
  	def_bool PPC64
 
@@ -622,7 +617,6 @@ config ARCH_SELECTS_KEXEC_FILE
  	def_bool y
  	depends on KEXEC_FILE
  	select KEXEC_ELF
-	select CRASH_DUMP
  	select HAVE_IMA_KEXEC if IMA
 
  config PPC64_BIG_ENDIAN_ELF_ABI_V2
@@ -694,8 +688,7 @@ config ARCH_SELECTS_CRASH_DUMP
 
  config FA_DUMP
  	bool "Firmware-assisted dump"
-	depends on PPC64 && (PPC_RTAS || PPC_POWERNV)
-	select CRASH_DUMP
+	depends on CRASH_DUMP && PPC64 && (PPC_RTAS || PPC_POWERNV)
  	help
  	  A robust mechanism to get reliable kernel crash dump with
  	  assistance from firmware. This approach does not use kexec,
arch/powerpc/include/asm/kexec.h +49 -49
index e1b43aa12175..fdb90e24dc74 100644
@@ -55,59 +55,18 @@
  typedef void (*crash_shutdown_t)(void);
 
  #ifdef CONFIG_KEXEC_CORE
-
-/*
- * This function is responsible for capturing register states if coming
- * via panic or invoking dump using sysrq-trigger.
- */
-static inline void crash_setup_regs(struct pt_regs *newregs,
-					struct pt_regs *oldregs)
-{
-	if (oldregs)
-		memcpy(newregs, oldregs, sizeof(*newregs));
-	else
-		ppc_save_regs(newregs);
-}
+struct kimage;
+struct pt_regs;
 
  extern void kexec_smp_wait(void);	/* get and clear naca physid, wait for
  					  master to copy new code to 0 */
-extern int crashing_cpu;
-extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *));
-extern void crash_ipi_callback(struct pt_regs *);
-extern int crash_wake_offline;
-
-struct kimage;
-struct pt_regs;
  extern void default_machine_kexec(struct kimage *image);
-extern void default_machine_crash_shutdown(struct pt_regs *regs);
-extern int crash_shutdown_register(crash_shutdown_t handler);
-extern int crash_shutdown_unregister(crash_shutdown_t handler);
-
-extern void crash_kexec_prepare(void);
-extern void crash_kexec_secondary(struct pt_regs *regs);
-int __init overlaps_crashkernel(unsigned long start, unsigned long size);
-extern void reserve_crashkernel(void);
  extern void machine_kexec_mask_interrupts(void);
 
-static inline bool kdump_in_progress(void)
-{
-	return crashing_cpu >= 0;
-}
-
  void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_code_buffer,
  			 unsigned long start_address) __noreturn;
-
  void kexec_copy_flush(struct kimage *image);
 
-#if defined(CONFIG_CRASH_DUMP)
-bool is_kdump_kernel(void);
-#define is_kdump_kernel			is_kdump_kernel
-#if defined(CONFIG_PPC_RTAS)
-void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
-#define crash_free_reserved_phys_range crash_free_reserved_phys_range
-#endif /* CONFIG_PPC_RTAS */
-#endif /* CONFIG_CRASH_DUMP */
-
  #ifdef CONFIG_KEXEC_FILE
  extern const struct kexec_file_ops kexec_elf64_ops;
 
@@ -152,15 +111,56 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
 
  #endif /* CONFIG_KEXEC_FILE */
 
-#else /* !CONFIG_KEXEC_CORE */
-static inline void crash_kexec_secondary(struct pt_regs *regs) { }
+#endif /* CONFIG_KEXEC_CORE */
+
+#ifdef CONFIG_CRASH_RESERVE
+int __init overlaps_crashkernel(unsigned long start, unsigned long size);
+extern void reserve_crashkernel(void);
+#else
+static inline void reserve_crashkernel(void) {}
+static inline int overlaps_crashkernel(unsigned long start, unsigned long size) { return 0; }
+#endif
 
-static inline int overlaps_crashkernel(unsigned long start, unsigned long size)
+#if defined(CONFIG_CRASH_DUMP)
+/*
+ * This function is responsible for capturing register states if coming
+ * via panic or invoking dump using sysrq-trigger.
+ */
+static inline void crash_setup_regs(struct pt_regs *newregs,
+					struct pt_regs *oldregs)
  {
-	return 0;
+	if (oldregs)
+		memcpy(newregs, oldregs, sizeof(*newregs));
+	else
+		ppc_save_regs(newregs);
+}
+
+extern int crashing_cpu;
+extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *));
+extern void crash_ipi_callback(struct pt_regs *regs);
+extern int crash_wake_offline;
+
+extern int crash_shutdown_register(crash_shutdown_t handler);
+extern int crash_shutdown_unregister(crash_shutdown_t handler);
+extern void default_machine_crash_shutdown(struct pt_regs *regs);
+
+extern void crash_kexec_prepare(void);
+extern void crash_kexec_secondary(struct pt_regs *regs);
+
+static inline bool kdump_in_progress(void)
+{
+	return crashing_cpu >= 0;
  }
 
-static inline void reserve_crashkernel(void) { ; }
+bool is_kdump_kernel(void);
+#define is_kdump_kernel			is_kdump_kernel
+#if defined(CONFIG_PPC_RTAS)
+void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
+#define crash_free_reserved_phys_range crash_free_reserved_phys_range
+#endif /* CONFIG_PPC_RTAS */
+
+#else /* !CONFIG_CRASH_DUMP */
+static inline void crash_kexec_secondary(struct pt_regs *regs) { }
 
  static inline int crash_shutdown_register(crash_shutdown_t handler)
  {
@@ -183,7 +183,7 @@ static inline void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
  {
  }
 
-#endif /* CONFIG_KEXEC_CORE */
+#endif /* CONFIG_CRASH_DUMP */
 
  #ifdef CONFIG_PPC_BOOK3S_64
  #include <asm/book3s/64/kexec.h>
arch/powerpc/kernel/prom.c +1 -1
index 0b5878c3125b..1edc34b711ba 100644
@@ -453,7 +453,7 @@ static int __init early_init_dt_scan_chosen_ppc(unsigned long node,
  		tce_alloc_end = *lprop;
  #endif
 
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_RESERVE
  	lprop = of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
  	if (lprop)
  		crashk_res.start = *lprop;
arch/powerpc/kernel/setup-common.c +1 -1
index 733f210ffda1..35cac3eaaf75 100644
@@ -109,7 +109,7 @@ int ppc_do_canonicalize_irqs;
  EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
  #endif
 
-#ifdef CONFIG_VMCORE_INFO
+#ifdef CONFIG_CRASH_DUMP
  /* This keeps a track of which one is the crashing cpu. */
  int crashing_cpu = -1;
  #endif
arch/powerpc/kernel/smp.c +2 -2
index 693334c20d07..aa81c95c73a4 100644
@@ -588,7 +588,7 @@ void smp_send_debugger_break(void)
  }
  #endif
 
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_DUMP
  void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
  {
  	int cpu;
@@ -631,7 +631,7 @@ void crash_smp_send_stop(void)
 
  	stopped = true;
 
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_DUMP
  	if (kexec_crash_image) {
  		crash_kexec_prepare();
  		return;
arch/powerpc/kexec/Makefile +0 -0
index 91e96f5168b7..8e469c4da3f8 100644
@@ -3,12 +3,13 @@
  # Makefile for the linux kernel.

arch/powerpc/kexec/Makefile line 12

Quoted 10 lines
arch/powerpc/kexec/Makefile +2 -1
  #
 
-obj-y				+= core.o crash.o core_$(BITS).o
+obj-y				+= core.o core_$(BITS).o
 
  obj-$(CONFIG_PPC32)		+= relocate_32.o
 
  obj-$(CONFIG_KEXEC_FILE)	+= file_load.o ranges.o file_load_$(BITS).o elf_$(BITS).o
  obj-$(CONFIG_VMCORE_INFO)	+= vmcore_info.o
+obj-$(CONFIG_CRASH_DUMP)	+= crash.o

Observed a build failure with this patch.

arch/powerpc/platforms/powernv/smp.c: In function ‘pnv_smp_init’:
arch/powerpc/platforms/powernv/smp.c:438:2: error: ‘crash_wake_offline’ undeclared (first use in this function); did you mean ‘cpu_is_offline’? crash_wake_offline = 1;
  ^~~~~~~~~~~~~~~~~~
  cpu_is_offline
arch/powerpc/platforms/powernv/smp.c:438:2: note: each undeclared identifier is reported only once for each function it appears in make[5]: *** [scripts/Makefile.build:244: arch/powerpc/platforms/powernv/smp.o] Error 1

CONFIG:

CONFIG_KEXEC=y
CONFIG_KEXEC_FILE=y
# CONFIG_CRASH_DUMP is not set

Below changes fixes the above issue:

arch/powerpc/platforms/powernv/smp.c +0 -0
index 9e1a25398f98..8f14f0581a21 100644
@@ -434,7 +434,7 @@ void __init pnv_smp_init(void)

        smp_ops = &pnv_smp_ops;

 #ifdef CONFIG_HOTPLUG_CPU
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_DUMP
        crash_wake_offline = 1;
 #endif
 #endif

Thanks,
Sourabh

Quoted 33 lines
arch/powerpc/kexec/Makefile +0 -0
  # Disable GCOV, KCOV & sanitizers in odd or sensitive code
  GCOV_PROFILE_core_$(BITS).o := n
arch/powerpc/kexec/core.c +4 -0
index 3ff4411ed496..b8333a49ea5d 100644
@@ -44,10 +44,12 @@ void machine_kexec_mask_interrupts(void) {
  	}
  }
 
+#ifdef CONFIG_CRASH_DUMP
  void machine_crash_shutdown(struct pt_regs *regs)
  {
  	default_machine_crash_shutdown(regs);
  }
+#endif
 
  void machine_kexec_cleanup(struct kimage *image)
  {
@@ -77,6 +79,7 @@ void machine_kexec(struct kimage *image)
  	for(;;);
  }
 
+#ifdef CONFIG_CRASH_RESERVE
  void __init reserve_crashkernel(void)
  {
  	unsigned long long crash_size, crash_base, total_mem_sz;
@@ -251,3 +254,4 @@ static int __init kexec_setup(void)
  	return 0;
  }
  late_initcall(kexec_setup);
+#endif /* CONFIG_CRASH_RESERVE */
#6 lore raw

Re: [PATCH linux-next 3/3] powerpc/kdump: Split KEXEC_CORE and CRASH_DUMP dependency

Quoted 1 line · Sourabh Jain

Hello Hari,

Hi Sourabh,

Quoted 2 lines

Build failure detected.

Thanks for trying out the patches.

Quoted 267 lines · Hari Bathini
Quoted 236 lines

Remove CONFIG_CRASH_DUMP dependency on CONFIG_KEXEC. CONFIG_KEXEC_CORE was used at places where CONFIG_CRASH_DUMP or CONFIG_CRASH_RESERVE was appropriate. Replace with appropriate #ifdefs to support CONFIG_KEXEC and !CONFIG_CRASH_DUMP configuration option. Also, make CONFIG_FA_DUMP dependent on CONFIG_CRASH_DUMP to avoid unmet dependencies for FA_DUMP with !CONFIG_KEXEC_CORE configuration option.

---
  arch/powerpc/Kconfig               |  9 +-- arch/powerpc/include/asm/kexec.h   | 98 +++++++++++++++--------------- arch/powerpc/kernel/prom.c         |  2 +- arch/powerpc/kernel/setup-common.c |  2 +- arch/powerpc/kernel/smp.c          |  4 +- arch/powerpc/kexec/Makefile        |  3 +- arch/powerpc/kexec/core.c          |  4 ++

  7 files changed, 60 insertions(+), 62 deletions(-)
arch/powerpc/Kconfig +0 -0
index 5cf8ad8d7e8e..e377deefa2dc 100644
@@ -607,11 +607,6 @@ config PPC64_SUPPORTS_MEMORY_FAILURE

  config ARCH_SUPPORTS_KEXEC
      def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)

arch/powerpc/Kconfig +0 -5
-config ARCH_SELECTS_KEXEC
-    def_bool y
-    depends on KEXEC
-    select CRASH_DUMP
-

  config ARCH_SUPPORTS_KEXEC_FILE
      def_bool PPC64

arch/powerpc/Kconfig +0 -0
@@ -622,7 +617,6 @@ config ARCH_SELECTS_KEXEC_FILE

      def_bool y
      depends on KEXEC_FILE
      select KEXEC_ELF
-    select CRASH_DUMP
      select HAVE_IMA_KEXEC if IMA
  config PPC64_BIG_ENDIAN_ELF_ABI_V2

arch/powerpc/Kconfig +0 -0
@@ -694,8 +688,7 @@ config ARCH_SELECTS_CRASH_DUMP

  config FA_DUMP
      bool "Firmware-assisted dump"
-    depends on PPC64 && (PPC_RTAS || PPC_POWERNV)
-    select CRASH_DUMP
+    depends on CRASH_DUMP && PPC64 && (PPC_RTAS || PPC_POWERNV) help
        A robust mechanism to get reliable kernel crash dump with assistance from firmware. This approach does not use kexec,

arch/powerpc/include/asm/kexec.h +2 -13
index e1b43aa12175..fdb90e24dc74 100644
@@ -55,59 +55,18 @@
   typedef void (*crash_shutdown_t)(void);
   #ifdef CONFIG_KEXEC_CORE
-
-/*
- * This function is responsible for capturing register states if coming
- * via panic or invoking dump using sysrq-trigger.
- */
-static inline void crash_setup_regs(struct pt_regs *newregs,
-                    struct pt_regs *oldregs)
-{
-    if (oldregs)
-        memcpy(newregs, oldregs, sizeof(*newregs));
-    else
-        ppc_save_regs(newregs);
-}
+struct kimage;
+struct pt_regs;

  extern void kexec_smp_wait(void);    /* get and clear naca physid, wait for master to copy new code to 0 */

arch/powerpc/include/asm/kexec.h +0 -2
-extern int crashing_cpu;
-extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs 

*));

arch/powerpc/include/asm/kexec.h +0 -5
-extern void crash_ipi_callback(struct pt_regs *);
-extern int crash_wake_offline;
-
-struct kimage;
-struct pt_regs;

  extern void default_machine_kexec(struct kimage *image);

arch/powerpc/include/asm/kexec.h +0 -7
-extern void default_machine_crash_shutdown(struct pt_regs *regs);
-extern int crash_shutdown_register(crash_shutdown_t handler);
-extern int crash_shutdown_unregister(crash_shutdown_t handler);
-
-extern void crash_kexec_prepare(void);
-extern void crash_kexec_secondary(struct pt_regs *regs);
-int __init overlaps_crashkernel(unsigned long start, unsigned long 

size);
-extern void reserve_crashkernel(void); extern void machine_kexec_mask_interrupts(void);

arch/powerpc/include/asm/kexec.h +0 -5
-static inline bool kdump_in_progress(void)
-{
-    return crashing_cpu >= 0;
-}
-

  void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_code_buffer, unsigned long start_address) __noreturn;
-
  void kexec_copy_flush(struct kimage *image);

arch/powerpc/include/asm/kexec.h +0 -5
-#if defined(CONFIG_CRASH_DUMP)
-bool is_kdump_kernel(void);
-#define is_kdump_kernel            is_kdump_kernel
-#if defined(CONFIG_PPC_RTAS)
-void crash_free_reserved_phys_range(unsigned long begin, unsigned 

long end);

arch/powerpc/include/asm/kexec.h +0 -4
-#define crash_free_reserved_phys_range crash_free_reserved_phys_range
-#endif /* CONFIG_PPC_RTAS */
-#endif /* CONFIG_CRASH_DUMP */
-

  #ifdef CONFIG_KEXEC_FILE
  extern const struct kexec_file_ops kexec_elf64_ops;

arch/powerpc/include/asm/kexec.h +46 -5
@@ -152,15 +111,56 @@ int setup_new_fdt_ppc64(const struct kimage 
 *image, void *fdt,
   #endif /* CONFIG_KEXEC_FILE */
-#else /* !CONFIG_KEXEC_CORE */
-static inline void crash_kexec_secondary(struct pt_regs *regs) { }
+#endif /* CONFIG_KEXEC_CORE */
+
+#ifdef CONFIG_CRASH_RESERVE
+int __init overlaps_crashkernel(unsigned long start, unsigned long 
 size);
+extern void reserve_crashkernel(void);
+#else
+static inline void reserve_crashkernel(void) {}
+static inline int overlaps_crashkernel(unsigned long start, unsigned 
 long size) { return 0; }
+#endif
-static inline int overlaps_crashkernel(unsigned long start, unsigned 
 long size)
+#if defined(CONFIG_CRASH_DUMP)
+/*
+ * This function is responsible for capturing register states if coming
+ * via panic or invoking dump using sysrq-trigger.
+ */
+static inline void crash_setup_regs(struct pt_regs *newregs,
+                    struct pt_regs *oldregs)
   {
-    return 0;
+    if (oldregs)
+        memcpy(newregs, oldregs, sizeof(*newregs));
+    else
+        ppc_save_regs(newregs);
+}
+
+extern int crashing_cpu;
+extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs 
 *));
+extern void crash_ipi_callback(struct pt_regs *regs);
+extern int crash_wake_offline;
+
+extern int crash_shutdown_register(crash_shutdown_t handler);
+extern int crash_shutdown_unregister(crash_shutdown_t handler);
+extern void default_machine_crash_shutdown(struct pt_regs *regs);
+
+extern void crash_kexec_prepare(void);
+extern void crash_kexec_secondary(struct pt_regs *regs);
+
+static inline bool kdump_in_progress(void)
+{
+    return crashing_cpu >= 0;
   }
-static inline void reserve_crashkernel(void) { ; }
+bool is_kdump_kernel(void);
+#define is_kdump_kernel            is_kdump_kernel
+#if defined(CONFIG_PPC_RTAS)
+void crash_free_reserved_phys_range(unsigned long begin, unsigned 
 long end);
+#define crash_free_reserved_phys_range crash_free_reserved_phys_range
+#endif /* CONFIG_PPC_RTAS */
+
+#else /* !CONFIG_CRASH_DUMP */
+static inline void crash_kexec_secondary(struct pt_regs *regs) { }
   static inline int crash_shutdown_register(crash_shutdown_t handler)

  {

arch/powerpc/include/asm/kexec.h +1 -1
@@ -183,7 +183,7 @@ static inline void crash_send_ipi(void 
 (*crash_ipi_callback)(struct pt_regs *))
   {
   }
-#endif /* CONFIG_KEXEC_CORE */
+#endif /* CONFIG_CRASH_DUMP */
   #ifdef CONFIG_PPC_BOOK3S_64
   #include <asm/book3s/64/kexec.h>
arch/powerpc/kernel/prom.c +1 -1
index 0b5878c3125b..1edc34b711ba 100644
@@ -453,7 +453,7 @@ static int __init 
 early_init_dt_scan_chosen_ppc(unsigned long node,
           tce_alloc_end = *lprop;
   #endif
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_RESERVE
       lprop = of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
       if (lprop)
           crashk_res.start = *lprop;
arch/powerpc/kernel/setup-common.c +1 -1
index 733f210ffda1..35cac3eaaf75 100644
@@ -109,7 +109,7 @@ int ppc_do_canonicalize_irqs;
   EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
   #endif
-#ifdef CONFIG_VMCORE_INFO
+#ifdef CONFIG_CRASH_DUMP
   /* This keeps a track of which one is the crashing cpu. */
   int crashing_cpu = -1;
   #endif
arch/powerpc/kernel/smp.c +2 -2
index 693334c20d07..aa81c95c73a4 100644
@@ -588,7 +588,7 @@ void smp_send_debugger_break(void)
   }
   #endif
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_DUMP
   void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
   {
       int cpu;
@@ -631,7 +631,7 @@ void crash_smp_send_stop(void)
       stopped = true;
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_DUMP
       if (kexec_crash_image) {
           crash_kexec_prepare();
           return;
arch/powerpc/kexec/Makefile +1 -1
index 91e96f5168b7..8e469c4da3f8 100644
@@ -3,12 +3,13 @@
   # Makefile for the linux kernel.
   #
-obj-y                += core.o crash.o core_$(BITS).o
+obj-y                += core.o core_$(BITS).o
Quoted 4 lines

  obj-$(CONFIG_PPC32)        += relocate_32.o
  obj-$(CONFIG_KEXEC_FILE)    += file_load.o ranges.o file_load_$(BITS).o elf_$(BITS).o obj-$(CONFIG_VMCORE_INFO)    += vmcore_info.o
+obj-$(CONFIG_CRASH_DUMP)    += crash.o

Observed a build failure with this patch.

arch/powerpc/platforms/powernv/smp.c: In function ‘pnv_smp_init’:
arch/powerpc/platforms/powernv/smp.c:438:2: error: ‘crash_wake_offline’ undeclared (first use in this function); did you mean ‘cpu_is_offline’?
  crash_wake_offline = 1;
  ^~~~~~~~~~~~~~~~~~
  cpu_is_offline
arch/powerpc/platforms/powernv/smp.c:438:2: note: each undeclared identifier is reported only once for each function it appears in make[5]: *** [scripts/Makefile.build:244: arch/powerpc/platforms/powernv/smp.o] Error 1

CONFIG:

CONFIG_KEXEC=y
CONFIG_KEXEC_FILE=y
# CONFIG_CRASH_DUMP is not set

Below changes fixes the above issue:

arch/powerpc/platforms/powernv/smp.c +0 -0
index 9e1a25398f98..8f14f0581a21 100644

arch/powerpc/platforms/powernv/smp.c void __init pnv_smp_init(void) · line 440

Quoted 8 lines
arch/powerpc/platforms/powernv/smp.c +1 -1
@@ -434,7 +434,7 @@ void __init pnv_smp_init(void)
         smp_ops = &pnv_smp_ops;
 
  #ifdef CONFIG_HOTPLUG_CPU
-#ifdef CONFIG_KEXEC_CORE
+#ifdef CONFIG_CRASH_DUMP
         crash_wake_offline = 1;
  #endif
  #endif

Right. Missed testing with CONFIG_PPC_POWERNV.
Will post v2.

Thanks
Hari

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec