All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next v3 08/14] ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP
  2024-01-24  5:12 [PATCH linux-next v3 00/14] Split crash out from kexec and clean up related config items Baoquan He
                     ` (2 preceding siblings ...)
  (?)
@ 2024-01-24  5:12   ` Baoquan He
  0 siblings, 0 replies; 6+ messages in thread
From: Baoquan He @ 2024-01-24  5:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: kexec, x86, linux-arm-kernel, linuxppc-dev, linux-s390, linux-sh,
	linux-mips, linux-riscv, loongarch, akpm, ebiederm, hbathini,
	piliu, viro, Baoquan He

In PowerPC, the crash dumping and kexec reboot share code in
arch_kexec_locate_mem_hole(), in which struct crash_mem is used.

Here enfoce enforce KEXEC and KEXEC_FILE to select CRASH_DUMP for now.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 arch/powerpc/Kconfig | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e66fd9923250..31f013e636e3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -608,6 +608,10 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
 config ARCH_SUPPORTS_KEXEC
 	def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
 
+config ARCH_SELECTS_KEXEC
+	def_bool y
+	select CRASH_DUMP
+
 config ARCH_SUPPORTS_KEXEC_FILE
 	def_bool PPC64
 
@@ -618,6 +622,7 @@ 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
-- 
2.41.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH linux-next v3 08/14] ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP
@ 2024-01-24  5:12   ` Baoquan He
  0 siblings, 0 replies; 6+ messages in thread
From: Baoquan He @ 2024-01-24  5:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: kexec, x86, linux-arm-kernel, linuxppc-dev, linux-s390, linux-sh,
	linux-mips, linux-riscv, loongarch, akpm, ebiederm, hbathini,
	piliu, viro, Baoquan He

In PowerPC, the crash dumping and kexec reboot share code in
arch_kexec_locate_mem_hole(), in which struct crash_mem is used.

Here enfoce enforce KEXEC and KEXEC_FILE to select CRASH_DUMP for now.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 arch/powerpc/Kconfig | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e66fd9923250..31f013e636e3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -608,6 +608,10 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
 config ARCH_SUPPORTS_KEXEC
 	def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
 
+config ARCH_SELECTS_KEXEC
+	def_bool y
+	select CRASH_DUMP
+
 config ARCH_SUPPORTS_KEXEC_FILE
 	def_bool PPC64
 
@@ -618,6 +622,7 @@ 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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH linux-next v3 08/14] ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP
@ 2024-01-24  5:12   ` Baoquan He
  0 siblings, 0 replies; 6+ messages in thread
From: Baoquan He @ 2024-01-24  5:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: kexec, x86, linux-arm-kernel, linuxppc-dev, linux-s390, linux-sh,
	linux-mips, linux-riscv, loongarch, akpm, ebiederm, hbathini,
	piliu, viro, Baoquan He

In PowerPC, the crash dumping and kexec reboot share code in
arch_kexec_locate_mem_hole(), in which struct crash_mem is used.

Here enfoce enforce KEXEC and KEXEC_FILE to select CRASH_DUMP for now.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 arch/powerpc/Kconfig | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e66fd9923250..31f013e636e3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -608,6 +608,10 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
 config ARCH_SUPPORTS_KEXEC
 	def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
 
+config ARCH_SELECTS_KEXEC
+	def_bool y
+	select CRASH_DUMP
+
 config ARCH_SUPPORTS_KEXEC_FILE
 	def_bool PPC64
 
@@ -618,6 +622,7 @@ 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
-- 
2.41.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH linux-next v3 08/14] ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP
@ 2024-01-24  5:12   ` Baoquan He
  0 siblings, 0 replies; 6+ messages in thread
From: Baoquan He @ 2024-01-24  5:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-s390, Baoquan He, piliu, linux-sh, x86, kexec, linux-mips,
	ebiederm, loongarch, hbathini, linux-riscv, linuxppc-dev, akpm,
	linux-arm-kernel, viro

In PowerPC, the crash dumping and kexec reboot share code in
arch_kexec_locate_mem_hole(), in which struct crash_mem is used.

Here enfoce enforce KEXEC and KEXEC_FILE to select CRASH_DUMP for now.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 arch/powerpc/Kconfig | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e66fd9923250..31f013e636e3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -608,6 +608,10 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
 config ARCH_SUPPORTS_KEXEC
 	def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
 
+config ARCH_SELECTS_KEXEC
+	def_bool y
+	select CRASH_DUMP
+
 config ARCH_SUPPORTS_KEXEC_FILE
 	def_bool PPC64
 
@@ -618,6 +622,7 @@ 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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH linux-next v3 08/14] ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP
@ 2024-01-24  5:12   ` Baoquan He
  0 siblings, 0 replies; 6+ messages in thread
From: Baoquan He @ 2024-01-24  5:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: kexec, x86, linux-arm-kernel, linuxppc-dev, linux-s390, linux-sh,
	linux-mips, linux-riscv, loongarch, akpm, ebiederm, hbathini,
	piliu, viro, Baoquan He

In PowerPC, the crash dumping and kexec reboot share code in
arch_kexec_locate_mem_hole(), in which struct crash_mem is used.

Here enfoce enforce KEXEC and KEXEC_FILE to select CRASH_DUMP for now.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 arch/powerpc/Kconfig | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e66fd9923250..31f013e636e3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -608,6 +608,10 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
 config ARCH_SUPPORTS_KEXEC
 	def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
 
+config ARCH_SELECTS_KEXEC
+	def_bool y
+	select CRASH_DUMP
+
 config ARCH_SUPPORTS_KEXEC_FILE
 	def_bool PPC64
 
@@ -618,6 +622,7 @@ 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
-- 
2.41.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH linux-next v3 08/14] ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP
@ 2024-01-27 11:51 kernel test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2024-01-27 11:51 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "only kconfig file changed"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20240124051254.67105-9-bhe@redhat.com>
References: <20240124051254.67105-9-bhe@redhat.com>
TO: Baoquan He <bhe@redhat.com>

Hi Baoquan,

kernel test robot noticed the following build errors:

[auto build test ERROR on next-20240123]

url:    https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec-split-crashkernel-reservation-code-out-from-crash_core-c/20240124-131952
base:   next-20240123
patch link:    https://lore.kernel.org/r/20240124051254.67105-9-bhe%40redhat.com
patch subject: [PATCH linux-next v3 08/14] ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: powerpc-allnoconfig (https://download.01.org/0day-ci/archive/20240127/202401271906.ORpeFe0T-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240127/202401271906.ORpeFe0T-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202401271906.ORpeFe0T-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   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: warning: control reaches end of non-void function [-Wreturn-type]
      95 | }
         | ^
   cc1: some warnings being treated as errors
--
>> 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)
         |                    ^~~~~~~~~~~~~~~

Kconfig warnings: (for reference only)
   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]


vim +43 kernel/crash_core.c

636be0013152f6 Baoquan He 2024-01-24   35  
636be0013152f6 Baoquan He 2024-01-24   36  int kimage_crash_copy_vmcoreinfo(struct kimage *image)
636be0013152f6 Baoquan He 2024-01-24   37  {
636be0013152f6 Baoquan He 2024-01-24   38  	struct page *vmcoreinfo_page;
636be0013152f6 Baoquan He 2024-01-24   39  	void *safecopy;
636be0013152f6 Baoquan He 2024-01-24   40  
636be0013152f6 Baoquan He 2024-01-24   41  	if (!IS_ENABLED(CONFIG_CRASH_DUMP))
636be0013152f6 Baoquan He 2024-01-24   42  		return 0;
636be0013152f6 Baoquan He 2024-01-24  @43  	if (image->type != KEXEC_TYPE_CRASH)
636be0013152f6 Baoquan He 2024-01-24   44  		return 0;
636be0013152f6 Baoquan He 2024-01-24   45  
636be0013152f6 Baoquan He 2024-01-24   46  	/*
636be0013152f6 Baoquan He 2024-01-24   47  	 * For kdump, allocate one vmcoreinfo safe copy from the
636be0013152f6 Baoquan He 2024-01-24   48  	 * crash memory. as we have arch_kexec_protect_crashkres()
636be0013152f6 Baoquan He 2024-01-24   49  	 * after kexec syscall, we naturally protect it from write
636be0013152f6 Baoquan He 2024-01-24   50  	 * (even read) access under kernel direct mapping. But on
636be0013152f6 Baoquan He 2024-01-24   51  	 * the other hand, we still need to operate it when crash
636be0013152f6 Baoquan He 2024-01-24   52  	 * happens to generate vmcoreinfo note, hereby we rely on
636be0013152f6 Baoquan He 2024-01-24   53  	 * vmap for this purpose.
636be0013152f6 Baoquan He 2024-01-24   54  	 */
636be0013152f6 Baoquan He 2024-01-24  @55  	vmcoreinfo_page = kimage_alloc_control_pages(image, 0);
636be0013152f6 Baoquan He 2024-01-24   56  	if (!vmcoreinfo_page) {
636be0013152f6 Baoquan He 2024-01-24   57  		pr_warn("Could not allocate vmcoreinfo buffer\n");
636be0013152f6 Baoquan He 2024-01-24   58  		return -ENOMEM;
636be0013152f6 Baoquan He 2024-01-24   59  	}
636be0013152f6 Baoquan He 2024-01-24   60  	safecopy = vmap(&vmcoreinfo_page, 1, VM_MAP, PAGE_KERNEL);
636be0013152f6 Baoquan He 2024-01-24   61  	if (!safecopy) {
636be0013152f6 Baoquan He 2024-01-24   62  		pr_warn("Could not vmap vmcoreinfo buffer\n");
636be0013152f6 Baoquan He 2024-01-24   63  		return -ENOMEM;
636be0013152f6 Baoquan He 2024-01-24   64  	}
636be0013152f6 Baoquan He 2024-01-24   65  
636be0013152f6 Baoquan He 2024-01-24   66  	image->vmcoreinfo_data_copy = safecopy;
636be0013152f6 Baoquan He 2024-01-24   67  	crash_update_vmcoreinfo_safecopy(safecopy);
636be0013152f6 Baoquan He 2024-01-24   68  
636be0013152f6 Baoquan He 2024-01-24   69  	return 0;
636be0013152f6 Baoquan He 2024-01-24   70  }
636be0013152f6 Baoquan He 2024-01-24   71  
636be0013152f6 Baoquan He 2024-01-24   72  
636be0013152f6 Baoquan He 2024-01-24   73  
636be0013152f6 Baoquan He 2024-01-24  @74  int kexec_should_crash(struct task_struct *p)
636be0013152f6 Baoquan He 2024-01-24   75  {
636be0013152f6 Baoquan He 2024-01-24   76  	/*
636be0013152f6 Baoquan He 2024-01-24   77  	 * If crash_kexec_post_notifiers is enabled, don't run
636be0013152f6 Baoquan He 2024-01-24   78  	 * crash_kexec() here yet, which must be run after panic
636be0013152f6 Baoquan He 2024-01-24   79  	 * notifiers in panic().
636be0013152f6 Baoquan He 2024-01-24   80  	 */
636be0013152f6 Baoquan He 2024-01-24   81  	if (crash_kexec_post_notifiers)
636be0013152f6 Baoquan He 2024-01-24   82  		return 0;
636be0013152f6 Baoquan He 2024-01-24   83  	/*
636be0013152f6 Baoquan He 2024-01-24   84  	 * There are 4 panic() calls in make_task_dead() path, each of which
636be0013152f6 Baoquan He 2024-01-24   85  	 * corresponds to each of these 4 conditions.
636be0013152f6 Baoquan He 2024-01-24   86  	 */
636be0013152f6 Baoquan He 2024-01-24   87  	if (in_interrupt() || !p->pid || is_global_init(p) || panic_on_oops)
636be0013152f6 Baoquan He 2024-01-24   88  		return 1;
636be0013152f6 Baoquan He 2024-01-24   89  	return 0;
636be0013152f6 Baoquan He 2024-01-24   90  }
636be0013152f6 Baoquan He 2024-01-24   91  
636be0013152f6 Baoquan He 2024-01-24  @92  int kexec_crash_loaded(void)
636be0013152f6 Baoquan He 2024-01-24   93  {
636be0013152f6 Baoquan He 2024-01-24  @94  	return !!kexec_crash_image;
636be0013152f6 Baoquan He 2024-01-24  @95  }
636be0013152f6 Baoquan He 2024-01-24   96  EXPORT_SYMBOL_GPL(kexec_crash_loaded);
636be0013152f6 Baoquan He 2024-01-24   97  
636be0013152f6 Baoquan He 2024-01-24   98  /*
636be0013152f6 Baoquan He 2024-01-24   99   * No panic_cpu check version of crash_kexec().  This function is called
636be0013152f6 Baoquan He 2024-01-24  100   * only when panic_cpu holds the current CPU number; this is the only CPU
636be0013152f6 Baoquan He 2024-01-24  101   * which processes crash_kexec routines.
636be0013152f6 Baoquan He 2024-01-24  102   */
636be0013152f6 Baoquan He 2024-01-24 @103  void __noclone __crash_kexec(struct pt_regs *regs)
636be0013152f6 Baoquan He 2024-01-24  104  {
636be0013152f6 Baoquan He 2024-01-24  105  	/* Take the kexec_lock here to prevent sys_kexec_load
636be0013152f6 Baoquan He 2024-01-24  106  	 * running on one cpu from replacing the crash kernel
636be0013152f6 Baoquan He 2024-01-24  107  	 * we are using after a panic on a different cpu.
636be0013152f6 Baoquan He 2024-01-24  108  	 *
636be0013152f6 Baoquan He 2024-01-24  109  	 * If the crash kernel was not located in a fixed area
636be0013152f6 Baoquan He 2024-01-24  110  	 * of memory the xchg(&kexec_crash_image) would be
636be0013152f6 Baoquan He 2024-01-24  111  	 * sufficient.  But since I reuse the memory...
636be0013152f6 Baoquan He 2024-01-24  112  	 */
636be0013152f6 Baoquan He 2024-01-24  113  	if (kexec_trylock()) {
636be0013152f6 Baoquan He 2024-01-24  114  		if (kexec_crash_image) {
636be0013152f6 Baoquan He 2024-01-24  115  			struct pt_regs fixed_regs;
636be0013152f6 Baoquan He 2024-01-24  116  
636be0013152f6 Baoquan He 2024-01-24 @117  			crash_setup_regs(&fixed_regs, regs);
636be0013152f6 Baoquan He 2024-01-24  118  			crash_save_vmcoreinfo();
636be0013152f6 Baoquan He 2024-01-24  119  			machine_crash_shutdown(&fixed_regs);
636be0013152f6 Baoquan He 2024-01-24 @120  			machine_kexec(kexec_crash_image);
636be0013152f6 Baoquan He 2024-01-24  121  		}
636be0013152f6 Baoquan He 2024-01-24  122  		kexec_unlock();
636be0013152f6 Baoquan He 2024-01-24  123  	}
636be0013152f6 Baoquan He 2024-01-24  124  }
636be0013152f6 Baoquan He 2024-01-24  125  STACK_FRAME_NON_STANDARD(__crash_kexec);
636be0013152f6 Baoquan He 2024-01-24  126  
636be0013152f6 Baoquan He 2024-01-24 @127  __bpf_kfunc void crash_kexec(struct pt_regs *regs)
636be0013152f6 Baoquan He 2024-01-24 @128  {
636be0013152f6 Baoquan He 2024-01-24  129  	int old_cpu, this_cpu;
636be0013152f6 Baoquan He 2024-01-24  130  
636be0013152f6 Baoquan He 2024-01-24  131  	/*
636be0013152f6 Baoquan He 2024-01-24  132  	 * Only one CPU is allowed to execute the crash_kexec() code as with
636be0013152f6 Baoquan He 2024-01-24  133  	 * panic().  Otherwise parallel calls of panic() and crash_kexec()
636be0013152f6 Baoquan He 2024-01-24  134  	 * may stop each other.  To exclude them, we use panic_cpu here too.
636be0013152f6 Baoquan He 2024-01-24  135  	 */
636be0013152f6 Baoquan He 2024-01-24  136  	old_cpu = PANIC_CPU_INVALID;
636be0013152f6 Baoquan He 2024-01-24  137  	this_cpu = raw_smp_processor_id();
636be0013152f6 Baoquan He 2024-01-24  138  
636be0013152f6 Baoquan He 2024-01-24  139  	if (atomic_try_cmpxchg(&panic_cpu, &old_cpu, this_cpu)) {
636be0013152f6 Baoquan He 2024-01-24  140  		/* This is the 1st CPU which comes here, so go ahead. */
636be0013152f6 Baoquan He 2024-01-24  141  		__crash_kexec(regs);
636be0013152f6 Baoquan He 2024-01-24  142  
636be0013152f6 Baoquan He 2024-01-24  143  		/*
636be0013152f6 Baoquan He 2024-01-24  144  		 * Reset panic_cpu to allow another panic()/crash_kexec()
636be0013152f6 Baoquan He 2024-01-24  145  		 * call.
636be0013152f6 Baoquan He 2024-01-24  146  		 */
636be0013152f6 Baoquan He 2024-01-24  147  		atomic_set(&panic_cpu, PANIC_CPU_INVALID);
636be0013152f6 Baoquan He 2024-01-24  148  	}
636be0013152f6 Baoquan He 2024-01-24  149  }
636be0013152f6 Baoquan He 2024-01-24  150  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-27 11:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-27 11:51 [PATCH linux-next v3 08/14] ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2024-01-24  5:12 [PATCH linux-next v3 00/14] Split crash out from kexec and clean up related config items Baoquan He
2024-01-24  5:12 ` [PATCH linux-next v3 08/14] ppc, crash: enforce KEXEC and KEXEC_FILE to select CRASH_DUMP Baoquan He
2024-01-24  5:12   ` Baoquan He
2024-01-24  5:12   ` Baoquan He
2024-01-24  5:12   ` Baoquan He
2024-01-24  5:12   ` Baoquan He

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.