1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_KEXEC_H
3 #define _ASM_POWERPC_KEXEC_H
6 #if defined(CONFIG_PPC_85xx) || defined(CONFIG_44x)
9 * On FSL-BookE we setup a 1:1 mapping which covers the first 2GiB of memory
10 * and therefore we can only deal with memory within this range
12 #define KEXEC_SOURCE_MEMORY_LIMIT (2 * 1024 * 1024 * 1024UL - 1)
13 #define KEXEC_DESTINATION_MEMORY_LIMIT (2 * 1024 * 1024 * 1024UL - 1)
14 #define KEXEC_CONTROL_MEMORY_LIMIT (2 * 1024 * 1024 * 1024UL - 1)
19 * Maximum page that is mapped directly into kernel memory.
20 * XXX: Since we copy virt we can use any page we allocate
22 #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
25 * Maximum address we can reach in physical address mode.
26 * XXX: I want to allow initrd in highmem. Otherwise set to rmo on LPAR.
28 #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
30 /* Maximum address we can use for the control code buffer */
32 #define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
34 /* TASK_SIZE, probably left over from use_mm ?? */
35 #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
39 #define KEXEC_CONTROL_PAGE_SIZE 4096
41 /* The native architecture */
43 #define KEXEC_ARCH KEXEC_ARCH_PPC64
45 #define KEXEC_ARCH KEXEC_ARCH_PPC
48 #define KEXEC_STATE_NONE 0
49 #define KEXEC_STATE_IRQS_OFF 1
50 #define KEXEC_STATE_REAL_MODE 2
55 typedef void (*crash_shutdown_t
)(void);
57 #ifdef CONFIG_KEXEC_CORE
61 extern void kexec_smp_wait(void); /* get and clear naca physid, wait for
62 master to copy new code to 0 */
63 extern void default_machine_kexec(struct kimage
*image
);
65 void relocate_new_kernel(unsigned long indirection_page
, unsigned long reboot_code_buffer
,
66 unsigned long start_address
) __noreturn
;
67 void kexec_copy_flush(struct kimage
*image
);
69 #ifdef CONFIG_KEXEC_FILE
70 extern const struct kexec_file_ops kexec_elf64_ops
;
72 #define ARCH_HAS_KIMAGE_ARCH
75 struct crash_mem
*exclude_ranges
;
77 unsigned long backup_start
;
82 char *setup_kdump_cmdline(struct kimage
*image
, char *cmdline
,
83 unsigned long cmdline_len
);
84 int setup_purgatory(struct kimage
*image
, const void *slave_code
,
85 const void *fdt
, unsigned long kernel_load_addr
,
86 unsigned long fdt_load_addr
);
91 int arch_kexec_kernel_image_probe(struct kimage
*image
, void *buf
, unsigned long buf_len
);
92 #define arch_kexec_kernel_image_probe arch_kexec_kernel_image_probe
94 int arch_kimage_file_post_load_cleanup(struct kimage
*image
);
95 #define arch_kimage_file_post_load_cleanup arch_kimage_file_post_load_cleanup
97 int arch_kexec_locate_mem_hole(struct kexec_buf
*kbuf
);
98 #define arch_kexec_locate_mem_hole arch_kexec_locate_mem_hole
100 int load_crashdump_segments_ppc64(struct kimage
*image
,
101 struct kexec_buf
*kbuf
);
102 int setup_purgatory_ppc64(struct kimage
*image
, const void *slave_code
,
103 const void *fdt
, unsigned long kernel_load_addr
,
104 unsigned long fdt_load_addr
);
105 unsigned int kexec_extra_fdt_size_ppc64(struct kimage
*image
, struct crash_mem
*rmem
);
106 int setup_new_fdt_ppc64(const struct kimage
*image
, void *fdt
, struct crash_mem
*rmem
);
107 #endif /* CONFIG_PPC64 */
109 #endif /* CONFIG_KEXEC_FILE */
111 #endif /* CONFIG_KEXEC_CORE */
113 #ifdef CONFIG_CRASH_RESERVE
114 int __init
overlaps_crashkernel(unsigned long start
, unsigned long size
);
115 extern void reserve_crashkernel(void);
117 static inline void reserve_crashkernel(void) {}
118 static inline int overlaps_crashkernel(unsigned long start
, unsigned long size
) { return 0; }
121 #if defined(CONFIG_CRASH_DUMP)
123 * This function is responsible for capturing register states if coming
124 * via panic or invoking dump using sysrq-trigger.
126 static inline void crash_setup_regs(struct pt_regs
*newregs
,
127 struct pt_regs
*oldregs
)
130 memcpy(newregs
, oldregs
, sizeof(*newregs
));
132 ppc_save_regs(newregs
);
135 #ifdef CONFIG_CRASH_HOTPLUG
136 void arch_crash_handle_hotplug_event(struct kimage
*image
, void *arg
);
137 #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event
139 int arch_crash_hotplug_support(struct kimage
*image
, unsigned long kexec_flags
);
140 #define arch_crash_hotplug_support arch_crash_hotplug_support
142 unsigned int arch_crash_get_elfcorehdr_size(void);
143 #define crash_get_elfcorehdr_size arch_crash_get_elfcorehdr_size
144 #endif /* CONFIG_CRASH_HOTPLUG */
146 extern int crashing_cpu
;
147 extern void crash_send_ipi(void (*crash_ipi_callback
)(struct pt_regs
*));
148 extern void crash_ipi_callback(struct pt_regs
*regs
);
149 extern int crash_wake_offline
;
151 extern int crash_shutdown_register(crash_shutdown_t handler
);
152 extern int crash_shutdown_unregister(crash_shutdown_t handler
);
153 extern void default_machine_crash_shutdown(struct pt_regs
*regs
);
155 extern void crash_kexec_prepare(void);
156 extern void crash_kexec_secondary(struct pt_regs
*regs
);
158 static inline bool kdump_in_progress(void)
160 return crashing_cpu
>= 0;
163 bool is_kdump_kernel(void);
164 #define is_kdump_kernel is_kdump_kernel
165 #if defined(CONFIG_PPC_RTAS)
166 void crash_free_reserved_phys_range(unsigned long begin
, unsigned long end
);
167 #define crash_free_reserved_phys_range crash_free_reserved_phys_range
168 #endif /* CONFIG_PPC_RTAS */
170 #else /* !CONFIG_CRASH_DUMP */
171 static inline void crash_kexec_secondary(struct pt_regs
*regs
) { }
173 static inline int crash_shutdown_register(crash_shutdown_t handler
)
178 static inline int crash_shutdown_unregister(crash_shutdown_t handler
)
183 static inline bool kdump_in_progress(void)
188 static inline void crash_ipi_callback(struct pt_regs
*regs
) { }
190 static inline void crash_send_ipi(void (*crash_ipi_callback
)(struct pt_regs
*))
194 #endif /* CONFIG_CRASH_DUMP */
196 #if defined(CONFIG_KEXEC_FILE) || defined(CONFIG_CRASH_DUMP)
197 int update_cpus_node(void *fdt
);
200 #ifdef CONFIG_PPC_BOOK3S_64
201 #include <asm/book3s/64/kexec.h>
205 #define reset_sprs reset_sprs
206 static inline void reset_sprs(void)
211 #endif /* ! __ASSEMBLY__ */
212 #endif /* __KERNEL__ */
213 #endif /* _ASM_POWERPC_KEXEC_H */