From: Milton Miller <miltonm@bga.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: ppcdev <linuxppc-dev@ozlabs.org>, Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH 5/15] bootwrapper: occuppied memory ranges
Date: Mon, 24 Sep 2007 04:33:46 -0500 [thread overview]
Message-ID: <940c77ad23c1ac82da1557fd7c2bb563@bga.com> (raw)
In-Reply-To: <20070924030937.GF8058@localhost.localdomain>
On Sep 23, 2007, at 10:09 PM, David Gibson wrote:
> On Fri, Sep 21, 2007 at 06:04:18PM -0500, Milton Miller wrote:
>> Add a set of library routines to manage gross memory allocations.
>>
>> This code uses an array in bss to store upto 32 entrys with merging
>> representing a range of memory below rma_end (aka end of real mode
>> memory at 0).
>>
>> To use this code, a platform would set rma_end (find_rma_end), mark
>> memory ranges occupied (add_known_ranges et al), initialize malloc in
>> the spaces between (ranges_init_malloc), and optionally use the
>> supplied
>> vmlinux_alloc may be used.
>
> Urg. It's an awful lot of code for the bootwrapper. Am I right in
> understanding that the only reason to use the ranges code is for the
> ranges based malloc() and vmlinux_alloc() you get out of it?
Yes.
The ranges based malloc is simple_alloc after finding a sutable chunk
to operate in.
When doing a kexec, there are several chunks of memory to avoid. There
are at least the wrapper, the initrd, the input device tree, and
possibly rtas and tce tables. The last two are avoided by parsing the
memory resrve list in the flat tree blob.
In practice, on 64 bit powerpc kexec-tools loads the kernel (in this
case zImage) immediately following the old kernel _end (becauset the
kernel doesnt' allow otherwise, like 32 bit and most other platforms
do). If the kernel being execd is larger than the kernel invoking
kexec, then the vmlinux will not fit below the wrapper, but when they
are the same it will fit. So in the malloc region we need space for
random temps, the final device tree, the kernel, and possibly the
initrd -- especially if its attached to the zImage instead of supplied
by kexec-tools.
While I titled this platform kexec, in reality, it is a generic chain
looading platform for flat device trees in that it is invoked with the
same calling conveintions as it calls the kernel. With the current
policy of run-where-loadeed, the wrapper has to be able to find out
what memory is available. It may be above or below itself, and the
bulk of available memory may be after any of the above mentioned
ranges. The only information is the the flat device tree and its
knowledge of itself. Most of this code deals with building the sorted
list of what memory is used.
Actually, there is a hole in that malloc may be initialzed below the
vmlinux.size and the initrd and deviece tree could end up overwritten.
This can't be eliminated without doing something like prpmc2800 where
the kernel decompression is started and the elf header is read before
initializing malloc. In practice has not triggered because the
vmlinux will be malloced before the device tree without an initrd, and
with it the kernel is likely smaller than the wrapper (since the memory
chunk at 0 is avoided, it requires the end of some other chunk to be
low in memory).
At one point you had mentioned considering changes to run out of bss
and handling the initrd and kernel with calls to memmove; any such
movement would requrie similar information to what is being built into
the storted structure in this code to support externally loaded initrds
and device-trees, which could not be allocated into the bss wihout
arbitrarilly limiting their size.
I've made several changes to the split btween memranges.c and kexec.c
over time. Perhaps there are more left. There is a bit of policy in
the ranges malloc initialilzation; that could probably be eliminated by
query functions for the largest chunk. The vmlinux alloc could try just
0 and malloc(). And the area from the last occupied range to roa_end
should be available for malloc as well as the kernel.
milton
next prev parent reply other threads:[~2007-09-24 9:33 UTC|newest]
Thread overview: 55+ 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 [this message]
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
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
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=940c77ad23c1ac82da1557fd7c2bb563@bga.com \
--to=miltonm@bga.com \
--cc=david@gibson.dropbear.id.au \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.