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#1182256 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/kernel/setup.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -610,8 +610,10 @@ static struct notifier_block kdump_mem_n
static void reserve_memory_end(void)
{
#ifdef CONFIG_CRASH_DUMP
- if (ipl_info.type == IPL_TYPE_FCP_DUMP &&
- !OLDMEM_BASE && sclp.hsa_size) {
+ if (OLDMEM_BASE) {
+ memory_end = min(memory_end ?: OLDMEM_SIZE, OLDMEM_SIZE);
+ memory_end_set = 1;
+ } else if (ipl_info.type == IPL_TYPE_FCP_DUMP && sclp.hsa_size) {
memory_end = sclp.hsa_size;
memory_end &= PAGE_MASK;
memory_end_set = 1;