hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/kernel/kexec_core.c
....@@ -1,9 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * kexec.c - kexec system call core code.
34 * 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.
75 */
86
97 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -38,7 +36,7 @@
3836 #include <linux/syscore_ops.h>
3937 #include <linux/compiler.h>
4038 #include <linux/hugetlb.h>
41
-#include <linux/frame.h>
39
+#include <linux/objtool.h>
4240
4341 #include <asm/page.h>
4442 #include <asm/sections.h>
....@@ -111,7 +109,7 @@
111109 * defined more restrictively in <asm/kexec.h>.
112110 *
113111 * 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
115113 * is given by KEXEC_CONTROL_PAGE_SIZE. In the best case only a single
116114 * page of memory is necessary, but some architectures require more.
117115 * Because this memory must be identity mapped in the transition from
....@@ -152,6 +150,7 @@
152150 int i;
153151 unsigned long nr_segments = image->nr_segments;
154152 unsigned long total_pages = 0;
153
+ unsigned long nr_pages = totalram_pages();
155154
156155 /*
157156 * Verify we have good destination addresses. The caller is
....@@ -217,13 +216,13 @@
217216 * wasted allocating pages, which can cause a soft lockup.
218217 */
219218 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)
221220 return -EINVAL;
222221
223222 total_pages += PAGE_COUNT(image->segment[i].memsz);
224223 }
225224
226
- if (total_pages > totalram_pages / 2)
225
+ if (total_pages > nr_pages / 2)
227226 return -EINVAL;
228227
229228 /*
....@@ -590,6 +589,12 @@
590589 kimage_free_page_list(&image->unusable_pages);
591590
592591 }
592
+
593
+int __weak machine_kexec_post_load(struct kimage *image)
594
+{
595
+ return 0;
596
+}
597
+
593598 void kimage_terminate(struct kimage *image)
594599 {
595600 if (*image->entry != 0)
....@@ -1150,7 +1155,7 @@
11501155 error = dpm_suspend_end(PMSG_FREEZE);
11511156 if (error)
11521157 goto Resume_devices;
1153
- error = disable_nonboot_cpus();
1158
+ error = suspend_disable_secondary_cpus();
11541159 if (error)
11551160 goto Enable_cpus;
11561161 local_irq_disable();
....@@ -1171,7 +1176,7 @@
11711176 * CPU hotplug again; so re-enable it here.
11721177 */
11731178 cpu_hotplug_enable();
1174
- pr_emerg("Starting new kernel\n");
1179
+ pr_notice("Starting new kernel\n");
11751180 machine_shutdown();
11761181 }
11771182
....@@ -1183,7 +1188,7 @@
11831188 Enable_irqs:
11841189 local_irq_enable();
11851190 Enable_cpus:
1186
- enable_nonboot_cpus();
1191
+ suspend_enable_secondary_cpus();
11871192 dpm_resume_start(PMSG_RESTORE);
11881193 Resume_devices:
11891194 dpm_resume_end(PMSG_RESTORE);