s390/kdump: Fix elfcorehdr size calculation
authorPhilipp Rudo <prudo@linux.ibm.com>
Thu, 19 Jul 2018 09:13:45 +0000 (11:13 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 31 Jul 2018 15:43:43 +0000 (17:43 +0200)
commit8cce437fbb5c1f2af2f63834fa05082596beca5d
tree9350eed87fba41b5f7fee8744a079040cba4b6ae
parent5223c671674c507cc9bcabdfc5a9b449c178330a
s390/kdump: Fix elfcorehdr size calculation

Before the memory for the elfcorehdr is allocated the required size is
estimated with

       alloc_size = 0x1000 + get_cpu_cnt() * 0x4a0 +
               mem_chunk_cnt * sizeof(Elf64_Phdr);

Where 0x4a0 is used as size for the ELF notes to store the register
contend. This size is 8 bytes too small. Usually this does not immediately
cause a problem because the page reserved for overhead (Elf_Ehdr,
vmcoreinfo, etc.) is pretty generous. So usually there is enough spare
memory to counter the mis-calculated per cpu size. However, with growing
overhead and/or a huge cpu count the allocated size gets too small for the
elfcorehdr. Ultimately a BUG_ON is triggered causing the crash kernel to
panic.

Fix this by properly calculating the required size instead of relying on
magic numbers.

Fixes: a62bc07392539 ("s390/kdump: add support for vector extension")
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/kernel/crash_dump.c