[PATCH] kexec: loongarch: add multi crash kernel segment support

Ming Wang wangming01 at loongson.cn
Sun May 19 18:32:41 PDT 2024


Production kernel may reserved multiple crash kernel segments, like:
'crashkernel=4G,high crashkernel=256M,low'.
So we should pass multiple mem=<size>@<address> parameters in capture kernel.

Signed-off-by: Hongchen Zhang <zhanghongchen at loongson.cn>
Signed-off-by: Ming Wang <wangming01 at loongson.cn>
---
 kexec/arch/loongarch/kexec-loongarch.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kexec/arch/loongarch/kexec-loongarch.c b/kexec/arch/loongarch/kexec-loongarch.c
index 32a42d2..f00027c 100644
--- a/kexec/arch/loongarch/kexec-loongarch.c
+++ b/kexec/arch/loongarch/kexec-loongarch.c
@@ -289,6 +289,7 @@ int loongarch_load_other_segments(struct kexec_info *info, unsigned long hole_mi
 	unsigned long initrd_min, hole_max;
 	char *initrd_buf = NULL;
 	unsigned long pagesize = getpagesize();
+	int i;
 
 	if (arch_options.command_line) {
 		if (strlen(arch_options.command_line) >
@@ -326,9 +327,11 @@ int loongarch_load_other_segments(struct kexec_info *info, unsigned long hole_mi
 		cmdline_add_elfcorehdr(cmdline, elfcorehdr_mem.start,
 				elfcorehdr_mem.end - elfcorehdr_mem.start + 1);
 
-		cmdline_add_mem(cmdline, crash_reserved_mem[usablemem_rgns.size - 1].start,
-			crash_reserved_mem[usablemem_rgns.size - 1].end -
-			crash_reserved_mem[usablemem_rgns.size - 1].start + 1);
+		for(i = 0;i < usablemem_rgns.size; i++) {
+			cmdline_add_mem(cmdline, crash_reserved_mem[i].start,
+			crash_reserved_mem[i].end -
+			crash_reserved_mem[i].start + 1);
+		}
 	}
 
 	cmdline[sizeof(cmdline) - 1] = 0;

base-commit: 2a3e54e9f734ce08dee20b4ff1bdd5037f1b0193
-- 
2.39.2




More information about the kexec mailing list