On Thu, May 17, 2018 at 12:07:29PM +0200, Oleksij Rempel wrote:
> Am 17.05.2018 um 11:56 schrieb Sascha Hauer:
> > On Wed, May 16, 2018 at 06:42:28PM +0200, Oleksij Rempel wrote:
> >> From: Antony Pavlov <antonynpav...@gmail.com>
> >>
> >> Signed-off-by: Antony Pavlov <antonynpav...@gmail.com>
> >> Signed-off-by: Peter Mamonov <pmamo...@gmail.com>
> >> ---
> >>  arch/mips/include/asm/elf.h        |   8 +-
> >>  arch/mips/lib/Makefile             |   4 +
> >>  arch/mips/lib/kexec-mach-generic.c |  21 +++
> >>  arch/mips/lib/kexec-mips.c         | 307 
> >> +++++++++++++++++++++++++++++++++++++
> >>  arch/mips/lib/machine_kexec.h      |  21 +++
> >>  arch/mips/lib/relocate_kernel.S    | 108 +++++++++++++
> >>  6 files changed, 468 insertions(+), 1 deletion(-)
> >>  create mode 100644 arch/mips/lib/kexec-mach-generic.c
> >>  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
> >>
> >> +int kexec_load(struct image_data *data, void *entry,
> >> +         unsigned long nr_segments,
> >> +         struct kexec_segment *segments)
> >> +{
> >> +  int i;
> >> +  struct resource *elf;
> >> +  resource_size_t start;
> >> +  LIST_HEAD(elf_segments);
> >> +
> >> +  for (i = 0; i < nr_segments; i++) {
> >> +          resource_size_t mem = (resource_size_t)segments[i].mem;
> >> +
> >> +          elf = create_resource("elf segment",
> >> +                  mem, mem + segments[i].memsz - 1);
> >> +
> >> +          list_add_used_region(&elf->sibling, &elf_segments);
> >> +  }
> >> +
> >> +  if (check_room_for_elf(&elf_segments)) {
> >> +          pr_err("ELF can't be loaded!\n");
> >> +          return -ENOSPC;
> >> +  }
> >> +
> >> +  start = dcheck_res(&elf_segments);
> >> +
> >> +  /* relocate_new_kernel() copy by register (4 or 8 bytes)
> >> +     so start address must be aligned to 4/8 */
> >> +  start = (start + 15) & 0xfffffff0;
> >> +
> >> +  for (i = 0; i < nr_segments; i++) {
> >> +          segments[i].mem = (void *)(phys_to_virt((unsigned 
> >> long)segments[i].mem));
> >> +          memcpy(phys_to_virt(start), segments[i].buf, segments[i].bufsz);
> >> +          request_sdram_region("kexec relocatable segment",
> >> +                  (unsigned long)phys_to_virt(start),
> >> +                  (unsigned long)segments[i].bufsz);
> > 
> > The return value of request_sdram_region should be checked and of course
> > the resource should be used after having checked the return value, not
> > before. Same for the other calls to request_sdram_region.
> 
> Will it be enough for initial inclusion?

No, to merge it I need the feeling that this code is understood, not in
the works-for-me state.

Sascha

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to