^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/pgtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <asm/ebcdic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <asm/sclp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/sections.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm/boot_data.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <asm/facility.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/uv.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "boot.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) char __bootdata(early_command_line)[COMMAND_LINE_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct ipl_parameter_block __bootdata_preserved(ipl_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) int __bootdata_preserved(ipl_block_valid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) unsigned int __bootdata_preserved(zlib_dfltcc_support) = ZLIB_DFLTCC_FULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) unsigned long __bootdata(vmalloc_size) = VMALLOC_DEFAULT_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) unsigned long __bootdata(memory_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int __bootdata(memory_end_set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) int __bootdata(noexec_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) int kaslr_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static inline int __diag308(unsigned long subcode, void *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) register unsigned long _addr asm("0") = (unsigned long)addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) register unsigned long _rc asm("1") = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned long reg1, reg2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) psw_t old;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) asm volatile(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) " mvc 0(16,%[psw_old]),0(%[psw_pgm])\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) " epsw %0,%1\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) " st %0,0(%[psw_pgm])\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) " st %1,4(%[psw_pgm])\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) " larl %0,1f\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) " stg %0,8(%[psw_pgm])\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) " diag %[addr],%[subcode],0x308\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) "1: mvc 0(16,%[psw_pgm]),0(%[psw_old])\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) : "=&d" (reg1), "=&a" (reg2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) "+Q" (S390_lowcore.program_new_psw),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) "=Q" (old),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) [addr] "+d" (_addr), "+d" (_rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) : [subcode] "d" (subcode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) [psw_old] "a" (&old),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) [psw_pgm] "a" (&S390_lowcore.program_new_psw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) : "cc", "memory");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) return _rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) void store_ipl_parmblock(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) rc = __diag308(DIAG308_STORE, &ipl_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) if (rc == DIAG308_RC_OK &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) ipl_block.hdr.version <= IPL_MAX_SUPPORTED_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) ipl_block_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static size_t scpdata_length(const u8 *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) while (count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) if (buf[count - 1] != '\0' && buf[count - 1] != ' ')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static size_t ipl_block_get_ascii_scpdata(char *dest, size_t size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) const struct ipl_parameter_block *ipb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) const __u8 *scp_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) __u32 scp_data_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) int has_lowercase;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) size_t count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) size_t i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) switch (ipb->pb0_hdr.pbt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) case IPL_PBT_FCP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) scp_data_len = ipb->fcp.scp_data_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) scp_data = ipb->fcp.scp_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) case IPL_PBT_NVME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) scp_data_len = ipb->nvme.scp_data_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) scp_data = ipb->nvme.scp_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) count = min(size - 1, scpdata_length(scp_data, scp_data_len));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if (!count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) has_lowercase = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (!isascii(scp_data[i])) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (!has_lowercase && islower(scp_data[i]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) has_lowercase = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (has_lowercase)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) memcpy(dest, scp_data, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) for (i = 0; i < count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) dest[i] = tolower(scp_data[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) dest[count] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static void append_ipl_block_parm(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) char *parm, *delim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) size_t len, rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) len = strlen(early_command_line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) delim = early_command_line + len; /* '\0' character position */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) parm = early_command_line + len + 1; /* append right after '\0' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) switch (ipl_block.pb0_hdr.pbt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) case IPL_PBT_CCW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) rc = ipl_block_get_ascii_vmparm(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) case IPL_PBT_FCP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) case IPL_PBT_NVME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) rc = ipl_block_get_ascii_scpdata(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (*parm == '=')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) memmove(early_command_line, parm + 1, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) *delim = ' '; /* replace '\0' with space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static inline int has_ebcdic_char(const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) for (i = 0; str[i]; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if (str[i] & 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) void setup_boot_command_line(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) COMMAND_LINE[ARCH_COMMAND_LINE_SIZE - 1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /* convert arch command line to ascii if necessary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (has_ebcdic_char(COMMAND_LINE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) EBCASC(COMMAND_LINE, ARCH_COMMAND_LINE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /* copy arch command line */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) strcpy(early_command_line, strim(COMMAND_LINE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /* append IPL PARM data to the boot command line */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (!is_prot_virt_guest() && ipl_block_valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) append_ipl_block_parm();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static void modify_facility(unsigned long nr, bool clear)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (clear)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) __clear_facility(nr, S390_lowcore.stfle_fac_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) __set_facility(nr, S390_lowcore.stfle_fac_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) static void check_cleared_facilities(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) unsigned long als[] = { FACILITIES_ALS };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) for (i = 0; i < ARRAY_SIZE(als); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if ((S390_lowcore.stfle_fac_list[i] & als[i]) != als[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) sclp_early_printk("Warning: The Linux kernel requires facilities cleared via command line option\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) print_missing_facilities();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static void modify_fac_list(char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) unsigned long val, endval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) char *endp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) bool clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) while (*str) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) clear = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (*str == '!') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) clear = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) str++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) val = simple_strtoull(str, &endp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (str == endp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) str = endp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (*str == '-') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) str++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) endval = simple_strtoull(str, &endp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if (str == endp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) str = endp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) while (val <= endval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) modify_facility(val, clear);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) val++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) modify_facility(val, clear);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (*str != ',')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) str++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) check_cleared_facilities();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static char command_line_buf[COMMAND_LINE_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) void parse_boot_command_line(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) char *param, *val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) bool enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) char *args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) kaslr_enabled = IS_ENABLED(CONFIG_RANDOMIZE_BASE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) args = strcpy(command_line_buf, early_command_line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) while (*args) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) args = next_arg(args, ¶m, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) if (!strcmp(param, "mem") && val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) memory_end = round_down(memparse(val, NULL), PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) memory_end_set = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) if (!strcmp(param, "vmalloc") && val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) vmalloc_size = round_up(memparse(val, NULL), PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) if (!strcmp(param, "dfltcc") && val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (!strcmp(val, "off"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) zlib_dfltcc_support = ZLIB_DFLTCC_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) else if (!strcmp(val, "on"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) zlib_dfltcc_support = ZLIB_DFLTCC_FULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) else if (!strcmp(val, "def_only"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) zlib_dfltcc_support = ZLIB_DFLTCC_DEFLATE_ONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) else if (!strcmp(val, "inf_only"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) zlib_dfltcc_support = ZLIB_DFLTCC_INFLATE_ONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) else if (!strcmp(val, "always"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) zlib_dfltcc_support = ZLIB_DFLTCC_FULL_DEBUG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (!strcmp(param, "noexec")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) rc = kstrtobool(val, &enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) if (!rc && !enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) noexec_disabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (!strcmp(param, "facilities") && val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) modify_fac_list(val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) if (!strcmp(param, "nokaslr"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) kaslr_enabled = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #if IS_ENABLED(CONFIG_KVM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (!strcmp(param, "prot_virt")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) rc = kstrtobool(val, &enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) if (!rc && enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) prot_virt_host = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) static inline bool is_ipl_block_dump(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) if (ipl_block.pb0_hdr.pbt == IPL_PBT_FCP &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) ipl_block.fcp.opt == IPL_PB0_FCP_OPT_DUMP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) if (ipl_block.pb0_hdr.pbt == IPL_PBT_NVME &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) ipl_block.nvme.opt == IPL_PB0_NVME_OPT_DUMP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) void setup_memory_end(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) #ifdef CONFIG_CRASH_DUMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) if (OLDMEM_BASE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) kaslr_enabled = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) } else if (ipl_block_valid && is_ipl_block_dump()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) kaslr_enabled = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) if (!sclp_early_get_hsa_size(&memory_end) && memory_end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) memory_end_set = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }