linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Milton Miller <miltonm@bga.com>
Cc: linuxppc-dev@ozlabs.org, Paul Mackerras <paulus@samba.org>,
	Rob Landley <rob@landley.net>
Subject: Re: [PATCH 7/15] bootwrapper: Add kexec callable zImage wrapper
Date: Mon, 24 Sep 2007 13:23:33 +1000	[thread overview]
Message-ID: <20070924032333.GH8058@localhost.localdomain> (raw)
In-Reply-To: <boot-8-07.miltonm@bga.com>

On Fri, Sep 21, 2007 at 06:04:58PM -0500, Milton Miller wrote:
> 
> This code creates a 32 bit zImage wrapper for a 32 or 64 bit PowerPC
> Linux kernel.  This allows you to kexec a zImage with its compressed
> vmlinux instead of the uncompressed vmlinux elf.  The code is also
> packaged as a 64 bit elf for use by kexec-tools on 64 bit kernels.
> 
> Limitations:
> Note: the device-tree generated by kexec-tools is currently version 2,
> not the version 16 supported by the boot code base.
> 
> Signed-off-by: Milton Miller <miltonm@bga.com>
> ---
> find_rmo_end moved to memranges as find_rma_end.
> early_scan_flat_tree replaced with calls to its pieces in
> kexec_platform_init
> rediff wrapper, Makefile, ops.h
> 
> Index: kernel/arch/powerpc/boot/kexec.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ kernel/arch/powerpc/boot/kexec.c	2007-09-21 04:52:46.000000000 -0500
> @@ -0,0 +1,122 @@
> +/*
> + * 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.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> + *
> + * Copyright IBM Corporation 2007
> + *
> + * Authors: Milton Miller <miltonm@bga.com>
> + */
> +
> +#include "ops.h"
> +#include "stdio.h"
> +#include "flatdevtree.h"
> +#include "page.h"
> +#include "types.h"
> +
> +extern char _start[];
> +extern char _end[];

Don't need these externs any more, they're in the headers.

> +
> +BSS_STACK(16*1024);
> +
> +static void find_console_from_tree(void)
> +{
> +	int rc = -1;
> +
> +	if (rc) {
> +		/* no console, oh well */
> +	}

Um... pointless function...?

> +}
> +
> +/**
> + * setup_initial_heap - setup a small heap in the bss
> + * Using a preallocated heap, setup for scanning the device tree.
> + * Intended for the initial read while the tree will remain read-only so
> + * a minimal malloc and search limit can be used.  This way we don't have
> + * lots of data or bss to clear.
> + */
> +static void setup_initial_heap(void)
> +{
> +	static char initial_heap[8*1024];
> +	void *heap_end;
> +
> +	heap_end = simple_alloc_init(initial_heap,
> +			sizeof(initial_heap) * 7 / 8,
> +			sizeof(long), 64);
> +
> +	if (heap_end - sizeof(initial_heap) > (void *)&initial_heap[0])
> +		fatal("Initial heap too big\n\r");
> +}
> +
> +static void init_flat_tree(struct boot_param_header *dt_blob)
> +{
> +	int rc;
> +
> +	rc = ft_init(dt_blob, dt_blob->totalsize, /* max_finddevice */ 1024);
> +	if (rc)
> +		fatal("Unable to initialize device_tree library!\n\r");
> +}
> +
> +static void *saved_vmlinux_addr;
> +
> +static void *kexec_vmlinux_alloc(unsigned long size)
> +{
> +	void *addr;
> +
> +	addr = ranges_vmlinux_alloc(size);
> +
> +	saved_vmlinux_addr = addr;
> +	return addr;
> +}
> +
> +static void kexec_fixups(void)
> +{
> +	wait_slaves_moved();
> +}
> +
> +static unsigned long (*finalize_chain)(void);
> +
> +static unsigned long kexec_finalize(void)
> +{
> +	send_slaves_to_kernel(saved_vmlinux_addr);

Ow, yuck, no.  The finalize callback is for finalizing the device
tree, don't abuse it for SMP entry.  It's a new thing that needs to be
done, so create a new callback for it.

> +
> +	return finalize_chain();
> +}
> +
> +void kexec_platform_init(struct boot_param_header *dt_blob)
> +{
> +	slaves_are_low();
> +	move_slaves_up();
> +
> +	setup_initial_heap();
> +	init_flat_tree(dt_blob);
> +	/*
> +	 * drivers can malloc and read the tree, but not realloc later
> +	 * or modify the tree now.
> +	 */
> +	if (!console_ops.write)
> +		find_console_from_tree();
> +
> +	find_rma_end();
> +	dt_find_initrd();
> +	add_known_ranges(dt_blob);
> +	ranges_init_malloc();
> +
> +	/* now that we have a malloc region, start over from the flat tree */
> +	init_flat_tree(dt_blob);
> +
> +	platform_ops.vmlinux_alloc = kexec_vmlinux_alloc;
> +	platform_ops.fixups = kexec_fixups;
> +	finalize_chain = dt_ops.finalize;
> +	dt_ops.finalize = kexec_finalize;
> +}
> Index: kernel/arch/powerpc/boot/crt0_kexec.S
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ kernel/arch/powerpc/boot/crt0_kexec.S	2007-09-21 04:52:46.000000000 -0500
> @@ -0,0 +1,45 @@
> +/*
> + * 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.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> + *
> + * Copyright 2007 IBM Corporation.
> + *
> + * Authors: Milton Miller <miltonm@bga.com>
> + *
> + */
> +	/*
> +	 * The kernel calls out to the first image with
> +	 * r3 = boot cpu, r4 = entrypoint, r5 = 0
> +	 *
> +	 * kexec-tools purgatory calls this as it would a linux kernel:
> +	 * r3 = boot block, r4 = entrypoint, r5 = 0
> +	 *
> +	 * The boot block boot_cpu field has been filled in.
> +	 *
> +	 * kexec-tools and its purgatory are suppposed to copy SMP_SLAVE_SIZE
> +	 * bytes from the from entry point, but aparently instead it copies
> +	 * from the image start.
> +	 */
> +	.globl _zimage_start
> +_zimage_start:
> +
> +#include "marshal_low.S"
> +
> +	.globl	_zimage_start_plat
> +_zimage_start_plat:
> +	b	_zimage_start_lib
> +
> +	.globl	platform_init
> +platform_init:
> +	b	kexec_platform_init
> Index: kernel/arch/powerpc/boot/wrapper
> ===================================================================
> --- kernel.orig/arch/powerpc/boot/wrapper	2007-09-21 04:51:31.000000000 -0500
> +++ kernel/arch/powerpc/boot/wrapper	2007-09-21 04:52:46.000000000 -0500
> @@ -133,6 +133,12 @@ coff)
>      platformo=$object/of.o
>      lds=$object/zImage.coff.lds
>      ;;
> +kexec)
> +    platformo=$object/crt0_kexec.o
> +    ;;
> +kexec64)
> +    platformo="-e _zimage_start_64 $object/crt0_kexec.o"

Arg. Again, just because it happens to fit is not a good reason to
abuse platformo - which, obviously enough, s meant to contain the .o
file for the platform - to also contain flags.

> +    ;;
>  miboot|uboot)
>      # miboot and U-boot want just the bare bits, not an ELF binary
>      ext=bin
> @@ -190,6 +196,9 @@ uboot)
>      fi
>      exit 0
>      ;;
> +kexec64)
> +    ${CROSS}objcopy -O elf64-powerpc $ofile
> +    ;;
>  esac
>  
>  addsec() {
> Index: kernel/arch/powerpc/boot/Makefile
> ===================================================================
> --- kernel.orig/arch/powerpc/boot/Makefile	2007-09-21 04:52:44.000000000 -0500
> +++ kernel/arch/powerpc/boot/Makefile	2007-09-21 04:52:46.000000000 -0500
> @@ -42,12 +42,12 @@ $(addprefix $(obj)/,$(zlib) gunzip_util.
>  	$(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader))
>  
>  src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
> -		marshal.c memranges.c \
> +		marshal.c memranges.c kexec.c \
>  		ns16550.c serial.c simple_alloc.c div64.S util.S \
>  		gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
>  		4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
>  		cpm-serial.c stdlib.c
> -src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
> +src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c crt0_kexec.S \
>  		cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
>  		ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \
>  		cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c cuboot-bamboo.c
> @@ -128,6 +128,9 @@ quiet_cmd_wrap	= WRAP    $@
>        cmd_wrap	=$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
>  		$(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux
>  
> +kexec-$(CONFIG_PPC32)			+= zImage.kexec
> +kexec-$(CONFIG_PPC64)			+= zImage.kexec64
> +
>  image-$(CONFIG_PPC_PSERIES)		+= zImage.pseries
>  image-$(CONFIG_PPC_MAPLE)		+= zImage.pseries
>  image-$(CONFIG_PPC_IBM_CELL_BLADE)	+= zImage.pseries
> @@ -140,6 +143,7 @@ image-$(CONFIG_PPC_HOLLY)		+= zImage.hol
>  image-$(CONFIG_PPC_PRPMC2800)		+= zImage.prpmc2800
>  image-$(CONFIG_PPC_ISERIES)		+= zImage.iseries
>  image-$(CONFIG_DEFAULT_UIMAGE)		+= uImage
> +image-$(CONFIG_KEXEC)			+= $(kexec-y)
>  
>  ifneq ($(CONFIG_DEVICE_TREE),"")
>  image-$(CONFIG_PPC_8xx)			+= cuImage.8xx
> @@ -158,7 +162,7 @@ ifeq ($(CONFIG_PPC32),y)
>  image-$(CONFIG_PPC_PMAC)	+= zImage.coff zImage.miboot
>  endif
>  
> -initrd-  := $(patsubst zImage%, zImage.initrd%, $(image-n) $(image-))
> +initrd-  := $(patsubst zImage%, zImage.initrd%, $(image-n) $(image-) $(kexec-))
>  initrd-y := $(patsubst zImage%, zImage.initrd%, \
>  		$(patsubst treeImage%, treeImage.initrd%, $(image-y)))
>  initrd-y := $(filter-out $(image-y), $(initrd-y))
> @@ -227,7 +231,7 @@ install: $(CONFIGURE) $(addprefix $(obj)
>  
>  # anything not in $(targets)
>  clean-files += $(image-) $(initrd-) zImage zImage.initrd cuImage.* treeImage.* \
> -	otheros.bld
> +	otheros.bld $(kexec-)
>  
>  # clean up files cached by wrapper
>  clean-kernel := vmlinux.strip vmlinux.bin
> Index: kernel/arch/powerpc/boot/ops.h
> ===================================================================
> --- kernel.orig/arch/powerpc/boot/ops.h	2007-09-21 04:52:44.000000000 -0500
> +++ kernel/arch/powerpc/boot/ops.h	2007-09-21 04:52:46.000000000 -0500
> @@ -95,6 +95,7 @@ void move_slaves_here(void *where);
>  void send_slaves_to_kernel(void *vmlinux_addr);
>  void slaves_are_low(void);
>  void wait_slaves_moved(void);
> +void kexec_platform_init(struct boot_param_header *dt_blob);

This platform specific function should not poluute ops.h.

>  
>  int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size);
>  int dt_xlate_addr(void *node, u32 *buf, int buflen, unsigned long *xlated_addr);
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

  reply	other threads:[~2007-09-24  3:23 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-21 23:02 [PATCH 0/15] bootwrapper: kexec and external payloads Milton Miller
2007-09-21 23:03 ` [PATCH 1/15] boot: find initrd location from device-tree Milton Miller
2007-09-24  2:58   ` David Gibson
2007-09-24  5:50     ` Rob Landley
2007-09-24  8:02     ` Milton Miller
2007-09-25  3:27       ` David Gibson
2007-09-26  5:49         ` Milton Miller
2007-09-21 23:03 ` [PATCH 2/15] boot: record header bytes in gunzip_start Milton Miller
2007-09-24  2:59   ` David Gibson
2007-09-21 23:03 ` [PATCH 3/15] boot: simplfy gunzip_finish Milton Miller
2007-09-21 23:03 ` [PATCH 4/15] bootwrapper: smp support code Milton Miller
2007-09-21 23:04 ` [PATCH 5/15] bootwrapper: occuppied memory ranges Milton Miller
2007-09-24  3:09   ` David Gibson
2007-09-24  9:33     ` Milton Miller
2007-09-21 23:04 ` [PATCH 6/15] bootwrapper: help for 64 bit cpus Milton Miller
2007-09-24  3:14   ` David Gibson
2007-09-21 23:04 ` [PATCH 7/15] bootwrapper: Add kexec callable zImage wrapper Milton Miller
2007-09-24  3:23   ` David Gibson [this message]
2007-09-21 23:05 ` [PATCH 8/15] bootwrapper: convert flatdevtree to version 16 Milton Miller
2007-09-24  3:36   ` David Gibson
2007-09-24  6:54     ` Milton Miller
2007-09-25  3:46       ` David Gibson
2007-09-26 16:19         ` Milton Miller
2007-09-27  2:45           ` David Gibson
2007-09-27 15:44             ` Milton Miller
2007-09-28  2:40               ` David Gibson
2007-09-28 15:16                 ` Milton Miller
2007-10-03  5:29                   ` David Gibson
2007-09-21 23:05 ` [PATCH 9/15] bootwrapper: rtas support Milton Miller
2007-09-24  3:46   ` David Gibson
2007-09-21 23:05 ` [PATCH 10/15] bootwrapper: add cpio file extraction library Milton Miller
2007-09-21 23:06 ` [PATCH 11/15] bootwrapper: allow vmlinuz to be an external payload Milton Miller
2007-09-21 23:06 ` [PATCH 12/15] bootwrapper: kexec extract vmlinux from initramfs Milton Miller
2007-09-21 23:06 ` [PATCH 13/15] bootwrapper: attach an empty vmlinux Milton Miller
2007-09-24  4:03   ` David Gibson
2007-09-21 23:08 ` [PATCH 14/15] boot: add a hook to start cpus Milton Miller
2007-09-21 23:08 ` [PATCH 15/15] bootwrapper: recheck for command line after fixups Milton Miller
2007-09-21 23:08 ` [PATCH 1/2] qemu platform, v2 Milton Miller
2007-09-22  9:55   ` Christoph Hellwig
2007-09-22 19:16     ` Rob Landley
2007-09-23  4:27       ` Paul Mackerras
2007-09-23 22:01         ` Rob Landley
2007-09-28 16:53         ` Segher Boessenkool
2007-09-28 20:14           ` Rob Landley
2007-10-01  5:33           ` David Gibson
2007-10-17 20:28             ` Grant Likely
2007-10-17 23:09               ` Rob Landley
2007-10-18  9:59               ` Matt Sealey
2007-10-18 17:19                 ` Milton Miller
2007-10-18 17:29                   ` Grant Likely
2007-10-19  6:28                     ` Rob Landley
2007-09-24  4:00     ` David Gibson
2007-09-24  7:46       ` Christoph Hellwig
2007-09-24  9:48         ` Milton Miller
2007-09-21 23:08 ` [PATCH 2/2] qemu platform rom, v2 Milton Miller
  -- strict thread matches above, loose matches on Subject: below --
2007-07-10 22:07 [PATCH 0/15] bootwrapper: support for kexec to zImage Milton Miller
2007-07-10 22:10 ` [PATCH 7/15] bootwrapper: Add kexec callable zImage wrapper Milton Miller
2007-07-10 23:16   ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070924032333.GH8058@localhost.localdomain \
    --to=david@gibson.dropbear.id.au \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=miltonm@bga.com \
    --cc=paulus@samba.org \
    --cc=rob@landley.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).