All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Sverdlin <alexander.sverdlin@gmail.com>
To: ext Tony Wu <tung7970@gmail.com>,
	Alexander Sverdlin <alexander.sverdlin@nokia.com>
Cc: linux-mips@linux-mips.org, David Daney <david.daney@cavium.com>,
	Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>,
	Huacai Chen <chenhc@lemote.com>,
	Andreas Herrmann <andreas.herrmann@caviumnetworks.com>,
	Joe Perches <joe@perches.com>,
	"Steven J. Hill" <Steven.Hill@imgtec.com>,
	Yusuf Khan <yusuf.khan@nokia.com>,
	Michael Kreuzer <michael.kreuzer@nokia.com>,
	Aaro Koskinen <aaro.koskinen@iki.fi>,
	Ralf Baechle <ralf@linux-mips.org>
Subject: Re: initrd support broken in mips kernel 4.2
Date: Wed, 2 Sep 2015 23:25:28 +0200	[thread overview]
Message-ID: <55E76948.2000101@gmail.com> (raw)
In-Reply-To: <20150831122702-tung7970@googlemail.com>

Hello Tony,

On 31/08/15 06:50, ext Tony Wu wrote:
> Commit a6335fa11 (MIPS: bootmem: Don't use memory holes for page bitmap) 
> crashes kernel with a initramfs unpacking error when initrd is enabled. 
> 
> ---- error message ----
> Unpacking initramfs...
> Initramfs unpacking failed: junk in compressed archive
> BUG: Bad page state in process swapper  pfn:00261
> page:81004c20 count:0 mapcount:-127 mapping:  (null) index:0x2
> flags: 0x0()
> page dumped because: nonzero mapcount
> CPU: 0 PID: 1 Comm: swapper Not tainted 4.2.0+ #1782
> -----------------------
> 
> The modified logic in bootmem_init does not guarantee mapstart to be placed 
> after initrd_end. mapstart is set to the maximum of reserved_end and
> start. In case initrd_end is greater than reserved_end, mapstart is placed
> before initrd_end, and causes initramfs unpacking error.

Indeed, seems that there are two problems with the patch. First, "<=" is wrong
in the condition. This will fail if initrd and next zone are separated (in
boot_mem_map), but have not gap in between. Second, without gap, initrd and PFN
area could be combined together by add_memory_region(), so seems that we need
to restore max() that was there before a6335fa11.

> ----- bootmem_init ---
>                 if (end <= reserved_end)
>                         continue;
> +#ifdef CONFIG_BLK_DEV_INITRD
> +               /* mapstart should be after initrd_end */
> +               if (initrd_end && end <= (unsigned long)PFN_UP(__pa(initrd_end)))
> +                       continue;
> +#endif
>                 if (start >= mapstart)
>                         continue;
>                 mapstart = max(reserved_end, start);
> -----------------------

Could you please test the following patch? It fixes the case with gap between
initrd and first usable zone and restores the effect of f9a7febd for the case
when initrd and the next zone are combined together.

--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -339,7 +339,7 @@ static void __init bootmem_init(void)
 			continue;
 #ifdef CONFIG_BLK_DEV_INITRD
 		/* mapstart should be after initrd_end */
-		if (initrd_end && end <= (unsigned long)PFN_UP(__pa(initrd_end)))
+		if (initrd_end && end < (unsigned long)PFN_UP(__pa(initrd_end)))
 			continue;
 #endif
 		if (start >= mapstart)
@@ -371,6 +371,14 @@ static void __init bootmem_init(void)
 		max_low_pfn = PFN_DOWN(HIGHMEM_START);
 	}

+#ifdef CONFIG_BLK_DEV_INITRD
+	/*
+	 * mapstart should be after initrd_end
+	 */
+	if (initrd_end)
+		mapstart = max(mapstart, (unsigned long)PFN_UP(__pa(initrd_end)));
+#endif
+
 	/*
 	 * Initialize the boot-time allocator with low memory only.
 	 */

  reply	other threads:[~2015-09-02 21:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-31  4:50 initrd support broken in mips kernel 4.2 Tony Wu
2015-09-02 21:25 ` Alexander Sverdlin [this message]
2015-09-02 21:32   ` Alexander Sverdlin

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=55E76948.2000101@gmail.com \
    --to=alexander.sverdlin@gmail.com \
    --cc=Steven.Hill@imgtec.com \
    --cc=Zubair.Kakakhel@imgtec.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=alexander.sverdlin@nokia.com \
    --cc=andreas.herrmann@caviumnetworks.com \
    --cc=chenhc@lemote.com \
    --cc=david.daney@cavium.com \
    --cc=joe@perches.com \
    --cc=linux-mips@linux-mips.org \
    --cc=michael.kreuzer@nokia.com \
    --cc=ralf@linux-mips.org \
    --cc=tung7970@gmail.com \
    --cc=yusuf.khan@nokia.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 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.