All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] kexec-tools:mips: Fix Kernel panic problem
@ 2022-04-24  2:35 ` Hui Li
  0 siblings, 0 replies; 6+ messages in thread
From: Hui Li @ 2022-04-24  2:35 UTC (permalink / raw)
  To: Simon Horman; +Cc: Eric Biederman, kexec, linux-mips

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-49ff-bcb6-54fe53813c2a" or unknown-block(0,0): error -6
[    3.431262] Please append a correct "root=" boot option; here are the available partitions:
...
...
...
[    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 on unknown-block(0,0)
[    3.582750] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---


The reason of this problem:
The kernel cannot parse the UUID,UUID is parsed in the initrd.
Loongson platform obtain the initrd through cmdline in kernel.
In kexec-tools, initrd is not added to cmdline.

The following two steps to solve this problem.

Hui Li (2):
  kexec-tools: mips: Add CONFIG_LOONGSON option.
  kexec-tools: mips: Add initrd parameter to cmdline

 configure.ac                     |  5 ++++
 kexec/arch/mips/crashdump-mips.h |  6 ++++-
 kexec/arch/mips/kexec-elf-mips.c | 43 ++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)

-- 
2.20.1


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

* [PATCH v2 0/2] kexec-tools:mips: Fix Kernel panic problem
@ 2022-04-24  2:35 ` Hui Li
  0 siblings, 0 replies; 6+ messages in thread
From: Hui Li @ 2022-04-24  2:35 UTC (permalink / raw)
  To: kexec

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-49ff-bcb6-54fe53813c2a" or unknown-block(0,0): error -6
[    3.431262] Please append a correct "root=" boot option; here are the available partitions:
...
...
...
[    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 on unknown-block(0,0)
[    3.582750] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---


The reason of this problem:
The kernel cannot parse the UUID,UUID is parsed in the initrd.
Loongson platform obtain the initrd through cmdline in kernel.
In kexec-tools, initrd is not added to cmdline.

The following two steps to solve this problem.

Hui Li (2):
  kexec-tools: mips: Add CONFIG_LOONGSON option.
  kexec-tools: mips: Add initrd parameter to cmdline

 configure.ac                     |  5 ++++
 kexec/arch/mips/crashdump-mips.h |  6 ++++-
 kexec/arch/mips/kexec-elf-mips.c | 43 ++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)

-- 
2.20.1



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

* [PATCH v2 1/2] kexec-tools: mips: Add CONFIG_LOONGSON option.
  2022-04-24  2:35 ` Hui Li
@ 2022-04-24  2:35   ` Hui Li
  -1 siblings, 0 replies; 6+ messages in thread
From: Hui Li @ 2022-04-24  2:35 UTC (permalink / raw)
  To: Simon Horman; +Cc: Eric Biederman, kexec, linux-mips

Under the mips architecture,PAGE_OFFSE is defined as 0xa800000000000000ULL.
But now loongson and many cpu's PAGE_OFFSET use 0xFFFFFFFF80000000ULL 
in kernel.so. add a --with-loongson option to distinguish PAGE_OFFSET 
between different platforms under mips.

Signed-off-by: Hui Li <lihui@loongson.cn>
---
 configure.ac                     | 5 +++++
 kexec/arch/mips/crashdump-mips.h | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index cf8e8a2..26bfbcd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,11 @@ AC_ARG_WITH([booke],
 		AC_DEFINE(CONFIG_BOOKE,1,
 			[Define to build for BookE]))
 
+AC_ARG_WITH([loongson],
+		AC_HELP_STRING([--with-loongson],[build for loongson]),
+		AC_DEFINE(CONFIG_LOONGSON,1,
+			[Define to build for LoongsoN]))
+
 dnl ---Programs
 dnl To specify a different compiler, just 'export CC=/path/to/compiler'
 if test "${build}" != "${host}" ; then
diff --git a/kexec/arch/mips/crashdump-mips.h b/kexec/arch/mips/crashdump-mips.h
index 7edd859..d53c696 100644
--- a/kexec/arch/mips/crashdump-mips.h
+++ b/kexec/arch/mips/crashdump-mips.h
@@ -5,7 +5,11 @@ struct kexec_info;
 int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,
 				unsigned long max_addr, unsigned long min_base);
 #ifdef __mips64
-#define PAGE_OFFSET	0xa800000000000000ULL
+#ifdef CONFIG_LOONGSON
+#define PAGE_OFFSET 0xFFFFFFFF80000000ULL
+#else
+#define PAGE_OFFSET 0xa800000000000000ULL
+#endif
 #define MAXMEM		0
 #else
 #define PAGE_OFFSET	0x80000000
-- 
2.20.1


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

* [PATCH v2 1/2] kexec-tools: mips: Add CONFIG_LOONGSON option.
@ 2022-04-24  2:35   ` Hui Li
  0 siblings, 0 replies; 6+ messages in thread
From: Hui Li @ 2022-04-24  2:35 UTC (permalink / raw)
  To: kexec

Under the mips architecture,PAGE_OFFSE is defined as 0xa800000000000000ULL.
But now loongson and many cpu's PAGE_OFFSET use 0xFFFFFFFF80000000ULL 
in kernel.so. add a --with-loongson option to distinguish PAGE_OFFSET 
between different platforms under mips.

Signed-off-by: Hui Li <lihui@loongson.cn>
---
 configure.ac                     | 5 +++++
 kexec/arch/mips/crashdump-mips.h | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index cf8e8a2..26bfbcd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,11 @@ AC_ARG_WITH([booke],
 		AC_DEFINE(CONFIG_BOOKE,1,
 			[Define to build for BookE]))
 
+AC_ARG_WITH([loongson],
+		AC_HELP_STRING([--with-loongson],[build for loongson]),
+		AC_DEFINE(CONFIG_LOONGSON,1,
+			[Define to build for LoongsoN]))
+
 dnl ---Programs
 dnl To specify a different compiler, just 'export CC=/path/to/compiler'
 if test "${build}" != "${host}" ; then
diff --git a/kexec/arch/mips/crashdump-mips.h b/kexec/arch/mips/crashdump-mips.h
index 7edd859..d53c696 100644
--- a/kexec/arch/mips/crashdump-mips.h
+++ b/kexec/arch/mips/crashdump-mips.h
@@ -5,7 +5,11 @@ struct kexec_info;
 int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,
 				unsigned long max_addr, unsigned long min_base);
 #ifdef __mips64
-#define PAGE_OFFSET	0xa800000000000000ULL
+#ifdef CONFIG_LOONGSON
+#define PAGE_OFFSET 0xFFFFFFFF80000000ULL
+#else
+#define PAGE_OFFSET 0xa800000000000000ULL
+#endif
 #define MAXMEM		0
 #else
 #define PAGE_OFFSET	0x80000000
-- 
2.20.1



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

* [PATCH v2 2/2] kexec-tools: mips: Add initrd parameter to cmdline
  2022-04-24  2:35 ` Hui Li
@ 2022-04-24  2:35   ` Hui Li
  -1 siblings, 0 replies; 6+ messages in thread
From: Hui Li @ 2022-04-24  2:35 UTC (permalink / raw)
  To: Simon Horman; +Cc: Eric Biederman, kexec, linux-mips

Loongson platform obtain the initrd parameter through cmdline in kernel.
But kexec-tools pass the initrd through DTB.So add initrd parameter
to cmdline in order to compatible with some platforms.It is still
to pass the initrd parameter via command line.

Signed-off-by: Hui Li <lihui@loongson.cn>
---
 kexec/arch/mips/kexec-elf-mips.c | 43 ++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index a2d11fc..1de418e 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -40,6 +40,44 @@ static const int probe_debug = 0;
 #define CMDLINE_PREFIX "kexec "
 static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX;
 
+/* Converts unsigned long to ascii string. */
+static void ultoa(unsigned long i, char *str)
+{
+	int j = 0, k;
+	char tmp;
+
+	do {
+		str[j++] = i % 10 + '0';
+	} while ((i /= 10) > 0);
+	str[j] = '\0';
+	/* Reverse the string. */
+	for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
+		tmp = str[k];
+		str[k] = str[j];
+		str[j] = tmp;
+	}
+}
+
+/* Adds initrd parameters to command line. */
+static int cmdline_add_initrd(char *cmdline, unsigned long addr, char *new_para)
+{
+	int cmdlen, len;
+	char str[30], *ptr;
+
+	ptr = str;
+	strcpy(str, new_para);
+	ptr += strlen(str);
+	ultoa(addr, ptr);
+	len = strlen(str);
+	cmdlen = strlen(cmdline) + len;
+	if (cmdlen > (COMMAND_LINE_SIZE - 1))
+		die("Command line overflow\n");
+	strcat(cmdline, str);
+
+	return 0;
+}
+
+
 int elf_mips_probe(const char *buf, off_t len)
 {
 	struct mem_ehdr ehdr;
@@ -171,6 +209,11 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
 		/* Now that the buffer for initrd is prepared, update the dtb
 		 * with an appropriate location */
 		dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size);
+
+		/* Add the initrd parameters to cmdline */
+		cmdline_add_initrd(cmdline_buf, PAGE_OFFSET + initrd_base, " rd_start=");
+		cmdline_add_initrd(cmdline_buf, initrd_size, " rd_size=");
+
 	}
 
 
-- 
2.20.1


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

* [PATCH v2 2/2] kexec-tools: mips: Add initrd parameter to cmdline
@ 2022-04-24  2:35   ` Hui Li
  0 siblings, 0 replies; 6+ messages in thread
From: Hui Li @ 2022-04-24  2:35 UTC (permalink / raw)
  To: kexec

Loongson platform obtain the initrd parameter through cmdline in kernel.
But kexec-tools pass the initrd through DTB.So add initrd parameter
to cmdline in order to compatible with some platforms.It is still
to pass the initrd parameter via command line.

Signed-off-by: Hui Li <lihui@loongson.cn>
---
 kexec/arch/mips/kexec-elf-mips.c | 43 ++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index a2d11fc..1de418e 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -40,6 +40,44 @@ static const int probe_debug = 0;
 #define CMDLINE_PREFIX "kexec "
 static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX;
 
+/* Converts unsigned long to ascii string. */
+static void ultoa(unsigned long i, char *str)
+{
+	int j = 0, k;
+	char tmp;
+
+	do {
+		str[j++] = i % 10 + '0';
+	} while ((i /= 10) > 0);
+	str[j] = '\0';
+	/* Reverse the string. */
+	for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
+		tmp = str[k];
+		str[k] = str[j];
+		str[j] = tmp;
+	}
+}
+
+/* Adds initrd parameters to command line. */
+static int cmdline_add_initrd(char *cmdline, unsigned long addr, char *new_para)
+{
+	int cmdlen, len;
+	char str[30], *ptr;
+
+	ptr = str;
+	strcpy(str, new_para);
+	ptr += strlen(str);
+	ultoa(addr, ptr);
+	len = strlen(str);
+	cmdlen = strlen(cmdline) + len;
+	if (cmdlen > (COMMAND_LINE_SIZE - 1))
+		die("Command line overflow\n");
+	strcat(cmdline, str);
+
+	return 0;
+}
+
+
 int elf_mips_probe(const char *buf, off_t len)
 {
 	struct mem_ehdr ehdr;
@@ -171,6 +209,11 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
 		/* Now that the buffer for initrd is prepared, update the dtb
 		 * with an appropriate location */
 		dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size);
+
+		/* Add the initrd parameters to cmdline */
+		cmdline_add_initrd(cmdline_buf, PAGE_OFFSET + initrd_base, " rd_start=");
+		cmdline_add_initrd(cmdline_buf, initrd_size, " rd_size=");
+
 	}
 
 
-- 
2.20.1



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

end of thread, other threads:[~2022-04-24  2:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24  2:35 [PATCH v2 0/2] kexec-tools:mips: Fix Kernel panic problem Hui Li
2022-04-24  2:35 ` Hui Li
2022-04-24  2:35 ` [PATCH v2 1/2] kexec-tools: mips: Add CONFIG_LOONGSON option Hui Li
2022-04-24  2:35   ` Hui Li
2022-04-24  2:35 ` [PATCH v2 2/2] kexec-tools: mips: Add initrd parameter to cmdline Hui Li
2022-04-24  2:35   ` Hui Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.