Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[S390] fix "mem=" handling in case of standby memory

Standby memory detected with the sclp interface gets always registered
with add_memory calls without considering the limitationt that the
"mem=" kernel paramater implies.
So fix this and only register standby memory that is below the specified
limit.
This fixes zfcpdump since it uses "mem=32M". In case there is appr.
2GB standby memory present all of usable memory would be used for the
struct pages needed for standby memory.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Heiko Carstens and committed by
Martin Schwidefsky
23d75d9c d5cd0343

+14 -2
+2
arch/s390/include/asm/setup.h
··· 43 43 44 44 extern struct mem_chunk memory_chunk[]; 45 45 extern unsigned long real_memory_size; 46 + extern int memory_end_set; 47 + extern unsigned long memory_end; 46 48 47 49 void detect_memory_layout(struct mem_chunk chunk[]); 48 50
+7 -2
arch/s390/kernel/setup.c
··· 82 82 83 83 struct mem_chunk __initdata memory_chunk[MEMORY_CHUNKS]; 84 84 volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */ 85 - static unsigned long __initdata memory_end; 85 + 86 + int __initdata memory_end_set; 87 + unsigned long __initdata memory_end; 86 88 87 89 /* 88 90 * This is set up by the setup-routine at boot-time ··· 283 281 static int __init early_parse_mem(char *p) 284 282 { 285 283 memory_end = memparse(p, &p); 284 + memory_end_set = 1; 286 285 return 0; 287 286 } 288 287 early_param("mem", early_parse_mem); ··· 511 508 int i; 512 509 513 510 #if defined(CONFIG_ZFCPDUMP) || defined(CONFIG_ZFCPDUMP_MODULE) 514 - if (ipl_info.type == IPL_TYPE_FCP_DUMP) 511 + if (ipl_info.type == IPL_TYPE_FCP_DUMP) { 515 512 memory_end = ZFCPDUMP_HSA_SIZE; 513 + memory_end_set = 1; 514 + } 516 515 #endif 517 516 memory_size = 0; 518 517 memory_end &= PAGE_MASK;
+5
drivers/s390/char/sclp_cmd.c
··· 19 19 #include <linux/memory.h> 20 20 #include <asm/chpid.h> 21 21 #include <asm/sclp.h> 22 + #include <asm/setup.h> 22 23 23 24 #include "sclp.h" 24 25 ··· 475 474 goto skip_add; 476 475 if (start + size > VMEM_MAX_PHYS) 477 476 size = VMEM_MAX_PHYS - start; 477 + if (memory_end_set && (start >= memory_end)) 478 + goto skip_add; 479 + if (memory_end_set && (start + size > memory_end)) 480 + size = memory_end - start; 478 481 add_memory(0, start, size); 479 482 skip_add: 480 483 first_rn = rn;