Discussion:
[PATCH 0/6] Kexec fixes and updates for MIPS platforms
Marcin Nowakowski
2016-12-02 09:49:05 UTC
Permalink
This patch series tries to bring the support for MIPS up to date and make it more
generic (fix little-endian support, simplify code for 32/64 bit handling), as well
as to clean up some existing incorrect code (patches 1-4).

Patches 5 & 6 add new functionality - passing external DTBs and initrd, especially
the DTB support is required for platforms that use a recently introduced generic
kernel infrastructure.

Note that patch 5 (and 6, as it depends on patch 5) require changes in the kernel
that are currently pending review:
https://patchwork.linux-mips.org/patch/14615/

Core dump support is currently broken on all MIPS kernels and is also pending
review:
https://patchwork.linux-mips.org/patch/14587/
https://patchwork.linux-mips.org/patch/14586/

Patches 1-4 can be safely added without waiting for kernel patches to be merged,
but patches 5-6 should be held until the kernel patches are accepted in case changes
are requested.

Cc: Ralf Baechle <***@linux-mips.org>
Cc: linux-***@linux-mips.org

Marcin Nowakowski (6):
mips: remove incorrect arch_usage string
mips: use arch_options for both 32 and 64 bit variants
mips: move arch option parsing from elf loader to common arch code
mips: crashdump: add little-endian support
mips: add dtb loading support
mips: add option to load initrd from a specified file

kexec/arch/mips/Makefile | 13 +++++
kexec/arch/mips/crashdump-mips.c | 22 +++++---
kexec/arch/mips/include/arch/options.h | 11 ++--
kexec/arch/mips/kexec-elf-mips.c | 96 +++++++++++++++++++---------------
kexec/arch/mips/kexec-mips.c | 46 +++++++++++++---
kexec/arch/mips/kexec-mips.h | 13 ++++-
6 files changed, 142 insertions(+), 59 deletions(-)
--
2.7.4
Marcin Nowakowski
2016-12-02 09:49:06 UTC
Permalink
arch_usage shows '--elf32-core-headers' as an option, but this is not
implemented.

Signed-off-by: Marcin Nowakowski <***@imgtec.com>
---
kexec/arch/mips/kexec-mips.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
index fe0c945..ebc3d9a 100644
--- a/kexec/arch/mips/kexec-mips.c
+++ b/kexec/arch/mips/kexec-mips.c
@@ -74,10 +74,6 @@ int file_types = sizeof(file_type) / sizeof(file_type[0]);

void arch_usage(void)
{
-#ifdef __mips64
- fprintf(stderr, " --elf32-core-headers Prepare core headers in "
- "ELF32 format\n");
-#endif
}

#ifdef __mips64
--
2.7.4
Marcin Nowakowski
2016-12-02 09:49:09 UTC
Permalink
Elf header for crashdump has until now been hardcoded as big-endian.
Change that to use the native endianness for the compile target so that
the crashdumps are generated properly for each CPU type.

Signed-off-by: Marcin Nowakowski <***@imgtec.com>
---
kexec/arch/mips/crashdump-mips.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index e56b3ef..278ee01 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -288,9 +288,17 @@ static int cmdline_add_elfcorehdr(char *cmdline, unsigned long addr)
return 0;
}

+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define ELFDATALOCAL ELFDATA2LSB
+#elif __BYTE_ORDER == __BIG_ENDIAN
+# define ELFDATALOCAL ELFDATA2MSB
+#else
+# error Unknown byte order
+#endif
+
static struct crash_elf_info elf_info64 = {
class: ELFCLASS64,
- data : ELFDATA2MSB,
+ data : ELFDATALOCAL,
machine : EM_MIPS,
page_offset : PAGE_OFFSET,
lowmem_limit : MAXMEM,
@@ -298,7 +306,7 @@ static struct crash_elf_info elf_info64 = {

static struct crash_elf_info elf_info32 = {
class: ELFCLASS32,
- data : ELFDATA2MSB,
+ data : ELFDATALOCAL,
machine : EM_MIPS,
page_offset : PAGE_OFFSET,
lowmem_limit : MAXMEM,
--
2.7.4
Marcin Nowakowski
2016-12-02 09:49:07 UTC
Permalink
At the moment arch_options structure is defined for 64-bit only and is
used exclusively in ifdef'ed code. Remove the ifdefs around the uses of
the structure and define it for all code variants as it will be used for
passing more arch options in the followup commits.

Signed-off-by: Marcin Nowakowski <***@imgtec.com>
---
kexec/arch/mips/crashdump-mips.c | 7 ++-----
kexec/arch/mips/kexec-mips.c | 8 +++++---
2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index dc68cb4..e56b3ef 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -288,7 +288,6 @@ static int cmdline_add_elfcorehdr(char *cmdline, unsigned long addr)
return 0;
}

-#ifdef __mips64
static struct crash_elf_info elf_info64 = {
class: ELFCLASS64,
data : ELFDATA2MSB,
@@ -296,7 +295,7 @@ static struct crash_elf_info elf_info64 = {
page_offset : PAGE_OFFSET,
lowmem_limit : MAXMEM,
};
-#endif
+
static struct crash_elf_info elf_info32 = {
class: ELFCLASS32,
data : ELFDATA2MSB,
@@ -321,13 +320,11 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
struct crash_elf_info *elf_info = &elf_info32;
unsigned long start_offset = 0x80000000UL;

-#ifdef __mips64
if (arch_options.core_header_type == CORE_TYPE_ELF64) {
elf_info = &elf_info64;
crash_create = crash_create_elf64_headers;
- start_offset = 0xffffffff80000000UL;
+ start_offset = (unsigned long)0xffffffff80000000UL;
}
-#endif

if (get_kernel_paddr(elf_info))
return -1;
diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
index ebc3d9a..de9019a 100644
--- a/kexec/arch/mips/kexec-mips.c
+++ b/kexec/arch/mips/kexec-mips.c
@@ -76,11 +76,13 @@ void arch_usage(void)
{
}

-#ifdef __mips64
struct arch_options_t arch_options = {
- .core_header_type = CORE_TYPE_ELF64
-};
+#ifdef __mips64
+ .core_header_type = CORE_TYPE_ELF64,
+#else
+ .core_header_type = CORE_TYPE_ELF32,
#endif
+};

int arch_process_options(int argc, char **argv)
{
--
2.7.4
Marcin Nowakowski
2016-12-02 09:49:08 UTC
Permalink
At the moment only commandline handling is implemented and there is
nothing elf-specific about it, so all of the commandline parsing logic
can be moved to common arch code.
getopt() options are moved to KEXEC_ARCH_OPTIONS macro (as many
platforms currently do) to avoid unnecessary duplication.

Signed-off-by: Marcin Nowakowski <***@imgtec.com>
---
kexec/arch/mips/include/arch/options.h | 6 ++---
kexec/arch/mips/kexec-elf-mips.c | 43 ++++------------------------------
kexec/arch/mips/kexec-mips.c | 22 +++++++++++++++++
kexec/arch/mips/kexec-mips.h | 3 ++-
4 files changed, 32 insertions(+), 42 deletions(-)

diff --git a/kexec/arch/mips/include/arch/options.h b/kexec/arch/mips/include/arch/options.h
index 07b4f63..a18251b 100644
--- a/kexec/arch/mips/include/arch/options.h
+++ b/kexec/arch/mips/include/arch/options.h
@@ -9,6 +9,8 @@
*/
#define KEXEC_ARCH_OPTIONS \
KEXEC_OPTIONS \
+ {"command-line", 1, 0, OPT_APPEND}, \
+ {"append", 1, 0, OPT_APPEND},

#define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""

@@ -27,9 +29,7 @@
* recognise -- as they now recognise (if not act upon) all possible options.
*/
#define KEXEC_ALL_OPTIONS \
- KEXEC_ARCH_OPTIONS \
- {"command-line", 1, 0, OPT_APPEND}, \
- {"append", 1, 0, OPT_APPEND},
+ KEXEC_ARCH_OPTIONS

#define KEXEC_ALL_OPT_STR KEXEC_ARCH_OPT_STR

diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index 8a6419a..7cb06f1 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -63,51 +63,18 @@ int elf_mips_probe(const char *buf, off_t len)

void elf_mips_usage(void)
{
- printf(" --command-line=STRING Set the kernel command line to "
- "STRING.\n"
- " --append=STRING Set the kernel command line to "
- "STRING.\n");
}

int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
struct kexec_info *info)
{
struct mem_ehdr ehdr;
- const char *command_line;
- int command_line_len;
+ int command_line_len = 0;
char *crash_cmdline;
- int opt;
int result;
unsigned long cmdline_addr;
size_t i;

- /* See options.h if adding any more options. */
- static const struct option options[] = {
- KEXEC_ARCH_OPTIONS
- {"command-line", 1, 0, OPT_APPEND},
- {"append", 1, 0, OPT_APPEND},
- {0, 0, 0, 0},
- };
-
- static const char short_options[] = KEXEC_ARCH_OPT_STR "d";
-
- command_line = 0;
- while ((opt = getopt_long(argc, argv, short_options,
- options, 0)) != -1) {
- switch (opt) {
- default:
- /* Ignore core options */
- if (opt < OPT_ARCH_MAX) {
- break;
- }
- case OPT_APPEND:
- command_line = optarg;
- break;
- }
- }
-
- command_line_len = 0;
-
/* Need to append some command line parameters internally in case of
* taking crash dumps.
*/
@@ -136,8 +103,8 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,

info->entry = (void *)virt_to_phys(ehdr.e_entry);

- if (command_line)
- command_line_len = strlen(command_line) + 1;
+ if (arch_options.command_line)
+ command_line_len = strlen(arch_options.command_line) + 1;

if (info->kexec_flags & KEXEC_ON_CRASH) {
result = load_crashdump_segments(info, crash_cmdline,
@@ -148,8 +115,8 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
}
}

- if (command_line)
- strncat(cmdline_buf, command_line, command_line_len);
+ if (arch_options.command_line)
+ strncat(cmdline_buf, arch_options.command_line, command_line_len);
if (crash_cmdline)
strncat(cmdline_buf, crash_cmdline,
sizeof(crash_cmdline) -
diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
index de9019a..867e9c3 100644
--- a/kexec/arch/mips/kexec-mips.c
+++ b/kexec/arch/mips/kexec-mips.c
@@ -74,6 +74,10 @@ int file_types = sizeof(file_type) / sizeof(file_type[0]);

void arch_usage(void)
{
+ printf(
+ " --command-line=STRING Set the kernel command line to STRING.\n"
+ " --append=STRING Set the kernel command line to STRING.\n"
+ );
}

struct arch_options_t arch_options = {
@@ -86,6 +90,24 @@ struct arch_options_t arch_options = {

int arch_process_options(int argc, char **argv)
{
+ static const struct option options[] = {
+ KEXEC_ARCH_OPTIONS
+ { 0 },
+ };
+ static const char short_options[] = KEXEC_ARCH_OPT_STR;
+ int opt;
+
+ while ((opt = getopt_long(argc, argv, short_options,
+ options, 0)) != -1) {
+ switch (opt) {
+ case OPT_APPEND:
+ arch_options.command_line = optarg;
+ break;
+ default:
+ break;
+ }
+ }
+
return 0;
}

diff --git a/kexec/arch/mips/kexec-mips.h b/kexec/arch/mips/kexec-mips.h
index e67960b..2991b2d 100644
--- a/kexec/arch/mips/kexec-mips.h
+++ b/kexec/arch/mips/kexec-mips.h
@@ -13,7 +13,8 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
void elf_mips_usage(void);

struct arch_options_t {
- int core_header_type;
+ char *command_line;
+ int core_header_type;
};

#endif /* KEXEC_MIPS_H */
--
2.7.4
Marcin Nowakowski
2016-12-02 09:49:11 UTC
Permalink
Use kexec's existing infrastrucutre for supporting initrd loading.
The initrd image is loaded into a buffer after the dtb and its details
passed through the device tree, so it's supported on newer platforms
that make use of the device tree passed from kexec.

Signed-off-by: Marcin Nowakowski <***@imgtec.com>
Cc: Ralf Baechle <***@linux-mips.org>
Cc: linux-***@linux-mips.org
---
kexec/arch/mips/include/arch/options.h | 4 +++-
kexec/arch/mips/kexec-elf-mips.c | 19 +++++++++++++++++++
kexec/arch/mips/kexec-mips.c | 4 ++++
kexec/arch/mips/kexec-mips.h | 1 +
4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/mips/include/arch/options.h b/kexec/arch/mips/include/arch/options.h
index 86b620f..416e224 100644
--- a/kexec/arch/mips/include/arch/options.h
+++ b/kexec/arch/mips/include/arch/options.h
@@ -4,6 +4,7 @@
#define OPT_ARCH_MAX (OPT_MAX+0)
#define OPT_APPEND (OPT_ARCH_MAX+0)
#define OPT_DTB (OPT_ARCH_MAX+1)
+#define OPT_RAMDISK (OPT_ARCH_MAX+2)

/* Options relevant to the architecture (excluding loader-specific ones),
* in this case none:
@@ -12,7 +13,8 @@
KEXEC_OPTIONS \
{"command-line", 1, 0, OPT_APPEND}, \
{"append", 1, 0, OPT_APPEND}, \
- {"dtb", 1, 0, OPT_DTB },
+ {"dtb", 1, 0, OPT_DTB }, \
+ {"initrd", 1, 0, OPT_RAMDISK },


#define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index 6ca7ca0..849a7ba 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -79,6 +79,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
size_t i;
off_t dtb_length;
char *dtb_buf;
+ char *initrd_buf = NULL;
unsigned long long kernel_addr = 0, kernel_size = 0;
unsigned long pagesize = getpagesize();

@@ -152,6 +153,24 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
create_flatten_tree(&dtb_buf, &dtb_length, cmdline_buf + strlen(CMDLINE_PREFIX));
}

+ if (arch_options.initrd_file) {
+ initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size);
+
+ /* Create initrd entries in dtb - although at this time
+ * they would not point to the correct location */
+ dtb_set_initrd(&dtb_buf, &dtb_length, initrd_buf, initrd_buf + initrd_size);
+
+ initrd_base = add_buffer(info, initrd_buf, initrd_size,
+ initrd_size, sizeof(void *),
+ _ALIGN_UP(kernel_addr + kernel_size + dtb_length,
+ pagesize), 0x0fffffff, 1);
+
+ /* 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);
+ }
+
+
/* This is a legacy method for commandline passing used
* currently by Octeon CPUs only */
add_buffer(info, cmdline_buf, sizeof(cmdline_buf),
diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
index 2605c17..ee3cd3a 100644
--- a/kexec/arch/mips/kexec-mips.c
+++ b/kexec/arch/mips/kexec-mips.c
@@ -82,6 +82,7 @@ void arch_usage(void)
" --command-line=STRING Set the kernel command line to STRING.\n"
" --append=STRING Set the kernel command line to STRING.\n"
" --dtb=FILE Use FILE as the device tree blob.\n"
+ " --initrd=FILE Use FILE as initial ramdisk.\n"
);
}

@@ -111,6 +112,9 @@ int arch_process_options(int argc, char **argv)
case OPT_DTB:
arch_options.dtb_file = optarg;
break;
+ case OPT_RAMDISK:
+ arch_options.initrd_file = optarg;
+ break;
default:
break;
}
diff --git a/kexec/arch/mips/kexec-mips.h b/kexec/arch/mips/kexec-mips.h
index a609fb5..222c815 100644
--- a/kexec/arch/mips/kexec-mips.h
+++ b/kexec/arch/mips/kexec-mips.h
@@ -20,6 +20,7 @@ void elf_mips_usage(void);
struct arch_options_t {
char *command_line;
char *dtb_file;
+ char *initrd_file;
int core_header_type;
};
--
2.7.4
Marcin Nowakowski
2016-12-02 09:49:10 UTC
Permalink
Kexec for MIPS currently does not support loading devicetrees, unless
they are embedded in the kernel elf file.

Add an option to either pass a new dtb file or - if not specified - to
be generated from existing device tree on the device. As new generic
platforms require a dtb to be passed separately this is required for
such platforms and will be ignored by the kernel otherwise.

Generic kexec infrastructure for dtb support is used.

Signed-off-by: Marcin Nowakowski <***@imgtec.com>
Cc: Ralf Baechle <***@linux-mips.org>
Cc: linux-***@linux-mips.org
---
kexec/arch/mips/Makefile | 13 +++++++++++++
kexec/arch/mips/crashdump-mips.c | 3 +++
kexec/arch/mips/include/arch/options.h | 5 ++++-
kexec/arch/mips/kexec-elf-mips.c | 34 +++++++++++++++++++++++++++++++---
kexec/arch/mips/kexec-mips.c | 8 ++++++++
kexec/arch/mips/kexec-mips.h | 9 +++++++++
6 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/kexec/arch/mips/Makefile b/kexec/arch/mips/Makefile
index 03bdb9a..1fe7886 100644
--- a/kexec/arch/mips/Makefile
+++ b/kexec/arch/mips/Makefile
@@ -6,6 +6,19 @@ mips_KEXEC_SRCS += kexec/arch/mips/kexec-elf-mips.c
mips_KEXEC_SRCS += kexec/arch/mips/kexec-elf-rel-mips.c
mips_KEXEC_SRCS += kexec/arch/mips/crashdump-mips.c

+mips_FS2DT = kexec/fs2dt.c
+mips_FS2DT_INCLUDE = \
+ -include $(srcdir)/kexec/arch/mips/crashdump-mips.h \
+ -include $(srcdir)/kexec/arch/mips/kexec-mips.h
+
+mips_DT_OPS += kexec/dt-ops.c
+
+include $(srcdir)/kexec/libfdt/Makefile.libfdt
+
+libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
+mips_CPPFLAGS += -I$(srcdir)/kexec/libfdt
+mips_KEXEC_SRCS += $(libfdt_SRCS)
+
mips_ADD_BUFFER =
mips_ADD_SEGMENT =
mips_VIRT_TO_PHYS =
diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index 278ee01..d6cff5a 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -39,6 +39,9 @@
* A separate program header is created for backup region */
static struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES];

+/* Not used currently but required by generic fs2dt code */
+struct memory_ranges usablemem_rgns;
+
/* Memory region reserved for storing panic kernel and other data. */
static struct memory_range crash_reserved_mem;

diff --git a/kexec/arch/mips/include/arch/options.h b/kexec/arch/mips/include/arch/options.h
index a18251b..86b620f 100644
--- a/kexec/arch/mips/include/arch/options.h
+++ b/kexec/arch/mips/include/arch/options.h
@@ -3,6 +3,7 @@

#define OPT_ARCH_MAX (OPT_MAX+0)
#define OPT_APPEND (OPT_ARCH_MAX+0)
+#define OPT_DTB (OPT_ARCH_MAX+1)

/* Options relevant to the architecture (excluding loader-specific ones),
* in this case none:
@@ -10,7 +11,9 @@
#define KEXEC_ARCH_OPTIONS \
KEXEC_OPTIONS \
{"command-line", 1, 0, OPT_APPEND}, \
- {"append", 1, 0, OPT_APPEND},
+ {"append", 1, 0, OPT_APPEND}, \
+ {"dtb", 1, 0, OPT_DTB },
+

#define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""

diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index 7cb06f1..6ca7ca0 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -29,13 +29,16 @@
#include "kexec-mips.h"
#include "crashdump-mips.h"
#include <arch/options.h>
+#include "../../fs2dt.h"
+#include "../../dt-ops.h"

static const int probe_debug = 0;

#define BOOTLOADER "kexec"
-#define MAX_COMMAND_LINE 256
#define UPSZ(X) _ALIGN_UP(sizeof(X), 4)
-static char cmdline_buf[256] = "kexec ";
+
+#define CMDLINE_PREFIX "kexec "
+static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX;

int elf_mips_probe(const char *buf, off_t len)
{
@@ -74,6 +77,10 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
int result;
unsigned long cmdline_addr;
size_t i;
+ off_t dtb_length;
+ char *dtb_buf;
+ unsigned long long kernel_addr = 0, kernel_size = 0;
+ unsigned long pagesize = getpagesize();

/* Need to append some command line parameters internally in case of
* taking crash dumps.
@@ -92,8 +99,11 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
for (i = 0; i < ehdr.e_phnum; i++) {
struct mem_phdr *phdr;
phdr = &ehdr.e_phdr[i];
- if (phdr->p_type == PT_LOAD)
+ if (phdr->p_type == PT_LOAD) {
phdr->p_paddr = virt_to_phys(phdr->p_paddr);
+ kernel_addr = phdr->p_paddr;
+ kernel_size = phdr->p_memsz;
+ }
}

/* Load the Elf data */
@@ -130,10 +140,28 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
else
cmdline_addr = 0;

+ /* MIPS systems that have been converted to use device tree
+ * passed through UHI will use commandline in the DTB and
+ * the DTB passed as a separate buffer. Note that
+ * CMDLINE_PREFIX is skipped here intentionally, as it is
+ * used only in the legacy method */
+
+ if (arch_options.dtb_file) {
+ dtb_buf = slurp_file(arch_options.dtb_file, &dtb_length);
+ } else {
+ create_flatten_tree(&dtb_buf, &dtb_length, cmdline_buf + strlen(CMDLINE_PREFIX));
+ }
+
+ /* This is a legacy method for commandline passing used
+ * currently by Octeon CPUs only */
add_buffer(info, cmdline_buf, sizeof(cmdline_buf),
sizeof(cmdline_buf), sizeof(void *),
cmdline_addr, 0x0fffffff, 1);

+ add_buffer(info, dtb_buf, dtb_length, dtb_length, 0,
+ _ALIGN_UP(kernel_addr + kernel_size, pagesize),
+ 0x0fffffff, 1);
+
return 0;
}

diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
index 867e9c3..2605c17 100644
--- a/kexec/arch/mips/kexec-mips.c
+++ b/kexec/arch/mips/kexec-mips.c
@@ -21,6 +21,10 @@
#include "kexec-mips.h"
#include <arch/options.h>

+/* Currently not used but required by top-level fs2dt code */
+off_t initrd_base = 0;
+off_t initrd_size = 0;
+
static struct memory_range memory_range[MAX_MEMORY_RANGES];

/* Return a sorted list of memory ranges. */
@@ -77,6 +81,7 @@ void arch_usage(void)
printf(
" --command-line=STRING Set the kernel command line to STRING.\n"
" --append=STRING Set the kernel command line to STRING.\n"
+ " --dtb=FILE Use FILE as the device tree blob.\n"
);
}

@@ -103,6 +108,9 @@ int arch_process_options(int argc, char **argv)
case OPT_APPEND:
arch_options.command_line = optarg;
break;
+ case OPT_DTB:
+ arch_options.dtb_file = optarg;
+ break;
default:
break;
}
diff --git a/kexec/arch/mips/kexec-mips.h b/kexec/arch/mips/kexec-mips.h
index 2991b2d..a609fb5 100644
--- a/kexec/arch/mips/kexec-mips.h
+++ b/kexec/arch/mips/kexec-mips.h
@@ -1,6 +1,11 @@
#ifndef KEXEC_MIPS_H
#define KEXEC_MIPS_H

+#include <sys/types.h>
+
+#define BOOT_BLOCK_VERSION 17
+#define BOOT_BLOCK_LAST_COMP_VERSION 16
+
#define MAX_MEMORY_RANGES 64
#define MAX_LINE 160

@@ -14,7 +19,11 @@ void elf_mips_usage(void);

struct arch_options_t {
char *command_line;
+ char *dtb_file;
int core_header_type;
};

+extern struct memory_ranges usablemem_rgns;
+extern off_t initrd_base, initrd_size;
+
#endif /* KEXEC_MIPS_H */
--
2.7.4
Simon Horman
2016-12-09 07:57:23 UTC
Permalink
Post by Marcin Nowakowski
This patch series tries to bring the support for MIPS up to date and make it more
generic (fix little-endian support, simplify code for 32/64 bit handling), as well
as to clean up some existing incorrect code (patches 1-4).
Patches 5 & 6 add new functionality - passing external DTBs and initrd, especially
the DTB support is required for platforms that use a recently introduced generic
kernel infrastructure.
Note that patch 5 (and 6, as it depends on patch 5) require changes in the kernel
https://patchwork.linux-mips.org/patch/14615/
Core dump support is currently broken on all MIPS kernels and is also pending
https://patchwork.linux-mips.org/patch/14587/
https://patchwork.linux-mips.org/patch/14586/
Patches 1-4 can be safely added without waiting for kernel patches to be merged,
but patches 5-6 should be held until the kernel patches are accepted in case changes
are requested.
Thanks, applied.

Loading...