hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
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)
....@@ -973,7 +978,6 @@
973978 old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, this_cpu);
974979 if (old_cpu == PANIC_CPU_INVALID) {
975980 /* This is the 1st CPU which comes here, so go ahead. */
976
- printk_safe_flush_on_panic();
977981 __crash_kexec(regs);
978982
979983 /*
....@@ -1150,7 +1154,7 @@
11501154 error = dpm_suspend_end(PMSG_FREEZE);
11511155 if (error)
11521156 goto Resume_devices;
1153
- error = disable_nonboot_cpus();
1157
+ error = suspend_disable_secondary_cpus();
11541158 if (error)
11551159 goto Enable_cpus;
11561160 local_irq_disable();
....@@ -1171,7 +1175,7 @@
11711175 * CPU hotplug again; so re-enable it here.
11721176 */
11731177 cpu_hotplug_enable();
1174
- pr_emerg("Starting new kernel\n");
1178
+ pr_notice("Starting new kernel\n");
11751179 machine_shutdown();
11761180 }
11771181
....@@ -1183,7 +1187,7 @@
11831187 Enable_irqs:
11841188 local_irq_enable();
11851189 Enable_cpus:
1186
- enable_nonboot_cpus();
1190
+ suspend_enable_secondary_cpus();
11871191 dpm_resume_start(PMSG_RESTORE);
11881192 Resume_devices:
11891193 dpm_resume_end(PMSG_RESTORE);