provide ELF/KEXEC support for MIPS ath79 and malta
Subsystems (3)
cover provide ELF/KEXEC support for MIPS ath79 and malta
This patch set is a squashed and rebased patch set of work done by:
Antony Pavlov and Yegor Yefremov.
This code suppose provide kernel start support for some MIPS machines. For example ath79 (Atheros) and malta should be able to work with it.
So far only kernel and cmdline passing is supported. ARM and other arches would probably work with some more or less work.
Antony Pavlov (5):
resource: add create_resource() helper function
filetype: add ELF type
bootm: add kexec ELF support
MIPS: add kexec ELF loading support
MIPS: malta: enable kexec
Oleksij Rempel (2):
MIPS: ath79: add kexec support
MIPS: configs: add KEXEC=y to atheros devices
arch/mips/Kconfig | 2 + arch/mips/configs/8devices-lima_defconfig | 1 + arch/mips/configs/black-swift_defconfig | 1 + arch/mips/configs/dptechnics-dpt-module_defconfig | 1 + arch/mips/configs/tplink-mr3020_defconfig | 1 + arch/mips/configs/tplink-wdr4300_defconfig | 1 + arch/mips/include/asm/elf.h | 8 +- arch/mips/lib/Makefile | 3 + arch/mips/lib/kexec-mips.c | 272 +++++++++ arch/mips/lib/machine_kexec.h | 21 + arch/mips/lib/relocate_kernel.S | 108 ++++ arch/mips/mach-ath79/Makefile | 1 + arch/mips/mach-ath79/reboot.c | 42 ++ arch/mips/mach-malta/Makefile | 1 + arch/mips/mach-malta/reboot.c | 106 ++++ commands/Kconfig | 7 + common/Kconfig | 3 + common/filetype.c | 5 + common/resource.c | 15 + include/bootm.h | 3 + include/filetype.h | 1 + include/linux/ioport.h | 2 + include/linux/reboot.h | 14 + lib/Makefile | 1 + lib/kexec/Makefile | 4 + lib/kexec/kexec-bootm-elf.c | 37 ++ lib/kexec/kexec-elf-exec.c | 79 +++ lib/kexec/kexec-elf.c | 678 ++++++++++++++++++++++ lib/kexec/kexec-elf.h | 66 +++ lib/kexec/kexec.c | 281 +++++++++ lib/kexec/kexec.h | 92 +++ 31 files changed, 1856 insertions(+), 1 deletion(-) create mode 100644 arch/mips/lib/kexec-mips.c create mode 100644 arch/mips/lib/machine_kexec.h create mode 100644 arch/mips/lib/relocate_kernel.S create mode 100644 arch/mips/mach-ath79/reboot.c create mode 100644 arch/mips/mach-malta/reboot.c create mode 100644 include/linux/reboot.h create mode 100644 lib/kexec/Makefile create mode 100644 lib/kexec/kexec-bootm-elf.c create mode 100644 lib/kexec/kexec-elf-exec.c create mode 100644 lib/kexec/kexec-elf.c create mode 100644 lib/kexec/kexec-elf.h create mode 100644 lib/kexec/kexec.c create mode 100644 lib/kexec/kexec.h
Signature · 7 lines
2.14.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC PATCH 6/7 MIPS: malta: enable kexec
From: Antony Pavlov <[email protected]>
--- arch/mips/Kconfig | 1 + arch/mips/mach-malta/Makefile | 1 + arch/mips/mach-malta/reboot.c | 106 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 arch/mips/mach-malta/reboot.c
arch/mips/Kconfig +1 -0
@@ -51,6 +51,7 @@ config MACH_MIPS_MALTA select HAS_DEBUG_LL select GPIOLIB select HW_HAS_PCI + select HAS_KEXEC config MACH_MIPS_AR231X bool "Atheros ar231x-based boards"
arch/mips/mach-malta/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-y += reset.o obj-$(CONFIG_PCI) += pci.o +obj-$(CONFIG_KEXEC) += reboot.o
arch/mips/mach-malta/reboot.c new file +106 -0
106 lines not on this page · raw message
Signature · 7 lines
2.14.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC PATCH 1/7 resource: add create_resource() helper function
In reply to Oleksij RempelFrom: Antony Pavlov <[email protected]>
--- common/resource.c | 15 +++++++++++++++ include/linux/ioport.h | 2 ++ 2 files changed, 17 insertions(+)
common/resource.c +15 -0
@@ -150,3 +150,18 @@ struct resource *request_ioport_region(const char *name,return res; } + +struct resource *create_resource (const char *name, +resource_size_t start,resource_size_t end) +{ +struct resource *t; + + t =xzalloc (sizeof *t); +INIT_LIST_HEAD (&t->children); + t->parent =NULL ; + t->name =xstrdup (name); + t->start = start; + t->end = end; + +return t; +}
include/linux/ioport.h +2 -0
@@ -140,6 +140,8 @@ struct resource *__request_region(struct resource *parent, resource_size_t size);int release_region (struct resource *res); +struct resource *create_resource (const char *name, +resource_size_t start,resource_size_t end);extern struct resource iomem_resource;extern struct resource ioport_resource;
Signature · 7 lines
2.14.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC PATCH 2/7 filetype: add ELF type
In reply to Oleksij RempelFrom: Antony Pavlov <[email protected]>
--- common/filetype.c | 5 +++++ include/filetype.h | 1 + 2 files changed, 6 insertions(+)
common/filetype.c +5 -0
@@ -27,6 +27,7 @@#include <envfs.h> #include <disks.h> #include <image-sparse.h> +#include <elf.h> struct filetype_str {const char *name;/* human readable filetype */
@@ -68,6 +69,7 @@ static const struct filetype_str filetype_str[] = { [filetype_kwbimage_v1] = { "MVEBU kwbimage (v1)", "kwb" }, [filetype_android_sparse] = { "Android sparse image", "sparse" }, [filetype_arm64_linux_image] = { "ARM aarch64 Linux image", "aarch64-linux" }, + [filetype_elf] = { "ELF", "elf" }, };const char *file_type_to_string (enum filetype f)
@@ -344,6 +346,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize) buf[7] == 0x47530000)return filetype_ch_image_be; +if (strncmp (buf8,ELFMAG ,4 ) ==0 ) +return filetype_elf; +return filetype_unknown; }
include/filetype.h +1 -0
@@ -41,6 +41,7 @@ enum filetype { filetype_kwbimage_v1, filetype_android_sparse, filetype_arm64_linux_image, + filetype_elf, filetype_max, };
Signature · 7 lines
2.14.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC PATCH 4/7 MIPS: add kexec ELF loading support
In reply to Oleksij RempelFrom: Antony Pavlov <[email protected]>
--- arch/mips/include/asm/elf.h | 8 +- arch/mips/lib/Makefile | 3 + arch/mips/lib/kexec-mips.c | 272 ++++++++++++++++++++++++++++++++++++++++ arch/mips/lib/machine_kexec.h | 21 ++++ arch/mips/lib/relocate_kernel.S | 108 ++++++++++++++++ 5 files changed, 411 insertions(+), 1 deletion(-) create mode 100644 arch/mips/lib/kexec-mips.c create mode 100644 arch/mips/lib/machine_kexec.h create mode 100644 arch/mips/lib/relocate_kernel.S
arch/mips/include/asm/elf.h +7 -1
@@ -17,12 +17,18 @@#ifndef ELF_ARCH +/* Legal values for e_machine (architecture). */ + +#define EM_MIPS 8/* MIPS R3000 big-endian */ +#define EM_MIPS_RS4_BE 10/* MIPS R4000 big-endian */ +#ifdef CONFIG_32BIT /* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch (hdr) \ +#define elf_check_arch (x) ((x)->e_machine == EM_MIPS) +/* * These are used to set parameters in the core dumps. */
arch/mips/lib/Makefile +3 -0
@@ -18,4 +18,7 @@ obj-$(CONFIG_CPU_MIPS64) += c-r4k.o obj-$(CONFIG_CMD_MIPS_CPUINFO) += cpuinfo.o obj-$(CONFIG_CMD_BOOTM) += bootm.o +obj-$(CONFIG_KEXEC) += kexec-mips.o +obj-$(CONFIG_KEXEC) += relocate_kernel.o + pbl-y += ashldi3.o
arch/mips/lib/kexec-mips.c new file +272 -0
272 lines not on this page · raw message
arch/mips/lib/machine_kexec.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef _MACHINE_KEXEC_H +#define _MACHINE_KEXEC_H + +#ifndef __ASSEMBLY__ +extern const unsigned char kexec_relocate_new_kernel[]; +extern unsigned long kexec_relocate_new_kernel_end; +extern unsigned long kexec_start_address; +extern unsigned long kexec_indirection_page; + +extern unsigned long kexec_args[4 ]; +extern char kexec_argv_buf[]; +extern char *kexec_argv[]; + +#define KEXEC_RELOCATE_NEW_KERNEL_SIZE ((unsigned long)&kexec_relocate_new_kernel_end - (unsigned long)kexec_relocate_new_kernel) +#endif /* !__ASSEMBLY__ */ + +#define KEXEC_COMMAND_LINE_SIZE 256 +#define KEXEC_ARGV_SIZE (KEXEC_COMMAND_LINE_SIZE / 16) +#define KEXEC_MAX_ARGC (KEXEC_ARGV_SIZE / sizeof(long)) + +#endif
arch/mips/lib/relocate_kernel.S new file +108 -0
108 lines not on this page · raw message
Signature · 7 lines
2.14.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC PATCH 5/7 MIPS: ath79: add kexec support
In reply to Oleksij Rempel--- arch/mips/Kconfig | 1 + arch/mips/mach-ath79/Makefile | 1 + arch/mips/mach-ath79/reboot.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 arch/mips/mach-ath79/reboot.c
arch/mips/Kconfig +1 -0
@@ -73,6 +73,7 @@ config MACH_MIPS_ATH79 select CLKDEV_LOOKUP select OFTREE select GPIOLIB + select HAS_KEXEC config MACH_MIPS_BCM47XX bool "Broadcom BCM47xx-based boards"
arch/mips/mach-ath79/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-y += reset.o obj-y += bbu.o +obj-$(CONFIG_KEXEC) += reboot.o
arch/mips/mach-ath79/reboot.c new file +42 -0
42 lines not on this page · raw message
Signature · 7 lines
2.14.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC PATCH 3/7 bootm: add kexec ELF support
In reply to Oleksij RempelFrom: Antony Pavlov <[email protected]>
Also introduce reboot() for starting already loaded via kexec ELF segments.
--- commands/Kconfig | 7 + common/Kconfig | 3 + include/bootm.h | 3 + include/linux/reboot.h | 14 + lib/Makefile | 1 + lib/kexec/Makefile | 4 + lib/kexec/kexec-bootm-elf.c | 37 +++ lib/kexec/kexec-elf-exec.c | 79 ++++++ lib/kexec/kexec-elf.c | 678 ++++++++++++++++++++++++++++++++++++++++++++ lib/kexec/kexec-elf.h | 66 +++++ lib/kexec/kexec.c | 281 ++++++++++++++++++ lib/kexec/kexec.h | 92 ++++++ 12 files changed, 1265 insertions(+) create mode 100644 include/linux/reboot.h create mode 100644 lib/kexec/Makefile create mode 100644 lib/kexec/kexec-bootm-elf.c create mode 100644 lib/kexec/kexec-elf-exec.c create mode 100644 lib/kexec/kexec-elf.c create mode 100644 lib/kexec/kexec-elf.h create mode 100644 lib/kexec/kexec.c create mode 100644 lib/kexec/kexec.h
commands/Kconfig +7 -0
@@ -476,6 +476,13 @@ config CMD_SAVES Save S-Record file to serial line with offset OFFS and length LEN. +config KEXEC + bool + prompt "bootm ELF image support" + depends on CMD_BOOTM && HAS_KEXEC + help + Support using ELF Images. + config CMD_UIMAGE select UIMAGE tristate
common/Kconfig +3 -0
@@ -1218,3 +1218,6 @@ config HAS_DEBUG_LL config DDR_SPD bool select CRC16 + +config HAS_KEXEC + bool
include/bootm.h +3 -0
@@ -72,6 +72,9 @@ struct image_data {char *oftree_file;char *oftree_part; +unsigned long oftree_address; + +unsigned long cmdline_address;const void *fit_kernel;unsigned long fit_kernel_size;
include/linux/reboot.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _LINUX_REBOOT_H +#define _LINUX_REBOOT_H + +/* +* Commands accepted by the _reboot() system call. +* +* KEXEC Restart system using a previously loaded Linux kernel +*/ + +#define LINUX_REBOOT_CMD_KEXEC 0x45584543 + +extern int reboot (int cmd,void *opaque); + +#endif /* _LINUX_REBOOT_H */
lib/Makefile +1 -0
@@ -65,3 +65,4 @@ obj-y += int_sqrt.o obj-y += parseopt.o obj-y += clz_ctz.o obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o +obj-$(CONFIG_KEXEC) += kexec/
lib/kexec/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +obj-y += kexec.o +obj-y += kexec-elf.o +obj-y += kexec-elf-exec.o +obj-y += kexec-bootm-elf.o
lib/kexec/kexec-bootm-elf.c new file +37 -0
@@ -0,0 +1,37 @@ +#include <bootm.h> +#include <init.h> +#include <binfmt.h> +#include <errno.h> +#include <linux/reboot.h> +#include <environment.h> + +#include "kexec.h" + +static int do_bootm_elf (struct image_data *data) +{ +kexec_load_bootm_data (data); + +reboot (LINUX_REBOOT_CMD_KEXEC , data); + +return -ERESTARTSYS ; +} + +static struct image_handler elf_handler = { + .name ="ELF" , + .bootm = do_bootm_elf, + .filetype = filetype_elf, +}; + +static struct binfmt_hook binfmt_elf_hook = { + .type = filetype_elf, + .exec ="bootm" , +}; + +static int elf_register_image_handler (void ) +{ +register_image_handler (&elf_handler); +binfmt_register (&binfmt_elf_hook); + +return 0 ; +} +late_initcall (elf_register_image_handler);
lib/kexec/kexec-elf-exec.c new file +79 -0
79 lines not on this page · raw message
lib/kexec/kexec-elf.c new file +678 -0
678 lines not on this page · raw message
lib/kexec/kexec-elf.h new file +66 -0
66 lines not on this page · raw message
lib/kexec/kexec.c new file +281 -0
281 lines not on this page · raw message
lib/kexec/kexec.h new file +92 -0
92 lines not on this page · raw message
Signature · 7 lines
2.14.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC PATCH 7/7 MIPS: configs: add KEXEC=y to atheros devices
In reply to Oleksij Rempelcurrently kexec is the only way we can boot linux kernel on this devices. So enable it in configs per default.
--- arch/mips/configs/8devices-lima_defconfig | 1 + arch/mips/configs/black-swift_defconfig | 1 + arch/mips/configs/dptechnics-dpt-module_defconfig | 1 + arch/mips/configs/tplink-mr3020_defconfig | 1 + arch/mips/configs/tplink-wdr4300_defconfig | 1 + 5 files changed, 5 insertions(+)
arch/mips/configs/8devices-lima_defconfig +1 -0
@@ -20,6 +20,7 @@ CONFIG_CMD_GO=y CONFIG_CMD_LOADB=y CONFIG_CMD_LOADY=y CONFIG_CMD_RESET=y +CONFIG_KEXEC=y CONFIG_CMD_EXPORT=y CONFIG_CMD_DEFAULTENV=y CONFIG_CMD_LOADENV=y
arch/mips/configs/black-swift_defconfig +1 -0
@@ -25,6 +25,7 @@ CONFIG_CMD_GO=y CONFIG_CMD_LOADB=y CONFIG_CMD_LOADY=y CONFIG_CMD_RESET=y +CONFIG_KEXEC=y CONFIG_CMD_PARTITION=y CONFIG_CMD_GLOBAL=y CONFIG_CMD_SHA1SUM=y
arch/mips/configs/dptechnics-dpt-module_defconfig +1 -0
@@ -22,6 +22,7 @@ CONFIG_CMD_GO=y CONFIG_CMD_LOADB=y CONFIG_CMD_LOADY=y CONFIG_CMD_RESET=y +CONFIG_KEXEC=y CONFIG_CMD_EXPORT=y CONFIG_CMD_DEFAULTENV=y CONFIG_CMD_LOADENV=y
arch/mips/configs/tplink-mr3020_defconfig +1 -0
@@ -19,6 +19,7 @@ CONFIG_CMD_GO=y CONFIG_CMD_LOADB=y CONFIG_CMD_LOADY=y CONFIG_CMD_RESET=y +CONFIG_KEXEC=y CONFIG_CMD_EXPORT=y CONFIG_CMD_DEFAULTENV=y CONFIG_CMD_LOADENV=y
arch/mips/configs/tplink-wdr4300_defconfig +1 -0
@@ -20,6 +20,7 @@ CONFIG_CMD_GO=y CONFIG_CMD_LOADB=y CONFIG_CMD_LOADY=y CONFIG_CMD_RESET=y +CONFIG_KEXEC=y CONFIG_CMD_EXPORT=y CONFIG_CMD_DEFAULTENV=y CONFIG_CMD_LOADENV=y
Signature · 7 lines
2.14.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC PATCH 3/7] bootm: add kexec ELF support
In reply to Oleksij Rempellib/kexec/kexec-bootm-elf.c line 18
Quoted 9 lines · Oleksij Rempel
lib/kexec/kexec-bootm-elf.c new file +9
-0+static int do_bootm_elf (struct image_data *data) +{ +kexec_load_bootm_data (data); + +reboot (LINUX_REBOOT_CMD_KEXEC , data); + +return -ERESTARTSYS ; +} +
I can't really judge this series. This is the only thing I stumbled
upon: I see no reason to name the architecture specific kexec function 'reboot'. I would expect some kexec specific name, like arch_kexec or similar.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC PATCH 3/7] bootm: add kexec ELF support
Quoted 16 lines · On Fri, 4 May 2018 07:54:08 +0200 Sascha Hauer <[email protected]> wrote:
lib/kexec/kexec-bootm-elf.c line 18
Quoted 9 lines · Oleksij Rempel
lib/kexec/kexec-bootm-elf.c new file +9
-0+static int do_bootm_elf (struct image_data *data) +{ +kexec_load_bootm_data (data); + +reboot (LINUX_REBOOT_CMD_KEXEC , data); + +return -ERESTARTSYS ; +} +I can't really judge this series. This is the only thing I stumbled
upon: I see no reason to name the architecture specific kexec function 'reboot'. I would expect some kexec specific name, likearch_kexecor similar.
This reboot function is copy-n-paste from linux kernel reboot syscall (see linux/kernel/reboot.c for details).
At the moment there is only one constant for reboot()'s first argument (LINUX_REBOOT_CMD_KEXEC), so it's reasonable to elimenate this first argument and rename function to kexec_reboot().
Quoted 11 lines
Signature · 10 lines
-- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 7 lines
Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC PATCH 3/7] bootm: add kexec ELF support
Am 04.05.2018 um 12:08 schrieb Antony Pavlov:
Quoted 20 lines
Quoted 16 lines · On Fri, 4 May 2018 07:54:08 +0200 Sascha Hauer <[email protected]> wrote:
lib/kexec/kexec-bootm-elf.c line 18
Quoted 9 lines · Oleksij Rempel
lib/kexec/kexec-bootm-elf.c new file +9
-0+static int do_bootm_elf (struct image_data *data) +{ +kexec_load_bootm_data (data); + +reboot (LINUX_REBOOT_CMD_KEXEC , data); + +return -ERESTARTSYS ; +} +I can't really judge this series. This is the only thing I stumbled
upon: I see no reason to name the architecture specific kexec function 'reboot'. I would expect some kexec specific name, likearch_kexecor similar.
Quoted 4 lines
This reboot function is copy-n-paste from linux kernel reboot syscall (see
linux/kernel/reboot.cfor details).
At the moment there is only one constant for reboot()'s first argument (LINUX_REBOOT_CMD_KEXEC), so it's reasonable to elimenate this first argument and rename function tokexec_reboot().
amy be better to rename it to kexec_arch or kexec_mach. kexec_reboot is kind if misleading
Signature · 2 lines
Regards, Oleksij
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC PATCH 3/7] bootm: add kexec ELF support
Quoted 21 lines · On Fri, 4 May 2018 11:53:48 +0200 Oleksij Rempel <[email protected]> wrote:
Am 04.05.2018 um 12:08 schrieb Antony Pavlov:
Quoted 20 lines
Quoted 16 lines · On Fri, 4 May 2018 07:54:08 +0200 Sascha Hauer <[email protected]> wrote:
lib/kexec/kexec-bootm-elf.c line 18
Quoted 9 lines · Oleksij Rempel
lib/kexec/kexec-bootm-elf.c new file +9
-0+static int do_bootm_elf (struct image_data *data) +{ +kexec_load_bootm_data (data); + +reboot (LINUX_REBOOT_CMD_KEXEC , data); + +return -ERESTARTSYS ; +} +I can't really judge this series. This is the only thing I stumbled
upon: I see no reason to name the architecture specific kexec function 'reboot'. I would expect some kexec specific name, likearch_kexecor similar.
Quoted 7 lines
Quoted 4 lines
This reboot function is copy-n-paste from linux kernel reboot syscall (see
linux/kernel/reboot.cfor details).
At the moment there is only one constant for reboot()'s first argument (LINUX_REBOOT_CMD_KEXEC), so it's reasonable to elimenate this first argument and rename function tokexec_reboot().amy be better to rename it to
kexec_archorkexec_mach.kexec_rebootis kind if misleading
Linux uses machine_kexec(struct kimage *image) in arch/mips/kernel/machine_kexec.c.
Signature · 7 lines
Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox