public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Cc: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 13/14] initrd vs bss section clearing.
Date: Tue, 03 Jun 2008 18:59:12 +0200	[thread overview]
Message-ID: <20080603170521.459372348@de.ibm.com> (raw)
In-Reply-To: 20080603165859.107949986@de.ibm.com

[-- Attachment #1: 112-initrd-bss.diff --]
[-- Type: text/plain, Size: 1832 bytes --]

From: Heiko Carstens <heiko.carstens@de.ibm.com>

In case the initrd is located within the bss section it will be
overwritten when the section is cleared. To prevent this just move
the initrd right behind the bss section if it starts within the
section.
The current code already moves the initrd if the bootmem allocator
bitmap would overwrite it. With this patch we should be safe against
initrd corruptions.

Cc: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 arch/s390/kernel/early.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Index: quilt-2.6/arch/s390/kernel/early.c
===================================================================
--- quilt-2.6.orig/arch/s390/kernel/early.c
+++ quilt-2.6/arch/s390/kernel/early.c
@@ -380,6 +380,23 @@ static __init void detect_machine_facili
 #endif
 }
 
+static __init void rescue_initrd(void)
+{
+#ifdef CONFIG_BLK_DEV_INITRD
+	/*
+	 * Move the initrd right behind the bss section in case it starts
+	 * within the bss section. So we don't overwrite it when the bss
+	 * section gets cleared.
+	 */
+	if (!INITRD_START || !INITRD_SIZE)
+		return;
+	if (INITRD_START >= (unsigned long) __bss_stop)
+		return;
+	memmove(__bss_stop, (void *) INITRD_START, INITRD_SIZE);
+	INITRD_START = (unsigned long) __bss_stop;
+#endif
+}
+
 /*
  * Save ipl parameters, clear bss memory, initialize storage keys
  * and create a kernel NSS at startup if the SAVESYS= parm is defined
@@ -389,6 +406,7 @@ void __init startup_init(void)
 	unsigned long long memsize;
 
 	ipl_save_parameters();
+	rescue_initrd();
 	clear_bss_section();
 	init_kernel_storage_key();
 	lockdep_init();

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

  parent reply	other threads:[~2008-06-03 16:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-03 16:58 [patch 00/14] s390 feature patches for 2.6.27 Martin Schwidefsky
2008-06-03 16:59 ` [patch 01/14] cio: Register all subchannels Martin Schwidefsky
2008-06-03 16:59 ` [patch 02/14] cio: Introduce modalias for css bus Martin Schwidefsky
2008-06-03 16:59 ` [patch 03/14] cio: Rework css driver Martin Schwidefsky
2008-06-03 16:59 ` [patch 04/14] cio: Cleanup crw interface Martin Schwidefsky
2008-06-03 16:59 ` [patch 05/14] cio: Export some symbols for modular css drivers Martin Schwidefsky
2008-06-03 16:59 ` [patch 06/14] cio: Base message subchannel handling Martin Schwidefsky
2008-06-03 16:59 ` [patch 07/14] cio: introduce fcx bit to chsc characteristics Martin Schwidefsky
2008-06-03 16:59 ` [patch 08/14] cio: introduce fcx enabled scsw format Martin Schwidefsky
2008-06-03 16:59 ` [patch 09/14] cio: provide functions for fcx enabled I/O Martin Schwidefsky
2008-06-03 16:59 ` [patch 10/14] cio: provide helper " Martin Schwidefsky
2008-06-03 16:59 ` [patch 11/14] cio: remove lock from ccw_device_oper_notify Martin Schwidefsky
2008-06-03 16:59 ` [patch 12/14] Introduce user_regset accessors for s390 Martin Schwidefsky
2008-06-03 16:59 ` Martin Schwidefsky [this message]
2008-06-03 16:59 ` [patch 14/14] stp support Martin Schwidefsky

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=20080603170521.459372348@de.ibm.com \
    --to=schwidefsky@de.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=peter.oberparleiter@de.ibm.com \
    /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