Skip to content

Commit 91c0e87

Browse files
mina86Joseph Salisbury
authored and
Joseph Salisbury
committed
mm: page_alloc: fix CMA area initialisation when pageblock > MAX_ORDER
BugLink: http://bugs.launchpad.net/bugs/1356913 commit dc78327 upstream. With a kernel configured with ARM64_64K_PAGES && !TRANSPARENT_HUGEPAGE, the following is triggered at early boot: SMP: Total of 8 processors activated. devtmpfs: initialized Unable to handle kernel NULL pointer dereference at virtual address 00000008 pgd = fffffe0000050000 [00000008] *pgd=00000043fba00003, *pmd=00000043fba00003, *pte=00e0000078010407 Internal error: Oops: 96000006 [#1] SMP Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.15.0-rc864k+ torvalds#44 task: fffffe03bc040000 ti: fffffe03bc080000 task.ti: fffffe03bc080000 PC is at __list_add+0x10/0xd4 LR is at free_one_page+0x270/0x638 ... Call trace: __list_add+0x10/0xd4 free_one_page+0x26c/0x638 __free_pages_ok.part.52+0x84/0xbc __free_pages+0x74/0xbc init_cma_reserved_pageblock+0xe8/0x104 cma_init_reserved_areas+0x190/0x1e4 do_one_initcall+0xc4/0x154 kernel_init_freeable+0x204/0x2a8 kernel_init+0xc/0xd4 This happens because init_cma_reserved_pageblock() calls __free_one_page() with pageblock_order as page order but it is bigger than MAX_ORDER. This in turn causes accesses past zone->free_list[]. Fix the problem by changing init_cma_reserved_pageblock() such that it splits pageblock into individual MAX_ORDER pages if pageblock is bigger than a MAX_ORDER page. In cases where !CONFIG_HUGETLB_PAGE_SIZE_VARIABLE, which is all architectures expect for ia64, powerpc and tile at the moment, the â��pageblock_order > MAX_ORDERâ�� condition will be optimised out since both sides of the operator are constants. In cases where pageblock size is variable, the performance degradation should not be significant anyway since init_cma_reserved_pageblock() is called only at boot time at most MAX_CMA_AREAS times which by default is eight. Signed-off-by: Michal Nazarewicz <[email protected]> Reported-by: Mark Salter <[email protected]> Tested-by: Mark Salter <[email protected]> Tested-by: Christopher Covington <[email protected]> Cc: Mel Gorman <[email protected]> Cc: David Rientjes <[email protected]> Cc: Marek Szyprowski <[email protected]> Cc: Catalin Marinas <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Joseph Salisbury <[email protected]>
1 parent 8b9557e commit 91c0e87

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Diff for: mm/page_alloc.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,21 @@ void __init init_cma_reserved_pageblock(struct page *page)
785785
set_page_count(p, 0);
786786
} while (++p, --i);
787787

788-
set_page_refcounted(page);
789788
set_pageblock_migratetype(page, MIGRATE_CMA);
790-
__free_pages(page, pageblock_order);
789+
790+
if (pageblock_order >= MAX_ORDER) {
791+
i = pageblock_nr_pages;
792+
p = page;
793+
do {
794+
set_page_refcounted(p);
795+
__free_pages(p, MAX_ORDER - 1);
796+
p += MAX_ORDER_NR_PAGES;
797+
} while (i -= MAX_ORDER_NR_PAGES);
798+
} else {
799+
set_page_refcounted(page);
800+
__free_pages(page, pageblock_order);
801+
}
802+
791803
adjust_managed_page_count(page, pageblock_nr_pages);
792804
}
793805
#endif

0 commit comments

Comments
 (0)