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 9ab14de6cSHeiko Carstens #include <linux/init.h> 10ab14de6cSHeiko Carstens #include <linux/errno.h> 11ab14de6cSHeiko Carstens #include <linux/string.h> 12ab14de6cSHeiko Carstens #include <linux/ctype.h> 13ab14de6cSHeiko Carstens #include <linux/lockdep.h> 14ab14de6cSHeiko Carstens #include <linux/module.h> 15ab14de6cSHeiko Carstens #include <linux/pfn.h> 16ab14de6cSHeiko Carstens #include <linux/uaccess.h> 1746b05d26SMichael Holzheu #include <asm/ipl.h> 18ab14de6cSHeiko Carstens #include <asm/lowcore.h> 19ab14de6cSHeiko Carstens #include <asm/processor.h> 20ab14de6cSHeiko Carstens #include <asm/sections.h> 21ab14de6cSHeiko Carstens #include <asm/setup.h> 22ab14de6cSHeiko Carstens #include <asm/cpcmd.h> 23ab14de6cSHeiko Carstens #include <asm/sclp.h> 24a806170eSHeiko Carstens #include "entry.h" 25ab14de6cSHeiko Carstens 26ab14de6cSHeiko Carstens /* 27ab14de6cSHeiko Carstens * Create a Kernel NSS if the SAVESYS= parameter is defined 28ab14de6cSHeiko Carstens */ 29ab14de6cSHeiko Carstens #define DEFSYS_CMD_SIZE 96 30ab14de6cSHeiko Carstens #define SAVESYS_CMD_SIZE 32 31ab14de6cSHeiko Carstens 32ab14de6cSHeiko Carstens char kernel_nss_name[NSS_NAME_SIZE + 1]; 33ab14de6cSHeiko Carstens 34ab14de6cSHeiko Carstens #ifdef CONFIG_SHARED_KERNEL 35ab14de6cSHeiko Carstens static noinline __init void create_kernel_nss(void) 36ab14de6cSHeiko Carstens { 37ab14de6cSHeiko Carstens unsigned int i, stext_pfn, eshared_pfn, end_pfn, min_size; 38ab14de6cSHeiko Carstens #ifdef CONFIG_BLK_DEV_INITRD 39ab14de6cSHeiko Carstens unsigned int sinitrd_pfn, einitrd_pfn; 40ab14de6cSHeiko Carstens #endif 41ab14de6cSHeiko Carstens int response; 42ab14de6cSHeiko Carstens char *savesys_ptr; 43ab14de6cSHeiko Carstens char upper_command_line[COMMAND_LINE_SIZE]; 44ab14de6cSHeiko Carstens char defsys_cmd[DEFSYS_CMD_SIZE]; 45ab14de6cSHeiko Carstens char savesys_cmd[SAVESYS_CMD_SIZE]; 46ab14de6cSHeiko Carstens 47ab14de6cSHeiko Carstens /* Do nothing if we are not running under VM */ 48ab14de6cSHeiko Carstens if (!MACHINE_IS_VM) 49ab14de6cSHeiko Carstens return; 50ab14de6cSHeiko Carstens 51ab14de6cSHeiko Carstens /* Convert COMMAND_LINE to upper case */ 52ab14de6cSHeiko Carstens for (i = 0; i < strlen(COMMAND_LINE); i++) 53ab14de6cSHeiko Carstens upper_command_line[i] = toupper(COMMAND_LINE[i]); 54ab14de6cSHeiko Carstens 55ab14de6cSHeiko Carstens savesys_ptr = strstr(upper_command_line, "SAVESYS="); 56ab14de6cSHeiko Carstens 57ab14de6cSHeiko Carstens if (!savesys_ptr) 58ab14de6cSHeiko Carstens return; 59ab14de6cSHeiko Carstens 60ab14de6cSHeiko Carstens savesys_ptr += 8; /* Point to the beginning of the NSS name */ 61ab14de6cSHeiko Carstens for (i = 0; i < NSS_NAME_SIZE; i++) { 62ab14de6cSHeiko Carstens if (savesys_ptr[i] == ' ' || savesys_ptr[i] == '\0') 63ab14de6cSHeiko Carstens break; 64ab14de6cSHeiko Carstens kernel_nss_name[i] = savesys_ptr[i]; 65ab14de6cSHeiko Carstens } 66ab14de6cSHeiko Carstens 67ab14de6cSHeiko Carstens stext_pfn = PFN_DOWN(__pa(&_stext)); 68ab14de6cSHeiko Carstens eshared_pfn = PFN_DOWN(__pa(&_eshared)); 69ab14de6cSHeiko Carstens end_pfn = PFN_UP(__pa(&_end)); 70ab14de6cSHeiko Carstens min_size = end_pfn << 2; 71ab14de6cSHeiko Carstens 72ab14de6cSHeiko Carstens sprintf(defsys_cmd, "DEFSYS %s 00000-%.5X EW %.5X-%.5X SR %.5X-%.5X", 73ab14de6cSHeiko Carstens kernel_nss_name, stext_pfn - 1, stext_pfn, eshared_pfn - 1, 74ab14de6cSHeiko Carstens eshared_pfn, end_pfn); 75ab14de6cSHeiko Carstens 76ab14de6cSHeiko Carstens #ifdef CONFIG_BLK_DEV_INITRD 77ab14de6cSHeiko Carstens if (INITRD_START && INITRD_SIZE) { 78ab14de6cSHeiko Carstens sinitrd_pfn = PFN_DOWN(__pa(INITRD_START)); 79ab14de6cSHeiko Carstens einitrd_pfn = PFN_UP(__pa(INITRD_START + INITRD_SIZE)); 80ab14de6cSHeiko Carstens min_size = einitrd_pfn << 2; 81ab14de6cSHeiko Carstens sprintf(defsys_cmd, "%s EW %.5X-%.5X", defsys_cmd, 82ab14de6cSHeiko Carstens sinitrd_pfn, einitrd_pfn); 83ab14de6cSHeiko Carstens } 84ab14de6cSHeiko Carstens #endif 85ab14de6cSHeiko Carstens 86ab14de6cSHeiko Carstens sprintf(defsys_cmd, "%s EW MINSIZE=%.7iK", defsys_cmd, min_size); 87ab14de6cSHeiko Carstens sprintf(savesys_cmd, "SAVESYS %s \n IPL %s", 88ab14de6cSHeiko Carstens kernel_nss_name, kernel_nss_name); 89ab14de6cSHeiko Carstens 90ab14de6cSHeiko Carstens __cpcmd(defsys_cmd, NULL, 0, &response); 91ab14de6cSHeiko Carstens 92583b33bcSHongjie Yang if (response != 0) { 93583b33bcSHongjie Yang kernel_nss_name[0] = '\0'; 94ab14de6cSHeiko Carstens return; 95583b33bcSHongjie Yang } 96ab14de6cSHeiko Carstens 97ab14de6cSHeiko Carstens __cpcmd(savesys_cmd, NULL, 0, &response); 98ab14de6cSHeiko Carstens 99583b33bcSHongjie Yang if (response != strlen(savesys_cmd)) { 100583b33bcSHongjie Yang kernel_nss_name[0] = '\0'; 101ab14de6cSHeiko Carstens return; 102583b33bcSHongjie Yang } 103ab14de6cSHeiko Carstens 104ab14de6cSHeiko Carstens ipl_flags = IPL_NSS_VALID; 105ab14de6cSHeiko Carstens } 106ab14de6cSHeiko Carstens 107ab14de6cSHeiko Carstens #else /* CONFIG_SHARED_KERNEL */ 108ab14de6cSHeiko Carstens 109ab14de6cSHeiko Carstens static inline void create_kernel_nss(void) { } 110ab14de6cSHeiko Carstens 111ab14de6cSHeiko Carstens #endif /* CONFIG_SHARED_KERNEL */ 112ab14de6cSHeiko Carstens 113ab14de6cSHeiko Carstens /* 114ab14de6cSHeiko Carstens * Clear bss memory 115ab14de6cSHeiko Carstens */ 116ab14de6cSHeiko Carstens static noinline __init void clear_bss_section(void) 117ab14de6cSHeiko Carstens { 118229d9c6dSHeiko Carstens memset(__bss_start, 0, __bss_stop - __bss_start); 119ab14de6cSHeiko Carstens } 120ab14de6cSHeiko Carstens 121ab14de6cSHeiko Carstens /* 122ab14de6cSHeiko Carstens * Initialize storage key for kernel pages 123ab14de6cSHeiko Carstens */ 124ab14de6cSHeiko Carstens static noinline __init void init_kernel_storage_key(void) 125ab14de6cSHeiko Carstens { 126ab14de6cSHeiko Carstens unsigned long end_pfn, init_pfn; 127ab14de6cSHeiko Carstens 128ab14de6cSHeiko Carstens end_pfn = PFN_UP(__pa(&_end)); 129ab14de6cSHeiko Carstens 130ab14de6cSHeiko Carstens for (init_pfn = 0 ; init_pfn < end_pfn; init_pfn++) 131ab14de6cSHeiko Carstens page_set_storage_key(init_pfn << PAGE_SHIFT, PAGE_DEFAULT_KEY); 132ab14de6cSHeiko Carstens } 133ab14de6cSHeiko Carstens 134ab14de6cSHeiko Carstens static noinline __init void detect_machine_type(void) 135ab14de6cSHeiko Carstens { 136ab14de6cSHeiko Carstens struct cpuinfo_S390 *cpuinfo = &S390_lowcore.cpu_data; 137ab14de6cSHeiko Carstens 13872960a02SMichael Holzheu get_cpu_id(&S390_lowcore.cpu_data.cpu_id); 139ab14de6cSHeiko Carstens 140ab14de6cSHeiko Carstens /* Running under z/VM ? */ 141ab14de6cSHeiko Carstens if (cpuinfo->cpu_id.version == 0xff) 142*2e5061e4SHeiko Carstens machine_flags |= MACHINE_FLAG_VM; 143ab14de6cSHeiko Carstens 144ab14de6cSHeiko Carstens /* Running on a P/390 ? */ 145ab14de6cSHeiko Carstens if (cpuinfo->cpu_id.machine == 0x7490) 146*2e5061e4SHeiko Carstens machine_flags |= MACHINE_FLAG_P390; 147fa587743SCarsten Otte 148fa587743SCarsten Otte /* Running under KVM ? */ 149fa587743SCarsten Otte if (cpuinfo->cpu_id.version == 0xfe) 150*2e5061e4SHeiko Carstens machine_flags |= MACHINE_FLAG_KVM; 151ab14de6cSHeiko Carstens } 152ab14de6cSHeiko Carstens 153257c6e1cSHeiko Carstens #ifdef CONFIG_64BIT 154ab14de6cSHeiko Carstens static noinline __init int memory_fast_detect(void) 155ab14de6cSHeiko Carstens { 156ab14de6cSHeiko Carstens unsigned long val0 = 0; 157ab14de6cSHeiko Carstens unsigned long val1 = 0xc; 158ab14de6cSHeiko Carstens int ret = -ENOSYS; 159ab14de6cSHeiko Carstens 160ab14de6cSHeiko Carstens if (ipl_flags & IPL_NSS_VALID) 161ab14de6cSHeiko Carstens return -ENOSYS; 162ab14de6cSHeiko Carstens 163ab14de6cSHeiko Carstens asm volatile( 164ab14de6cSHeiko Carstens " diag %1,%2,0x260\n" 165ab14de6cSHeiko Carstens "0: lhi %0,0\n" 166ab14de6cSHeiko Carstens "1:\n" 167ab14de6cSHeiko Carstens EX_TABLE(0b,1b) 168ab14de6cSHeiko Carstens : "+d" (ret), "+d" (val0), "+d" (val1) : : "cc"); 169ab14de6cSHeiko Carstens 170ab14de6cSHeiko Carstens if (ret || val0 != val1) 171ab14de6cSHeiko Carstens return -ENOSYS; 172ab14de6cSHeiko Carstens 173257c6e1cSHeiko Carstens memory_chunk[0].size = val0 + 1; 174ab14de6cSHeiko Carstens return 0; 175ab14de6cSHeiko Carstens } 176257c6e1cSHeiko Carstens #else 177257c6e1cSHeiko Carstens static inline int memory_fast_detect(void) 178257c6e1cSHeiko Carstens { 179257c6e1cSHeiko Carstens return -ENOSYS; 180257c6e1cSHeiko Carstens } 181257c6e1cSHeiko Carstens #endif 182ab14de6cSHeiko Carstens 183ab14de6cSHeiko Carstens static inline __init unsigned long __tprot(unsigned long addr) 184ab14de6cSHeiko Carstens { 185ab14de6cSHeiko Carstens int cc = -1; 186ab14de6cSHeiko Carstens 187ab14de6cSHeiko Carstens asm volatile( 188ab14de6cSHeiko Carstens " tprot 0(%1),0\n" 189ab14de6cSHeiko Carstens "0: ipm %0\n" 190ab14de6cSHeiko Carstens " srl %0,28\n" 191ab14de6cSHeiko Carstens "1:\n" 192ab14de6cSHeiko Carstens EX_TABLE(0b,1b) 193ab14de6cSHeiko Carstens : "+d" (cc) : "a" (addr) : "cc"); 194ab14de6cSHeiko Carstens return (unsigned long)cc; 195ab14de6cSHeiko Carstens } 196ab14de6cSHeiko Carstens 197ab14de6cSHeiko Carstens /* Checking memory in 128KB increments. */ 198ab14de6cSHeiko Carstens #define CHUNK_INCR (1UL << 17) 19905dd2530SHeiko Carstens #define ADDR2G (1UL << 31) 200ab14de6cSHeiko Carstens 201ab14de6cSHeiko Carstens static noinline __init void find_memory_chunks(unsigned long memsize) 202ab14de6cSHeiko Carstens { 203ab14de6cSHeiko Carstens unsigned long addr = 0, old_addr = 0; 204ab14de6cSHeiko Carstens unsigned long old_cc = CHUNK_READ_WRITE; 205ab14de6cSHeiko Carstens unsigned long cc; 206ab14de6cSHeiko Carstens int chunk = 0; 207ab14de6cSHeiko Carstens 208ab14de6cSHeiko Carstens while (chunk < MEMORY_CHUNKS) { 209ab14de6cSHeiko Carstens cc = __tprot(addr); 210ab14de6cSHeiko Carstens while (cc == old_cc) { 211ab14de6cSHeiko Carstens addr += CHUNK_INCR; 212a2cb0737SHeiko Carstens if (memsize && addr >= memsize) 2130b8da654SHeiko Carstens break; 214ab14de6cSHeiko Carstens #ifndef CONFIG_64BIT 215ab14de6cSHeiko Carstens if (addr == ADDR2G) 216ab14de6cSHeiko Carstens break; 217ab14de6cSHeiko Carstens #endif 2180b8da654SHeiko Carstens cc = __tprot(addr); 219ab14de6cSHeiko Carstens } 220ab14de6cSHeiko Carstens 221ab14de6cSHeiko Carstens if (old_addr != addr && 222ab14de6cSHeiko Carstens (old_cc == CHUNK_READ_WRITE || old_cc == CHUNK_READ_ONLY)) { 223ab14de6cSHeiko Carstens memory_chunk[chunk].addr = old_addr; 224ab14de6cSHeiko Carstens memory_chunk[chunk].size = addr - old_addr; 225ab14de6cSHeiko Carstens memory_chunk[chunk].type = old_cc; 226ab14de6cSHeiko Carstens chunk++; 227ab14de6cSHeiko Carstens } 228ab14de6cSHeiko Carstens 229ab14de6cSHeiko Carstens old_addr = addr; 230ab14de6cSHeiko Carstens old_cc = cc; 231ab14de6cSHeiko Carstens 232ab14de6cSHeiko Carstens #ifndef CONFIG_64BIT 233ab14de6cSHeiko Carstens if (addr == ADDR2G) 234ab14de6cSHeiko Carstens break; 235ab14de6cSHeiko Carstens #endif 236ab14de6cSHeiko Carstens /* 23729c380f5SHeiko Carstens * Finish memory detection at the first hole 23829c380f5SHeiko Carstens * if storage size is unknown. 239ab14de6cSHeiko Carstens */ 24029c380f5SHeiko Carstens if (cc == -1UL && !memsize) 241ab14de6cSHeiko Carstens break; 242ab14de6cSHeiko Carstens if (memsize && addr >= memsize) 243ab14de6cSHeiko Carstens break; 244ab14de6cSHeiko Carstens } 245ab14de6cSHeiko Carstens } 246ab14de6cSHeiko Carstens 247ab14de6cSHeiko Carstens static __init void early_pgm_check_handler(void) 248ab14de6cSHeiko Carstens { 249ab14de6cSHeiko Carstens unsigned long addr; 250ab14de6cSHeiko Carstens const struct exception_table_entry *fixup; 251ab14de6cSHeiko Carstens 252ab14de6cSHeiko Carstens addr = S390_lowcore.program_old_psw.addr; 253ab14de6cSHeiko Carstens fixup = search_exception_tables(addr & PSW_ADDR_INSN); 254ab14de6cSHeiko Carstens if (!fixup) 255ab14de6cSHeiko Carstens disabled_wait(0); 256ab14de6cSHeiko Carstens S390_lowcore.program_old_psw.addr = fixup->fixup | PSW_ADDR_AMODE; 257ab14de6cSHeiko Carstens } 258ab14de6cSHeiko Carstens 259ab14de6cSHeiko Carstens static noinline __init void setup_lowcore_early(void) 260ab14de6cSHeiko Carstens { 261ab14de6cSHeiko Carstens psw_t psw; 262ab14de6cSHeiko Carstens 263ab14de6cSHeiko Carstens psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY; 264ab14de6cSHeiko Carstens psw.addr = PSW_ADDR_AMODE | (unsigned long) s390_base_ext_handler; 265ab14de6cSHeiko Carstens S390_lowcore.external_new_psw = psw; 266ab14de6cSHeiko Carstens psw.addr = PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler; 267ab14de6cSHeiko Carstens S390_lowcore.program_new_psw = psw; 268ab14de6cSHeiko Carstens s390_base_pgm_handler_fn = early_pgm_check_handler; 269ab14de6cSHeiko Carstens } 270ab14de6cSHeiko Carstens 271*2e5061e4SHeiko Carstens static __init void detect_mvpg(void) 272*2e5061e4SHeiko Carstens { 273*2e5061e4SHeiko Carstens #ifndef CONFIG_64BIT 274*2e5061e4SHeiko Carstens int rc; 275*2e5061e4SHeiko Carstens 276*2e5061e4SHeiko Carstens asm volatile( 277*2e5061e4SHeiko Carstens " la 0,0\n" 278*2e5061e4SHeiko Carstens " mvpg %2,%2\n" 279*2e5061e4SHeiko Carstens "0: la %0,0\n" 280*2e5061e4SHeiko Carstens "1:\n" 281*2e5061e4SHeiko Carstens EX_TABLE(0b,1b) 282*2e5061e4SHeiko Carstens : "=d" (rc) : "0" (-EOPNOTSUPP), "a" (0) : "memory", "cc", "0"); 283*2e5061e4SHeiko Carstens if (!rc) 284*2e5061e4SHeiko Carstens machine_flags |= MACHINE_FLAG_MVPG; 285*2e5061e4SHeiko Carstens #endif 286*2e5061e4SHeiko Carstens } 287*2e5061e4SHeiko Carstens 288*2e5061e4SHeiko Carstens static __init void detect_ieee(void) 289*2e5061e4SHeiko Carstens { 290*2e5061e4SHeiko Carstens #ifndef CONFIG_64BIT 291*2e5061e4SHeiko Carstens int rc, tmp; 292*2e5061e4SHeiko Carstens 293*2e5061e4SHeiko Carstens asm volatile( 294*2e5061e4SHeiko Carstens " efpc %1,0\n" 295*2e5061e4SHeiko Carstens "0: la %0,0\n" 296*2e5061e4SHeiko Carstens "1:\n" 297*2e5061e4SHeiko Carstens EX_TABLE(0b,1b) 298*2e5061e4SHeiko Carstens : "=d" (rc), "=d" (tmp): "0" (-EOPNOTSUPP) : "cc"); 299*2e5061e4SHeiko Carstens if (!rc) 300*2e5061e4SHeiko Carstens machine_flags |= MACHINE_FLAG_IEEE; 301*2e5061e4SHeiko Carstens #endif 302*2e5061e4SHeiko Carstens } 303*2e5061e4SHeiko Carstens 304*2e5061e4SHeiko Carstens static __init void detect_csp(void) 305*2e5061e4SHeiko Carstens { 306*2e5061e4SHeiko Carstens #ifndef CONFIG_64BIT 307*2e5061e4SHeiko Carstens int rc; 308*2e5061e4SHeiko Carstens 309*2e5061e4SHeiko Carstens asm volatile( 310*2e5061e4SHeiko Carstens " la 0,0\n" 311*2e5061e4SHeiko Carstens " la 1,0\n" 312*2e5061e4SHeiko Carstens " la 2,4\n" 313*2e5061e4SHeiko Carstens " csp 0,2\n" 314*2e5061e4SHeiko Carstens "0: la %0,0\n" 315*2e5061e4SHeiko Carstens "1:\n" 316*2e5061e4SHeiko Carstens EX_TABLE(0b,1b) 317*2e5061e4SHeiko Carstens : "=d" (rc) : "0" (-EOPNOTSUPP) : "cc", "0", "1", "2"); 318*2e5061e4SHeiko Carstens if (!rc) 319*2e5061e4SHeiko Carstens machine_flags |= MACHINE_FLAG_CSP; 320*2e5061e4SHeiko Carstens #endif 321*2e5061e4SHeiko Carstens } 322*2e5061e4SHeiko Carstens 323*2e5061e4SHeiko Carstens static __init void detect_diag9c(void) 324*2e5061e4SHeiko Carstens { 325*2e5061e4SHeiko Carstens unsigned int cpu_address; 326*2e5061e4SHeiko Carstens int rc; 327*2e5061e4SHeiko Carstens 328*2e5061e4SHeiko Carstens cpu_address = stap(); 329*2e5061e4SHeiko Carstens asm volatile( 330*2e5061e4SHeiko Carstens " diag %2,0,0x9c\n" 331*2e5061e4SHeiko Carstens "0: la %0,0\n" 332*2e5061e4SHeiko Carstens "1:\n" 333*2e5061e4SHeiko Carstens EX_TABLE(0b,1b) 334*2e5061e4SHeiko Carstens : "=d" (rc) : "0" (-EOPNOTSUPP), "d" (cpu_address) : "cc"); 335*2e5061e4SHeiko Carstens if (!rc) 336*2e5061e4SHeiko Carstens machine_flags |= MACHINE_FLAG_DIAG9C; 337*2e5061e4SHeiko Carstens } 338*2e5061e4SHeiko Carstens 339*2e5061e4SHeiko Carstens static __init void detect_diag44(void) 340*2e5061e4SHeiko Carstens { 341*2e5061e4SHeiko Carstens #ifdef CONFIG_64BIT 342*2e5061e4SHeiko Carstens int rc; 343*2e5061e4SHeiko Carstens 344*2e5061e4SHeiko Carstens asm volatile( 345*2e5061e4SHeiko Carstens " diag 0,0,0x44\n" 346*2e5061e4SHeiko Carstens "0: la %0,0\n" 347*2e5061e4SHeiko Carstens "1:\n" 348*2e5061e4SHeiko Carstens EX_TABLE(0b,1b) 349*2e5061e4SHeiko Carstens : "=d" (rc) : "0" (-EOPNOTSUPP) : "cc"); 350*2e5061e4SHeiko Carstens if (!rc) 351*2e5061e4SHeiko Carstens machine_flags |= MACHINE_FLAG_DIAG44; 352*2e5061e4SHeiko Carstens #endif 353*2e5061e4SHeiko Carstens } 354*2e5061e4SHeiko Carstens 355*2e5061e4SHeiko Carstens static __init void detect_machine_facilities(void) 356*2e5061e4SHeiko Carstens { 357*2e5061e4SHeiko Carstens #ifdef CONFIG_64BIT 358*2e5061e4SHeiko Carstens unsigned int facilities; 359*2e5061e4SHeiko Carstens 360*2e5061e4SHeiko Carstens facilities = stfl(); 361*2e5061e4SHeiko Carstens if (facilities & (1 << 28)) 362*2e5061e4SHeiko Carstens machine_flags |= MACHINE_FLAG_IDTE; 363*2e5061e4SHeiko Carstens if (facilities & (1 << 4)) 364*2e5061e4SHeiko Carstens machine_flags |= MACHINE_FLAG_MVCOS; 365*2e5061e4SHeiko Carstens #endif 366*2e5061e4SHeiko Carstens } 367*2e5061e4SHeiko Carstens 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 { 37405dd2530SHeiko Carstens unsigned long long memsize; 375ab14de6cSHeiko Carstens 376ab14de6cSHeiko Carstens ipl_save_parameters(); 377ab14de6cSHeiko Carstens clear_bss_section(); 378ab14de6cSHeiko Carstens init_kernel_storage_key(); 379ab14de6cSHeiko Carstens lockdep_init(); 380ab14de6cSHeiko Carstens lockdep_off(); 381ab14de6cSHeiko Carstens detect_machine_type(); 382ab14de6cSHeiko Carstens create_kernel_nss(); 383ab14de6cSHeiko Carstens sort_main_extable(); 384ab14de6cSHeiko Carstens setup_lowcore_early(); 385*2e5061e4SHeiko Carstens detect_mvpg(); 386*2e5061e4SHeiko Carstens detect_ieee(); 387*2e5061e4SHeiko Carstens detect_csp(); 388*2e5061e4SHeiko Carstens detect_diag9c(); 389*2e5061e4SHeiko Carstens detect_diag44(); 390*2e5061e4SHeiko Carstens detect_machine_facilities(); 39108d07968SHeiko Carstens sclp_read_info_early(); 39283119ad4SHeiko Carstens sclp_facilities_detect(); 393ab14de6cSHeiko Carstens memsize = sclp_memory_detect(); 39405dd2530SHeiko Carstens #ifndef CONFIG_64BIT 39505dd2530SHeiko Carstens /* 39605dd2530SHeiko Carstens * Can't deal with more than 2G in 31 bit addressing mode, so 39705dd2530SHeiko Carstens * limit the value in order to avoid strange side effects. 39805dd2530SHeiko Carstens */ 39905dd2530SHeiko Carstens if (memsize > ADDR2G) 40005dd2530SHeiko Carstens memsize = ADDR2G; 40105dd2530SHeiko Carstens #endif 402ab14de6cSHeiko Carstens if (memory_fast_detect() < 0) 40305dd2530SHeiko Carstens find_memory_chunks((unsigned long) memsize); 404ab14de6cSHeiko Carstens lockdep_on(); 405ab14de6cSHeiko Carstens } 406