Skip to content
  • James Hogan's avatar
    MIPS: Fix memory regions reaching top of physical · 58cae9b0
    James Hogan authored
    
    
    Memory regions added with add_memory_region() at the top of the physical
    address space will have their end address overflow to 0. This causes
    them to be rejected as invalid, and would cause various other issues
    later on.
    
    This causes issues on Malta and Boston platforms when wanting to use all
    2GB of RAM on a 32-bit kernel, either via highmem (using physical
    addresses 0x90000000..0xFFFFFFFF), or with the Malta Enhanced Virtual
    Addressing (EVA) layout which exposes the whole 0x80000000..0xFFFFFFFF
    physical address range to kernel mode at 0x00000000..0x7FFFFFFF.
    
    Due to the abundance of these non-overflow assumptions and the fact that
    memblock already avoids the arithmetic overflow by limiting the size of
    new memory regions without the arch code knowing it (in particular
    mem_init_free_highmem() will trigger a page dump due to nonzero mapcount
    on the last page), it is simpler and safer to just limit the size of the
    region in a similar way to memblock but at the arch level to allow most
    of the RAM to be used without arithmetic overflows.
    
    Therefore we detect this case specifically and reduce the size of the
    region slightly to avoid the arithmetic overflows and cause the last
    page to be ignored.
    
    Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/13857/
    
    
    Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
    58cae9b0