summaryrefslogtreecommitdiff
path: root/kexec/arch
diff options
context:
space:
mode:
authorJinyang He <hejinyang@loongson.cn>2020-12-04 08:29:47 +0800
committerSimon Horman <horms@verge.net.au>2020-12-09 13:47:27 +0100
commit0eac64052636dff57d8020ab4d8a3ff2c99d8005 (patch)
tree1ff3327f81574fc6f55e8442d9f561b0e83932bd /kexec/arch
parentfa917094e1a9a6d75fb0bdfeb9b4aebc1b9f87d6 (diff)
downloadkexec-tools-0eac64052636dff57d8020ab4d8a3ff2c99d8005.tar.gz
kexec: mips: Fix mem parameters
"mem=" is useful to indicate the memory region when capture kernel boot. Otherwise, capture kernel will breakdown the memory of panic kernel. Although it can be add by user, adding "mem" by software is a better way. What's more, "mem" should contain elfcorehdr range. Elfcorehdr memory should be managed by kernel. Fixes: 7bd251654aad ("kexec-tools: mips: Remove commandline parameter "mem"") Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Jinyang He <hejinyang@loongson.cn> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/arch')
-rw-r--r--kexec/arch/mips/crashdump-mips.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index a135386..56b8fe8 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -243,6 +243,33 @@ static void ultoa(unsigned long i, char *str)
}
}
+/* Adds the appropriate mem= options to command line, indicating the
+ * memory region the new kernel can use to boot into. */
+static int cmdline_add_mem(char *cmdline, unsigned long addr,
+ unsigned long size)
+{
+ int cmdlen, len;
+ char str[50], *ptr;
+
+ addr = addr/1024;
+ size = size/1024;
+ ptr = str;
+ strcpy(str, " mem=");
+ ptr += strlen(str);
+ ultoa(size, ptr);
+ strcat(str, "K@");
+ ptr = str + strlen(str);
+ ultoa(addr, ptr);
+ strcat(str, "K");
+ len = strlen(str);
+ cmdlen = strlen(cmdline) + len;
+ if (cmdlen > (COMMAND_LINE_SIZE - 1))
+ die("Command line overflow\n");
+ strcat(cmdline, str);
+
+ return 0;
+}
+
/* Adds the elfcorehdr= command line parameter to command line. */
static int cmdline_add_elfcorehdr(char *cmdline, unsigned long addr)
{
@@ -373,6 +400,8 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
* backup segment is after elfcorehdr, so use elfcorehdr as top of
* kernel's available memory
*/
+ cmdline_add_mem(mod_cmdline, crash_reserved_mem.start,
+ crash_reserved_mem.end - crash_reserved_mem.start);
cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr);
dbgprintf("CRASH MEMORY RANGES:\n");