linux/arch/mips
Maciej W. Rozycki cf3af0a4d3 MIPS: DEC: Restore bootmem reservation for firmware working memory area
Fix a crash on DEC platforms starting with:

VFS: Mounted root (nfs filesystem) on device 0:11.
Freeing unused PROM memory: 124k freed
BUG: Bad page state in process swapper  pfn:00001
page:(ptrval) refcount:0 mapcount:-128 mapping:00000000 index:0x1 pfn:0x1
flags: 0x0()
raw: 00000000 00000100 00000122 00000000 00000001 00000000 ffffff7f 00000000
page dumped because: nonzero mapcount
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 5.9.0-00858-g865c50e1d279 #1
Stack : 8065dc48 0000000b 8065d2b8 9bc27dcc 80645bfc 9bc259a4 806a1b97 80703124
        80710000 8064a900 00000001 80099574 806b116c 1000ec00 9bc27d88 806a6f30
        00000000 00000000 80645bfc 00000000 31232039 80706ba4 2e392e35 8039f348
        2d383538 00000070 0000000a 35363867 00000000 806c2830 80710000 806b0000
        80710000 8064a900 00000001 81000000 00000000 00000000 8035af2c 80700000
        ...
Call Trace:
[<8004bc5c>] show_stack+0x34/0x104
[<8015675c>] bad_page+0xfc/0x128
[<80157714>] free_pcppages_bulk+0x1f4/0x5dc
[<801591cc>] free_unref_page+0xc0/0x130
[<8015cb04>] free_reserved_area+0x144/0x1d8
[<805abd78>] kernel_init+0x20/0x100
[<80046070>] ret_from_kernel_thread+0x14/0x1c
Disabling lock debugging due to kernel taint

caused by an attempt to free bootmem space that as from
commit b93ddc4f91 ("mips: Reserve memory for the kernel image resources")
has not been anymore reserved due to the removal of generic MIPS arch code
that used to reserve all the memory from the beginning of RAM up to the
kernel load address.

This memory does need to be reserved on DEC platforms however as it is
used by REX firmware as working area, as per the TURBOchannel firmware
specification[1]:

Table 2-2  REX Memory Regions
-------------------------------------------------------------------------
        Starting        Ending
Region  Address         Address         Use
-------------------------------------------------------------------------
0       0xa0000000      0xa000ffff      Restart block, exception vectors,
                                        REX stack and bss
1       0xa0010000      0xa0017fff      Keyboard or tty drivers

2       0xa0018000      0xa001f3ff 1)   CRT driver

3       0xa0020000      0xa002ffff      boot, cnfg, init and t objects

4       0xa0020000      0xa002ffff      64KB scratch space
-------------------------------------------------------------------------
1) Note that the last 3 Kbytes of region 2 are reserved for backward
compatibility with previous system software.
-------------------------------------------------------------------------

(this table uses KSEG2 unmapped virtual addresses, which in the MIPS
architecture are offset from physical addresses by a fixed value of
0xa0000000 and therefore the regions referred do correspond to the
beginning of the physical address space) and we call into the firmware
on several occasions throughout the bootstrap process.  It is believed
that pre-REX firmware used with non-TURBOchannel DEC platforms has the
same requirements, as hinted by note #1 cited.

Recreate the discarded reservation then, in DEC platform code, removing
the crash.

References:

[1] "TURBOchannel Firmware Specification", On-line version,
    EK-TCAAD-FS-004, Digital Equipment Corporation, January 1993,
    Chapter 2 "System Module Firmware", p. 2-5

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Fixes: b93ddc4f91 ("mips: Reserve memory for the kernel image resources")
Cc: stable@vger.kernel.org # v5.2+

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2020-10-14 23:57:57 +02:00
..
alchemy MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
ar7 MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
ath25 MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
ath79 MIPS: ath79: Remove unused include <asm/mips_machine.h> 2020-07-28 10:20:44 +02:00
bcm47xx MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
bcm63xx MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
bmips MIPS: Only include the platform file needed 2020-05-13 00:17:18 +02:00
boot MIPS: Loongson64: Add UART node for LS7A PCH 2020-09-21 22:19:07 +02:00
cavium-octeon MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
cobalt MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
configs MIPS: Loongson64: Select SMP in Kconfig to avoid build error 2020-10-12 11:22:40 +02:00
crypto crypto: {arm,arm64,mips}/poly1305 - remove redundant non-reduction from emit 2020-01-16 15:18:12 +08:00
dec MIPS: DEC: Restore bootmem reservation for firmware working memory area 2020-10-14 23:57:57 +02:00
fw MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
generic MIPS: Ingenic: Add system type for new Ingenic SoCs. 2020-09-27 10:57:27 +02:00
include MIPS: cpu-probe: remove MIPS_CPU_BP_GHIST option bit 2020-10-12 12:05:40 +02:00
ingenic MIPS: jz4740: Rename jz4740 folders to ingenic 2020-09-18 16:35:05 +02:00
jazz mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
kernel MIPS: cpu-probe: remove MIPS_CPU_BP_GHIST option bit 2020-10-12 12:05:40 +02:00
kvm KVM: MIPS/VZ: Fix build error caused by 'kvm_run' cleanup 2020-08-11 07:19:41 -04:00
lantiq MIPS: lantiq: add missing GPHY clock aliases for ar10 and grx390 2020-08-17 13:01:07 +02:00
lib treewide: Remove uninitialized_var() usage 2020-07-16 12:35:15 -07:00
loongson2ef MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
loongson32 MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
loongson64 MIPS: Loongson64: Clean up numa.c 2020-10-12 11:22:58 +02:00
math-emu MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
mm MIPS: Ingenic: Fix bugs when detecting L2 cache of JZ4775 and X1000E. 2020-09-27 10:58:10 +02:00
mti-malta MIPS: malta: remove mach-malta/malta-dtshim.h header file 2020-09-21 22:16:47 +02:00
net MIPS: BPF: Use sizeof_field() instead of FIELD_SIZEOF() 2020-01-10 11:33:35 -08:00
netlogic MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
oprofile MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
pci MIPS: pci: use devm_platform_ioremap_resource_byname 2020-09-18 15:29:35 +02:00
pic32 MIPS: Only include the platform file needed 2020-05-13 00:17:18 +02:00
pistachio MIPS: Fix exception handler memcpy() 2020-05-24 09:15:54 +02:00
power mips: check for dsp presence only once before save/restore 2019-10-07 10:58:53 -07:00
ralink MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
rb532 MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
sgi-ip22 MIPS: Only include the platform file needed 2020-05-13 00:17:18 +02:00
sgi-ip27 mm/sparse: cleanup the code surrounding memory_present() 2020-08-07 11:33:27 -07:00
sgi-ip30 MIPS: SGI-IP30: Move irq bits to better header files 2020-09-21 22:15:49 +02:00
sgi-ip32 MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
sibyte MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
sni MIPS: Only include the platform file needed 2020-05-13 00:17:18 +02:00
tools MIPS: tools: Fix resource leak in elf-entry.c 2020-05-24 09:29:48 +02:00
txx9 MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
vdso Kbuild updates for v5.9 2020-08-09 14:10:26 -07:00
vr41xx MIPS: Fix builds for VR41xx platforms 2020-05-15 09:09:58 +02:00
Kbuild MIPS: Fix "make clean" error due to recent changes 2020-05-13 13:20:22 +02:00
Kbuild.platforms MIPS: generic: Add support for Ingenic SoCs 2020-09-18 16:33:59 +02:00
Kconfig mips: ralink: enable zboot support 2020-10-13 11:11:40 +02:00
Kconfig.debug mips: Add CPS_NS16550_WIDTH config 2020-05-22 09:12:52 +02:00
Makefile mips: Add MIPS Warrior P5600 support 2020-05-22 09:10:53 +02:00
Makefile.postlink MIPS: fix indentation of the 'RELOCS' message 2020-01-20 15:37:30 -08:00