MIPS: fix memory setup for platforms with PHYS_OFFSET != 0 [Linux 5.0]

MIPS: fix memory setup for platforms with PHYS_OFFSET != 0 [Linux 5.0]

This Linux kernel change "MIPS: fix memory setup for platforms with PHYS_OFFSET != 0" is included in the Linux 5.0 release. This change is authored by Thomas Bogendoerfer <tbogendoerfer [at] suse.de> on Wed Feb 27 10:42:56 2019 +0100. The commit for this change in Linux stable tree is e0bf304 (patch).

MIPS: fix memory setup for platforms with PHYS_OFFSET != 0

For platforms, which use a PHYS_OFFSET != 0, symbol _end also
contains that offset. So when calling memblock_reserve() for
reserving kernel the size argument needs to be adjusted.

Fixes: bcec54bf3118 ("mips: switch to NO_BOOTMEM")
Acked-by: Mike Rapoport <[email protected]>
Signed-off-by: Thomas Bogendoerfer <[email protected]>
Signed-off-by: Paul Burton <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: James Hogan <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Mike Rapoport <[email protected]>
Cc: [email protected] # v4.20+

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 arch/mips/kernel/setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 8c6c48ed..d2e5a5a 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -384,7 +384,8 @@ static void __init bootmem_init(void)
    init_initrd();
    reserved_end = (unsigned long) PFN_UP(__pa_symbol(&_end));

-   memblock_reserve(PHYS_OFFSET, reserved_end << PAGE_SHIFT);
+   memblock_reserve(PHYS_OFFSET,
+            (reserved_end << PAGE_SHIFT) - PHYS_OFFSET);

    /*
     * max_low_pfn is not a number of pages. The number of pages

Leave a Reply

Your email address will not be published. Required fields are marked *