Skip to contentSkip to conversation

kexec-tools: mips: Pass initrd parameter via cmdline

PATCH In review Hui Li 2 participants 2 messages Jun 25, 2022 – Jun 26, 2022

Subsystems (2)
lore
Share & tools
lore

Hui Li

author
#0 lore raw

PATCH v6 1/1 kexec-tools: mips: Pass initrd parameter via cmdline

Under loongson platform, use command:
kexec -l vmlinux... --append="root=UUID=28e1..." --initrd=... kexec -e
quick restart failed like this:

********************************************************************

[    3.420791] VFS: Cannot open root device "UUID=6462a8a4-02fb-49..."
[    3.431262] Please append a correct "root=" boot option; ...
...
...
...
[    3.543175]   0801         4194304 sda1 554e69cc-01
[    3.543175]
[    3.549494]   0802        62914560 sda2 554e69cc-02
[    3.549495]
[    3.555818]   0803         8388608 sda3 554e69cc-03
[    3.555819]
[    3.562139]   0804       174553229 sda4 554e69cc-04
[    3.562139]
[    3.568463] 0b00         1048575 sr0
[    3.568464]  driver: sr
[    3.574524] Kernel panic - not syncing: VFS: Unable to mount root fs...
[    3.582750] ---[ end Kernel panic - not syncing: VFS:...

*******************************************************************

The kernel cannot parse the UUID, the UUID is parsed in the initrd. For compatibility with previous platforms, loongson platform obtain initrd parameter through cmdline in kernel, the kernel supports use cmdline to parse initrd. But under the mips architecture, kexec-tools pass the initrd through DTB.

Made the following modifications:

(1) in kexec/arch/mips/kexec-elf-mips.c
Add patch_initrd_info(), at runtime to distinguish different cpu, only for loongson cpu, add initrd parameter to cmdline.

(2) in kexec/arch/mips/crashdump-mips.c
Because loongson uses a different page_offset, it should be modified to ensure that crashdump functionality is correct and reliable.

(3) in kexec/arch/mips/crashdump-mips.h
Added platform-specific page_offset macro definition.

---
 kexec/arch/mips/crashdump-mips.c |  5 ++-
 kexec/arch/mips/crashdump-mips.h |  2 +
 kexec/arch/mips/kexec-elf-mips.c | 76 +++++++++++++++++++++++++++++++-
 3 files changed, 80 insertions(+), 3 deletions(-)
kexec/arch/mips/crashdump-mips.c +4 -1
index aa09c83..d9f4515 100644
@@ -334,7 +334,10 @@ static int patch_elf_info(void)
 		if (strncmp(line, "cpu model", 9) == 0) {
 			/* OCTEON uses a different page_offset. */
 			if (strstr(line, "Octeon"))
-				elf_info64.page_offset = 0x8000000000000000ULL;
+				elf_info64.page_offset = OCTEON_PAGE_OFFSET;
+			/* LOONGSON uses a different page_offset. */
+			else if (strstr(line, "Loongson"))
+				elf_info64.page_offset = LOONGSON_PAGE_OFFSET;
 			break;
 		}
 	}
kexec/arch/mips/crashdump-mips.h +2 -0
index 7edd859..55c9925 100644
@@ -13,6 +13,8 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,
 #endif
 #define __pa(x)		((unsigned long)(X) & 0x7fffffff)
 
+#define LOONGSON_PAGE_OFFSET	0xffffffff80000000ULL
+#define OCTEON_PAGE_OFFSET	0x8000000000000000ULL
 
 #define CRASH_MAX_MEMMAP_NR	(KEXEC_MAX_SEGMENTS + 1)
 #define CRASH_MAX_MEMORY_RANGES	(MAX_MEMORY_RANGES + 2)
kexec/arch/mips/kexec-elf-mips.c +74 -2

89 lines not on this page · raw message

Signature · 7 lines
2.20.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw
Quoted 37 lines · Hui Li

Under loongson platform, use command:
kexec -l vmlinux... --append="root=UUID=28e1..." --initrd=... kexec -e
quick restart failed like this:

********************************************************************

[    3.420791] VFS: Cannot open root device "UUID=6462a8a4-02fb-49..."
[    3.431262] Please append a correct "root=" boot option; ...
...
...
...
[    3.543175]   0801         4194304 sda1 554e69cc-01
[    3.543175]
[    3.549494]   0802        62914560 sda2 554e69cc-02
[    3.549495]
[    3.555818]   0803         8388608 sda3 554e69cc-03
[    3.555819]
[    3.562139]   0804       174553229 sda4 554e69cc-04
[    3.562139]
[    3.568463] 0b00         1048575 sr0
[    3.568464]  driver: sr
[    3.574524] Kernel panic - not syncing: VFS: Unable to mount root fs...
[    3.582750] ---[ end Kernel panic - not syncing: VFS:...

*******************************************************************

The kernel cannot parse the UUID, the UUID is parsed in the initrd. For compatibility with previous platforms, loongson platform obtain initrd parameter through cmdline in kernel, the kernel supports use cmdline to parse initrd. But under the mips architecture, kexec-tools pass the initrd through DTB.

Made the following modifications:

(1) in kexec/arch/mips/kexec-elf-mips.c
Add patch_initrd_info(), at runtime to distinguish different cpu, only for loongson cpu, add initrd parameter to cmdline.

Quoted 8 lines

(2) in kexec/arch/mips/crashdump-mips.c
Because loongson uses a different page_offset, it should be modified to ensure that crashdump functionality is correct and reliable.

(3) in kexec/arch/mips/crashdump-mips.h
Added platform-specific page_offset macro definition.

Thanks for addressing all my review comments.
I have applied this patch for inclusion in the next release of kexec-tools.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec