Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 2 | /* |
Hans-Joachim Picht | 155af2f | 2009-06-16 10:30:52 +0200 | [diff] [blame] | 3 | * Copyright IBM Corp. 2007, 2009 |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 4 | * Author(s): Hongjie Yang <hongjie@us.ibm.com>, |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Hendrik Brueckner | 11af97e | 2009-09-11 10:28:53 +0200 | [diff] [blame] | 7 | #define KMSG_COMPONENT "setup" |
| 8 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 9 | |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 10 | #include <linux/compiler.h> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 11 | #include <linux/init.h> |
| 12 | #include <linux/errno.h> |
| 13 | #include <linux/string.h> |
| 14 | #include <linux/ctype.h> |
| 15 | #include <linux/lockdep.h> |
Paul Gortmaker | dcc096c | 2016-09-19 17:54:56 -0400 | [diff] [blame] | 16 | #include <linux/extable.h> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 17 | #include <linux/pfn.h> |
| 18 | #include <linux/uaccess.h> |
Hendrik Brueckner | 11af97e | 2009-09-11 10:28:53 +0200 | [diff] [blame] | 19 | #include <linux/kernel.h> |
Heiko Carstens | d09a307 | 2022-02-28 11:22:12 +0100 | [diff] [blame] | 20 | #include <asm/asm-extable.h> |
Alexander Gordeev | bb1520d | 2022-12-13 11:35:11 +0100 | [diff] [blame] | 21 | #include <linux/memblock.h> |
Martin Schwidefsky | 1ec2772 | 2015-08-20 17:28:44 +0200 | [diff] [blame] | 22 | #include <asm/diag.h> |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 23 | #include <asm/ebcdic.h> |
Michael Holzheu | 46b05d2 | 2007-02-21 10:55:21 +0100 | [diff] [blame] | 24 | #include <asm/ipl.h> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 25 | #include <asm/lowcore.h> |
| 26 | #include <asm/processor.h> |
| 27 | #include <asm/sections.h> |
| 28 | #include <asm/setup.h> |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 29 | #include <asm/sysinfo.h> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 30 | #include <asm/cpcmd.h> |
| 31 | #include <asm/sclp.h> |
David Howells | a0616cd | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 32 | #include <asm/facility.h> |
Vasily Gorbik | 4969874 | 2018-05-15 13:28:53 +0200 | [diff] [blame] | 33 | #include <asm/boot_data.h> |
Vasily Gorbik | c231359 | 2019-11-14 14:08:28 +0100 | [diff] [blame] | 34 | #include <asm/switch_to.h> |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 35 | #include "entry.h" |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 36 | |
Vasily Gorbik | 8ee0d2f | 2023-02-17 14:00:54 +0100 | [diff] [blame] | 37 | #define decompressor_handled_param(param) \ |
| 38 | static int __init ignore_decompressor_param_##param(char *s) \ |
| 39 | { \ |
| 40 | return 0; \ |
| 41 | } \ |
| 42 | early_param(#param, ignore_decompressor_param_##param) |
| 43 | |
| 44 | decompressor_handled_param(mem); |
| 45 | decompressor_handled_param(vmalloc); |
| 46 | decompressor_handled_param(dfltcc); |
Vasily Gorbik | 8ee0d2f | 2023-02-17 14:00:54 +0100 | [diff] [blame] | 47 | decompressor_handled_param(facilities); |
| 48 | decompressor_handled_param(nokaslr); |
Heiko Carstens | 468a3bc | 2023-10-27 14:12:36 +0200 | [diff] [blame] | 49 | decompressor_handled_param(cmma); |
Vasily Gorbik | 8ee0d2f | 2023-02-17 14:00:54 +0100 | [diff] [blame] | 50 | #if IS_ENABLED(CONFIG_KVM) |
| 51 | decompressor_handled_param(prot_virt); |
| 52 | #endif |
| 53 | |
Vasily Gorbik | 557b197 | 2023-02-09 22:05:11 +0100 | [diff] [blame] | 54 | static void __init kasan_early_init(void) |
| 55 | { |
| 56 | #ifdef CONFIG_KASAN |
| 57 | init_task.kasan_depth = 0; |
| 58 | sclp_early_printk("KernelAddressSanitizer initialized\n"); |
| 59 | #endif |
| 60 | } |
| 61 | |
Vasily Gorbik | 2e83e0e | 2019-08-11 20:55:18 +0200 | [diff] [blame] | 62 | static void __init reset_tod_clock(void) |
| 63 | { |
Heiko Carstens | 530f639 | 2021-02-08 13:56:49 +0100 | [diff] [blame] | 64 | union tod_clock clk; |
Vasily Gorbik | 2e83e0e | 2019-08-11 20:55:18 +0200 | [diff] [blame] | 65 | |
Heiko Carstens | 530f639 | 2021-02-08 13:56:49 +0100 | [diff] [blame] | 66 | if (store_tod_clock_ext_cc(&clk) == 0) |
Vasily Gorbik | 2e83e0e | 2019-08-11 20:55:18 +0200 | [diff] [blame] | 67 | return; |
| 68 | /* TOD clock not running. Set the clock to Unix Epoch. */ |
Heiko Carstens | 530f639 | 2021-02-08 13:56:49 +0100 | [diff] [blame] | 69 | if (set_tod_clock(TOD_UNIX_EPOCH) || store_tod_clock_ext_cc(&clk)) |
Vasily Gorbik | 2e83e0e | 2019-08-11 20:55:18 +0200 | [diff] [blame] | 70 | disabled_wait(); |
| 71 | |
Heiko Carstens | f8d8977 | 2021-02-08 16:06:10 +0100 | [diff] [blame] | 72 | memset(&tod_clock_base, 0, sizeof(tod_clock_base)); |
| 73 | tod_clock_base.tod = TOD_UNIX_EPOCH; |
Vasily Gorbik | 2e83e0e | 2019-08-11 20:55:18 +0200 | [diff] [blame] | 74 | S390_lowcore.last_update_clock = TOD_UNIX_EPOCH; |
| 75 | } |
| 76 | |
Martin Schwidefsky | b6112cc | 2009-04-14 15:36:28 +0200 | [diff] [blame] | 77 | /* |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 78 | * Initialize storage key for kernel pages |
| 79 | */ |
| 80 | static noinline __init void init_kernel_storage_key(void) |
| 81 | { |
Martin Schwidefsky | 127c1fe | 2013-10-07 12:12:32 +0200 | [diff] [blame] | 82 | #if PAGE_DEFAULT_KEY |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 83 | unsigned long end_pfn, init_pfn; |
| 84 | |
Vasily Gorbik | 320d955 | 2018-02-20 13:28:33 +0100 | [diff] [blame] | 85 | end_pfn = PFN_UP(__pa(_end)); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 86 | |
| 87 | for (init_pfn = 0 ; init_pfn < end_pfn; init_pfn++) |
Martin Schwidefsky | e2b8d7af | 2010-10-25 16:10:14 +0200 | [diff] [blame] | 88 | page_set_storage_key(init_pfn << PAGE_SHIFT, |
| 89 | PAGE_DEFAULT_KEY, 0); |
Martin Schwidefsky | 127c1fe | 2013-10-07 12:12:32 +0200 | [diff] [blame] | 90 | #endif |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 91 | } |
| 92 | |
Heiko Carstens | fade4dc4 | 2012-09-04 14:26:03 +0200 | [diff] [blame] | 93 | static __initdata char sysinfo_page[PAGE_SIZE] __aligned(PAGE_SIZE); |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 94 | |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 95 | static noinline __init void detect_machine_type(void) |
| 96 | { |
Heiko Carstens | fade4dc4 | 2012-09-04 14:26:03 +0200 | [diff] [blame] | 97 | struct sysinfo_3_2_2 *vmms = (struct sysinfo_3_2_2 *)&sysinfo_page; |
| 98 | |
Martin Schwidefsky | 27d7160 | 2010-02-26 22:37:38 +0100 | [diff] [blame] | 99 | /* Check current-configuration-level */ |
Heiko Carstens | caf757c | 2012-09-06 14:42:13 +0200 | [diff] [blame] | 100 | if (stsi(NULL, 0, 0, 0) <= 2) { |
Martin Schwidefsky | 27d7160 | 2010-02-26 22:37:38 +0100 | [diff] [blame] | 101 | S390_lowcore.machine_flags |= MACHINE_FLAG_LPAR; |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 102 | return; |
Martin Schwidefsky | 27d7160 | 2010-02-26 22:37:38 +0100 | [diff] [blame] | 103 | } |
| 104 | /* Get virtual-machine cpu information. */ |
Heiko Carstens | caf757c | 2012-09-06 14:42:13 +0200 | [diff] [blame] | 105 | if (stsi(vmms, 3, 2, 2) || !vmms->count) |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 106 | return; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 107 | |
Christian Borntraeger | 03aa047 | 2018-11-09 09:21:47 +0100 | [diff] [blame] | 108 | /* Detect known hypervisors */ |
Heiko Carstens | fade4dc4 | 2012-09-04 14:26:03 +0200 | [diff] [blame] | 109 | if (!memcmp(vmms->vm[0].cpi, "\xd2\xe5\xd4", 3)) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame] | 110 | S390_lowcore.machine_flags |= MACHINE_FLAG_KVM; |
Christian Borntraeger | 03aa047 | 2018-11-09 09:21:47 +0100 | [diff] [blame] | 111 | else if (!memcmp(vmms->vm[0].cpi, "\xa9\x61\xe5\xd4", 4)) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame] | 112 | S390_lowcore.machine_flags |= MACHINE_FLAG_VM; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 113 | } |
| 114 | |
Heiko Carstens | d2f0397 | 2017-03-11 11:58:27 +0100 | [diff] [blame] | 115 | /* Remove leading, trailing and double whitespace. */ |
| 116 | static inline void strim_all(char *str) |
| 117 | { |
| 118 | char *s; |
| 119 | |
| 120 | s = strim(str); |
| 121 | if (s != str) |
| 122 | memmove(str, s, strlen(s)); |
| 123 | while (*str) { |
| 124 | if (!isspace(*str++)) |
| 125 | continue; |
| 126 | if (isspace(*str)) { |
| 127 | s = skip_spaces(str); |
| 128 | memmove(str, s, strlen(s) + 1); |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
Christian Borntraeger | 4b8fe77 | 2016-05-24 15:23:20 +0200 | [diff] [blame] | 133 | static noinline __init void setup_arch_string(void) |
| 134 | { |
| 135 | struct sysinfo_1_1_1 *mach = (struct sysinfo_1_1_1 *)&sysinfo_page; |
Heiko Carstens | 2f8876f | 2017-03-11 12:22:11 +0100 | [diff] [blame] | 136 | struct sysinfo_3_2_2 *vm = (struct sysinfo_3_2_2 *)&sysinfo_page; |
| 137 | char mstr[80], hvstr[17]; |
Christian Borntraeger | 4b8fe77 | 2016-05-24 15:23:20 +0200 | [diff] [blame] | 138 | |
| 139 | if (stsi(mach, 1, 1, 1)) |
| 140 | return; |
| 141 | EBCASC(mach->manufacturer, sizeof(mach->manufacturer)); |
| 142 | EBCASC(mach->type, sizeof(mach->type)); |
| 143 | EBCASC(mach->model, sizeof(mach->model)); |
| 144 | EBCASC(mach->model_capacity, sizeof(mach->model_capacity)); |
Heiko Carstens | d2f0397 | 2017-03-11 11:58:27 +0100 | [diff] [blame] | 145 | sprintf(mstr, "%-16.16s %-4.4s %-16.16s %-16.16s", |
| 146 | mach->manufacturer, mach->type, |
| 147 | mach->model, mach->model_capacity); |
| 148 | strim_all(mstr); |
Heiko Carstens | 2f8876f | 2017-03-11 12:22:11 +0100 | [diff] [blame] | 149 | if (stsi(vm, 3, 2, 2) == 0 && vm->count) { |
| 150 | EBCASC(vm->vm[0].cpi, sizeof(vm->vm[0].cpi)); |
| 151 | sprintf(hvstr, "%-16.16s", vm->vm[0].cpi); |
| 152 | strim_all(hvstr); |
| 153 | } else { |
| 154 | sprintf(hvstr, "%s", |
| 155 | MACHINE_IS_LPAR ? "LPAR" : |
| 156 | MACHINE_IS_VM ? "z/VM" : |
| 157 | MACHINE_IS_KVM ? "KVM" : "unknown"); |
| 158 | } |
| 159 | dump_stack_set_arch_desc("%s (%s)", mstr, hvstr); |
Christian Borntraeger | 4b8fe77 | 2016-05-24 15:23:20 +0200 | [diff] [blame] | 160 | } |
| 161 | |
Heiko Carstens | fade4dc4 | 2012-09-04 14:26:03 +0200 | [diff] [blame] | 162 | static __init void setup_topology(void) |
| 163 | { |
Heiko Carstens | fade4dc4 | 2012-09-04 14:26:03 +0200 | [diff] [blame] | 164 | int max_mnest; |
| 165 | |
| 166 | if (!test_facility(11)) |
| 167 | return; |
| 168 | S390_lowcore.machine_flags |= MACHINE_FLAG_TOPOLOGY; |
| 169 | for (max_mnest = 6; max_mnest > 1; max_mnest--) { |
Heiko Carstens | caf757c | 2012-09-06 14:42:13 +0200 | [diff] [blame] | 170 | if (stsi(&sysinfo_page, 15, 1, max_mnest) == 0) |
Heiko Carstens | fade4dc4 | 2012-09-04 14:26:03 +0200 | [diff] [blame] | 171 | break; |
| 172 | } |
| 173 | topology_max_mnest = max_mnest; |
Heiko Carstens | fade4dc4 | 2012-09-04 14:26:03 +0200 | [diff] [blame] | 174 | } |
| 175 | |
Heiko Carstens | 8580601 | 2022-05-20 19:23:48 +0200 | [diff] [blame] | 176 | void __do_early_pgm_check(struct pt_regs *regs) |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 177 | { |
Heiko Carstens | 46fee16 | 2022-02-28 14:29:25 +0100 | [diff] [blame] | 178 | if (!fixup_exception(regs)) |
Martin Schwidefsky | 98587c2 | 2019-04-30 12:33:45 +0200 | [diff] [blame] | 179 | disabled_wait(); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 180 | } |
| 181 | |
Heiko Carstens | 5f954c3 | 2009-07-24 12:39:49 +0200 | [diff] [blame] | 182 | static noinline __init void setup_lowcore_early(void) |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 183 | { |
| 184 | psw_t psw; |
| 185 | |
Heiko Carstens | 8580601 | 2022-05-20 19:23:48 +0200 | [diff] [blame] | 186 | psw.addr = (unsigned long)early_pgm_check_handler; |
Alexander Gordeev | bb1520d | 2022-12-13 11:35:11 +0100 | [diff] [blame] | 187 | psw.mask = PSW_KERNEL_BITS; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 188 | S390_lowcore.program_new_psw = psw; |
Martin Schwidefsky | c360192 | 2016-10-25 12:21:44 +0200 | [diff] [blame] | 189 | S390_lowcore.preempt_count = INIT_PREEMPT_COUNT; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 190 | } |
| 191 | |
Martin Schwidefsky | 14375bc | 2010-10-25 16:10:51 +0200 | [diff] [blame] | 192 | static noinline __init void setup_facility_list(void) |
| 193 | { |
Sven Schnelle | 17e89e1 | 2021-05-05 22:01:10 +0200 | [diff] [blame] | 194 | memcpy(alt_stfle_fac_list, stfle_fac_list, sizeof(alt_stfle_fac_list)); |
Martin Schwidefsky | d768bd8 | 2018-01-16 07:11:45 +0100 | [diff] [blame] | 195 | if (!IS_ENABLED(CONFIG_KERNEL_NOBP)) |
Sven Schnelle | 17e89e1 | 2021-05-05 22:01:10 +0200 | [diff] [blame] | 196 | __clear_facility(82, alt_stfle_fac_list); |
Martin Schwidefsky | 14375bc | 2010-10-25 16:10:51 +0200 | [diff] [blame] | 197 | } |
| 198 | |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 199 | static __init void detect_diag9c(void) |
| 200 | { |
| 201 | unsigned int cpu_address; |
| 202 | int rc; |
| 203 | |
| 204 | cpu_address = stap(); |
Martin Schwidefsky | 1ec2772 | 2015-08-20 17:28:44 +0200 | [diff] [blame] | 205 | diag_stat_inc(DIAG_STAT_X09C); |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 206 | asm volatile( |
| 207 | " diag %2,0,0x9c\n" |
| 208 | "0: la %0,0\n" |
| 209 | "1:\n" |
| 210 | EX_TABLE(0b,1b) |
| 211 | : "=d" (rc) : "0" (-EOPNOTSUPP), "d" (cpu_address) : "cc"); |
| 212 | if (!rc) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame] | 213 | S390_lowcore.machine_flags |= MACHINE_FLAG_DIAG9C; |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 214 | } |
| 215 | |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 216 | static __init void detect_machine_facilities(void) |
| 217 | { |
Heiko Carstens | 3c7ef08 | 2012-09-28 15:06:41 +0200 | [diff] [blame] | 218 | if (test_facility(8)) { |
| 219 | S390_lowcore.machine_flags |= MACHINE_FLAG_EDAT1; |
Heiko Carstens | 99441a3 | 2023-09-11 21:40:13 +0200 | [diff] [blame] | 220 | system_ctl_set_bit(0, CR0_EDAT_BIT); |
Heiko Carstens | 3c7ef08 | 2012-09-28 15:06:41 +0200 | [diff] [blame] | 221 | } |
Heiko Carstens | 85e9d0e5 | 2012-09-27 10:45:06 +0200 | [diff] [blame] | 222 | if (test_facility(78)) |
| 223 | S390_lowcore.machine_flags |= MACHINE_FLAG_EDAT2; |
Martin Schwidefsky | 14375bc | 2010-10-25 16:10:51 +0200 | [diff] [blame] | 224 | if (test_facility(3)) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame] | 225 | S390_lowcore.machine_flags |= MACHINE_FLAG_IDTE; |
Heiko Carstens | a1c5bef | 2017-11-09 12:29:34 +0100 | [diff] [blame] | 226 | if (test_facility(50) && test_facility(73)) { |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 227 | S390_lowcore.machine_flags |= MACHINE_FLAG_TE; |
Heiko Carstens | 99441a3 | 2023-09-11 21:40:13 +0200 | [diff] [blame] | 228 | system_ctl_set_bit(0, CR0_TRANSACTIONAL_EXECUTION_BIT); |
Heiko Carstens | a1c5bef | 2017-11-09 12:29:34 +0100 | [diff] [blame] | 229 | } |
Martin Schwidefsky | 1b948d6 | 2014-04-03 13:55:01 +0200 | [diff] [blame] | 230 | if (test_facility(51)) |
| 231 | S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_LC; |
Heiko Carstens | 1856475 | 2023-12-01 15:42:19 +0100 | [diff] [blame] | 232 | if (test_facility(129)) |
Heiko Carstens | 99441a3 | 2023-09-11 21:40:13 +0200 | [diff] [blame] | 233 | system_ctl_set_bit(0, CR0_VECTOR_BIT); |
Heiko Carstens | c0f1d47 | 2023-08-25 14:29:48 +0200 | [diff] [blame] | 234 | if (test_facility(130)) |
Martin Schwidefsky | 57d7f93 | 2016-03-22 10:54:24 +0100 | [diff] [blame] | 235 | S390_lowcore.machine_flags |= MACHINE_FLAG_NX; |
Martin Schwidefsky | 916cda1 | 2016-01-26 14:10:34 +0100 | [diff] [blame] | 236 | if (test_facility(133)) |
| 237 | S390_lowcore.machine_flags |= MACHINE_FLAG_GS; |
Heiko Carstens | f8d8977 | 2021-02-08 16:06:10 +0100 | [diff] [blame] | 238 | if (test_facility(139) && (tod_clock_base.tod >> 63)) { |
Martin Schwidefsky | 6e2ef5e | 2016-10-27 12:41:39 +0200 | [diff] [blame] | 239 | /* Enabled signed clock comparator comparisons */ |
| 240 | S390_lowcore.machine_flags |= MACHINE_FLAG_SCC; |
| 241 | clock_comparator_max = -1ULL >> 1; |
Heiko Carstens | 99441a3 | 2023-09-11 21:40:13 +0200 | [diff] [blame] | 242 | system_ctl_set_bit(0, CR0_CLOCK_COMPARATOR_SIGN_BIT); |
Martin Schwidefsky | 6e2ef5e | 2016-10-27 12:41:39 +0200 | [diff] [blame] | 243 | } |
Niklas Schnelle | 3322ba0 | 2021-07-08 14:55:42 +0200 | [diff] [blame] | 244 | if (IS_ENABLED(CONFIG_PCI) && test_facility(153)) { |
| 245 | S390_lowcore.machine_flags |= MACHINE_FLAG_PCI_MIO; |
| 246 | /* the control bit is set during PCI initialization */ |
| 247 | } |
Gerald Schaefer | 0807b85 | 2023-02-06 17:48:21 +0100 | [diff] [blame] | 248 | if (test_facility(194)) |
| 249 | S390_lowcore.machine_flags |= MACHINE_FLAG_RDP; |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 250 | } |
| 251 | |
Martin Schwidefsky | 1a36a39 | 2015-10-29 10:28:26 +0100 | [diff] [blame] | 252 | static inline void save_vector_registers(void) |
| 253 | { |
| 254 | #ifdef CONFIG_CRASH_DUMP |
| 255 | if (test_facility(129)) |
| 256 | save_vx_regs(boot_cpu_vector_save_area); |
| 257 | #endif |
| 258 | } |
| 259 | |
Heiko Carstens | 4a17252 | 2023-09-05 15:49:37 +0200 | [diff] [blame] | 260 | static inline void setup_low_address_protection(void) |
Vasily Gorbik | c02ee6a | 2019-11-12 17:35:28 +0100 | [diff] [blame] | 261 | { |
Heiko Carstens | 99441a3 | 2023-09-11 21:40:13 +0200 | [diff] [blame] | 262 | system_ctl_set_bit(0, CR0_LOW_ADDRESS_PROTECTION_BIT); |
Vasily Gorbik | c02ee6a | 2019-11-12 17:35:28 +0100 | [diff] [blame] | 263 | } |
| 264 | |
Vasily Gorbik | c231359 | 2019-11-14 14:08:28 +0100 | [diff] [blame] | 265 | static inline void setup_access_registers(void) |
| 266 | { |
| 267 | unsigned int acrs[NUM_ACRS] = { 0 }; |
| 268 | |
| 269 | restore_access_regs(acrs); |
| 270 | } |
| 271 | |
Vasily Gorbik | 4969874 | 2018-05-15 13:28:53 +0200 | [diff] [blame] | 272 | char __bootdata(early_command_line)[COMMAND_LINE_SIZE]; |
Michael Holzheu | 1fb8105 | 2011-12-27 11:25:46 +0100 | [diff] [blame] | 273 | static void __init setup_boot_command_line(void) |
| 274 | { |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 275 | /* copy arch command line */ |
Wolfram Sang | 820109f | 2022-08-18 22:59:47 +0200 | [diff] [blame] | 276 | strscpy(boot_command_line, early_command_line, COMMAND_LINE_SIZE); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 277 | } |
| 278 | |
Heiko Carstens | a156f09 | 2022-02-28 10:45:43 +0100 | [diff] [blame] | 279 | static void __init sort_amode31_extable(void) |
| 280 | { |
| 281 | sort_extable(__start_amode31_ex_table, __stop_amode31_ex_table); |
| 282 | } |
| 283 | |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 284 | void __init startup_init(void) |
| 285 | { |
Vasily Gorbik | 557b197 | 2023-02-09 22:05:11 +0100 | [diff] [blame] | 286 | kasan_early_init(); |
Vasily Gorbik | 2e83e0e | 2019-08-11 20:55:18 +0200 | [diff] [blame] | 287 | reset_tod_clock(); |
Martin Schwidefsky | b1c0854 | 2016-10-10 09:43:41 +0200 | [diff] [blame] | 288 | time_early_init(); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 289 | init_kernel_storage_key(); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 290 | lockdep_off(); |
Heiko Carstens | a156f09 | 2022-02-28 10:45:43 +0100 | [diff] [blame] | 291 | sort_amode31_extable(); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 292 | setup_lowcore_early(); |
Martin Schwidefsky | 14375bc | 2010-10-25 16:10:51 +0200 | [diff] [blame] | 293 | setup_facility_list(); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 294 | detect_machine_type(); |
Christian Borntraeger | 4b8fe77 | 2016-05-24 15:23:20 +0200 | [diff] [blame] | 295 | setup_arch_string(); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 296 | setup_boot_command_line(); |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 297 | detect_diag9c(); |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 298 | detect_machine_facilities(); |
Martin Schwidefsky | 1a36a39 | 2015-10-29 10:28:26 +0100 | [diff] [blame] | 299 | save_vector_registers(); |
Heiko Carstens | fade4dc4 | 2012-09-04 14:26:03 +0200 | [diff] [blame] | 300 | setup_topology(); |
Michael Holzheu | 7b50da5 | 2013-11-13 10:38:27 +0100 | [diff] [blame] | 301 | sclp_early_detect(); |
Heiko Carstens | 4a17252 | 2023-09-05 15:49:37 +0200 | [diff] [blame] | 302 | setup_low_address_protection(); |
Vasily Gorbik | c231359 | 2019-11-14 14:08:28 +0100 | [diff] [blame] | 303 | setup_access_registers(); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 304 | lockdep_on(); |
| 305 | } |