linux-stable/arch/arm/mm
Linus Torvalds a412897fb5 memblock, arm: fix crashes caused by holes in the memory map
The coordination between freeing of unused memory map, pfn_valid() and core
 mm assumptions about validity of the memory map in various ranges was not
 designed for complex layouts of the physical memory with a lot of holes all
 over the place.
 
 Kefen Wang reported crashes in move_freepages() on a system with the
 following memory layout [1]:
 
   node   0: [mem 0x0000000080a00000-0x00000000855fffff]
   node   0: [mem 0x0000000086a00000-0x0000000087dfffff]
   node   0: [mem 0x000000008bd00000-0x000000008c4fffff]
   node   0: [mem 0x000000008e300000-0x000000008ecfffff]
   node   0: [mem 0x0000000090d00000-0x00000000bfffffff]
   node   0: [mem 0x00000000cc000000-0x00000000dc9fffff]
   node   0: [mem 0x00000000de700000-0x00000000de9fffff]
   node   0: [mem 0x00000000e0800000-0x00000000e0bfffff]
   node   0: [mem 0x00000000f4b00000-0x00000000f6ffffff]
   node   0: [mem 0x00000000fda00000-0x00000000ffffefff]
 
 These crashes can be mitigated by enabling CONFIG_HOLES_IN_ZONE on ARM and
 essentially turning pfn_valid_within() to pfn_valid() instead of having it
 hardwired to 1 on that architecture, but this would require to keep
 CONFIG_HOLES_IN_ZONE solely for this purpose.
 
 A cleaner approach is to update ARM's implementation of pfn_valid() to take
 into accounting rounding of the freed memory map to pageblock boundaries
 and make sure it returns true for PFNs that have memory map entries even if
 there is no physical memory backing those PFNs.
 
 [1] https://lore.kernel.org/lkml/2a1592ad-bc9d-4664-fd19-f7448a37edc0@huawei.com
 -----BEGIN PGP SIGNATURE-----
 
 iQFHBAABCAAxFiEEeOVYVaWZL5900a/pOQOGJssO/ZEFAmDhzQQTHHJwcHRAbGlu
 dXguaWJtLmNvbQAKCRA5A4Ymyw79kXeUCACS0lssuKbaBxFk6OkEe0nbmbwN/n9z
 zKd2AWzw9xFxYZkLfOCmi5EPUMI0IeDYjOyZmnj8YDDd7wRLVxZ51LSdyFDZafXY
 j6SVYprSmwUjLkuajmqifY5DLbZYeGuI6WFvNVLljltHc0i/GIzx1Tld2yO/M0Jk
 NzHQ0/5nXmU74PvvY8LrWk+rRjTYqMuolHvbbl4nNId5e/FYEWNxEqNO5gq6aG5g
 +5t1BjyLf1NMp67uc5aLoLmr2ZwK8/UmZeSZ7i9z03gU/5B1srLluhoBsYBPVHFY
 hRNRKwWUDRUmqjJnu5/EzI+iQnj7t6zV1hyt+E5B1gb89vuSVcJNOPQt
 =wCcY
 -----END PGP SIGNATURE-----

Merge tag 'memblock-v5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock

Pull memblock updates from Mike Rapoport:
 "Fix arm crashes caused by holes in the memory map.

  The coordination between freeing of unused memory map, pfn_valid() and
  core mm assumptions about validity of the memory map in various ranges
  was not designed for complex layouts of the physical memory with a lot
  of holes all over the place.

  Kefen Wang reported crashes in move_freepages() on a system with the
  following memory layout [1]:

	node 0: [mem 0x0000000080a00000-0x00000000855fffff]
	node 0: [mem 0x0000000086a00000-0x0000000087dfffff]
	node 0: [mem 0x000000008bd00000-0x000000008c4fffff]
	node 0: [mem 0x000000008e300000-0x000000008ecfffff]
	node 0: [mem 0x0000000090d00000-0x00000000bfffffff]
	node 0: [mem 0x00000000cc000000-0x00000000dc9fffff]
	node 0: [mem 0x00000000de700000-0x00000000de9fffff]
	node 0: [mem 0x00000000e0800000-0x00000000e0bfffff]
	node 0: [mem 0x00000000f4b00000-0x00000000f6ffffff]
	node 0: [mem 0x00000000fda00000-0x00000000ffffefff]

  These crashes can be mitigated by enabling CONFIG_HOLES_IN_ZONE on ARM
  and essentially turning pfn_valid_within() to pfn_valid() instead of
  having it hardwired to 1 on that architecture, but this would require
  to keep CONFIG_HOLES_IN_ZONE solely for this purpose.

  A cleaner approach is to update ARM's implementation of pfn_valid() to
  take into accounting rounding of the freed memory map to pageblock
  boundaries and make sure it returns true for PFNs that have memory map
  entries even if there is no physical memory backing those PFNs"

Link: https://lore.kernel.org/lkml/2a1592ad-bc9d-4664-fd19-f7448a37edc0@huawei.com [1]

* tag 'memblock-v5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock:
  arm: extend pfn_valid to take into account freed memory map alignment
  memblock: ensure there is no overflow in memblock_overlaps_region()
  memblock: align freed memory map on pageblock boundaries with SPARSEMEM
  memblock: free_unused_memmap: use pageblock units instead of MAX_ORDER
2021-07-04 12:23:05 -07:00
..
abort-ev4.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
abort-ev4t.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
abort-ev5t.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
abort-ev5tj.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
abort-ev6.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
abort-ev7.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
abort-lv4t.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
abort-macro.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
abort-nommu.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
alignment.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
cache-b15-rac.c ARM: mm: Remove virtual address print from B15 RAC driver 2020-05-06 11:12:12 -07:00
cache-fa.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
cache-feroceon-l2.c
cache-l2x0-pmu.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
cache-l2x0.c ARM: 9007/1: l2c: fix prefetch bits init in L2X0_AUX_CTRL using DT values 2020-09-15 14:35:53 +01:00
cache-nop.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
cache-tauros2.c ARM: l2c: tauros2: use descriptive definitions for register bits 2015-11-26 22:12:26 +00:00
cache-tauros3.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 171 2019-05-30 11:26:39 -07:00
cache-uniphier.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
cache-v4.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
cache-v4wb.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
cache-v4wt.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
cache-v6.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
cache-v7.S ARM: 9059/1: cache-v7: get rid of mini-stack 2021-03-09 10:25:18 +00:00
cache-v7m.S sched/rt, ARM: Use CONFIG_PREEMPTION 2019-12-08 14:37:32 +01:00
cache-xsc3l2.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
context.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
copypage-fa.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
copypage-feroceon.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
copypage-v4mc.c mm: move page_mapping_file to pagemap.h 2021-04-30 11:20:37 -07:00
copypage-v4wb.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
copypage-v4wt.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
copypage-v6.c mm: move page_mapping_file to pagemap.h 2021-04-30 11:20:37 -07:00
copypage-xsc3.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
copypage-xscale.c mm: move page_mapping_file to pagemap.h 2021-04-30 11:20:37 -07:00
dma-mapping-nommu.c dma-mapping: split <linux/dma-mapping.h> 2020-10-06 07:07:03 +02:00
dma-mapping.c dma-mapping: merge <linux/dma-noncoherent.h> into <linux/dma-map-ops.h> 2020-10-06 07:07:06 +02:00
dma.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
dump.c ARM: 9073/1: ptdump: add __init section marker to three functions 2021-04-18 19:15:12 +01:00
extable.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fault-armv.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
fault.c mm/arm: use general page fault accounting 2020-08-12 10:58:03 -07:00
fault.h ARM: 8898/1: mm: Don't treat faults reported from cache maintenance as writes 2019-08-23 11:39:34 +01:00
flush.c mm: introduce compound_nr() 2019-09-24 15:54:08 -07:00
fsr-2level.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fsr-3level.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hugetlbpage.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
idmap.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
init.c arm: extend pfn_valid to take into account freed memory map alignment 2021-06-30 11:39:00 +03:00
iomap.c ARM: 8923/1: mm: include <asm/vga.h> for vga_base 2019-10-31 16:58:54 +00:00
ioremap.c mm: pgtable: add shortcuts for accessing kernel PMD and PTE 2020-06-09 09:39:13 -07:00
kasan_init.c ARM: 9016/2: Initialize the mapping of KASan shadow memory 2020-10-27 12:11:10 +00:00
Kconfig ARM: drop efm32 platform 2021-01-15 17:42:10 +01:00
l2c-common.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
l2c-l2x0-resume.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile ARM updates for 5.11: 2020-12-22 13:34:27 -08:00
mm.h mm: pgtable: add shortcuts for accessing kernel PMD and PTE 2020-06-09 09:39:13 -07:00
mmap.c arm: Use the generic devmem_is_allowed() 2020-12-11 12:28:24 -08:00
mmu.c ARM: 9063/1: mm: reduce maximum number of CPUs if DEBUG_KMAP_LOCAL is enabled 2021-03-25 10:25:19 +00:00
nommu.c arm: remove ioremap_cached 2019-11-11 17:19:40 +01:00
pabort-legacy.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pabort-v6.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pabort-v7.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pageattr.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
pgd.c ARM: 9016/2: Initialize the mapping of KASan shadow memory 2020-10-27 12:11:10 +00:00
physaddr.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pmsa-v7.c ARM: 9069/1: NOMMU: Fix conversion for_each_membock() to for_each_mem_range() 2021-03-25 10:25:20 +00:00
pmsa-v8.c ARM: 9069/1: NOMMU: Fix conversion for_each_membock() to for_each_mem_range() 2021-03-25 10:25:20 +00:00
proc-arm7tdmi.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm9tdmi.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm720.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm740.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm920.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm922.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm925.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm926.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm940.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm946.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm1020.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm1020e.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm1022.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-arm1026.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-fa526.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-feroceon.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-macros.S ARM: 8982/1: mm: Simplify act_mm macro 2020-07-21 16:33:36 +01:00
proc-mohawk.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-sa110.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-sa1100.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-syms.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
proc-v6.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-v7-2level.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
proc-v7-3level.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
proc-v7-bugs.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
proc-v7.S ARM: 9059/1: cache-v7: get rid of mini-stack 2021-03-09 10:25:18 +00:00
proc-v7m.S ARM: 8933/1: replace Sun/Solaris style flag on section directive 2019-11-15 22:21:19 +00:00
proc-xsc3.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
proc-xscale.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
ptdump_debugfs.c ARM: 9074/1: ptdump: convert to DEFINE_SHOW_ATTRIBUTE 2021-04-18 19:15:13 +01:00
pv-fixup-asm.S ARM: 9012/1: move device tree mapping out of linear region 2020-10-27 12:11:01 +00:00
tcm.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00
tlb-fa.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
tlb-v4.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
tlb-v4wb.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
tlb-v4wbi.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
tlb-v6.S mm: update legacy flush_tlb_* to use vma 2021-06-29 10:53:52 -07:00
tlb-v7.S mm: update legacy flush_tlb_* to use vma 2021-06-29 10:53:52 -07:00