From: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Subject: s390/kdump: fix out-of-memory with PCI
Patch-mainline: never, fixed upstream with larger code rework
References: bsc#1182257 LTC#191375
Description: s390/kdump: fix out-of-memory with PCI
Symptom: The kdump kernel runs out of memory when allocating memory for
PCI IOMMU bitmaps in zpci_dma_init_device().
Problem: The kdump kernel does not properly restrict memory_end, which
the PCI code uses to calculate the size of the IOMMU bitmap, and
too much memory will be allocated.
Solution: Properly restrict memory_end to the available memory of the
kdump kernel (OLDMEM_SIZE), similar to how it would be done with
a "mem=" kernel parameter.
This was fixed inadvertently by an unrelated upstream commit
73045a08cf55 ("s390: unify identity mapping limits handling").
But that commit cannot easily be backported to distribution
levels, so only the part that fixes this bug will be submitted.
Reproduction: Try kdump on a system with large memory size and many PCI
functions.
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
arch/s390/boot/ipl_parm.c | 2 ++
1 file changed, 2 insertions(+)
--- a/arch/s390/boot/ipl_parm.c
+++ b/arch/s390/boot/ipl_parm.c
@@ -243,6 +243,8 @@ void setup_memory_end(void)
#ifdef CONFIG_CRASH_DUMP
if (OLDMEM_BASE) {
kaslr_enabled = 0;
+ memory_end = min(memory_end ?: OLDMEM_SIZE, OLDMEM_SIZE);
+ memory_end_set = 1;
} else if (ipl_block_valid &&
ipl_block.pb0_hdr.pbt == IPL_PBT_FCP &&
ipl_block.fcp.opt == IPL_PB0_FCP_OPT_DUMP) {