linux-brain/arch/xtensa
Max Filippov a5ecf56cb2 xtensa: fix high memory/reserved memory collision
commit 6ac5a11dc6 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-28 10:18:30 +01:00
..
boot xtensa: rearrange CCOUNT calibration 2016-09-20 18:52:59 -07:00
configs xtensa: add default memmap and mmio32native options to defconfigs 2016-09-20 20:43:24 -07:00
include xtensa: fix futex_atomic_cmpxchg_inatomic 2018-02-17 13:21:19 +01:00
kernel xtensa: don't limit csum_partial export by CONFIG_NET 2017-08-16 13:43:16 -07:00
lib xtensa: fixes for configs without loop option 2015-11-02 18:02:47 +03:00
mm xtensa: fix high memory/reserved memory collision 2018-02-28 10:18:30 +01:00
oprofile xtensa: move oprofile stack tracing to stacktrace.c 2015-08-17 07:32:49 +03:00
platforms xtensa: don't use linux IRQ #0 2017-06-17 06:41:58 +02:00
variants xtensa: Added Cadence CSP kernel configuration for Xtensa 2016-09-09 18:39:09 -07:00
Kconfig xtensa: disable MMU initialization option on MMUv2 cores 2016-09-29 12:55:00 -07:00
Kconfig.debug xtensa: disable link optimization 2014-12-15 23:47:24 -08:00
Makefile xtensa: define CONFIG_CPU_{BIG,LITTLE}_ENDIAN 2016-03-11 08:53:31 +00:00