.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * kexec.c - kexec system call core code. |
---|
3 | 4 | * Copyright (C) 2002-2004 Eric Biederman <ebiederm@xmission.com> |
---|
4 | | - * |
---|
5 | | - * This source code is licensed under the GNU General Public License, |
---|
6 | | - * Version 2. See the file COPYING for more details. |
---|
7 | 5 | */ |
---|
8 | 6 | |
---|
9 | 7 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
38 | 36 | #include <linux/syscore_ops.h> |
---|
39 | 37 | #include <linux/compiler.h> |
---|
40 | 38 | #include <linux/hugetlb.h> |
---|
41 | | -#include <linux/frame.h> |
---|
| 39 | +#include <linux/objtool.h> |
---|
42 | 40 | |
---|
43 | 41 | #include <asm/page.h> |
---|
44 | 42 | #include <asm/sections.h> |
---|
.. | .. |
---|
111 | 109 | * defined more restrictively in <asm/kexec.h>. |
---|
112 | 110 | * |
---|
113 | 111 | * The code for the transition from the current kernel to the |
---|
114 | | - * the new kernel is placed in the control_code_buffer, whose size |
---|
| 112 | + * new kernel is placed in the control_code_buffer, whose size |
---|
115 | 113 | * is given by KEXEC_CONTROL_PAGE_SIZE. In the best case only a single |
---|
116 | 114 | * page of memory is necessary, but some architectures require more. |
---|
117 | 115 | * Because this memory must be identity mapped in the transition from |
---|
.. | .. |
---|
152 | 150 | int i; |
---|
153 | 151 | unsigned long nr_segments = image->nr_segments; |
---|
154 | 152 | unsigned long total_pages = 0; |
---|
| 153 | + unsigned long nr_pages = totalram_pages(); |
---|
155 | 154 | |
---|
156 | 155 | /* |
---|
157 | 156 | * Verify we have good destination addresses. The caller is |
---|
.. | .. |
---|
217 | 216 | * wasted allocating pages, which can cause a soft lockup. |
---|
218 | 217 | */ |
---|
219 | 218 | for (i = 0; i < nr_segments; i++) { |
---|
220 | | - if (PAGE_COUNT(image->segment[i].memsz) > totalram_pages / 2) |
---|
| 219 | + if (PAGE_COUNT(image->segment[i].memsz) > nr_pages / 2) |
---|
221 | 220 | return -EINVAL; |
---|
222 | 221 | |
---|
223 | 222 | total_pages += PAGE_COUNT(image->segment[i].memsz); |
---|
224 | 223 | } |
---|
225 | 224 | |
---|
226 | | - if (total_pages > totalram_pages / 2) |
---|
| 225 | + if (total_pages > nr_pages / 2) |
---|
227 | 226 | return -EINVAL; |
---|
228 | 227 | |
---|
229 | 228 | /* |
---|
.. | .. |
---|
590 | 589 | kimage_free_page_list(&image->unusable_pages); |
---|
591 | 590 | |
---|
592 | 591 | } |
---|
| 592 | + |
---|
| 593 | +int __weak machine_kexec_post_load(struct kimage *image) |
---|
| 594 | +{ |
---|
| 595 | + return 0; |
---|
| 596 | +} |
---|
| 597 | + |
---|
593 | 598 | void kimage_terminate(struct kimage *image) |
---|
594 | 599 | { |
---|
595 | 600 | if (*image->entry != 0) |
---|
.. | .. |
---|
973 | 978 | old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, this_cpu); |
---|
974 | 979 | if (old_cpu == PANIC_CPU_INVALID) { |
---|
975 | 980 | /* This is the 1st CPU which comes here, so go ahead. */ |
---|
976 | | - printk_safe_flush_on_panic(); |
---|
977 | 981 | __crash_kexec(regs); |
---|
978 | 982 | |
---|
979 | 983 | /* |
---|
.. | .. |
---|
1150 | 1154 | error = dpm_suspend_end(PMSG_FREEZE); |
---|
1151 | 1155 | if (error) |
---|
1152 | 1156 | goto Resume_devices; |
---|
1153 | | - error = disable_nonboot_cpus(); |
---|
| 1157 | + error = suspend_disable_secondary_cpus(); |
---|
1154 | 1158 | if (error) |
---|
1155 | 1159 | goto Enable_cpus; |
---|
1156 | 1160 | local_irq_disable(); |
---|
.. | .. |
---|
1171 | 1175 | * CPU hotplug again; so re-enable it here. |
---|
1172 | 1176 | */ |
---|
1173 | 1177 | cpu_hotplug_enable(); |
---|
1174 | | - pr_emerg("Starting new kernel\n"); |
---|
| 1178 | + pr_notice("Starting new kernel\n"); |
---|
1175 | 1179 | machine_shutdown(); |
---|
1176 | 1180 | } |
---|
1177 | 1181 | |
---|
.. | .. |
---|
1183 | 1187 | Enable_irqs: |
---|
1184 | 1188 | local_irq_enable(); |
---|
1185 | 1189 | Enable_cpus: |
---|
1186 | | - enable_nonboot_cpus(); |
---|
| 1190 | + suspend_enable_secondary_cpus(); |
---|
1187 | 1191 | dpm_resume_start(PMSG_RESTORE); |
---|
1188 | 1192 | Resume_devices: |
---|
1189 | 1193 | dpm_resume_end(PMSG_RESTORE); |
---|