summaryrefslogtreecommitdiff
path: root/arch/mips/kernel/setup.c
diff options
context:
space:
mode:
authorYouling Tang <tangyouling@loongson.cn>2020-09-19 09:55:46 +0800
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>2020-09-21 22:40:07 +0200
commit262623961478836b0f467f9bbb9a3dd2a0c8a9be (patch)
treeafe8fdc60d1b6d6f82074a3f1697d6ba721cc017 /arch/mips/kernel/setup.c
parent5fa1f7680f2728d62561db6d4a9282c4d21f2324 (diff)
MIPS: kexec: Add crashkernel=YM handling
When the kernel crashkernel parameter is specified with just a size, we are supposed to allocate a region from RAM to store the crashkernel. However, MIPS merely reserves physical address zero with no checking that there is even RAM there. Fix this by lifting similar code from x86, importing it to MIPS with the MIPS specific parameters added. In the absence of any platform specific information, we allocate the crashkernel region from the first 512MB of physical memory (limited to CKSEG0 or KSEG0 address range). When X is not specified, crash_base defaults to 0 (crashkernel=YM@XM). E.g. without this patch: The environment as follows: [ 0.000000] MIPS: machine is loongson,loongson64c-4core-ls7a ... [ 0.000000] Kernel command line: root=/dev/sda2 crashkernel=96M ... The warning as follows: [ 0.000000] Invalid memory region reserved for crash kernel And the iomem as follows: 00200000-0effffff : System RAM 00200000-00b47f87 : Kernel code 00b47f88-00dfffff : Kernel data 00e60000-01f73c7f : Kernel bss 1a000000-1bffffff : pci@1a000000 ... With this patch: After increasing crash_base <= 0 handling. And the iomem as follows: 00200000-0effffff : System RAM 00200000-00b47f87 : Kernel code 00b47f88-00dfffff : Kernel data 00e60000-01f73c7f : Kernel bss 04000000-09ffffff : Crash kernel 1a000000-1bffffff : pci@1a000000 ... Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Diffstat (limited to 'arch/mips/kernel/setup.c')
-rw-r--r--arch/mips/kernel/setup.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 8589a34c28de..4c04a86f075b 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -477,6 +477,11 @@ early_param("elfcorehdr", early_parse_elfcorehdr);
#endif
#ifdef CONFIG_KEXEC
+
+/* 64M alignment for crash kernel regions */
+#define CRASH_ALIGN SZ_64M
+#define CRASH_ADDR_MAX SZ_512M
+
static void __init mips_parse_crashkernel(void)
{
unsigned long long total_mem;
@@ -489,9 +494,22 @@ static void __init mips_parse_crashkernel(void)
if (ret != 0 || crash_size <= 0)
return;
- if (!memblock_find_in_range(crash_base, crash_base + crash_size, crash_size, 1)) {
- pr_warn("Invalid memory region reserved for crash kernel\n");
- return;
+ if (crash_base <= 0) {
+ crash_base = memblock_find_in_range(CRASH_ALIGN, CRASH_ADDR_MAX,
+ crash_size, CRASH_ALIGN);
+ if (!crash_base) {
+ pr_warn("crashkernel reservation failed - No suitable area found.\n");
+ return;
+ }
+ } else {
+ unsigned long long start;
+
+ start = memblock_find_in_range(crash_base, crash_base + crash_size,
+ crash_size, 1);
+ if (start != crash_base) {
+ pr_warn("Invalid memory region reserved for crash kernel\n");
+ return;
+ }
}
crashk_res.start = crash_base;