arm64: Fix mapping of memory banks not ending on a PMD_SIZE boundary
authorCatalin Marinas <catalin.marinas@arm.com>
Fri, 23 Aug 2013 17:04:44 +0000 (18:04 +0100)
committerMark Brown <broonie@linaro.org>
Thu, 15 May 2014 19:00:29 +0000 (20:00 +0100)
commit6d5002154f8dad3866240e5368c4341a1af6aafc
tree5848d0c841ae79f9b3dfe29439665d986d044ba6
parentc3efb58a10fc46a19e9ec57434e06fb299f5ea70
arm64: Fix mapping of memory banks not ending on a PMD_SIZE boundary

The map_mem() function limits the current memblock limit to PGDIR_SIZE
(the initial swapper_pg_dir mapping) to avoid create_mapping()
allocating memory from unmapped areas. However, if the first block is
within PGDIR_SIZE and not ending on a PMD_SIZE boundary, when 4K page
configuration is enabled, create_mapping() will try to allocate a pte
page. Such page may be returned by memblock_alloc() from the end of such
bank (or any subsequent bank within PGDIR_SIZE) which is not mapped yet.

The patch limits the current memblock limit to the aligned end of the
first bank and gradually increases it as more memory is mapped. It also
ensures that the start of the first bank is aligned to PMD_SIZE to avoid
pte page allocation for this mapping.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Reported-by: "Leizhen (ThunderTown, Euler)" <thunder.leizhen@huawei.com>
Tested-by: "Leizhen (ThunderTown, Euler)" <thunder.leizhen@huawei.com>
(cherry picked from commit e25208f77c2dad5a9f2ab3d3df61252a90b71afa)
Signed-off-by: Mark Brown <broonie@linaro.org>
arch/arm64/mm/mmu.c