linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]powerpc: Force page alignment for early reserved memory
@ 2011-05-20 21:26 Dave Carroll
  2011-05-20 22:27 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 18+ messages in thread
From: Dave Carroll @ 2011-05-20 21:26 UTC (permalink / raw)
  To: Benjamin Herrenschmidt (E-mail), Paul Mackerras (E-mail),
	Grant Likely (E-mail)
  Cc: LPPC (E-mail), LKML (E-mail)


When using 64K pages with a separate cpio rootfs, U-Boot will align the roo=
tfs on a 4K
page boundary. When the memory is reserved, and subsequent early memblock_a=
lloc
is called, it will allocate memory between the 64K page alignment and reser=
ved
memory. When the reserved memory is subsequently freed, it is done so by pa=
ges,
causing the early memblock_alloc requests to be re-used, which in my case, =
caused
the device-tree to be clobbered.

This patch forces all early reserved memory to be kernel page aligned, to m=
atch
the mechanism used to free reserved memory.

Signed-off-by: Dave Carroll <dcarroll@astekcorp.com>
---
 arch/powerpc/kernel/prom.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index e74fa12..2744792 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -534,6 +534,19 @@ void __init early_init_dt_setup_initrd_arch(unsigned l=
ong start,
 }
 #endif

+static void __init reserve_mem(u64 base, u64 size)
+{
+       u64 top =3D base + size;
+       if (size =3D=3D 0)
+               return;
+
+       base =3D _ALIGN_DOWN(base, PAGE_SIZE);
+       top =3D _ALIGN_UP(top, PAGE_SIZE);
+       size =3D top - base;
+       memblock_reserve(base, size);
+
+}
+
 static void __init early_reserve_mem(void)
 {
        u64 base, size;
@@ -547,12 +560,12 @@ static void __init early_reserve_mem(void)
        /* before we do anything, lets reserve the dt blob */
        self_base =3D __pa((unsigned long)initial_boot_params);
        self_size =3D initial_boot_params->totalsize;
-       memblock_reserve(self_base, self_size);
+       reserve_mem(self_base, self_size);

 #ifdef CONFIG_BLK_DEV_INITRD
        /* then reserve the initrd, if any */
        if (initrd_start && (initrd_end > initrd_start))
-               memblock_reserve(__pa(initrd_start), initrd_end - initrd_st=
art);
+               reserve_mem(__pa(initrd_start), initrd_end - initrd_start);
 #endif /* CONFIG_BLK_DEV_INITRD */

 #ifdef CONFIG_PPC32
@@ -573,7 +586,7 @@ static void __init early_reserve_mem(void)
                        if (base_32 =3D=3D self_base && size_32 =3D=3D self=
_size)
                                continue;
                        DBG("reserving: %x -> %x\n", base_32, size_32);
-                       memblock_reserve(base_32, size_32);
+                       reserve_mem(base_32, size_32);
                }
                return;
        }
@@ -584,7 +597,7 @@ static void __init early_reserve_mem(void)
                if (size =3D=3D 0)
                        break;
                DBG("reserving: %llx -> %llx\n", base, size);
-               memblock_reserve(base, size);
+               reserve_mem(base, size);
        }
 }

--
1.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2011-06-11  1:57 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-20 21:26 [PATCH]powerpc: Force page alignment for early reserved memory Dave Carroll
2011-05-20 22:27 ` Benjamin Herrenschmidt
2011-05-20 23:23   ` [PATCH v2]powerpc: Force page alignment for initrd Dave Carroll
2011-05-21 10:36     ` [v2] powerpc: " Milton Miller
2011-05-21 17:05       ` [PATCH v3] powerpc: Force page alignment for initrd reserved memory Dave Carroll
2011-05-22 21:17         ` [PATCH v3] powerpc: Force page alignment for initrd reserved memory, " 'Milton Miller'
2011-05-23  1:29           ` Dave Carroll
2011-05-23  2:31           ` [PATCH v4] " Dave Carroll
2011-05-23 16:50             ` [ " Dave Carroll
2011-05-23 17:39               ` Milton Miller
2011-05-23 22:54                 ` [PATCH v5] " Dave Carroll
2011-05-25  9:28                   ` [v5] " Milton Miller
2011-05-26  2:00                     ` [PATCH v6] " Dave Carroll
2011-05-26  2:32                     ` [PATCH v7] " Dave Carroll
2011-05-26 11:18                       ` Milton Miller
2011-05-26 16:53                         ` [PATCH v8] " Dave Carroll
2011-06-11  1:38                     ` [PATCH 1/2] powerpc: Move free_initmem to common code Dave Carroll
2011-06-11  1:38                       ` [PATCH 2/2] powerpc: Add printk companion for ppc_md.progress Dave Carroll

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).