PPC32 kexec v3
Subsystems (2)
Hi Simon,
sorry for the delay. I broke something and wanted to make sure that whatever I sent is working.
I'm sending the whole series which should be bisectable and care about HAVE_LIBZ.
Patch 6 splits my uImage handling and 7 reuses it for SH and ARM. This is only compile tested for ARM. The only benefit is that with libz it will be crc32 tested.
The whole series is also at
git://git.breakpoint.cc/bigeasy/kexec-tools.git ppc32
Sebastian
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH 1/7 slurpfile: use lseek() on character nodes instead of fstat() for file size
From: Sebastian Andrzej Siewior <[email protected]>
fstat() is used to determine the filesize before read() and it requires a filesystem. That means that it can not be used on character nodes. This makes it impossible to obtains the kernel from a char node like mtd or more likely ubi. We can't use this in every case because files in /proc don't support lseek(). This is required by the powerpc part to read some device-tree entries.
--- kexec/kexec.c | 23 +++++++++++++++++++++-- 1 files changed, 21 insertions(+), 2 deletions(-)
kexec/kexec.c +21 -2
@@ -475,7 +475,7 @@ char *slurp_file(const char *filename, off_t *r_size) {int fd;char *buf; -off_t size, progress; +off_t size, progress, err;ssize_t result;struct stat stats;
@@ -494,7 +494,26 @@ char *slurp_file(const char *filename, off_t *r_size)die ("Cannot stat: %s: %s\n" , filename,strerror (errno)); } - size = stats.st_size; +/* +* Seek in case the kernel is a character node like /dev/ubi0_0. +* This does not work on regular files which live in /proc and +* we need this for some /proc/device-tree entries +*/ +if (S_ISCHR (stats.st_mode)) { + + size =lseek (fd,0 ,SEEK_END ); +if (size <0 ) +die ("Can not seek file %s: %s\n" , filename, +strerror (errno)); + + err =lseek (fd,0 ,SEEK_SET ); +if (err <0 ) +die ("Can not seek to the begin of file %s: %s\n" , + filename,strerror (errno)); + }else { + size = stats.st_size; + } + *r_size = size; buf =xmalloc (size); progress =0 ;
Signature · 7 lines
1.6.5.2 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 2/7 powerpc: dtb and purgatory support for ppc32
In reply to Sebastian Andrzej SiewiorFrom: Sebastian Andrzej Siewior <[email protected]>
Some code dtb scanning & filling has been borrowed from ppc64. The old behavior is still available if compiled with GameCube, other PowerPC platform use the can purgatory and specify a new dtb.
Booting a self contained elf image (incl. dtb / without the need for a bd sturct or the like) can be booted. The dtb support is currently optional. That means if the elf image does not contain a dtb file then the user has to supply a complete dtb (including mem size, command line, bus freq., mac addr, ...)
--- kexec/arch/ppc/kexec-elf-ppc.c | 108 +++++++--- kexec/arch/ppc/kexec-elf-rel-ppc.c | 4 + kexec/arch/ppc/kexec-ppc.c | 449 +++++++++++++++++++++++++++++++++++- kexec/arch/ppc/kexec-ppc.h | 7 + purgatory/arch/ppc/Makefile | 1 + purgatory/arch/ppc/purgatory-ppc.c | 6 + purgatory/arch/ppc/v2wrap.S | 66 ++++++ 7 files changed, 608 insertions(+), 33 deletions(-) create mode 100644 purgatory/arch/ppc/v2wrap.S
kexec/arch/ppc/kexec-elf-ppc.c +81 -27
@@ -91,16 +91,6 @@ int elf_ppc_probe(const char *buf, off_t len)return result; } -void elf_ppc_usage (void ) -{ -printf - ( -" --command-line=STRING Set the kernel command line to STRING.\n" -" --append=STRING Set the kernel command line to STRING.\n" -" --gamecube=1|0 Enable/disable support for ELFs with changed\n" -" addresses suitable for the GameCube.\n" ); -} -static void gamecube_hack_addresses (struct mem_ehdr *ehdr) {struct mem_phdr *phdr, *phdr_end;
@@ -122,39 +112,56 @@ static void gamecube_hack_addresses(struct mem_ehdr *ehdr) } } +#define OPT_APPEND (OPT_ARCH_MAX+0) +#define OPT_GAMECUBE (OPT_ARCH_MAX+1) +#define OPT_DTB (OPT_ARCH_MAX+2) +static const struct option options[] = { + KEXEC_ARCH_OPTIONS + {"command-line" ,1 ,0 ,OPT_APPEND }, + {"append" ,1 ,0 ,OPT_APPEND }, + {"gamecube" ,1 ,0 ,OPT_GAMECUBE }, + {"dtb" ,1 ,0 ,OPT_DTB }, + {0 ,0 ,0 ,0 }, +}; +static const char short_options[] =KEXEC_ARCH_OPT_STR "d" ; + +void elf_ppc_usage (void ) +{ +printf ( +" --command-line=STRING Set the kernel command line to STRING.\n" +" --append=STRING Set the kernel command line to STRING.\n" +" --gamecube=1|0 Enable/disable support for ELFs with changed\n" +" addresses suitable for the GameCube.\n" +" --dtb=<filename> Specify device tree blob file.\n" + ); +} +int elf_ppc_load (int argc,char **argv,const char *buf,off_t len,struct kexec_info *info) {struct mem_ehdr ehdr; +char *command_line; +int command_line_len; +char *dtb; +int result; +#ifdef WITH_GAMECUBE +int target_is_gamecube =1 ;char *arg_buf;size_t arg_bytes;unsigned long arg_base;struct boot_notes *notes;size_t note_bytes; -const char *command_line; -int command_line_len;unsigned char *setup_start;uint32_t setup_size; -int result; -#ifdef WITH_GAMECUBE -int target_is_gamecube =1 ;#else int target_is_gamecube =0 ; +unsigned int addr; +unsigned long dtb_addr;#endif int opt; -#define OPT_APPEND (OPT_ARCH_MAX+0) -#define OPT_GAMECUBE (OPT_ARCH_MAX+1) -static const struct option options[] = { - KEXEC_ARCH_OPTIONS - {"command-line" ,1 ,0 ,OPT_APPEND }, - {"append" ,1 ,0 ,OPT_APPEND }, - {"gamecube" ,1 ,0 ,OPT_GAMECUBE }, - {0 ,0 ,0 ,0 }, - }; -static const char short_options[] =KEXEC_ARCH_OPT_STR "d" ; - - command_line =0 ; + command_line =NULL ; + dtb =NULL ;while ((opt =getopt_long (argc, argv, short_options, options,0 )) !=-1 ) {switch (opt) {default :
@@ -171,6 +178,10 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len,case OPT_GAMECUBE : target_is_gamecube =atoi (optarg);break ; + +case OPT_DTB : + dtb = optarg; +break ; } } command_line_len =0 ;
@@ -194,6 +205,12 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len,return result; } +/* +* In case of a toy we take the hardcoded things and an easy setup via +* one of the assembly startups. Every thing else should be grown up +* and go through the purgatory. +*/ +#ifdef WITH_GAMECUBE if (target_is_gamecube) { setup_start = setup_dol_start; setup_size = setup_dol_size;
@@ -220,5 +237,42 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len, notes->hdr.b_checksum =compute_ip_checksum (notes, note_bytes); info->entry = (void *)arg_base; +#else +elf_rel_build_load (info, &info->rhdr, (const char *)purgatory, + purgatory_size,0 ,elf_max_addr (&ehdr),1 ,0 ); + +if (dtb) { +char *blob_buf; +off_t blob_size =0 ; + +/* Grab device tree from buffer */ + blob_buf =slurp_file (dtb, &blob_size); + dtb_addr =add_buffer (info, blob_buf, blob_size, blob_size,0 ,0 , +KERNEL_ACCESS_TOP ,-1 ); +if (command_line) +die ("Don't consider command line because dtb is supplied\n" ); + }else { +die ("Missing dtb.\n" ); + } + +/* set various variables for the purgatory */ + addr = ehdr.e_entry; +elf_rel_set_symbol (&info->rhdr,"kernel" , &addr,sizeof (addr)); + + addr = dtb_addr; +elf_rel_set_symbol (&info->rhdr,"dt_offset" , &addr,sizeof (addr)); + + addr = rmo_top; +elf_rel_set_symbol (&info->rhdr,"mem_size" , &addr,sizeof (addr)); + +#define PUL_STACK_SIZE (16 * 1024) + addr =locate_hole (info,PUL_STACK_SIZE ,0 ,0 ,elf_max_addr (&ehdr),1 ); + addr +=PUL_STACK_SIZE ; +elf_rel_set_symbol (&info->rhdr,"pul_stack" , &addr,sizeof (addr)); +#undef PUL_STACK_SIZE + + addr =elf_rel_get_addr (&info->rhdr,"purgatory_start" ); + info->entry = (void *)addr; +#endif return 0 ; }
kexec/arch/ppc/kexec-elf-rel-ppc.c +4 -0
@@ -31,6 +31,10 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), unsigned long r_type, *(uint16_t *)location = value;break ; +case R_PPC_ADDR16_HI : + *(uint16_t *)location = (value>>16 ) &0xffff ; +break ; +case R_PPC_ADDR16_HA :/* Sign-adjusted lower 16 bits: PPC ELF ABI says: (((x >> 16) + ((x & 0x8000) ? 1 : 0))) & 0xFFFF.
kexec/arch/ppc/kexec-ppc.c +443 -6
471 lines not on this page · raw message
kexec/arch/ppc/kexec-ppc.h +7 -0
@@ -10,6 +10,7 @@ extern struct {extern unsigned char setup_dol_start[];extern uint32_t setup_dol_size; +extern uint64_t rmo_top; extern struct { uint32_t spr8;
@@ -25,4 +26,10 @@ int dol_ppc_load(int argc, char **argv, const char *buf, off_t len, struct kexec_info *info);void dol_ppc_usage (void ); +/* +* During inital setup the kernel does not map the whole memory but a part of +* it. On Book-E that is 64MiB, 601 24MiB or 256MiB (if possible). +*/ +#define KERNEL_ACCESS_TOP (24 * 1024 * 1024) +#endif /* KEXEC_PPC_H */
purgatory/arch/ppc/Makefile +1 -0
@@ -2,6 +2,7 @@ # Purgatory ppc # +ppc_PURGATORY_SRCS += purgatory/arch/ppc/v2wrap.S ppc_PURGATORY_SRCS += purgatory/arch/ppc/misc.S ppc_PURGATORY_SRCS += purgatory/arch/ppc/purgatory-ppc.c ppc_PURGATORY_SRCS += purgatory/arch/ppc/console-ppc.c
purgatory/arch/ppc/purgatory-ppc.c +6 -0
@@ -1,6 +1,12 @@#include <purgatory.h> #include "purgatory-ppc.h" +unsigned int pul_stack =0 ; +unsigned int dt_offset =0 ; +unsigned int kernel =0 ; +unsigned int epapr_magic =0 ; +unsigned int mem_size =0 ; +void setup_arch (void ) {/* Nothing for now */
purgatory/arch/ppc/v2wrap.S new file +66 -0
66 lines not on this page · raw message
Signature · 7 lines
1.6.5.2 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 3/7 powerpc32: pull in libfdt
In reply to Sebastian Andrzej SiewiorFrom: Sebastian Andrzej Siewior <[email protected]>
This is v1.2.0 of libfdt from the dtc project which is available at
git://www.jdl.com/software/dtc.git
The other files
- include/page.h
- include/types.h
- libfdt-wrapper.c
- ops.h
are part of the glue code which is used the powerpc boot wrapper code is comming from the Linux kernel v2.6.27-rc6 and has been modified a little to fit.
--- kexec/arch/ppc/Makefile | 10 +- kexec/arch/ppc/include/page.h | 34 + kexec/arch/ppc/include/types.h | 27 + kexec/arch/ppc/libfdt-wrapper.c | 189 ++++++ kexec/arch/ppc/libfdt/Makefile.libfdt | 8 + kexec/arch/ppc/libfdt/TODO | 3 + kexec/arch/ppc/libfdt/fdt.c | 201 ++++++ kexec/arch/ppc/libfdt/fdt.h | 60 ++ kexec/arch/ppc/libfdt/fdt_ro.c | 466 +++++++++++++ kexec/arch/ppc/libfdt/fdt_rw.c | 463 +++++++++++++ kexec/arch/ppc/libfdt/fdt_strerror.c | 96 +++ kexec/arch/ppc/libfdt/fdt_sw.c | 257 ++++++++ kexec/arch/ppc/libfdt/fdt_wip.c | 145 +++++ kexec/arch/ppc/libfdt/libfdt.h | 1076 +++++++++++++++++++++++++++++++ kexec/arch/ppc/libfdt/libfdt_env.h | 23 + kexec/arch/ppc/libfdt/libfdt_internal.h | 95 +++ kexec/arch/ppc/ops.h | 151 +++++ 17 files changed, 3303 insertions(+), 1 deletions(-) create mode 100644 kexec/arch/ppc/include/page.h create mode 100644 kexec/arch/ppc/include/types.h create mode 100644 kexec/arch/ppc/libfdt-wrapper.c create mode 100644 kexec/arch/ppc/libfdt/Makefile.libfdt create mode 100644 kexec/arch/ppc/libfdt/TODO create mode 100644 kexec/arch/ppc/libfdt/fdt.c create mode 100644 kexec/arch/ppc/libfdt/fdt.h create mode 100644 kexec/arch/ppc/libfdt/fdt_ro.c create mode 100644 kexec/arch/ppc/libfdt/fdt_rw.c create mode 100644 kexec/arch/ppc/libfdt/fdt_strerror.c create mode 100644 kexec/arch/ppc/libfdt/fdt_sw.c create mode 100644 kexec/arch/ppc/libfdt/fdt_wip.c create mode 100644 kexec/arch/ppc/libfdt/libfdt.h create mode 100644 kexec/arch/ppc/libfdt/libfdt_env.h create mode 100644 kexec/arch/ppc/libfdt/libfdt_internal.h create mode 100644 kexec/arch/ppc/ops.h
kexec/arch/ppc/Makefile +9 -1
@@ -1,6 +1,8 @@ # # kexec ppc (linux booting linux) # +include kexec/arch/ppc/libfdt/Makefile.libfdt + ppc_KEXEC_SRCS = kexec/arch/ppc/kexec-ppc.c ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-elf-ppc.c ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-elf-rel-ppc.c
@@ -8,7 +10,13 @@ ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-dol-ppc.c ppc_KEXEC_SRCS += kexec/arch/ppc/ppc-setup-simple.S ppc_KEXEC_SRCS += kexec/arch/ppc/ppc-setup-dol.S +libfdt_SRCS = kexec/arch/ppc/libfdt-wrapper.c +libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/arch/ppc/libfdt/%) + +CPPFLAGS+=-I$(srcdir)/kexec/arch/$(ARCH)/libfdt + +ppc_KEXEC_SRCS += $(libfdt_SRCS) + dist += kexec/arch/ppc/Makefile $(ppc_KEXEC_SRCS) \ kexec/arch/ppc/kexec-ppc.h kexec/arch/ppc/ppc_asm.h \ kexec/arch/ppc/include/arch/options.h -
kexec/arch/ppc/include/page.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef _PPC_BOOT_PAGE_H +#define _PPC_BOOT_PAGE_H +/* +* Copyright (C) 2001 PPC64 Team, IBM Corp +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#ifdef __ASSEMBLY__ +#define ASM_CONST (x) x +#else +#define __ASM_CONST (x) x##UL +#define ASM_CONST (x) __ASM_CONST(x) +#endif + +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +/* align addr on a size boundary - adjust address up/down if needed */ +#define _ALIGN_UP (addr,size) (((addr)+((size)-1))&(~((size)-1))) +#define _ALIGN_DOWN (addr,size) ((addr)&(~((size)-1))) + +/* align addr on a size boundary - adjust address up if needed */ +#define _ALIGN (addr,size) _ALIGN_UP(addr,size) + +/* to align the pointer to the (next) page boundary */ +#define PAGE_ALIGN (addr) _ALIGN(addr, PAGE_SIZE) + +#endif /* _PPC_BOOT_PAGE_H */
kexec/arch/ppc/include/types.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef _TYPES_H_ +#define _TYPES_H_ + +#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0])) + +typedef unsigned char u8 ; +typedef unsigned short u16 ; +typedef unsigned int u32 ; +typedef unsigned long long u64 ; +typedef signed char s8 ; +typedef short s16 ; +typedef int s32 ; +typedef long long s64 ; + +#define min (x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x < _y ? _x : _y; }) + +#define max (x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x > _y ? _x : _y; }) + +#endif /* _TYPES_H_ */
kexec/arch/ppc/libfdt-wrapper.c new file +189 -0
189 lines not on this page · raw message
kexec/arch/ppc/libfdt/Makefile.libfdt new file +8 -0
@@ -0,0 +1,8 @@ +# Makefile.libfdt +# +# This is not a complete Makefile of itself. Instead, it is designed to +# be easily embeddable into other systems of Makefiles. +# +LIBFDT_INCLUDES = fdt.h libfdt.h +LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c +LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
kexec/arch/ppc/libfdt/TODO new file +3 -0
@@ -0,0 +1,3 @@ +- Tree traversal functions +- Graft function +- Complete libfdt.h documenting comments
kexec/arch/ppc/libfdt/fdt.c new file +201 -0
201 lines not on this page · raw message
kexec/arch/ppc/libfdt/fdt.h new file +60 -0
60 lines not on this page · raw message
kexec/arch/ppc/libfdt/fdt_ro.c new file +466 -0
466 lines not on this page · raw message
kexec/arch/ppc/libfdt/fdt_rw.c new file +463 -0
463 lines not on this page · raw message
kexec/arch/ppc/libfdt/fdt_strerror.c new file +96 -0
96 lines not on this page · raw message
kexec/arch/ppc/libfdt/fdt_sw.c new file +257 -0
257 lines not on this page · raw message
kexec/arch/ppc/libfdt/fdt_wip.c new file +145 -0
145 lines not on this page · raw message
kexec/arch/ppc/libfdt/libfdt.h new file +1076 -0
1,029 lines not on this page · raw message
kexec/arch/ppc/libfdt/libfdt_env.h new file +23 -0
Lines of this file are not shown. View the raw message.
kexec/arch/ppc/libfdt/libfdt_internal.h new file +95 -0
95 lines not on this page · raw message
kexec/arch/ppc/ops.h new file +151 -0
151 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 7 lines
1.6.5.2 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Part of the diff is not shown here. View the raw message.
Re: [PATCH 3/7] powerpc32: pull in libfdt
Quoted 11 lines · Sebastian Andrzej Siewior
From: Sebastian Andrzej Siewior <[email protected]>
This is v1.2.0 of libfdt from the dtc project which is available at
git://www.jdl.com/software/dtc.gitThe other files
-include/page.h
-include/types.h
-libfdt-wrapper.c
-ops.h
Quoted 3 lines
are part of the glue code which is used the powerpc boot wrapper code is comming from the Linux kernel v2.6.27-rc6 and has been modified a little to fit.
Hi,
I'm seeing some signed vs unsigned comparison warnings in this code. Here is a stab that I took at fixing them. Do they seem reasonable to you? If so, we could either merge them into your patch or just apply them as another patch.
kexec/arch/ppc/libfdt/fdt.c +2 -2
@@ -74,7 +74,7 @@ int fdt_check_header(const void *fdt)return 0 ; } -const void *fdt_offset_ptr (const void *fdt,int offset,int len) +const void *fdt_offset_ptr (const void *fdt,unsigned offset,unsigned len) {const char *p;
@@ -189,7 +189,7 @@ const char *_fdt_find_string(const charreturn NULL ; } -int fdt_move (const void *fdt,void *buf,int bufsize) +int fdt_move (const void *fdt,void *buf,unsigned bufsize) {FDT_CHECK_HEADER (fdt);
kexec/arch/ppc/libfdt/libfdt.h +4 -4
@@ -122,7 +122,7 @@/* Low-level functions (you probably don't need these) */ /**********************************************************************/ -const void *fdt_offset_ptr (const void *fdt,int offset,int checklen); +const void *fdt_offset_ptr (const void *fdt,unsigned offset,unsigned checklen);static inline void *fdt_offset_ptr_w (void *fdt,int offset,int checklen) {return (void *)(uintptr_t )fdt_offset_ptr (fdt, offset, checklen);
@@ -206,7 +206,7 @@ int fdt_check_header(const void *fdt);* -FDT_ERR_BADVERSION, * -FDT_ERR_BADSTATE, standard meanings */ -int fdt_move (const void *fdt,void *buf,int bufsize); +int fdt_move (const void *fdt,void *buf,unsigned bufsize);/**********************************************************************/ /* Read-only functions */
@@ -781,7 +781,7 @@ int fdt_nop_node(void *fdt, int nodeoffs/* Sequential write functions */ /**********************************************************************/ -int fdt_create (void *buf,int bufsize); +int fdt_create (void *buf,unsigned bufsize);int fdt_add_reservemap_entry (void *fdt,uint64_t addr,uint64_t size);int fdt_finish_reservemap (void *fdt);int fdt_begin_node (void *fdt,const char *name);
@@ -1071,6 +1071,6 @@ int fdt_del_node(void *fdt, int nodeoffs/* Debugging / informational functions */ /**********************************************************************/ -const char *fdt_strerror (int errval); +const char *fdt_strerror (unsigned errval);#endif /* _LIBFDT_H */
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 3/7] powerpc32: pull in libfdt
Quoted 1 line · * Simon Horman | 2010-04-01 09:58:19 [+1100]:
Hi,
Hi,
Quoted 2 lines
I'm seeing some signed vs unsigned comparison warnings in this code. Here is a stab that I took at fixing them. Do they seem reasonable to you?
All but fdt_create() and fdt_strerror() look fine on the first look. The two mentioned don't have the .c file updated. fdt_strerror() should remain unsigned as the error code is negative.
Quoted 2 lines
If so, we could either merge them into your patch or just apply them as another patch.
I would prefer leaving it as it. It is an external library and the time we update it, we lose this changes. If you are going to compile this with -Werror could you add -Wno-sign-compare for the libfdt part? If not please apply it as a separate patch and I try to forward it upstream if you don't.
Sebastian
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 3/7] powerpc32: pull in libfdt
Quoted 11 lines · Sebastian Andrzej Siewior
Quoted 1 line · * Simon Horman | 2010-04-01 09:58:19 [+1100]:
Hi,
Hi,
Quoted 2 lines
I'm seeing some signed vs unsigned comparison warnings in this code. Here is a stab that I took at fixing them. Do they seem reasonable to you?
All but
fdt_create()andfdt_strerror()look fine on the first look. The two mentioned don't have the .c file updated.fdt_strerror()should remain unsigned as the error code is negative.
Quoted 7 lines
Quoted 2 lines
If so, we could either merge them into your patch or just apply them as another patch.
I would prefer leaving it as it. It is an external library and the time we update it, we lose this changes. If you are going to compile this with -Werror could you add -Wno-sign-compare for the libfdt part? If not please apply it as a separate patch and I try to forward it upstream if you don't.
Ok, how about we a) merge your changes as is and b) try and get a patch upstream that we add to kexec-tools later. I understand your reasoning behind not wanting to diverge from libfdt-upstream, but at the same time, I'd like to get this fixed if possible.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 3/7] powerpc32: pull in libfdt
Quoted 4 lines · * Simon Horman | 2010-04-06 16:12:52 [+1000]:
Ok, how about we a) merge your changes as is and b) try and get a patch upstream that we add to kexec-tools later. I understand your reasoning behind not wanting to diverge from libfdt-upstream, but at the same time, I'd like to get this fixed if possible.
Yeah, this sounds good to me. One of your fixes has allready been applied [0]. There is no newer version of libfdt taged at this time. Current HEAD of it produces a .so file. Is it okay with you if pull the lib in and switch to a library once there is a official one?
[0] http://git.jdl.com/gitweb/?p=dtc.git;a=commit;h=b236893fc4bc173877adfa4270b14d7d7209fb10
Sebastian
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 3/7] powerpc32: pull in libfdt
Quoted 10 lines · Sebastian Andrzej Siewior
Quoted 4 lines · * Simon Horman | 2010-04-06 16:12:52 [+1000]:
Ok, how about we a) merge your changes as is and b) try and get a patch upstream that we add to kexec-tools later. I understand your reasoning behind not wanting to diverge from libfdt-upstream, but at the same time, I'd like to get this fixed if possible.
Yeah, this sounds good to me. One of your fixes has allready been applied [0]. There is no newer version of libfdt taged at this time. Current HEAD of it produces a .so file. Is it okay with you if pull the lib in and switch to a library once there is a official one?
Yes, I think that is fine. Do you want me to just take the changes that you posted last week?
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 3/7] powerpc32: pull in libfdt
Quoted 2 lines · * Simon Horman | 2010-04-06 18:41:34 [+1000]:
Do you want me to just take the changes that you
posted last week?
Please do it.
Sebastian
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 3/7] powerpc32: pull in libfdt
Quoted 6 lines · Sebastian Andrzej Siewior
Quoted 2 lines · * Simon Horman | 2010-04-06 18:41:34 [+1000]:
Do you want me to just take the changes that you
posted last week?Please do it.
Done :-)
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 3/7] powerpc32: pull in libfdt
Quoted 1 line · * Simon Horman | 2010-04-07 09:40:44 [+1000]:
Done :-)
I kinda forgot: What is the status on fixing the signed/unsigned things in here?
Am I looking after it or did you want to push some patches first?
Sebastian
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 3/7] powerpc32: pull in libfdt
Quoted 7 lines · Sebastian Andrzej Siewior
Quoted 1 line · * Simon Horman | 2010-04-07 09:40:44 [+1000]:
Done :-)
I kinda forgot: What is the status on fixing the signed/unsigned things in here?
Am I looking after it or did you want to push some patches first?
I was hoping you would forward either my patch of a variant upstream. I'm happy to send it directly if you think that would be better.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH 4/7 powerpc32: add support to fixup the dtb
In reply to Sebastian Andrzej SiewiorFrom: Sebastian Andrzej Siewior <[email protected]>
A few device nodes are dynamically determined by the bootloader (MAC address, memory size, ..) and are not part of the device tree. The kernel command line is also read from dtb and usually not part of the device tree. With the libfdt it is now easy to add/replace nodes in the device tree. The user may specify "--reuse-node=/memory/reg" to update the memory/reg node to what ever is now. This requires the kernel to export the device tree via the procfs in /proc/device-tree.
--- kexec/arch/ppc/Makefile | 1 + kexec/arch/ppc/fixup_dtb.c | 105 ++++++++++++++++++++++++++++++++++++++++ kexec/arch/ppc/fixup_dtb.h | 6 ++ kexec/arch/ppc/kexec-elf-ppc.c | 29 ++++++++++-- 4 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 kexec/arch/ppc/fixup_dtb.c create mode 100644 kexec/arch/ppc/fixup_dtb.h
kexec/arch/ppc/Makefile +1 -0
@@ -9,6 +9,7 @@ ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-elf-rel-ppc.c ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-dol-ppc.c ppc_KEXEC_SRCS += kexec/arch/ppc/ppc-setup-simple.S ppc_KEXEC_SRCS += kexec/arch/ppc/ppc-setup-dol.S +ppc_KEXEC_SRCS += kexec/arch/ppc/fixup_dtb.c libfdt_SRCS = kexec/arch/ppc/libfdt-wrapper.c libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/arch/ppc/libfdt/%)
kexec/arch/ppc/fixup_dtb.c new file +105 -0
105 lines not on this page · raw message
kexec/arch/ppc/fixup_dtb.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __FIXUP_DTB_H +#define __FIXUP_DTB_H + +char *fixup_dtb_nodes (char *blob_buf,off_t *blob_size,char *nodes[],char *cmdline); + +#endif
kexec/arch/ppc/kexec-elf-ppc.c +25 -4
@@ -25,6 +25,7 @@#include <arch/options.h> #include "config.h" +#include "fixup_dtb.h" static const int probe_debug =0 ;
@@ -115,12 +116,14 @@ static void gamecube_hack_addresses(struct mem_ehdr *ehdr)#define OPT_APPEND (OPT_ARCH_MAX+0)#define OPT_GAMECUBE (OPT_ARCH_MAX+1)#define OPT_DTB (OPT_ARCH_MAX+2) +#define OPT_NODES (OPT_ARCH_MAX+3)static const struct option options[] = { KEXEC_ARCH_OPTIONS {"command-line" ,1 ,0 ,OPT_APPEND }, {"append" ,1 ,0 ,OPT_APPEND }, {"gamecube" ,1 ,0 ,OPT_GAMECUBE }, {"dtb" ,1 ,0 ,OPT_DTB }, + {"reuse-node" ,1 ,0 ,OPT_NODES }, {0 ,0 ,0 ,0 }, };static const char short_options[] =KEXEC_ARCH_OPT_STR "d" ;
@@ -132,7 +135,9 @@ void elf_ppc_usage(void)" --append=STRING Set the kernel command line to STRING.\n" " --gamecube=1|0 Enable/disable support for ELFs with changed\n" " addresses suitable for the GameCube.\n" -" --dtb=<filename> Specify device tree blob file.\n" +" --dtb=<filename> Specify device tree blob file.\n" +" --reuse-node=node Specify nodes which should be taken from /proc/device-tree.\n" +" Can be set multiple times.\n" ); }
@@ -157,6 +162,9 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len,int target_is_gamecube =0 ;unsigned int addr;unsigned long dtb_addr; +#define FIXUP_ENTRYS (20) +char *fixup_nodes[FIXUP_ENTRYS +1 ]; +int cur_fixup =0 ;#endif int opt;
@@ -182,13 +190,25 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len,case OPT_DTB : dtb = optarg;break ; + +case OPT_NODES : +if (cur_fixup >=FIXUP_ENTRYS ) { +fprintf (stderr,"The number of entries for the fixup is too large\n" ); +exit (1 ); + } + fixup_nodes[cur_fixup] = optarg; + cur_fixup++; +break ; } } + command_line_len =0 ;if (command_line) { command_line_len =strlen (command_line) +1 ; } + fixup_nodes[cur_fixup] =NULL ; +/* Parse the Elf file */ result =build_elf_exec_info (buf, len, &ehdr,0 );if (result <0 ) {
@@ -247,12 +267,13 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len,/* Grab device tree from buffer */ blob_buf =slurp_file (dtb, &blob_size); +if (!blob_buf || !blob_size) +die ("Device tree seems to be an empty file.\n" ); + blob_buf =fixup_dtb_nodes (blob_buf, &blob_size, fixup_nodes, command_line); dtb_addr =add_buffer (info, blob_buf, blob_size, blob_size,0 ,0 ,KERNEL_ACCESS_TOP ,-1 ); -if (command_line) -die ("Don't consider command line because dtb is supplied\n" ); }else { -die ("Missing dtb.\n" ); + dtb_addr =0 ; }/* set various variables for the purgatory */
Signature · 7 lines
1.6.5.2 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 5/7 powerpc32: add support for uImage
In reply to Sebastian Andrzej SiewiorFrom: Sebastian Andrzej Siewior <[email protected]>
On PowerPC the uImage usually contains the compressed "final" kernel and not a tiny wrapper which relocates itself und uncomprosses the final kernel to its final position. Instead we uncompress the gzip image and put it the its final position.
--- kexec/arch/ppc/Makefile | 1 + kexec/arch/ppc/kexec-ppc.c | 3 +- kexec/arch/ppc/kexec-ppc.h | 5 + kexec/arch/ppc/kexec-uImage-ppc.c | 348 +++++++++++++++++++++++++++++++++++++ 4 files changed, 356 insertions(+), 1 deletions(-) create mode 100644 kexec/arch/ppc/kexec-uImage-ppc.c
kexec/arch/ppc/Makefile +1 -0
@@ -7,6 +7,7 @@ ppc_KEXEC_SRCS = kexec/arch/ppc/kexec-ppc.c ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-elf-ppc.c ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-elf-rel-ppc.c ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-dol-ppc.c +ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-uImage-ppc.c ppc_KEXEC_SRCS += kexec/arch/ppc/ppc-setup-simple.S ppc_KEXEC_SRCS += kexec/arch/ppc/ppc-setup-dol.S ppc_KEXEC_SRCS += kexec/arch/ppc/fixup_dtb.c
kexec/arch/ppc/kexec-ppc.c +2 -1
@@ -250,7 +250,7 @@ static int get_base_ranges(void)/* Get devtree details and create exclude_range array * Also create usablemem_ranges for KEXEC_ON_CRASH */ -static int get_devtree_details (unsigned long kexec_flags) +static int get_devtree_details (unsigned long UNUSED (kexec_flags )) {uint64_t rmo_base;char buf[MAXBYTES ];
@@ -485,6 +485,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges,struct file_type file_type[] = { {"elf-ppc" , elf_ppc_probe, elf_ppc_load, elf_ppc_usage}, {"dol-ppc" , dol_ppc_probe, dol_ppc_load, dol_ppc_usage}, + {"uImage-ppc" , uImage_ppc_probe, uImage_ppc_load, uImage_ppc_usage }, };int file_types =sizeof (file_type) /sizeof (file_type[0 ]);
kexec/arch/ppc/kexec-ppc.h +5 -0
@@ -21,6 +21,11 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len, struct kexec_info *info);void elf_ppc_usage (void ); +int uImage_ppc_probe (const char *buf,off_t len); +int uImage_ppc_load (int argc,char **argv,const char *buf,off_t len, +struct kexec_info *info); +void uImage_ppc_usage (void ); +int dol_ppc_probe (const char *buf,off_t len);int dol_ppc_load (int argc,char **argv,const char *buf,off_t len,struct kexec_info *info);
kexec/arch/ppc/kexec-uImage-ppc.c new file +348 -0
348 lines not on this page · raw message
Signature · 7 lines
1.6.5.2 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 6/7 Split Powerpc's uImage code
In reply to Sebastian Andrzej SiewiorFrom: Sebastian Andrzej Siewior <[email protected]>
The check and uncompress code could be split and recycled by other arch.
--- include/kexec-uImage.h | 13 +++ kexec/arch/ppc/Makefile | 1 + kexec/arch/ppc/kexec-uImage-ppc.c | 201 ++--------------------------------- kexec/kexec-uImage.c | 213 +++++++++++++++++++++++++++++++++++++ 4 files changed, 236 insertions(+), 192 deletions(-) create mode 100644 include/kexec-uImage.h create mode 100644 kexec/kexec-uImage.c
include/kexec-uImage.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef __KEXEC_UIMAGE_H__ +#define __KEXEC_UIMAGE_H__ + +struct Image_info { +const char *buf; +off_t len; +unsigned int base; +unsigned int ep; +}; + +int uImage_probe (const char *buf,off_t len,unsigned int arch); +int uImage_load (const char *buf,off_t len,struct Image_info *info); +#endif
kexec/arch/ppc/Makefile +1 -0
@@ -11,6 +11,7 @@ ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-uImage-ppc.c ppc_KEXEC_SRCS += kexec/arch/ppc/ppc-setup-simple.S ppc_KEXEC_SRCS += kexec/arch/ppc/ppc-setup-dol.S ppc_KEXEC_SRCS += kexec/arch/ppc/fixup_dtb.c +ppc_KEXEC_SRCS += kexec/kexec-uImage.c libfdt_SRCS = kexec/arch/ppc/libfdt-wrapper.c libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/arch/ppc/libfdt/%)
kexec/arch/ppc/kexec-uImage-ppc.c +9 -192
228 lines not on this page · raw message
kexec/kexec-uImage.c new file +213 -0
213 lines not on this page · raw message
Signature · 7 lines
1.6.5.2 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 7/7 Let SH adn ARM use common uImage probe code
In reply to Sebastian Andrzej SiewiorFrom: Sebastian Andrzej Siewior <[email protected]>
The now generic probe function is more complete than the currently used. It seems that ARM's and SH's uImage are always uncompressed so it might be good to check for this.
--- kexec/arch/arm/Makefile | 1 + kexec/arch/arm/kexec-uImage-arm.c | 15 ++------------- kexec/arch/sh/Makefile | 1 + kexec/arch/sh/kexec-uImage-sh.c | 15 ++------------- 4 files changed, 6 insertions(+), 26 deletions(-)
kexec/arch/arm/Makefile +1 -0
@@ -5,6 +5,7 @@ arm_KEXEC_SRCS= kexec/arch/arm/kexec-elf-rel-arm.c arm_KEXEC_SRCS+= kexec/arch/arm/kexec-zImage-arm.c arm_KEXEC_SRCS+= kexec/arch/arm/kexec-uImage-arm.c arm_KEXEC_SRCS+= kexec/arch/arm/kexec-arm.c +arm_KEXEC_SRCS+= kexec/kexec-uImage.c dist += kexec/arch/arm/Makefile $(arm_KEXEC_SRCS) \ kexec/arch/arm/kexec-arm.h \
kexec/arch/arm/kexec-uImage-arm.c +2 -13
@@ -5,24 +5,13 @@#include <string.h> #include <sys/types.h> #include <image.h> +#include <kexec-uImage.h> #include "../../kexec.h" #include "kexec-arm.h" int uImage_arm_probe (const char *buf,off_t len) { -struct image_header header; - -if ((uintmax_t )len < (uintmax_t )sizeof (header)) -return -1 ; - -memcpy (&header, buf,sizeof (header)); - -if (cpu_to_be32 (header.ih_magic) !=IH_MAGIC ) -return -1 ; - -/* XXX: check CRC Checksum? */ - -return 0 ; +return uImage_probe (buf, len,IH_ARCH_ARM ); } int uImage_arm_load(int argc, char **argv, const char *buf, off_t len,
kexec/arch/sh/Makefile +1 -0
@@ -9,6 +9,7 @@ sh_KEXEC_SRCS += kexec/arch/sh/kexec-elf-sh.c sh_KEXEC_SRCS += kexec/arch/sh/kexec-elf-rel-sh.c sh_KEXEC_SRCS += kexec/arch/sh/netbsd_booter.S sh_KEXEC_SRCS += kexec/arch/sh/crashdump-sh.c +sh_KEXEC_SRCS += kexec/kexec-uImage.c sh_ADD_BUFFER = sh_ADD_SEGMENT =
kexec/arch/sh/kexec-uImage-sh.c +2 -13
@@ -7,24 +7,13 @@#include <string.h> #include <sys/types.h> #include <image.h> +#include <kexec-uImage.h> #include "../../kexec.h" #include "kexec-sh.h" int uImage_sh_probe (const char *buf,off_t len) { -struct image_header header; - -if ((uintmax_t )len < (uintmax_t )sizeof (header)) -return -1 ; - -memcpy (&header, buf,sizeof (header)); - -if (cpu_to_be32 (header.ih_magic) !=IH_MAGIC ) -return -1 ; - -/* XXX: check CRC Checksum? */ - -return 0 ; +return uImage_probe (buf, len,IH_ARCH_SH ); } int uImage_sh_load(int argc, char **argv, const char *buf, off_t len,
Signature · 7 lines
1.6.5.2 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec