xref: /linux/arch/s390/kernel/early.c (revision 92e6ecf392fac3082653ac9d84b1bdf53d0ea160)
1ab14de6cSHeiko Carstens /*
2ab14de6cSHeiko Carstens  *  arch/s390/kernel/early.c
3ab14de6cSHeiko Carstens  *
4ab14de6cSHeiko Carstens  *    Copyright IBM Corp. 2007
5ab14de6cSHeiko Carstens  *    Author(s): Hongjie Yang <hongjie@us.ibm.com>,
6ab14de6cSHeiko Carstens  *		 Heiko Carstens <heiko.carstens@de.ibm.com>
7ab14de6cSHeiko Carstens  */
8ab14de6cSHeiko Carstens 
9*92e6ecf3SChristian Borntraeger #include <linux/compiler.h>
10ab14de6cSHeiko Carstens #include <linux/init.h>
11ab14de6cSHeiko Carstens #include <linux/errno.h>
12ab14de6cSHeiko Carstens #include <linux/string.h>
13ab14de6cSHeiko Carstens #include <linux/ctype.h>
14ab14de6cSHeiko Carstens #include <linux/lockdep.h>
15ab14de6cSHeiko Carstens #include <linux/module.h>
16ab14de6cSHeiko Carstens #include <linux/pfn.h>
17ab14de6cSHeiko Carstens #include <linux/uaccess.h>
18a0443fbbSHendrik Brueckner #include <asm/ebcdic.h>
1946b05d26SMichael Holzheu #include <asm/ipl.h>
20ab14de6cSHeiko Carstens #include <asm/lowcore.h>
21ab14de6cSHeiko Carstens #include <asm/processor.h>
22ab14de6cSHeiko Carstens #include <asm/sections.h>
23ab14de6cSHeiko Carstens #include <asm/setup.h>
24*92e6ecf3SChristian Borntraeger #include <asm/sysinfo.h>
25ab14de6cSHeiko Carstens #include <asm/cpcmd.h>
26ab14de6cSHeiko Carstens #include <asm/sclp.h>
27a806170eSHeiko Carstens #include "entry.h"
28ab14de6cSHeiko Carstens 
29ab14de6cSHeiko Carstens /*
30ab14de6cSHeiko Carstens  * Create a Kernel NSS if the SAVESYS= parameter is defined
31ab14de6cSHeiko Carstens  */
32a0443fbbSHendrik Brueckner #define DEFSYS_CMD_SIZE		128
33ab14de6cSHeiko Carstens #define SAVESYS_CMD_SIZE	32
34ab14de6cSHeiko Carstens 
35ab14de6cSHeiko Carstens char kernel_nss_name[NSS_NAME_SIZE + 1];
36ab14de6cSHeiko Carstens 
37a0443fbbSHendrik Brueckner static void __init setup_boot_command_line(void);
38a0443fbbSHendrik Brueckner 
39a0443fbbSHendrik Brueckner 
40ab14de6cSHeiko Carstens #ifdef CONFIG_SHARED_KERNEL
41a0443fbbSHendrik Brueckner int __init savesys_ipl_nss(char *cmd, const int cmdlen);
42a0443fbbSHendrik Brueckner 
43a0443fbbSHendrik Brueckner asm(
44a0443fbbSHendrik Brueckner 	"	.section .init.text,\"ax\",@progbits\n"
45a0443fbbSHendrik Brueckner 	"	.align	4\n"
46a0443fbbSHendrik Brueckner 	"	.type	savesys_ipl_nss, @function\n"
47a0443fbbSHendrik Brueckner 	"savesys_ipl_nss:\n"
48a0443fbbSHendrik Brueckner #ifdef CONFIG_64BIT
49a0443fbbSHendrik Brueckner 	"	stmg	6,15,48(15)\n"
50a0443fbbSHendrik Brueckner 	"	lgr	14,3\n"
51a0443fbbSHendrik Brueckner 	"	sam31\n"
52a0443fbbSHendrik Brueckner 	"	diag	2,14,0x8\n"
53a0443fbbSHendrik Brueckner 	"	sam64\n"
54a0443fbbSHendrik Brueckner 	"	lgr	2,14\n"
55a0443fbbSHendrik Brueckner 	"	lmg	6,15,48(15)\n"
56a0443fbbSHendrik Brueckner #else
57a0443fbbSHendrik Brueckner 	"	stm	6,15,24(15)\n"
58a0443fbbSHendrik Brueckner 	"	lr	14,3\n"
59a0443fbbSHendrik Brueckner 	"	diag	2,14,0x8\n"
60a0443fbbSHendrik Brueckner 	"	lr	2,14\n"
61a0443fbbSHendrik Brueckner 	"	lm	6,15,24(15)\n"
62a0443fbbSHendrik Brueckner #endif
63a0443fbbSHendrik Brueckner 	"	br	14\n"
64a0443fbbSHendrik Brueckner 	"	.size	savesys_ipl_nss, .-savesys_ipl_nss\n");
65a0443fbbSHendrik Brueckner 
66ab14de6cSHeiko Carstens static noinline __init void create_kernel_nss(void)
67ab14de6cSHeiko Carstens {
68ab14de6cSHeiko Carstens 	unsigned int i, stext_pfn, eshared_pfn, end_pfn, min_size;
69ab14de6cSHeiko Carstens #ifdef CONFIG_BLK_DEV_INITRD
70ab14de6cSHeiko Carstens 	unsigned int sinitrd_pfn, einitrd_pfn;
71ab14de6cSHeiko Carstens #endif
72ab14de6cSHeiko Carstens 	int response;
73a0443fbbSHendrik Brueckner 	size_t len;
74ab14de6cSHeiko Carstens 	char *savesys_ptr;
75ab14de6cSHeiko Carstens 	char upper_command_line[COMMAND_LINE_SIZE];
76ab14de6cSHeiko Carstens 	char defsys_cmd[DEFSYS_CMD_SIZE];
77ab14de6cSHeiko Carstens 	char savesys_cmd[SAVESYS_CMD_SIZE];
78ab14de6cSHeiko Carstens 
79ab14de6cSHeiko Carstens 	/* Do nothing if we are not running under VM */
80ab14de6cSHeiko Carstens 	if (!MACHINE_IS_VM)
81ab14de6cSHeiko Carstens 		return;
82ab14de6cSHeiko Carstens 
83ab14de6cSHeiko Carstens 	/* Convert COMMAND_LINE to upper case */
84a0443fbbSHendrik Brueckner 	for (i = 0; i < strlen(boot_command_line); i++)
85a0443fbbSHendrik Brueckner 		upper_command_line[i] = toupper(boot_command_line[i]);
86ab14de6cSHeiko Carstens 
87ab14de6cSHeiko Carstens 	savesys_ptr = strstr(upper_command_line, "SAVESYS=");
88ab14de6cSHeiko Carstens 
89ab14de6cSHeiko Carstens 	if (!savesys_ptr)
90ab14de6cSHeiko Carstens 		return;
91ab14de6cSHeiko Carstens 
92ab14de6cSHeiko Carstens 	savesys_ptr += 8;    /* Point to the beginning of the NSS name */
93ab14de6cSHeiko Carstens 	for (i = 0; i < NSS_NAME_SIZE; i++) {
94ab14de6cSHeiko Carstens 		if (savesys_ptr[i] == ' ' || savesys_ptr[i] == '\0')
95ab14de6cSHeiko Carstens 			break;
96ab14de6cSHeiko Carstens 		kernel_nss_name[i] = savesys_ptr[i];
97ab14de6cSHeiko Carstens 	}
98ab14de6cSHeiko Carstens 
99ab14de6cSHeiko Carstens 	stext_pfn = PFN_DOWN(__pa(&_stext));
100ab14de6cSHeiko Carstens 	eshared_pfn = PFN_DOWN(__pa(&_eshared));
101ab14de6cSHeiko Carstens 	end_pfn = PFN_UP(__pa(&_end));
102ab14de6cSHeiko Carstens 	min_size = end_pfn << 2;
103ab14de6cSHeiko Carstens 
104ab14de6cSHeiko Carstens 	sprintf(defsys_cmd, "DEFSYS %s 00000-%.5X EW %.5X-%.5X SR %.5X-%.5X",
105ab14de6cSHeiko Carstens 		kernel_nss_name, stext_pfn - 1, stext_pfn, eshared_pfn - 1,
106ab14de6cSHeiko Carstens 		eshared_pfn, end_pfn);
107ab14de6cSHeiko Carstens 
108ab14de6cSHeiko Carstens #ifdef CONFIG_BLK_DEV_INITRD
109ab14de6cSHeiko Carstens 	if (INITRD_START && INITRD_SIZE) {
110ab14de6cSHeiko Carstens 		sinitrd_pfn = PFN_DOWN(__pa(INITRD_START));
111ab14de6cSHeiko Carstens 		einitrd_pfn = PFN_UP(__pa(INITRD_START + INITRD_SIZE));
112ab14de6cSHeiko Carstens 		min_size = einitrd_pfn << 2;
113ab14de6cSHeiko Carstens 		sprintf(defsys_cmd, "%s EW %.5X-%.5X", defsys_cmd,
114ab14de6cSHeiko Carstens 		sinitrd_pfn, einitrd_pfn);
115ab14de6cSHeiko Carstens 	}
116ab14de6cSHeiko Carstens #endif
117ab14de6cSHeiko Carstens 
118a0443fbbSHendrik Brueckner 	sprintf(defsys_cmd, "%s EW MINSIZE=%.7iK PARMREGS=0-13",
119a0443fbbSHendrik Brueckner 		defsys_cmd, min_size);
120ab14de6cSHeiko Carstens 	sprintf(savesys_cmd, "SAVESYS %s \n IPL %s",
121ab14de6cSHeiko Carstens 		kernel_nss_name, kernel_nss_name);
122ab14de6cSHeiko Carstens 
123ab14de6cSHeiko Carstens 	__cpcmd(defsys_cmd, NULL, 0, &response);
124ab14de6cSHeiko Carstens 
125583b33bcSHongjie Yang 	if (response != 0) {
126583b33bcSHongjie Yang 		kernel_nss_name[0] = '\0';
127ab14de6cSHeiko Carstens 		return;
128583b33bcSHongjie Yang 	}
129ab14de6cSHeiko Carstens 
130a0443fbbSHendrik Brueckner 	len = strlen(savesys_cmd);
131a0443fbbSHendrik Brueckner 	ASCEBC(savesys_cmd, len);
132a0443fbbSHendrik Brueckner 	response = savesys_ipl_nss(savesys_cmd, len);
133ab14de6cSHeiko Carstens 
134a0443fbbSHendrik Brueckner 	/* On success: response is equal to the command size,
135a0443fbbSHendrik Brueckner 	 *	       max SAVESYS_CMD_SIZE
136a0443fbbSHendrik Brueckner 	 * On error: response contains the numeric portion of cp error message.
137a0443fbbSHendrik Brueckner 	 *	     for SAVESYS it will be >= 263
138a0443fbbSHendrik Brueckner 	 */
139a0443fbbSHendrik Brueckner 	if (response > SAVESYS_CMD_SIZE) {
140583b33bcSHongjie Yang 		kernel_nss_name[0] = '\0';
141ab14de6cSHeiko Carstens 		return;
142583b33bcSHongjie Yang 	}
143ab14de6cSHeiko Carstens 
144a0443fbbSHendrik Brueckner 	/* re-setup boot command line with new ipl vm parms */
145a0443fbbSHendrik Brueckner 	ipl_update_parameters();
146a0443fbbSHendrik Brueckner 	setup_boot_command_line();
147a0443fbbSHendrik Brueckner 
148ab14de6cSHeiko Carstens 	ipl_flags = IPL_NSS_VALID;
149ab14de6cSHeiko Carstens }
150ab14de6cSHeiko Carstens 
151ab14de6cSHeiko Carstens #else /* CONFIG_SHARED_KERNEL */
152ab14de6cSHeiko Carstens 
153ab14de6cSHeiko Carstens static inline void create_kernel_nss(void) { }
154ab14de6cSHeiko Carstens 
155ab14de6cSHeiko Carstens #endif /* CONFIG_SHARED_KERNEL */
156ab14de6cSHeiko Carstens 
157ab14de6cSHeiko Carstens /*
158ab14de6cSHeiko Carstens  * Clear bss memory
159ab14de6cSHeiko Carstens  */
160ab14de6cSHeiko Carstens static noinline __init void clear_bss_section(void)
161ab14de6cSHeiko Carstens {
162229d9c6dSHeiko Carstens 	memset(__bss_start, 0, __bss_stop - __bss_start);
163ab14de6cSHeiko Carstens }
164ab14de6cSHeiko Carstens 
165ab14de6cSHeiko Carstens /*
166ab14de6cSHeiko Carstens  * Initialize storage key for kernel pages
167ab14de6cSHeiko Carstens  */
168ab14de6cSHeiko Carstens static noinline __init void init_kernel_storage_key(void)
169ab14de6cSHeiko Carstens {
170ab14de6cSHeiko Carstens 	unsigned long end_pfn, init_pfn;
171ab14de6cSHeiko Carstens 
172ab14de6cSHeiko Carstens 	end_pfn = PFN_UP(__pa(&_end));
173ab14de6cSHeiko Carstens 
174ab14de6cSHeiko Carstens 	for (init_pfn = 0 ; init_pfn < end_pfn; init_pfn++)
175ab14de6cSHeiko Carstens 		page_set_storage_key(init_pfn << PAGE_SHIFT, PAGE_DEFAULT_KEY);
176ab14de6cSHeiko Carstens }
177ab14de6cSHeiko Carstens 
178*92e6ecf3SChristian Borntraeger static __initdata struct sysinfo_3_2_2 vmms __aligned(PAGE_SIZE);
179*92e6ecf3SChristian Borntraeger 
180ab14de6cSHeiko Carstens static noinline __init void detect_machine_type(void)
181ab14de6cSHeiko Carstens {
182*92e6ecf3SChristian Borntraeger 	/* No VM information? Looks like LPAR */
183*92e6ecf3SChristian Borntraeger 	if (stsi(&vmms, 3, 2, 2) == -ENOSYS)
184*92e6ecf3SChristian Borntraeger 		return;
185*92e6ecf3SChristian Borntraeger 	if (!vmms.count)
186*92e6ecf3SChristian Borntraeger 		return;
187ab14de6cSHeiko Carstens 
188*92e6ecf3SChristian Borntraeger 	/* Running under KVM? If not we assume z/VM */
189*92e6ecf3SChristian Borntraeger 	if (!memcmp(vmms.vm[0].cpi, "\xd2\xe5\xd4", 3))
1902e5061e4SHeiko Carstens 		machine_flags |= MACHINE_FLAG_KVM;
191*92e6ecf3SChristian Borntraeger 	else
192*92e6ecf3SChristian Borntraeger 		machine_flags |= MACHINE_FLAG_VM;
193ab14de6cSHeiko Carstens }
194ab14de6cSHeiko Carstens 
195ab14de6cSHeiko Carstens static __init void early_pgm_check_handler(void)
196ab14de6cSHeiko Carstens {
197ab14de6cSHeiko Carstens 	unsigned long addr;
198ab14de6cSHeiko Carstens 	const struct exception_table_entry *fixup;
199ab14de6cSHeiko Carstens 
200ab14de6cSHeiko Carstens 	addr = S390_lowcore.program_old_psw.addr;
201ab14de6cSHeiko Carstens 	fixup = search_exception_tables(addr & PSW_ADDR_INSN);
202ab14de6cSHeiko Carstens 	if (!fixup)
203ab14de6cSHeiko Carstens 		disabled_wait(0);
204ab14de6cSHeiko Carstens 	S390_lowcore.program_old_psw.addr = fixup->fixup | PSW_ADDR_AMODE;
205ab14de6cSHeiko Carstens }
206ab14de6cSHeiko Carstens 
207ab14de6cSHeiko Carstens static noinline __init void setup_lowcore_early(void)
208ab14de6cSHeiko Carstens {
209ab14de6cSHeiko Carstens 	psw_t psw;
210ab14de6cSHeiko Carstens 
211ab14de6cSHeiko Carstens 	psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY;
212ab14de6cSHeiko Carstens 	psw.addr = PSW_ADDR_AMODE | (unsigned long) s390_base_ext_handler;
213ab14de6cSHeiko Carstens 	S390_lowcore.external_new_psw = psw;
214ab14de6cSHeiko Carstens 	psw.addr = PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler;
215ab14de6cSHeiko Carstens 	S390_lowcore.program_new_psw = psw;
216ab14de6cSHeiko Carstens 	s390_base_pgm_handler_fn = early_pgm_check_handler;
217ab14de6cSHeiko Carstens }
218ab14de6cSHeiko Carstens 
21953492b1dSGerald Schaefer static noinline __init void setup_hpage(void)
22053492b1dSGerald Schaefer {
22153492b1dSGerald Schaefer #ifndef CONFIG_DEBUG_PAGEALLOC
22253492b1dSGerald Schaefer 	unsigned int facilities;
22353492b1dSGerald Schaefer 
22453492b1dSGerald Schaefer 	facilities = stfl();
22553492b1dSGerald Schaefer 	if (!(facilities & (1UL << 23)) || !(facilities & (1UL << 29)))
22653492b1dSGerald Schaefer 		return;
22753492b1dSGerald Schaefer 	machine_flags |= MACHINE_FLAG_HPAGE;
22853492b1dSGerald Schaefer 	__ctl_set_bit(0, 23);
22953492b1dSGerald Schaefer #endif
23053492b1dSGerald Schaefer }
23153492b1dSGerald Schaefer 
2322e5061e4SHeiko Carstens static __init void detect_mvpg(void)
2332e5061e4SHeiko Carstens {
2342e5061e4SHeiko Carstens #ifndef CONFIG_64BIT
2352e5061e4SHeiko Carstens 	int rc;
2362e5061e4SHeiko Carstens 
2372e5061e4SHeiko Carstens 	asm volatile(
2382e5061e4SHeiko Carstens 		"	la	0,0\n"
2392e5061e4SHeiko Carstens 		"	mvpg	%2,%2\n"
2402e5061e4SHeiko Carstens 		"0:	la	%0,0\n"
2412e5061e4SHeiko Carstens 		"1:\n"
2422e5061e4SHeiko Carstens 		EX_TABLE(0b,1b)
2432e5061e4SHeiko Carstens 		: "=d" (rc) : "0" (-EOPNOTSUPP), "a" (0) : "memory", "cc", "0");
2442e5061e4SHeiko Carstens 	if (!rc)
2452e5061e4SHeiko Carstens 		machine_flags |= MACHINE_FLAG_MVPG;
2462e5061e4SHeiko Carstens #endif
2472e5061e4SHeiko Carstens }
2482e5061e4SHeiko Carstens 
2492e5061e4SHeiko Carstens static __init void detect_ieee(void)
2502e5061e4SHeiko Carstens {
2512e5061e4SHeiko Carstens #ifndef CONFIG_64BIT
2522e5061e4SHeiko Carstens 	int rc, tmp;
2532e5061e4SHeiko Carstens 
2542e5061e4SHeiko Carstens 	asm volatile(
2552e5061e4SHeiko Carstens 		"	efpc	%1,0\n"
2562e5061e4SHeiko Carstens 		"0:	la	%0,0\n"
2572e5061e4SHeiko Carstens 		"1:\n"
2582e5061e4SHeiko Carstens 		EX_TABLE(0b,1b)
2592e5061e4SHeiko Carstens 		: "=d" (rc), "=d" (tmp): "0" (-EOPNOTSUPP) : "cc");
2602e5061e4SHeiko Carstens 	if (!rc)
2612e5061e4SHeiko Carstens 		machine_flags |= MACHINE_FLAG_IEEE;
2622e5061e4SHeiko Carstens #endif
2632e5061e4SHeiko Carstens }
2642e5061e4SHeiko Carstens 
2652e5061e4SHeiko Carstens static __init void detect_csp(void)
2662e5061e4SHeiko Carstens {
2672e5061e4SHeiko Carstens #ifndef CONFIG_64BIT
2682e5061e4SHeiko Carstens 	int rc;
2692e5061e4SHeiko Carstens 
2702e5061e4SHeiko Carstens 	asm volatile(
2712e5061e4SHeiko Carstens 		"	la	0,0\n"
2722e5061e4SHeiko Carstens 		"	la	1,0\n"
2732e5061e4SHeiko Carstens 		"	la	2,4\n"
2742e5061e4SHeiko Carstens 		"	csp	0,2\n"
2752e5061e4SHeiko Carstens 		"0:	la	%0,0\n"
2762e5061e4SHeiko Carstens 		"1:\n"
2772e5061e4SHeiko Carstens 		EX_TABLE(0b,1b)
2782e5061e4SHeiko Carstens 		: "=d" (rc) : "0" (-EOPNOTSUPP) : "cc", "0", "1", "2");
2792e5061e4SHeiko Carstens 	if (!rc)
2802e5061e4SHeiko Carstens 		machine_flags |= MACHINE_FLAG_CSP;
2812e5061e4SHeiko Carstens #endif
2822e5061e4SHeiko Carstens }
2832e5061e4SHeiko Carstens 
2842e5061e4SHeiko Carstens static __init void detect_diag9c(void)
2852e5061e4SHeiko Carstens {
2862e5061e4SHeiko Carstens 	unsigned int cpu_address;
2872e5061e4SHeiko Carstens 	int rc;
2882e5061e4SHeiko Carstens 
2892e5061e4SHeiko Carstens 	cpu_address = stap();
2902e5061e4SHeiko Carstens 	asm volatile(
2912e5061e4SHeiko Carstens 		"	diag	%2,0,0x9c\n"
2922e5061e4SHeiko Carstens 		"0:	la	%0,0\n"
2932e5061e4SHeiko Carstens 		"1:\n"
2942e5061e4SHeiko Carstens 		EX_TABLE(0b,1b)
2952e5061e4SHeiko Carstens 		: "=d" (rc) : "0" (-EOPNOTSUPP), "d" (cpu_address) : "cc");
2962e5061e4SHeiko Carstens 	if (!rc)
2972e5061e4SHeiko Carstens 		machine_flags |= MACHINE_FLAG_DIAG9C;
2982e5061e4SHeiko Carstens }
2992e5061e4SHeiko Carstens 
3002e5061e4SHeiko Carstens static __init void detect_diag44(void)
3012e5061e4SHeiko Carstens {
3022e5061e4SHeiko Carstens #ifdef CONFIG_64BIT
3032e5061e4SHeiko Carstens 	int rc;
3042e5061e4SHeiko Carstens 
3052e5061e4SHeiko Carstens 	asm volatile(
3062e5061e4SHeiko Carstens 		"	diag	0,0,0x44\n"
3072e5061e4SHeiko Carstens 		"0:	la	%0,0\n"
3082e5061e4SHeiko Carstens 		"1:\n"
3092e5061e4SHeiko Carstens 		EX_TABLE(0b,1b)
3102e5061e4SHeiko Carstens 		: "=d" (rc) : "0" (-EOPNOTSUPP) : "cc");
3112e5061e4SHeiko Carstens 	if (!rc)
3122e5061e4SHeiko Carstens 		machine_flags |= MACHINE_FLAG_DIAG44;
3132e5061e4SHeiko Carstens #endif
3142e5061e4SHeiko Carstens }
3152e5061e4SHeiko Carstens 
3162e5061e4SHeiko Carstens static __init void detect_machine_facilities(void)
3172e5061e4SHeiko Carstens {
3182e5061e4SHeiko Carstens #ifdef CONFIG_64BIT
3192e5061e4SHeiko Carstens 	unsigned int facilities;
3202e5061e4SHeiko Carstens 
3212e5061e4SHeiko Carstens 	facilities = stfl();
3222e5061e4SHeiko Carstens 	if (facilities & (1 << 28))
3232e5061e4SHeiko Carstens 		machine_flags |= MACHINE_FLAG_IDTE;
32453492b1dSGerald Schaefer 	if (facilities & (1 << 23))
32553492b1dSGerald Schaefer 		machine_flags |= MACHINE_FLAG_PFMF;
3262e5061e4SHeiko Carstens 	if (facilities & (1 << 4))
3272e5061e4SHeiko Carstens 		machine_flags |= MACHINE_FLAG_MVCOS;
3282e5061e4SHeiko Carstens #endif
3292e5061e4SHeiko Carstens }
3302e5061e4SHeiko Carstens 
331761cdf6aSHeiko Carstens static __init void rescue_initrd(void)
332761cdf6aSHeiko Carstens {
333761cdf6aSHeiko Carstens #ifdef CONFIG_BLK_DEV_INITRD
334761cdf6aSHeiko Carstens 	/*
335761cdf6aSHeiko Carstens 	 * Move the initrd right behind the bss section in case it starts
336761cdf6aSHeiko Carstens 	 * within the bss section. So we don't overwrite it when the bss
337761cdf6aSHeiko Carstens 	 * section gets cleared.
338761cdf6aSHeiko Carstens 	 */
339761cdf6aSHeiko Carstens 	if (!INITRD_START || !INITRD_SIZE)
340761cdf6aSHeiko Carstens 		return;
341761cdf6aSHeiko Carstens 	if (INITRD_START >= (unsigned long) __bss_stop)
342761cdf6aSHeiko Carstens 		return;
343761cdf6aSHeiko Carstens 	memmove(__bss_stop, (void *) INITRD_START, INITRD_SIZE);
344761cdf6aSHeiko Carstens 	INITRD_START = (unsigned long) __bss_stop;
345761cdf6aSHeiko Carstens #endif
346761cdf6aSHeiko Carstens }
347761cdf6aSHeiko Carstens 
348a0443fbbSHendrik Brueckner /* Set up boot command line */
349a0443fbbSHendrik Brueckner static void __init setup_boot_command_line(void)
350a0443fbbSHendrik Brueckner {
351a0443fbbSHendrik Brueckner 	char *parm = NULL;
352a0443fbbSHendrik Brueckner 
353a0443fbbSHendrik Brueckner 	/* copy arch command line */
354a0443fbbSHendrik Brueckner 	strlcpy(boot_command_line, COMMAND_LINE, ARCH_COMMAND_LINE_SIZE);
355a0443fbbSHendrik Brueckner 	boot_command_line[ARCH_COMMAND_LINE_SIZE - 1] = 0;
356a0443fbbSHendrik Brueckner 
357a0443fbbSHendrik Brueckner 	/* append IPL PARM data to the boot command line */
358a0443fbbSHendrik Brueckner 	if (MACHINE_IS_VM) {
359a0443fbbSHendrik Brueckner 		parm = boot_command_line + strlen(boot_command_line);
360a0443fbbSHendrik Brueckner 		*parm++ = ' ';
361a0443fbbSHendrik Brueckner 		get_ipl_vmparm(parm);
362a0443fbbSHendrik Brueckner 		if (parm[0] == '=')
363a0443fbbSHendrik Brueckner 			memmove(boot_command_line, parm + 1, strlen(parm));
364a0443fbbSHendrik Brueckner 	}
365a0443fbbSHendrik Brueckner }
366a0443fbbSHendrik Brueckner 
367a0443fbbSHendrik Brueckner 
368ab14de6cSHeiko Carstens /*
369ab14de6cSHeiko Carstens  * Save ipl parameters, clear bss memory, initialize storage keys
370ab14de6cSHeiko Carstens  * and create a kernel NSS at startup if the SAVESYS= parm is defined
371ab14de6cSHeiko Carstens  */
372ab14de6cSHeiko Carstens void __init startup_init(void)
373ab14de6cSHeiko Carstens {
374ab14de6cSHeiko Carstens 	ipl_save_parameters();
375761cdf6aSHeiko Carstens 	rescue_initrd();
376ab14de6cSHeiko Carstens 	clear_bss_section();
377ab14de6cSHeiko Carstens 	init_kernel_storage_key();
378ab14de6cSHeiko Carstens 	lockdep_init();
379ab14de6cSHeiko Carstens 	lockdep_off();
380ab14de6cSHeiko Carstens 	sort_main_extable();
381ab14de6cSHeiko Carstens 	setup_lowcore_early();
382a0443fbbSHendrik Brueckner 	detect_machine_type();
383a0443fbbSHendrik Brueckner 	ipl_update_parameters();
384a0443fbbSHendrik Brueckner 	setup_boot_command_line();
385a0443fbbSHendrik Brueckner 	create_kernel_nss();
3862e5061e4SHeiko Carstens 	detect_mvpg();
3872e5061e4SHeiko Carstens 	detect_ieee();
3882e5061e4SHeiko Carstens 	detect_csp();
3892e5061e4SHeiko Carstens 	detect_diag9c();
3902e5061e4SHeiko Carstens 	detect_diag44();
3912e5061e4SHeiko Carstens 	detect_machine_facilities();
39253492b1dSGerald Schaefer 	setup_hpage();
39383119ad4SHeiko Carstens 	sclp_facilities_detect();
39423d17421SHeiko Carstens 	detect_memory_layout(memory_chunk);
395ab14de6cSHeiko Carstens 	lockdep_on();
396ab14de6cSHeiko Carstens }
397