linux-sg2042/arch/xtensa/mm
Max Filippov 6ac5a11dc6 xtensa: fix high memory/reserved memory collision
Xtensa memory initialization code frees high memory pages without
checking whether they are in the reserved memory regions or not. That
results in invalid value of totalram_pages and duplicate page usage by
CMA and highmem. It produces a bunch of BUGs at startup looking like
this:

BUG: Bad page state in process swapper  pfn:70800
page:be60c000 count:0 mapcount:-127 mapping:  (null) index:0x1
flags: 0x80000000()
raw: 80000000 00000000 00000001 ffffff80 00000000 be60c014 be60c014 0000000a
page dumped because: nonzero mapcount
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Tainted: G    B            4.16.0-rc1-00015-g7928b2cbe55b-dirty #23
Stack:
 bd839d33 00000000 00000018 ba97b64c a106578c bd839d70 be60c000 00000000
 a1378054 bd86a000 00000003 ba97b64c a1066166 bd839da0 be60c000 ffe00000
 a1066b58 bd839dc0 be504000 00000000 000002f4 bd838000 00000000 0000001e
Call Trace:
 [<a1065734>] bad_page+0xac/0xd0
 [<a106578c>] free_pages_check_bad+0x34/0x4c
 [<a1066166>] __free_pages_ok+0xae/0x14c
 [<a1066b58>] __free_pages+0x30/0x64
 [<a1365de5>] init_cma_reserved_pageblock+0x35/0x44
 [<a13682dc>] cma_init_reserved_areas+0xf4/0x148
 [<a10034b8>] do_one_initcall+0x80/0xf8
 [<a1361c16>] kernel_init_freeable+0xda/0x13c
 [<a125b59d>] kernel_init+0x9/0xd0
 [<a1004304>] ret_from_kernel_thread+0xc/0x18

Only free high memory pages that are not reserved.

Cc: stable@vger.kernel.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-02-15 09:46:42 -08:00
..
Makefile xtensa: add support for KASAN 2017-12-16 22:37:12 -08:00
cache.c xtensa: clean up custom-controlled debug output 2017-12-16 22:37:08 -08:00
fault.c xtensa: clean up custom-controlled debug output 2017-12-16 22:37:08 -08:00
highmem.c sched/preempt, mm/kmap: Explicitly disable/enable preemption in kmap_atomic_* 2015-05-19 08:39:14 +02:00
init.c xtensa: fix high memory/reserved memory collision 2018-02-15 09:46:42 -08:00
ioremap.c xtensa: support ioremap for memory outside KIO region 2016-01-11 17:37:36 +03:00
kasan_init.c xtensa: add support for KASAN 2017-12-16 22:37:12 -08:00
misc.S xtensa: implement clear_user_highpage and copy_user_highpage 2014-08-14 11:59:20 +04:00
mmu.c xtensa: don't clear swapper_pg_dir in paging_init 2017-12-16 22:37:11 -08:00
tlb.c xtensa: clean up custom-controlled debug output 2017-12-16 22:37:08 -08:00