Re: [PATCH 04/12] mips: Reserve memory for the kernel image resources

Serge Semin
2019-05-22T13:54:33Z

[-- Attachment #1: Type: text/plain, Size: 2420 bytes --]

On Wed, May 22, 2019 at 03:44:47PM +0200, Geert Uytterhoeven wrote:
> Hi Serge,
>
> ...
>
> >
> > The problem might be fixed there by the next patch:
> > ---
> > diff --git a/arch/mips/dec/prom/memory.c b/arch/mips/dec/prom/memory.c
> > index 5073d2ed78bb..5a0c734b5d04 100644
> > --- a/arch/mips/dec/prom/memory.c
> > +++ b/arch/mips/dec/prom/memory.c
> > @@ -91,29 +91,14 @@ void __init prom_meminit(u32 magic)
> > pmax_setup_memory_region();
> > else
> > rex_setup_memory_region();
> > -}
> > -
> > -void __init prom_free_prom_memory(void)
> > -{
> > - unsigned long end;
> > -
> > - /*
> > - * Free everything below the kernel itself but leave
> > - * the first page reserved for the exception handlers.
> > - */
> >
> > #if IS_ENABLED(CONFIG_DECLANCE)
> > /*
> > - * Leave 128 KB reserved for Lance memory for
> > - * IOASIC DECstations.
> > + * Reserve 128 KB for Lance memory for IOASIC DECstations.
> > *
> > * XXX: save this address for use in dec_lance.c?
> > */
> > if (IOASIC)
> > - end = __pa(&_text) - 0x00020000;
> > - else
> > + memblock_reserve(__pa_symbol(&_text), 0x00020000);
>
> Shouldn't that be
>
> memblock_reserve(__pa_symbol(&_text) - 0x00020000, 0x00020000);
>
> ?
>

Right. Thanks. The updated version of the patch is attached to this email.

-Sergey

> > #endif
> > - end = __pa(&_text);
> > -
> > - free_init_pages("unused PROM memory", PAGE_SIZE, end);
> > }
> > ---
> >
> > Didn't wanna use prom_FREE_prom_memory to actually reserve a memory
> > chunk, so I moved the reservation into the prom_meminit() method.
>
> I guess Maciej will test this on real hardware, eventually...
>
> > Regarding the first page for the exception handlers. We don't need
> > to reserve it here, since it is already done in arch/mips/kernel/traps.c .
>
> Thanks for checking! That was actually something I was still wondering
> about...
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds

[-- Attachment #2: fix_dec.patch --]
[-- Type: text/x-patch, Size: 952 bytes --]

diff --git a/arch/mips/dec/prom/memory.c b/arch/mips/dec/prom/memory.c
index 5073d2ed78bb..031c0cd45d85 100644
--- a/arch/mips/dec/prom/memory.c
+++ b/arch/mips/dec/prom/memory.c
@@ -91,29 +91,14 @@ void __init prom_meminit(u32 magic)
pmax_setup_memory_region();
else
rex_setup_memory_region();
-}
-
-void __init prom_free_prom_memory(void)
-{
- unsigned long end;
-
- /*
- * Free everything below the kernel itself but leave
- * the first page reserved for the exception handlers.
- */

#if IS_ENABLED(CONFIG_DECLANCE)
/*
- * Leave 128 KB reserved for Lance memory for
- * IOASIC DECstations.
+ * Reserve 128 KB for Lance memory for IOASIC DECstations.
*
* XXX: save this address for use in dec_lance.c?
*/
if (IOASIC)
- end = __pa(&_text) - 0x00020000;
- else
+ memblock_reserve(__pa_symbol(&_text) - 0x00020000, 0x00020000);
#endif
- end = __pa(&_text);
-
- free_init_pages("unused PROM memory", PAGE_SIZE, end);
}