Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec: mips: Fix mem parameters
@ 2020-12-04  0:29 Jinyang He
  2020-12-09 12:48 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Jinyang He @ 2020-12-04  0:29 UTC (permalink / raw)
  To: Simon Horman; +Cc: Youling Tang, kexec

"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>
---
 kexec/arch/mips/crashdump-mips.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

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");
-- 
2.1.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kexec: mips: Fix mem parameters
  2020-12-04  0:29 [PATCH] kexec: mips: Fix mem parameters Jinyang He
@ 2020-12-09 12:48 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2020-12-09 12:48 UTC (permalink / raw)
  To: Jinyang He; +Cc: kexec, Youling Tang

On Fri, Dec 04, 2020 at 08:29:47AM +0800, Jinyang He wrote:
> "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>

Thanks, applied.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-09 12:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-04  0:29 [PATCH] kexec: mips: Fix mem parameters Jinyang He
2020-12-09 12:48 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox