diff options
author | Dave P Martin <Dave.Martin@arm.com> | 2015-06-16 12:38:47 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-07-21 13:10:03 -0400 |
commit | da8de4cde423fcd62233467ff9c067137beda0e8 (patch) | |
tree | 5c5af134b2791264ed37a3f93d6963e837432b6c /arch | |
parent | f6b01e505aa5785eaeda028fc0f151599f90b557 (diff) |
arm64: mm: Fix freeing of the wrong memmap entries with !SPARSEMEM_VMEMMAP
commit b9bcc919931611498e856eae9bf66337330d04cc upstream.
The memmap freeing code in free_unused_memmap() computes the end of
each memblock by adding the memblock size onto the base. However,
if SPARSEMEM is enabled then the value (start) used for the base
may already have been rounded downwards to work out which memmap
entries to free after the previous memblock.
This may cause memmap entries that are in use to get freed.
In general, you're not likely to hit this problem unless there
are at least 2 memblocks and one of them is not aligned to a
sparsemem section boundary. Note that carve-outs can increase
the number of memblocks by splitting the regions listed in the
device tree.
This problem doesn't occur with SPARSEMEM_VMEMMAP, because the
vmemmap code deals with freeing the unused regions of the memmap
instead of requiring the arch code to do it.
This patch gets the memblock base out of the memblock directly when
computing the block end address to ensure the correct value is used.
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm64/mm/init.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 597831bdddf3..ad87ce826cce 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c | |||
@@ -262,7 +262,7 @@ static void __init free_unused_memmap(void) | |||
262 | * memmap entries are valid from the bank end aligned to | 262 | * memmap entries are valid from the bank end aligned to |
263 | * MAX_ORDER_NR_PAGES. | 263 | * MAX_ORDER_NR_PAGES. |
264 | */ | 264 | */ |
265 | prev_end = ALIGN(start + __phys_to_pfn(reg->size), | 265 | prev_end = ALIGN(__phys_to_pfn(reg->base + reg->size), |
266 | MAX_ORDER_NR_PAGES); | 266 | MAX_ORDER_NR_PAGES); |
267 | } | 267 | } |
268 | 268 | ||