Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Michael Ellerman | e1df870 | 2005-11-03 15:35:45 +1100 | [diff] [blame] | 2 | #ifndef _ASM_POWERPC_KEXEC_H |
| 3 | #define _ASM_POWERPC_KEXEC_H |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 4 | #ifdef __KERNEL__ |
Michael Ellerman | e1df870 | 2005-11-03 15:35:45 +1100 | [diff] [blame] | 5 | |
Suzuki Poulose | 674bfa4 | 2011-07-18 03:29:20 +0000 | [diff] [blame] | 6 | #if defined(CONFIG_FSL_BOOKE) || defined(CONFIG_44x) |
Sebastian Andrzej Siewior | b3df895 | 2010-04-04 22:19:03 +0200 | [diff] [blame] | 7 | |
| 8 | /* |
| 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 |
| 11 | */ |
Kumar Gala | 23dcab8 | 2010-07-22 13:30:44 -0500 | [diff] [blame] | 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) |
Sebastian Andrzej Siewior | b3df895 | 2010-04-04 22:19:03 +0200 | [diff] [blame] | 15 | |
| 16 | #else |
| 17 | |
Michael Ellerman | e1df870 | 2005-11-03 15:35:45 +1100 | [diff] [blame] | 18 | /* |
| 19 | * Maximum page that is mapped directly into kernel memory. |
| 20 | * XXX: Since we copy virt we can use any page we allocate |
| 21 | */ |
| 22 | #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL) |
| 23 | |
| 24 | /* |
| 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. |
| 27 | */ |
| 28 | #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL) |
| 29 | |
| 30 | /* Maximum address we can use for the control code buffer */ |
| 31 | #ifdef __powerpc64__ |
| 32 | #define KEXEC_CONTROL_MEMORY_LIMIT (-1UL) |
| 33 | #else |
| 34 | /* TASK_SIZE, probably left over from use_mm ?? */ |
| 35 | #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE |
| 36 | #endif |
Sebastian Andrzej Siewior | b3df895 | 2010-04-04 22:19:03 +0200 | [diff] [blame] | 37 | #endif |
Michael Ellerman | e1df870 | 2005-11-03 15:35:45 +1100 | [diff] [blame] | 38 | |
Huang Ying | 163f687 | 2008-08-15 00:40:22 -0700 | [diff] [blame] | 39 | #define KEXEC_CONTROL_PAGE_SIZE 4096 |
Michael Ellerman | e1df870 | 2005-11-03 15:35:45 +1100 | [diff] [blame] | 40 | |
| 41 | /* The native architecture */ |
| 42 | #ifdef __powerpc64__ |
| 43 | #define KEXEC_ARCH KEXEC_ARCH_PPC64 |
| 44 | #else |
| 45 | #define KEXEC_ARCH KEXEC_ARCH_PPC |
| 46 | #endif |
| 47 | |
Michael Neuling | 1fc711f | 2010-05-13 19:40:11 +0000 | [diff] [blame] | 48 | #define KEXEC_STATE_NONE 0 |
| 49 | #define KEXEC_STATE_IRQS_OFF 1 |
| 50 | #define KEXEC_STATE_REAL_MODE 2 |
| 51 | |
Michael Ellerman | 2babf5c | 2006-05-17 18:00:46 +1000 | [diff] [blame] | 52 | #ifndef __ASSEMBLY__ |
Anton Vorontsov | 7375331 | 2008-12-17 10:09:01 +0000 | [diff] [blame] | 53 | #include <asm/reg.h> |
Michael Ellerman | 2babf5c | 2006-05-17 18:00:46 +1000 | [diff] [blame] | 54 | |
Arnd Bergmann | aee10c6 | 2008-06-12 19:14:34 +1000 | [diff] [blame] | 55 | typedef void (*crash_shutdown_t)(void); |
| 56 | |
Thiago Jung Bauermann | da66588 | 2016-11-29 23:45:50 +1100 | [diff] [blame] | 57 | #ifdef CONFIG_KEXEC_CORE |
Michael Ellerman | cc53291 | 2005-12-04 18:39:43 +1100 | [diff] [blame] | 58 | |
Haren Myneni | 8385a6a | 2006-01-13 19:15:36 -0800 | [diff] [blame] | 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)); |
Anton Vorontsov | 7375331 | 2008-12-17 10:09:01 +0000 | [diff] [blame] | 68 | else |
| 69 | ppc_save_regs(newregs); |
Anton Vorontsov | 7375331 | 2008-12-17 10:09:01 +0000 | [diff] [blame] | 70 | } |
Haren Myneni | 8385a6a | 2006-01-13 19:15:36 -0800 | [diff] [blame] | 71 | |
Michael Ellerman | e1df870 | 2005-11-03 15:35:45 +1100 | [diff] [blame] | 72 | extern void kexec_smp_wait(void); /* get and clear naca physid, wait for |
| 73 | master to copy new code to 0 */ |
Michael Ellerman | cc53291 | 2005-12-04 18:39:43 +1100 | [diff] [blame] | 74 | extern int crashing_cpu; |
| 75 | extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *)); |
Balbir Singh | 4145f35 | 2017-12-15 19:14:55 +1100 | [diff] [blame] | 76 | extern void crash_ipi_callback(struct pt_regs *); |
| 77 | extern int crash_wake_offline; |
Michael Ellerman | e1df870 | 2005-11-03 15:35:45 +1100 | [diff] [blame] | 78 | |
Michael Ellerman | 3d1229d | 2005-11-14 23:35:00 +1100 | [diff] [blame] | 79 | struct kimage; |
Michael Ellerman | cc53291 | 2005-12-04 18:39:43 +1100 | [diff] [blame] | 80 | struct pt_regs; |
Michael Ellerman | 3d1229d | 2005-11-14 23:35:00 +1100 | [diff] [blame] | 81 | extern void default_machine_kexec(struct kimage *image); |
| 82 | extern int default_machine_kexec_prepare(struct kimage *image); |
Michael Ellerman | cc53291 | 2005-12-04 18:39:43 +1100 | [diff] [blame] | 83 | extern void default_machine_crash_shutdown(struct pt_regs *regs); |
Michael Neuling | 496b010 | 2008-01-18 15:50:30 +1100 | [diff] [blame] | 84 | extern int crash_shutdown_register(crash_shutdown_t handler); |
| 85 | extern int crash_shutdown_unregister(crash_shutdown_t handler); |
Michael Ellerman | cc53291 | 2005-12-04 18:39:43 +1100 | [diff] [blame] | 86 | |
David Wilder | c0ce7d0 | 2006-06-23 15:29:34 -0700 | [diff] [blame] | 87 | extern void crash_kexec_secondary(struct pt_regs *regs); |
Michael Ellerman | 2babf5c | 2006-05-17 18:00:46 +1000 | [diff] [blame] | 88 | extern int overlaps_crashkernel(unsigned long start, unsigned long size); |
Michael Ellerman | 35dd543 | 2006-05-18 11:16:11 +1000 | [diff] [blame] | 89 | extern void reserve_crashkernel(void); |
Matthew McClintock | c71635d | 2010-09-16 17:58:23 -0500 | [diff] [blame] | 90 | extern void machine_kexec_mask_interrupts(void); |
Albert Herranz | 39931e4 | 2006-02-01 03:05:57 -0800 | [diff] [blame] | 91 | |
Hari Bathini | c1caae3 | 2014-12-18 23:36:55 +0530 | [diff] [blame] | 92 | static inline bool kdump_in_progress(void) |
| 93 | { |
| 94 | return crashing_cpu >= 0; |
| 95 | } |
| 96 | |
Thiago Jung Bauermann | a045828 | 2016-11-29 23:45:51 +1100 | [diff] [blame] | 97 | #ifdef CONFIG_KEXEC_FILE |
AKASHI Takahiro | 9ec4ece | 2018-04-13 15:35:49 -0700 | [diff] [blame] | 98 | extern const struct kexec_file_ops kexec_elf64_ops; |
Thiago Jung Bauermann | a045828 | 2016-11-29 23:45:51 +1100 | [diff] [blame] | 99 | |
Thiago Jung Bauermann | ab6b1d1 | 2016-12-19 16:22:45 -0800 | [diff] [blame] | 100 | #ifdef CONFIG_IMA_KEXEC |
| 101 | #define ARCH_HAS_KIMAGE_ARCH |
| 102 | |
| 103 | struct kimage_arch { |
| 104 | phys_addr_t ima_buffer_addr; |
| 105 | size_t ima_buffer_size; |
| 106 | }; |
| 107 | #endif |
| 108 | |
Thiago Jung Bauermann | a045828 | 2016-11-29 23:45:51 +1100 | [diff] [blame] | 109 | int setup_purgatory(struct kimage *image, const void *slave_code, |
| 110 | const void *fdt, unsigned long kernel_load_addr, |
| 111 | unsigned long fdt_load_addr); |
Thiago Jung Bauermann | ab6b1d1 | 2016-12-19 16:22:45 -0800 | [diff] [blame] | 112 | int setup_new_fdt(const struct kimage *image, void *fdt, |
| 113 | unsigned long initrd_load_addr, unsigned long initrd_len, |
| 114 | const char *cmdline); |
Thiago Jung Bauermann | 467d278 | 2016-12-19 16:22:32 -0800 | [diff] [blame] | 115 | int delete_fdt_mem_rsv(void *fdt, unsigned long start, unsigned long size); |
Thiago Jung Bauermann | a045828 | 2016-11-29 23:45:51 +1100 | [diff] [blame] | 116 | #endif /* CONFIG_KEXEC_FILE */ |
| 117 | |
Thiago Jung Bauermann | da66588 | 2016-11-29 23:45:50 +1100 | [diff] [blame] | 118 | #else /* !CONFIG_KEXEC_CORE */ |
David Wilder | c0ce7d0 | 2006-06-23 15:29:34 -0700 | [diff] [blame] | 119 | static inline void crash_kexec_secondary(struct pt_regs *regs) { } |
Michael Ellerman | 2babf5c | 2006-05-17 18:00:46 +1000 | [diff] [blame] | 120 | |
| 121 | static inline int overlaps_crashkernel(unsigned long start, unsigned long size) |
| 122 | { |
| 123 | return 0; |
| 124 | } |
| 125 | |
Michael Ellerman | 35dd543 | 2006-05-18 11:16:11 +1000 | [diff] [blame] | 126 | static inline void reserve_crashkernel(void) { ; } |
| 127 | |
Arnd Bergmann | aee10c6 | 2008-06-12 19:14:34 +1000 | [diff] [blame] | 128 | static inline int crash_shutdown_register(crash_shutdown_t handler) |
| 129 | { |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | static inline int crash_shutdown_unregister(crash_shutdown_t handler) |
| 134 | { |
| 135 | return 0; |
| 136 | } |
| 137 | |
Hari Bathini | c1caae3 | 2014-12-18 23:36:55 +0530 | [diff] [blame] | 138 | static inline bool kdump_in_progress(void) |
| 139 | { |
| 140 | return false; |
| 141 | } |
| 142 | |
Guenter Roeck | 9109617 | 2018-02-12 14:34:07 -0800 | [diff] [blame] | 143 | static inline void crash_ipi_callback(struct pt_regs *regs) { } |
| 144 | |
| 145 | static inline void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *)) |
| 146 | { |
| 147 | } |
| 148 | |
Thiago Jung Bauermann | da66588 | 2016-11-29 23:45:50 +1100 | [diff] [blame] | 149 | #endif /* CONFIG_KEXEC_CORE */ |
Michael Ellerman | 2babf5c | 2006-05-17 18:00:46 +1000 | [diff] [blame] | 150 | #endif /* ! __ASSEMBLY__ */ |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 151 | #endif /* __KERNEL__ */ |
Michael Ellerman | e1df870 | 2005-11-03 15:35:45 +1100 | [diff] [blame] | 152 | #endif /* _ASM_POWERPC_KEXEC_H */ |