* initrd support broken in mips kernel 4.2
@ 2015-08-31 4:50 Tony Wu
2015-09-02 21:25 ` Alexander Sverdlin
0 siblings, 1 reply; 3+ messages in thread
From: Tony Wu @ 2015-08-31 4:50 UTC (permalink / raw)
To: Alexander Sverdlin
Cc: linux-mips, David Daney, Zubair Lutfullah Kakakhel, Huacai Chen,
Andreas Herrmann, Joe Perches, Steven J. Hill, Yusuf Khan,
Michael Kreuzer, Aaro Koskinen, Ralf Baechle
Hello,
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.
----- 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);
-----------------------
Thanks,
Tony
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: initrd support broken in mips kernel 4.2
2015-08-31 4:50 initrd support broken in mips kernel 4.2 Tony Wu
@ 2015-09-02 21:25 ` Alexander Sverdlin
2015-09-02 21:32 ` Alexander Sverdlin
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Sverdlin @ 2015-09-02 21:25 UTC (permalink / raw)
To: ext Tony Wu, Alexander Sverdlin
Cc: linux-mips, David Daney, Zubair Lutfullah Kakakhel, Huacai Chen,
Andreas Herrmann, Joe Perches, Steven J. Hill, Yusuf Khan,
Michael Kreuzer, Aaro Koskinen, Ralf Baechle
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.
*/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: initrd support broken in mips kernel 4.2
2015-09-02 21:25 ` Alexander Sverdlin
@ 2015-09-02 21:32 ` Alexander Sverdlin
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Sverdlin @ 2015-09-02 21:32 UTC (permalink / raw)
To: ext Tony Wu, Alexander Sverdlin
Cc: linux-mips, David Daney, Zubair Lutfullah Kakakhel, Huacai Chen,
Andreas Herrmann, Joe Perches, Steven J. Hill, Yusuf Khan,
Michael Kreuzer, Aaro Koskinen, Ralf Baechle
Hello Tony,
On 02/09/15 23:25, Alexander Sverdlin 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
Oh, "<=" is indeed correct. Could you please test this patch instead of the
previously proposed:
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -338,7 +338,7 @@ static void __init bootmem_init(void)
if (end <= reserved_end)
continue;
#ifdef CONFIG_BLK_DEV_INITRD
- /* mapstart should be after initrd_end */
+ /* Skip zones before initrd and initrd itself */
if (initrd_end && end <= (unsigned long)PFN_UP(__pa(initrd_end)))
continue;
#endif
@@ -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.
*/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-02 21:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-31 4:50 initrd support broken in mips kernel 4.2 Tony Wu
2015-09-02 21:25 ` Alexander Sverdlin
2015-09-02 21:32 ` Alexander Sverdlin
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.