// SPDX-License-Identifier: GPL-2.0-only /* * Code to handle transition of Linux booting another kernel. * * Copyright (C) 2002-2003 Eric Biederman <ebiederm@xmission.com> * GameCube/ppc32 port Copyright (C) 2004 Albert Herranz * Copyright (C) 2005 IBM Corporation.
*/
/* * Do not allocate memory (or fail in any way) in machine_kexec(). * We are past the point of no return, committed to rebooting now.
*/ void machine_kexec(struct kimage *image)
{ int save_ftrace_enabled;
if (!crash_base) { #ifdef CONFIG_PPC64 /* * On the LPAR platform place the crash kernel to mid of * RMA size (max. of 512MB) to ensure the crash kernel * gets enough space to place itself and some stack to be * in the first segment. At the same time normal kernel * also get enough space to allocate memory for essential * system resource in the first segment. Keep the crash * kernel starts at 128MB offset on other platforms.
*/ if (firmware_has_feature(FW_FEATURE_LPAR))
crash_base = min_t(u64, ppc64_rma_size / 2, SZ_512M); else
crash_base = min_t(u64, ppc64_rma_size / 2, SZ_128M); #else
crash_base = KDUMP_KERNELBASE; #endif
}
crash_base_align = PAGE_ALIGN(crash_base); if (crash_base != crash_base_align)
pr_warn("Crash kernel base must be aligned to 0x%lx\n", PAGE_SIZE);
/* The crash region must not overlap the current kernel */ if ((kernel_start + kernel_size > crash_base) && (kernel_start <= crash_end)) {
pr_warn("Crash kernel can not overlap current kernel\n"); return;
}
/* Values we need to export to the second kernel via the device tree. */ static phys_addr_t kernel_end; static phys_addr_t crashk_base; static phys_addr_t crashk_size; staticunsignedlonglong mem_limit;
staticvoid __init export_crashk_values(struct device_node *node)
{ /* There might be existing crash kernel properties, but we can't
* be sure what's in them, so remove them. */
of_remove_property(node, of_find_property(node, "linux,crashkernel-base", NULL));
of_remove_property(node, of_find_property(node, "linux,crashkernel-size", NULL));
/* * memory_limit is required by the kexec-tools to limit the * crash regions to the actual memory used.
*/
mem_limit = cpu_to_be_ulong(memory_limit);
of_update_property(node, &memory_limit_prop);
}
node = of_find_node_by_path("/chosen"); if (!node) return -ENOENT;
/* remove any stale properties so ours can be found */
of_remove_property(node, of_find_property(node, kernel_end_prop.name, NULL));
/* information needed by userspace when using default_machine_kexec */
kernel_end = cpu_to_be_ulong(__pa(_end));
of_add_property(node, &kernel_end_prop);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.