summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/core/runtime.c
diff options
context:
space:
mode:
authorMichael Brown2012-02-09 17:41:05 +0100
committerMichael Brown2012-02-09 17:49:30 +0100
commit3a4253868ce0c9c1f6fc7fd0f8a2e06afc19e9bb (patch)
tree855c287fe5f92082cbc73ac5644c6db4a73a0fd3 /src/arch/i386/core/runtime.c
parent[tg3] Fix compilation on newer gcc versions (diff)
downloadipxe-3a4253868ce0c9c1f6fc7fd0f8a2e06afc19e9bb.tar.gz
ipxe-3a4253868ce0c9c1f6fc7fd0f8a2e06afc19e9bb.tar.xz
ipxe-3a4253868ce0c9c1f6fc7fd0f8a2e06afc19e9bb.zip
[prefix] Delay initrd image copy until memory map is ready
initrd_init() calls umalloc() to allocate space for the initrd image, but does so before hide_etherboot() has been called. It is therefore possible for the initrd to end up overwriting iPXE itself. Fix by converting initrd_init() from an init_fn to a startup_fn. Originally-fixed-by: Till Straumann <strauman@slac.stanford.edu> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/i386/core/runtime.c')
-rw-r--r--src/arch/i386/core/runtime.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/arch/i386/core/runtime.c b/src/arch/i386/core/runtime.c
index 2ad8c20a..2053bf21 100644
--- a/src/arch/i386/core/runtime.c
+++ b/src/arch/i386/core/runtime.c
@@ -135,6 +135,9 @@ static int cmdline_init ( void ) {
DBGC ( colour, "RUNTIME found command line \"%s\" at %08x\n",
cmdline, cmdline_phys );
+ /* Mark command line as consumed */
+ cmdline_phys = 0;
+
/* Strip unwanted cruft from the command line */
cmdline_strip ( cmdline, "BOOT_IMAGE=" );
cmdline_strip ( cmdline, "initrd=" );
@@ -205,6 +208,9 @@ static int initrd_init ( void ) {
memcpy_user ( image->data, 0, phys_to_user ( initrd_phys ), 0,
initrd_len );
+ /* Mark initrd as consumed */
+ initrd_phys = 0;
+
/* Register image */
if ( ( rc = register_image ( image ) ) != 0 ) {
DBGC ( colour, "RUNTIME could not register initrd: %s\n",
@@ -245,6 +251,6 @@ static void runtime_init ( void ) {
}
/** Command line and initrd initialisation function */
-struct init_fn runtime_init_fn __init_fn ( INIT_NORMAL ) = {
- .initialise = runtime_init,
+struct startup_fn runtime_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
+ .startup = runtime_init,
};