Skip to content

Commit 4db4221

Browse files
committed
Automatic merge of 'next' into merge (2024-03-23 11:19)
2 parents 0c8835f + 5c4233c commit 4db4221

File tree

16 files changed

+274
-231
lines changed

16 files changed

+274
-231
lines changed

arch/powerpc/Kconfig

+1-8
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,6 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
607607
config ARCH_SUPPORTS_KEXEC
608608
def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
609609

610-
config ARCH_SELECTS_KEXEC
611-
def_bool y
612-
depends on KEXEC
613-
select CRASH_DUMP
614-
615610
config ARCH_SUPPORTS_KEXEC_FILE
616611
def_bool PPC64
617612

@@ -622,7 +617,6 @@ config ARCH_SELECTS_KEXEC_FILE
622617
def_bool y
623618
depends on KEXEC_FILE
624619
select KEXEC_ELF
625-
select CRASH_DUMP
626620
select HAVE_IMA_KEXEC if IMA
627621

628622
config PPC64_BIG_ENDIAN_ELF_ABI_V2
@@ -694,8 +688,7 @@ config ARCH_SELECTS_CRASH_DUMP
694688

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

arch/powerpc/include/asm/kexec.h

+49-49
Original file line numberDiff line numberDiff line change
@@ -55,59 +55,18 @@
5555
typedef void (*crash_shutdown_t)(void);
5656

5757
#ifdef CONFIG_KEXEC_CORE
58-
59-
/*
60-
* This function is responsible for capturing register states if coming
61-
* via panic or invoking dump using sysrq-trigger.
62-
*/
63-
static inline void crash_setup_regs(struct pt_regs *newregs,
64-
struct pt_regs *oldregs)
65-
{
66-
if (oldregs)
67-
memcpy(newregs, oldregs, sizeof(*newregs));
68-
else
69-
ppc_save_regs(newregs);
70-
}
58+
struct kimage;
59+
struct pt_regs;
7160

7261
extern void kexec_smp_wait(void); /* get and clear naca physid, wait for
7362
master to copy new code to 0 */
74-
extern int crashing_cpu;
75-
extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *));
76-
extern void crash_ipi_callback(struct pt_regs *);
77-
extern int crash_wake_offline;
78-
79-
struct kimage;
80-
struct pt_regs;
8163
extern void default_machine_kexec(struct kimage *image);
82-
extern void default_machine_crash_shutdown(struct pt_regs *regs);
83-
extern int crash_shutdown_register(crash_shutdown_t handler);
84-
extern int crash_shutdown_unregister(crash_shutdown_t handler);
85-
86-
extern void crash_kexec_prepare(void);
87-
extern void crash_kexec_secondary(struct pt_regs *regs);
88-
int __init overlaps_crashkernel(unsigned long start, unsigned long size);
89-
extern void reserve_crashkernel(void);
9064
extern void machine_kexec_mask_interrupts(void);
9165

92-
static inline bool kdump_in_progress(void)
93-
{
94-
return crashing_cpu >= 0;
95-
}
96-
9766
void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_code_buffer,
9867
unsigned long start_address) __noreturn;
99-
10068
void kexec_copy_flush(struct kimage *image);
10169

102-
#if defined(CONFIG_CRASH_DUMP)
103-
bool is_kdump_kernel(void);
104-
#define is_kdump_kernel is_kdump_kernel
105-
#if defined(CONFIG_PPC_RTAS)
106-
void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
107-
#define crash_free_reserved_phys_range crash_free_reserved_phys_range
108-
#endif /* CONFIG_PPC_RTAS */
109-
#endif /* CONFIG_CRASH_DUMP */
110-
11170
#ifdef CONFIG_KEXEC_FILE
11271
extern const struct kexec_file_ops kexec_elf64_ops;
11372

@@ -152,15 +111,56 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
152111

153112
#endif /* CONFIG_KEXEC_FILE */
154113

155-
#else /* !CONFIG_KEXEC_CORE */
156-
static inline void crash_kexec_secondary(struct pt_regs *regs) { }
114+
#endif /* CONFIG_KEXEC_CORE */
115+
116+
#ifdef CONFIG_CRASH_RESERVE
117+
int __init overlaps_crashkernel(unsigned long start, unsigned long size);
118+
extern void reserve_crashkernel(void);
119+
#else
120+
static inline void reserve_crashkernel(void) {}
121+
static inline int overlaps_crashkernel(unsigned long start, unsigned long size) { return 0; }
122+
#endif
157123

158-
static inline int overlaps_crashkernel(unsigned long start, unsigned long size)
124+
#if defined(CONFIG_CRASH_DUMP)
125+
/*
126+
* This function is responsible for capturing register states if coming
127+
* via panic or invoking dump using sysrq-trigger.
128+
*/
129+
static inline void crash_setup_regs(struct pt_regs *newregs,
130+
struct pt_regs *oldregs)
159131
{
160-
return 0;
132+
if (oldregs)
133+
memcpy(newregs, oldregs, sizeof(*newregs));
134+
else
135+
ppc_save_regs(newregs);
136+
}
137+
138+
extern int crashing_cpu;
139+
extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *));
140+
extern void crash_ipi_callback(struct pt_regs *regs);
141+
extern int crash_wake_offline;
142+
143+
extern int crash_shutdown_register(crash_shutdown_t handler);
144+
extern int crash_shutdown_unregister(crash_shutdown_t handler);
145+
extern void default_machine_crash_shutdown(struct pt_regs *regs);
146+
147+
extern void crash_kexec_prepare(void);
148+
extern void crash_kexec_secondary(struct pt_regs *regs);
149+
150+
static inline bool kdump_in_progress(void)
151+
{
152+
return crashing_cpu >= 0;
161153
}
162154

163-
static inline void reserve_crashkernel(void) { ; }
155+
bool is_kdump_kernel(void);
156+
#define is_kdump_kernel is_kdump_kernel
157+
#if defined(CONFIG_PPC_RTAS)
158+
void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
159+
#define crash_free_reserved_phys_range crash_free_reserved_phys_range
160+
#endif /* CONFIG_PPC_RTAS */
161+
162+
#else /* !CONFIG_CRASH_DUMP */
163+
static inline void crash_kexec_secondary(struct pt_regs *regs) { }
164164

165165
static inline int crash_shutdown_register(crash_shutdown_t handler)
166166
{
@@ -183,7 +183,7 @@ static inline void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
183183
{
184184
}
185185

186-
#endif /* CONFIG_KEXEC_CORE */
186+
#endif /* CONFIG_CRASH_DUMP */
187187

188188
#ifdef CONFIG_PPC_BOOK3S_64
189189
#include <asm/book3s/64/kexec.h>

arch/powerpc/kernel/prom.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ static int __init early_init_dt_scan_chosen_ppc(unsigned long node,
475475
tce_alloc_end = *lprop;
476476
#endif
477477

478-
#ifdef CONFIG_KEXEC_CORE
478+
#ifdef CONFIG_CRASH_RESERVE
479479
lprop = of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
480480
if (lprop)
481481
crashk_res.start = *lprop;

arch/powerpc/kernel/setup-common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int ppc_do_canonicalize_irqs;
110110
EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
111111
#endif
112112

113-
#ifdef CONFIG_VMCORE_INFO
113+
#ifdef CONFIG_CRASH_DUMP
114114
/* This keeps a track of which one is the crashing cpu. */
115115
int crashing_cpu = -1;
116116
#endif

arch/powerpc/kernel/smp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ void smp_send_debugger_break(void)
588588
}
589589
#endif
590590

591-
#ifdef CONFIG_KEXEC_CORE
591+
#ifdef CONFIG_CRASH_DUMP
592592
void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
593593
{
594594
int cpu;
@@ -631,7 +631,7 @@ void crash_smp_send_stop(void)
631631

632632
stopped = true;
633633

634-
#ifdef CONFIG_KEXEC_CORE
634+
#ifdef CONFIG_CRASH_DUMP
635635
if (kexec_crash_image) {
636636
crash_kexec_prepare();
637637
return;

arch/powerpc/kexec/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# Makefile for the linux kernel.
44
#
55

6-
obj-y += core.o crash.o core_$(BITS).o
6+
obj-y += core.o core_$(BITS).o
77

88
obj-$(CONFIG_PPC32) += relocate_32.o
99

1010
obj-$(CONFIG_KEXEC_FILE) += file_load.o ranges.o file_load_$(BITS).o elf_$(BITS).o
1111
obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o
12+
obj-$(CONFIG_CRASH_DUMP) += crash.o
1213

1314
# Disable GCOV, KCOV & sanitizers in odd or sensitive code
1415
GCOV_PROFILE_core_$(BITS).o := n

arch/powerpc/kexec/core.c

+4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ void machine_kexec_mask_interrupts(void) {
4444
}
4545
}
4646

47+
#ifdef CONFIG_CRASH_DUMP
4748
void machine_crash_shutdown(struct pt_regs *regs)
4849
{
4950
default_machine_crash_shutdown(regs);
5051
}
52+
#endif
5153

5254
void machine_kexec_cleanup(struct kimage *image)
5355
{
@@ -77,6 +79,7 @@ void machine_kexec(struct kimage *image)
7779
for(;;);
7880
}
7981

82+
#ifdef CONFIG_CRASH_RESERVE
8083
void __init reserve_crashkernel(void)
8184
{
8285
unsigned long long crash_size, crash_base, total_mem_sz;
@@ -251,3 +254,4 @@ static int __init kexec_setup(void)
251254
return 0;
252255
}
253256
late_initcall(kexec_setup);
257+
#endif /* CONFIG_CRASH_RESERVE */

arch/powerpc/kexec/elf_64.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
4747
if (ret)
4848
return ERR_PTR(ret);
4949

50-
if (image->type == KEXEC_TYPE_CRASH) {
50+
if (IS_ENABLED(CONFIG_CRASH_DUMP) && image->type == KEXEC_TYPE_CRASH) {
5151
/* min & max buffer values for kdump case */
5252
kbuf.buf_min = pbuf.buf_min = crashk_res.start;
5353
kbuf.buf_max = pbuf.buf_max =
@@ -70,7 +70,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
7070
kexec_dprintk("Loaded purgatory at 0x%lx\n", pbuf.mem);
7171

7272
/* Load additional segments needed for panic kernel */
73-
if (image->type == KEXEC_TYPE_CRASH) {
73+
if (IS_ENABLED(CONFIG_CRASH_DUMP) && image->type == KEXEC_TYPE_CRASH) {
7474
ret = load_crashdump_segments_ppc64(image, &kbuf);
7575
if (ret) {
7676
pr_err("Failed to load kdump kernel segments\n");

0 commit comments

Comments
 (0)