.. | .. |
---|
| 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) |
---|
.. | .. |
---|
1150 | 1155 | error = dpm_suspend_end(PMSG_FREEZE); |
---|
1151 | 1156 | if (error) |
---|
1152 | 1157 | goto Resume_devices; |
---|
1153 | | - error = disable_nonboot_cpus(); |
---|
| 1158 | + error = suspend_disable_secondary_cpus(); |
---|
1154 | 1159 | if (error) |
---|
1155 | 1160 | goto Enable_cpus; |
---|
1156 | 1161 | local_irq_disable(); |
---|
.. | .. |
---|
1171 | 1176 | * CPU hotplug again; so re-enable it here. |
---|
1172 | 1177 | */ |
---|
1173 | 1178 | cpu_hotplug_enable(); |
---|
1174 | | - pr_emerg("Starting new kernel\n"); |
---|
| 1179 | + pr_notice("Starting new kernel\n"); |
---|
1175 | 1180 | machine_shutdown(); |
---|
1176 | 1181 | } |
---|
1177 | 1182 | |
---|
.. | .. |
---|
1183 | 1188 | Enable_irqs: |
---|
1184 | 1189 | local_irq_enable(); |
---|
1185 | 1190 | Enable_cpus: |
---|
1186 | | - enable_nonboot_cpus(); |
---|
| 1191 | + suspend_enable_secondary_cpus(); |
---|
1187 | 1192 | dpm_resume_start(PMSG_RESTORE); |
---|
1188 | 1193 | Resume_devices: |
---|
1189 | 1194 | dpm_resume_end(PMSG_RESTORE); |
---|