linux/arch/mips
Serge Semin e1a9ae4573 mips: Fix max_mapnr being uninitialized on early stages
max_mapnr variable is utilized in the pfn_valid() method in order to
determine the upper PFN space boundary. Having it uninitialized
effectively makes any PFN passed to that method invalid. That in its turn
causes the kernel mm-subsystem occasion malfunctions even after the
max_mapnr variable is actually properly updated. For instance,
pfn_valid() is called in the init_unavailable_range() method in the
framework of the calls-chain on MIPS:
setup_arch()
+-> paging_init()
    +-> free_area_init()
        +-> memmap_init()
            +-> memmap_init_zone_range()
                +-> init_unavailable_range()

Since pfn_valid() always returns "false" value before max_mapnr is
initialized in the mem_init() method, any flatmem page-holes will be left
in the poisoned/uninitialized state including the IO-memory pages. Thus
any further attempts to map/remap the IO-memory by using MMU may fail.
In particular it happened in my case on attempt to map the SRAM region.
The kernel bootup procedure just crashed on the unhandled unaligned access
bug raised in the __update_cache() method:

> Unhandled kernel unaligned access[#1]:
> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.7.0-rc1-XXX-dirty #2056
> ...
> Call Trace:
> [<8011ef9c>] __update_cache+0x88/0x1bc
> [<80385944>] ioremap_page_range+0x110/0x2a4
> [<80126948>] ioremap_prot+0x17c/0x1f4
> [<80711b80>] __devm_ioremap+0x8c/0x120
> [<80711e0c>] __devm_ioremap_resource+0xf4/0x218
> [<808bf244>] sram_probe+0x4f4/0x930
> [<80889d20>] platform_probe+0x68/0xec
> ...

Let's fix the problem by initializing the max_mapnr variable as soon as
the required data is available. In particular it can be done right in the
paging_init() method before free_area_init() is called since all the PFN
zone boundaries have already been calculated by that time.

Cc: stable@vger.kernel.org
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2023-12-21 15:32:09 +01:00
..
alchemy MIPS: Alchemy: only build mmc support helpers if au1xmmc is enabled 2023-09-25 11:43:55 +02:00
ath25 MIPS: ath25: Constify static irq_domain_ops 2022-02-22 09:39:03 +01:00
ath79 MIPS: ath79: remove obsolete ATH79_DEV_* configs 2023-03-17 10:28:04 +01:00
bcm47xx mips: implement the new page table range API 2023-08-24 16:20:22 -07:00
bcm63xx MIPS: BCM63xx: Add check for NULL for clk in clk_enable 2022-12-09 23:37:06 +01:00
bmips MIPS: Explicitly include correct DT includes 2023-07-25 10:42:01 +02:00
boot MIPS: compressed: Use correct instruction for 64 bit code 2023-12-21 15:30:03 +01:00
cavium-octeon just cleanups and fixes 2023-09-07 10:35:14 -07:00
cobalt
configs MIPS: AR7: remove platform 2023-10-19 10:39:46 +02:00
crypto crypto: mips/crc32 - remove redundant setting of alignmask to 0 2023-10-27 18:04:24 +08:00
dec MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
fw MIPS: fw: Allow firmware to pass a empty env 2023-04-12 15:07:36 +02:00
generic mips: ingenic: Enable EXT/2 divider on JZ4750/55/60 if EXT is 24 MHz 2023-06-09 09:54:17 +02:00
include mips: dmi: Fix early remap on MIPS32 2023-12-21 15:31:25 +01:00
ingenic
jazz vgacon, arch/*: remove unused screen_info definitions 2023-10-17 10:17:02 +02:00
kernel mips: Fix incorrect max_low_pfn adjustment 2023-12-21 15:31:46 +01:00
kvm MIPS: KVM: Fix a build warning about variable set but not used 2023-10-19 10:25:31 +02:00
lantiq MIPS: Fixup explicit DT include clean-up 2023-07-28 11:41:09 +02:00
lib mips: implement xor_unlock_is_negative_byte 2023-10-18 14:34:17 -07:00
loongson2ef MIPS: loongson2ef: Add missing break in cs5536_isa 2023-04-12 15:12:24 +02:00
loongson32 MIPS: loongson32: Remove dma.h and nand.h 2023-10-06 10:10:13 +02:00
loongson64 MIPS: Loongson64: Handle more memory types passed from firmware 2023-12-05 18:45:24 +01:00
math-emu MIPS: Fix comment typo 2022-09-12 15:33:24 +02:00
mm mips: Fix max_mapnr being uninitialized on early stages 2023-12-21 15:32:09 +01:00
mti-malta vgacon: clean up global screen_info instances 2023-10-17 10:17:02 +02:00
n64
net bpf, mips: Implement R4000 workarounds for JIT 2023-02-28 14:52:55 +01:00
pci MIPS: lantiq: Remove unnecessary include of <linux/of_irq.h> 2023-10-19 10:26:17 +02:00
pic32 MIPS: Fixup explicit DT include clean-up 2023-07-28 11:41:09 +02:00
power
ralink MIPS: More explicit DT include clean-ups 2023-07-28 11:41:18 +02:00
rb532 MIPS: rb532: move GPIOD definition into C-files 2022-03-30 20:26:26 +02:00
sgi-ip22 driver core: make struct bus_type.uevent() take a const * 2023-01-27 13:45:52 +01:00
sgi-ip27 MIPS: SGI-IP27: hubio: fix nasid kernel-doc warning 2023-12-11 21:42:53 +01:00
sgi-ip30 MIPS: SGI-IP30: Fix platform-device leak in bridge_platform_create() 2022-09-19 16:32:54 +02:00
sgi-ip32
sibyte vgacon: fix mips/sibyte build regression 2023-10-24 08:54:37 +02:00
sni vgacon: clean up global screen_info instances 2023-10-17 10:17:02 +02:00
tools MIPS: fix typos in comments 2022-05-04 22:22:59 +02:00
txx9 MIPS: TXx9: Do PCI error checks on own line 2023-08-28 09:59:06 +02:00
vdso MIPS: VDSO: Conditionally export __vdso_gettimeofday() 2023-08-23 09:06:38 +02:00
Kbuild kbuild: remove --include-dir MAKEFLAG from top Makefile 2023-02-05 18:51:22 +09:00
Kbuild.platforms MIPS: AR7: remove platform 2023-10-19 10:39:46 +02:00
Kconfig MIPS: Loongson64: Enable DMA noncoherent support 2023-12-05 18:45:14 +01:00
Kconfig.debug
Makefile Revert MIPS: Loongson: Fix build error when make modules_install 2023-07-25 10:42:01 +02:00
Makefile.postlink kbuild: remove ARCH_POSTLINK from module builds 2023-10-28 21:10:08 +09:00