1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_KEXEC_H
3 #define _ASM_POWERPC_KEXEC_H
6 #if defined(CONFIG_FSL_BOOKE) || 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
60 * This function is responsible for capturing register states if coming
61 * via panic or invoking dump using sysrq-trigger.
63 static inline void crash_setup_regs(struct pt_regs
*newregs
,
64 struct pt_regs
*oldregs
)
67 memcpy(newregs
, oldregs
, sizeof(*newregs
));
69 ppc_save_regs(newregs
);
72 extern void kexec_smp_wait(void); /* get and clear naca physid, wait for
73 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
;
81 extern void default_machine_kexec(struct kimage
*image
);
82 extern int default_machine_kexec_prepare(struct kimage
*image
);
83 extern void default_machine_crash_shutdown(struct pt_regs
*regs
);
84 extern int crash_shutdown_register(crash_shutdown_t handler
);
85 extern int crash_shutdown_unregister(crash_shutdown_t handler
);
87 extern void crash_kexec_secondary(struct pt_regs
*regs
);
88 extern int overlaps_crashkernel(unsigned long start
, unsigned long size
);
89 extern void reserve_crashkernel(void);
90 extern void machine_kexec_mask_interrupts(void);
92 static inline bool kdump_in_progress(void)
94 return crashing_cpu
>= 0;
97 void relocate_new_kernel(unsigned long indirection_page
, unsigned long reboot_code_buffer
,
98 unsigned long start_address
) __noreturn
;
100 #ifdef CONFIG_KEXEC_FILE
101 extern const struct kexec_file_ops kexec_elf64_ops
;
103 #ifdef CONFIG_IMA_KEXEC
104 #define ARCH_HAS_KIMAGE_ARCH
107 phys_addr_t ima_buffer_addr
;
108 size_t ima_buffer_size
;
112 int setup_purgatory(struct kimage
*image
, const void *slave_code
,
113 const void *fdt
, unsigned long kernel_load_addr
,
114 unsigned long fdt_load_addr
);
115 int setup_new_fdt(const struct kimage
*image
, void *fdt
,
116 unsigned long initrd_load_addr
, unsigned long initrd_len
,
117 const char *cmdline
);
118 int delete_fdt_mem_rsv(void *fdt
, unsigned long start
, unsigned long size
);
119 #endif /* CONFIG_KEXEC_FILE */
121 #else /* !CONFIG_KEXEC_CORE */
122 static inline void crash_kexec_secondary(struct pt_regs
*regs
) { }
124 static inline int overlaps_crashkernel(unsigned long start
, unsigned long size
)
129 static inline void reserve_crashkernel(void) { ; }
131 static inline int crash_shutdown_register(crash_shutdown_t handler
)
136 static inline int crash_shutdown_unregister(crash_shutdown_t handler
)
141 static inline bool kdump_in_progress(void)
146 static inline void crash_ipi_callback(struct pt_regs
*regs
) { }
148 static inline void crash_send_ipi(void (*crash_ipi_callback
)(struct pt_regs
*))
152 #endif /* CONFIG_KEXEC_CORE */
153 #endif /* ! __ASSEMBLY__ */
154 #endif /* __KERNEL__ */
155 #endif /* _ASM_POWERPC_KEXEC_H */