xref: /openbmc/linux/arch/s390/boot/startup.c (revision 84733284)
18f75582aSVasily Gorbik // SPDX-License-Identifier: GPL-2.0
28f75582aSVasily Gorbik #include <linux/string.h>
3805bc0bcSGerald Schaefer #include <linux/elf.h>
473045a08SVasily Gorbik #include <asm/boot_data.h>
5a80313ffSGerald Schaefer #include <asm/sections.h>
6d7e7fbbaSVasily Gorbik #include <asm/cpu_mf.h>
715426ca4SVasily Gorbik #include <asm/setup.h>
80c4f2623SVasily Gorbik #include <asm/kasan.h>
9805bc0bcSGerald Schaefer #include <asm/kexec.h>
107516fc11SVasily Gorbik #include <asm/sclp.h>
11a80313ffSGerald Schaefer #include <asm/diag.h>
125abb9351SVasily Gorbik #include <asm/uv.h>
138f75582aSVasily Gorbik #include "compressed/decompressor.h"
148f75582aSVasily Gorbik #include "boot.h"
15c5cf5054SAlexander Egorenkov #include "uv.h"
168f75582aSVasily Gorbik 
17b2d24b97SGerald Schaefer unsigned long __bootdata_preserved(__kaslr_offset);
180c4f2623SVasily Gorbik unsigned long __bootdata_preserved(VMALLOC_START);
190c4f2623SVasily Gorbik unsigned long __bootdata_preserved(VMALLOC_END);
200c4f2623SVasily Gorbik struct page *__bootdata_preserved(vmemmap);
210c4f2623SVasily Gorbik unsigned long __bootdata_preserved(vmemmap_size);
220c4f2623SVasily Gorbik unsigned long __bootdata_preserved(MODULES_VADDR);
230c4f2623SVasily Gorbik unsigned long __bootdata_preserved(MODULES_END);
2473045a08SVasily Gorbik unsigned long __bootdata(ident_map_size);
259f744abbSAlexander Egorenkov int __bootdata(is_full_image) = 1;
26*84733284SAlexander Egorenkov struct initrd_data __bootdata(initrd_data);
27d1b52a43SVasily Gorbik 
2817e89e13SSven Schnelle u64 __bootdata_preserved(stfle_fac_list[16]);
2917e89e13SSven Schnelle u64 __bootdata_preserved(alt_stfle_fac_list[16]);
3017e89e13SSven Schnelle 
31a80313ffSGerald Schaefer /*
32a80313ffSGerald Schaefer  * Some code and data needs to stay below 2 GB, even when the kernel would be
33a80313ffSGerald Schaefer  * relocated above 2 GB, because it has to use 31 bit addresses.
34a80313ffSGerald Schaefer  * Such code and data is part of the .dma section, and its location is passed
35a80313ffSGerald Schaefer  * over to the decompressed / relocated kernel via the .boot.preserved.data
36a80313ffSGerald Schaefer  * section.
37a80313ffSGerald Schaefer  */
38a80313ffSGerald Schaefer unsigned long __bootdata_preserved(__sdma) = __pa(&_sdma);
39a80313ffSGerald Schaefer unsigned long __bootdata_preserved(__edma) = __pa(&_edma);
40a80313ffSGerald Schaefer unsigned long __bootdata_preserved(__stext_dma) = __pa(&_stext_dma);
41a80313ffSGerald Schaefer unsigned long __bootdata_preserved(__etext_dma) = __pa(&_etext_dma);
42a80313ffSGerald Schaefer struct exception_table_entry *
43a80313ffSGerald Schaefer 	__bootdata_preserved(__start_dma_ex_table) = _start_dma_ex_table;
44a80313ffSGerald Schaefer struct exception_table_entry *
45a80313ffSGerald Schaefer 	__bootdata_preserved(__stop_dma_ex_table) = _stop_dma_ex_table;
46a80313ffSGerald Schaefer 
47a80313ffSGerald Schaefer int _diag210_dma(struct diag210 *addr);
48a80313ffSGerald Schaefer int _diag26c_dma(void *req, void *resp, enum diag26c_sc subcode);
49a80313ffSGerald Schaefer int _diag14_dma(unsigned long rx, unsigned long ry1, unsigned long subcode);
50a80313ffSGerald Schaefer void _diag0c_dma(struct hypfs_diag0c_entry *entry);
51a80313ffSGerald Schaefer void _diag308_reset_dma(void);
52a80313ffSGerald Schaefer struct diag_ops __bootdata_preserved(diag_dma_ops) = {
53a80313ffSGerald Schaefer 	.diag210 = _diag210_dma,
54a80313ffSGerald Schaefer 	.diag26c = _diag26c_dma,
55a80313ffSGerald Schaefer 	.diag14 = _diag14_dma,
56a80313ffSGerald Schaefer 	.diag0c = _diag0c_dma,
57a80313ffSGerald Schaefer 	.diag308_reset = _diag308_reset_dma
58a80313ffSGerald Schaefer };
5933def849SJoe Perches static struct diag210 _diag210_tmp_dma __section(".dma.data");
60a80313ffSGerald Schaefer struct diag210 *__bootdata_preserved(__diag210_tmp_dma) = &_diag210_tmp_dma;
61a80313ffSGerald Schaefer 
627516fc11SVasily Gorbik void error(char *x)
637516fc11SVasily Gorbik {
647516fc11SVasily Gorbik 	sclp_early_printk("\n\n");
657516fc11SVasily Gorbik 	sclp_early_printk(x);
667516fc11SVasily Gorbik 	sclp_early_printk("\n\n -- System halted");
677516fc11SVasily Gorbik 
6898587c2dSMartin Schwidefsky 	disabled_wait();
697516fc11SVasily Gorbik }
707516fc11SVasily Gorbik 
71d7e7fbbaSVasily Gorbik static void setup_lpp(void)
72d7e7fbbaSVasily Gorbik {
73d7e7fbbaSVasily Gorbik 	S390_lowcore.current_pid = 0;
74d7e7fbbaSVasily Gorbik 	S390_lowcore.lpp = LPP_MAGIC;
75d7e7fbbaSVasily Gorbik 	if (test_facility(40))
76d7e7fbbaSVasily Gorbik 		lpp(&S390_lowcore.lpp);
77d7e7fbbaSVasily Gorbik }
78d7e7fbbaSVasily Gorbik 
7915426ca4SVasily Gorbik #ifdef CONFIG_KERNEL_UNCOMPRESSED
8015426ca4SVasily Gorbik unsigned long mem_safe_offset(void)
8115426ca4SVasily Gorbik {
8215426ca4SVasily Gorbik 	return vmlinux.default_lma + vmlinux.image_size + vmlinux.bss_size;
8315426ca4SVasily Gorbik }
8415426ca4SVasily Gorbik #endif
8515426ca4SVasily Gorbik 
869641b8ccSMartin Schwidefsky static void rescue_initrd(unsigned long addr)
8715426ca4SVasily Gorbik {
8815426ca4SVasily Gorbik 	if (!IS_ENABLED(CONFIG_BLK_DEV_INITRD))
8915426ca4SVasily Gorbik 		return;
90*84733284SAlexander Egorenkov 	if (!initrd_data.start || !initrd_data.size)
9115426ca4SVasily Gorbik 		return;
92*84733284SAlexander Egorenkov 	if (addr <= initrd_data.start)
9315426ca4SVasily Gorbik 		return;
94*84733284SAlexander Egorenkov 	memmove((void *)addr, (void *)initrd_data.start, initrd_data.size);
95*84733284SAlexander Egorenkov 	initrd_data.start = addr;
9615426ca4SVasily Gorbik }
9715426ca4SVasily Gorbik 
98d1b52a43SVasily Gorbik static void copy_bootdata(void)
99d1b52a43SVasily Gorbik {
100d1b52a43SVasily Gorbik 	if (__boot_data_end - __boot_data_start != vmlinux.bootdata_size)
101d1b52a43SVasily Gorbik 		error(".boot.data section size mismatch");
102d1b52a43SVasily Gorbik 	memcpy((void *)vmlinux.bootdata_off, __boot_data_start, vmlinux.bootdata_size);
103bf9921a9SGerald Schaefer 	if (__boot_data_preserved_end - __boot_data_preserved_start != vmlinux.bootdata_preserved_size)
104bf9921a9SGerald Schaefer 		error(".boot.preserved.data section size mismatch");
105bf9921a9SGerald Schaefer 	memcpy((void *)vmlinux.bootdata_preserved_off, __boot_data_preserved_start, vmlinux.bootdata_preserved_size);
106d1b52a43SVasily Gorbik }
107d1b52a43SVasily Gorbik 
108805bc0bcSGerald Schaefer static void handle_relocs(unsigned long offset)
109805bc0bcSGerald Schaefer {
110805bc0bcSGerald Schaefer 	Elf64_Rela *rela_start, *rela_end, *rela;
111805bc0bcSGerald Schaefer 	int r_type, r_sym, rc;
112805bc0bcSGerald Schaefer 	Elf64_Addr loc, val;
113805bc0bcSGerald Schaefer 	Elf64_Sym *dynsym;
114805bc0bcSGerald Schaefer 
115805bc0bcSGerald Schaefer 	rela_start = (Elf64_Rela *) vmlinux.rela_dyn_start;
116805bc0bcSGerald Schaefer 	rela_end = (Elf64_Rela *) vmlinux.rela_dyn_end;
117805bc0bcSGerald Schaefer 	dynsym = (Elf64_Sym *) vmlinux.dynsym_start;
118805bc0bcSGerald Schaefer 	for (rela = rela_start; rela < rela_end; rela++) {
119805bc0bcSGerald Schaefer 		loc = rela->r_offset + offset;
120ac49303dSGerald Schaefer 		val = rela->r_addend;
121805bc0bcSGerald Schaefer 		r_sym = ELF64_R_SYM(rela->r_info);
122ac49303dSGerald Schaefer 		if (r_sym) {
123ac49303dSGerald Schaefer 			if (dynsym[r_sym].st_shndx != SHN_UNDEF)
124ac49303dSGerald Schaefer 				val += dynsym[r_sym].st_value + offset;
125ac49303dSGerald Schaefer 		} else {
126ac49303dSGerald Schaefer 			/*
127ac49303dSGerald Schaefer 			 * 0 == undefined symbol table index (STN_UNDEF),
128ac49303dSGerald Schaefer 			 * used for R_390_RELATIVE, only add KASLR offset
129ac49303dSGerald Schaefer 			 */
130ac49303dSGerald Schaefer 			val += offset;
131ac49303dSGerald Schaefer 		}
132805bc0bcSGerald Schaefer 		r_type = ELF64_R_TYPE(rela->r_info);
133805bc0bcSGerald Schaefer 		rc = arch_kexec_do_relocs(r_type, (void *) loc, val, 0);
134805bc0bcSGerald Schaefer 		if (rc)
135805bc0bcSGerald Schaefer 			error("Unknown relocation type");
136805bc0bcSGerald Schaefer 	}
137805bc0bcSGerald Schaefer }
138805bc0bcSGerald Schaefer 
139980d5f9aSAlexander Egorenkov /*
14073045a08SVasily Gorbik  * Merge information from several sources into a single ident_map_size value.
14173045a08SVasily Gorbik  * "ident_map_size" represents the upper limit of physical memory we may ever
14273045a08SVasily Gorbik  * reach. It might not be all online memory, but also include standby (offline)
14373045a08SVasily Gorbik  * memory. "ident_map_size" could be lower then actual standby or even online
14473045a08SVasily Gorbik  * memory present, due to limiting factors. We should never go above this limit.
14573045a08SVasily Gorbik  * It is the size of our identity mapping.
14673045a08SVasily Gorbik  *
14773045a08SVasily Gorbik  * Consider the following factors:
14873045a08SVasily Gorbik  * 1. max_physmem_end - end of physical memory online or standby.
14973045a08SVasily Gorbik  *    Always <= end of the last online memory block (get_mem_detect_end()).
15073045a08SVasily Gorbik  * 2. CONFIG_MAX_PHYSMEM_BITS - the maximum size of physical memory the
15173045a08SVasily Gorbik  *    kernel is able to support.
15273045a08SVasily Gorbik  * 3. "mem=" kernel command line option which limits physical memory usage.
15373045a08SVasily Gorbik  * 4. OLDMEM_BASE which is a kdump memory limit when the kernel is executed as
15473045a08SVasily Gorbik  *    crash kernel.
15573045a08SVasily Gorbik  * 5. "hsa" size which is a memory limit when the kernel is executed during
15673045a08SVasily Gorbik  *    zfcp/nvme dump.
15773045a08SVasily Gorbik  */
15873045a08SVasily Gorbik static void setup_ident_map_size(unsigned long max_physmem_end)
15973045a08SVasily Gorbik {
16073045a08SVasily Gorbik 	unsigned long hsa_size;
16173045a08SVasily Gorbik 
16273045a08SVasily Gorbik 	ident_map_size = max_physmem_end;
16373045a08SVasily Gorbik 	if (memory_limit)
16473045a08SVasily Gorbik 		ident_map_size = min(ident_map_size, memory_limit);
16573045a08SVasily Gorbik 	ident_map_size = min(ident_map_size, 1UL << MAX_PHYSMEM_BITS);
16673045a08SVasily Gorbik 
16773045a08SVasily Gorbik #ifdef CONFIG_CRASH_DUMP
16873045a08SVasily Gorbik 	if (OLDMEM_BASE) {
16973045a08SVasily Gorbik 		kaslr_enabled = 0;
17073045a08SVasily Gorbik 		ident_map_size = min(ident_map_size, OLDMEM_SIZE);
17173045a08SVasily Gorbik 	} else if (ipl_block_valid && is_ipl_block_dump()) {
17273045a08SVasily Gorbik 		kaslr_enabled = 0;
17373045a08SVasily Gorbik 		if (!sclp_early_get_hsa_size(&hsa_size) && hsa_size)
17473045a08SVasily Gorbik 			ident_map_size = min(ident_map_size, hsa_size);
17573045a08SVasily Gorbik 	}
17673045a08SVasily Gorbik #endif
17773045a08SVasily Gorbik }
17873045a08SVasily Gorbik 
1790c4f2623SVasily Gorbik static void setup_kernel_memory_layout(void)
1800c4f2623SVasily Gorbik {
1810c4f2623SVasily Gorbik 	bool vmalloc_size_verified = false;
1820c4f2623SVasily Gorbik 	unsigned long vmemmap_off;
1830c4f2623SVasily Gorbik 	unsigned long vspace_left;
1840c4f2623SVasily Gorbik 	unsigned long rte_size;
1850c4f2623SVasily Gorbik 	unsigned long pages;
1860c4f2623SVasily Gorbik 	unsigned long vmax;
1870c4f2623SVasily Gorbik 
1880c4f2623SVasily Gorbik 	pages = ident_map_size / PAGE_SIZE;
1890c4f2623SVasily Gorbik 	/* vmemmap contains a multiple of PAGES_PER_SECTION struct pages */
1900c4f2623SVasily Gorbik 	vmemmap_size = SECTION_ALIGN_UP(pages) * sizeof(struct page);
1910c4f2623SVasily Gorbik 
1920c4f2623SVasily Gorbik 	/* choose kernel address space layout: 4 or 3 levels. */
1930c4f2623SVasily Gorbik 	vmemmap_off = round_up(ident_map_size, _REGION3_SIZE);
1940c4f2623SVasily Gorbik 	if (IS_ENABLED(CONFIG_KASAN) ||
1950c4f2623SVasily Gorbik 	    vmalloc_size > _REGION2_SIZE ||
1960c4f2623SVasily Gorbik 	    vmemmap_off + vmemmap_size + vmalloc_size + MODULES_LEN > _REGION2_SIZE)
1970c4f2623SVasily Gorbik 		vmax = _REGION1_SIZE;
1980c4f2623SVasily Gorbik 	else
1990c4f2623SVasily Gorbik 		vmax = _REGION2_SIZE;
2000c4f2623SVasily Gorbik 
2010c4f2623SVasily Gorbik 	/* keep vmemmap_off aligned to a top level region table entry */
2020c4f2623SVasily Gorbik 	rte_size = vmax == _REGION1_SIZE ? _REGION2_SIZE : _REGION3_SIZE;
2030c4f2623SVasily Gorbik 	MODULES_END = vmax;
2040c4f2623SVasily Gorbik 	if (is_prot_virt_host()) {
2050c4f2623SVasily Gorbik 		/*
2060c4f2623SVasily Gorbik 		 * forcing modules and vmalloc area under the ultravisor
2070c4f2623SVasily Gorbik 		 * secure storage limit, so that any vmalloc allocation
2080c4f2623SVasily Gorbik 		 * we do could be used to back secure guest storage.
2090c4f2623SVasily Gorbik 		 */
2100c4f2623SVasily Gorbik 		adjust_to_uv_max(&MODULES_END);
2110c4f2623SVasily Gorbik 	}
2120c4f2623SVasily Gorbik 
2130c4f2623SVasily Gorbik #ifdef CONFIG_KASAN
2140c4f2623SVasily Gorbik 	if (MODULES_END < vmax) {
2150c4f2623SVasily Gorbik 		/* force vmalloc and modules below kasan shadow */
2160c4f2623SVasily Gorbik 		MODULES_END = min(MODULES_END, KASAN_SHADOW_START);
2170c4f2623SVasily Gorbik 	} else {
2180c4f2623SVasily Gorbik 		/*
2190c4f2623SVasily Gorbik 		 * leave vmalloc and modules above kasan shadow but make
2200c4f2623SVasily Gorbik 		 * sure they don't overlap with it
2210c4f2623SVasily Gorbik 		 */
2220c4f2623SVasily Gorbik 		vmalloc_size = min(vmalloc_size, vmax - KASAN_SHADOW_END - MODULES_LEN);
2230c4f2623SVasily Gorbik 		vmalloc_size_verified = true;
2240c4f2623SVasily Gorbik 		vspace_left = KASAN_SHADOW_START;
2250c4f2623SVasily Gorbik 	}
2260c4f2623SVasily Gorbik #endif
2270c4f2623SVasily Gorbik 	MODULES_VADDR = MODULES_END - MODULES_LEN;
2280c4f2623SVasily Gorbik 	VMALLOC_END = MODULES_VADDR;
2290c4f2623SVasily Gorbik 
2300c4f2623SVasily Gorbik 	if (vmalloc_size_verified) {
2310c4f2623SVasily Gorbik 		VMALLOC_START = VMALLOC_END - vmalloc_size;
2320c4f2623SVasily Gorbik 	} else {
2330c4f2623SVasily Gorbik 		vmemmap_off = round_up(ident_map_size, rte_size);
2340c4f2623SVasily Gorbik 
2350c4f2623SVasily Gorbik 		if (vmemmap_off + vmemmap_size > VMALLOC_END ||
2360c4f2623SVasily Gorbik 		    vmalloc_size > VMALLOC_END - vmemmap_off - vmemmap_size) {
2370c4f2623SVasily Gorbik 			/*
2380c4f2623SVasily Gorbik 			 * allow vmalloc area to occupy up to 1/2 of
2390c4f2623SVasily Gorbik 			 * the rest virtual space left.
2400c4f2623SVasily Gorbik 			 */
2410c4f2623SVasily Gorbik 			vmalloc_size = min(vmalloc_size, VMALLOC_END / 2);
2420c4f2623SVasily Gorbik 		}
2430c4f2623SVasily Gorbik 		VMALLOC_START = VMALLOC_END - vmalloc_size;
2440c4f2623SVasily Gorbik 		vspace_left = VMALLOC_START;
2450c4f2623SVasily Gorbik 	}
2460c4f2623SVasily Gorbik 
2470c4f2623SVasily Gorbik 	pages = vspace_left / (PAGE_SIZE + sizeof(struct page));
2480c4f2623SVasily Gorbik 	pages = SECTION_ALIGN_UP(pages);
2490c4f2623SVasily Gorbik 	vmemmap_off = round_up(vspace_left - pages * sizeof(struct page), rte_size);
2500c4f2623SVasily Gorbik 	/* keep vmemmap left most starting from a fresh region table entry */
2510c4f2623SVasily Gorbik 	vmemmap_off = min(vmemmap_off, round_up(ident_map_size, rte_size));
2520c4f2623SVasily Gorbik 	/* take care that identity map is lower then vmemmap */
2530c4f2623SVasily Gorbik 	ident_map_size = min(ident_map_size, vmemmap_off);
2540c4f2623SVasily Gorbik 	vmemmap_size = SECTION_ALIGN_UP(ident_map_size / PAGE_SIZE) * sizeof(struct page);
2550c4f2623SVasily Gorbik 	VMALLOC_START = max(vmemmap_off + vmemmap_size, VMALLOC_START);
2560c4f2623SVasily Gorbik 	vmemmap = (struct page *)vmemmap_off;
2570c4f2623SVasily Gorbik }
2580c4f2623SVasily Gorbik 
25973045a08SVasily Gorbik /*
260980d5f9aSAlexander Egorenkov  * This function clears the BSS section of the decompressed Linux kernel and NOT the decompressor's.
261980d5f9aSAlexander Egorenkov  */
2622e83e0ebSVasily Gorbik static void clear_bss_section(void)
2632e83e0ebSVasily Gorbik {
2642e83e0ebSVasily Gorbik 	memset((void *)vmlinux.default_lma + vmlinux.image_size, 0, vmlinux.bss_size);
2652e83e0ebSVasily Gorbik }
2662e83e0ebSVasily Gorbik 
26790178c19SHeiko Carstens /*
26890178c19SHeiko Carstens  * Set vmalloc area size to an 8th of (potential) physical memory
26990178c19SHeiko Carstens  * size, unless size has been set by kernel command line parameter.
27090178c19SHeiko Carstens  */
27190178c19SHeiko Carstens static void setup_vmalloc_size(void)
27290178c19SHeiko Carstens {
27390178c19SHeiko Carstens 	unsigned long size;
27490178c19SHeiko Carstens 
27590178c19SHeiko Carstens 	if (vmalloc_size_set)
27690178c19SHeiko Carstens 		return;
27773045a08SVasily Gorbik 	size = round_up(ident_map_size / 8, _SEGMENT_SIZE);
27890178c19SHeiko Carstens 	vmalloc_size = max(size, vmalloc_size);
27990178c19SHeiko Carstens }
28090178c19SHeiko Carstens 
2818f75582aSVasily Gorbik void startup_kernel(void)
2828f75582aSVasily Gorbik {
283b2d24b97SGerald Schaefer 	unsigned long random_lma;
2849641b8ccSMartin Schwidefsky 	unsigned long safe_addr;
285369f91c3SVasily Gorbik 	void *img;
2868f75582aSVasily Gorbik 
287*84733284SAlexander Egorenkov 	initrd_data.start = parmarea.initrd_start;
288*84733284SAlexander Egorenkov 	initrd_data.size = parmarea.initrd_size;
289*84733284SAlexander Egorenkov 
290d7e7fbbaSVasily Gorbik 	setup_lpp();
29149698745SVasily Gorbik 	store_ipl_parmblock();
2929641b8ccSMartin Schwidefsky 	safe_addr = mem_safe_offset();
2939641b8ccSMartin Schwidefsky 	safe_addr = read_ipl_report(safe_addr);
2949641b8ccSMartin Schwidefsky 	uv_query_info();
2959641b8ccSMartin Schwidefsky 	rescue_initrd(safe_addr);
2969641b8ccSMartin Schwidefsky 	sclp_early_read_info();
29749698745SVasily Gorbik 	setup_boot_command_line();
298b5e80459SVasily Gorbik 	parse_boot_command_line();
29942c89439SAlexander Egorenkov 	sanitize_prot_virt_host();
30073045a08SVasily Gorbik 	setup_ident_map_size(detect_memory());
30190178c19SHeiko Carstens 	setup_vmalloc_size();
3020c4f2623SVasily Gorbik 	setup_kernel_memory_layout();
303b2d24b97SGerald Schaefer 
304b2d24b97SGerald Schaefer 	random_lma = __kaslr_offset = 0;
305b2d24b97SGerald Schaefer 	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_enabled) {
306b2d24b97SGerald Schaefer 		random_lma = get_random_base(safe_addr);
307b2d24b97SGerald Schaefer 		if (random_lma) {
308b2d24b97SGerald Schaefer 			__kaslr_offset = random_lma - vmlinux.default_lma;
309b2d24b97SGerald Schaefer 			img = (void *)vmlinux.default_lma;
310b2d24b97SGerald Schaefer 			vmlinux.default_lma += __kaslr_offset;
311b2d24b97SGerald Schaefer 			vmlinux.entry += __kaslr_offset;
312b2d24b97SGerald Schaefer 			vmlinux.bootdata_off += __kaslr_offset;
313b2d24b97SGerald Schaefer 			vmlinux.bootdata_preserved_off += __kaslr_offset;
314b2d24b97SGerald Schaefer 			vmlinux.rela_dyn_start += __kaslr_offset;
315b2d24b97SGerald Schaefer 			vmlinux.rela_dyn_end += __kaslr_offset;
316b2d24b97SGerald Schaefer 			vmlinux.dynsym_start += __kaslr_offset;
317b2d24b97SGerald Schaefer 		}
318b2d24b97SGerald Schaefer 	}
319b2d24b97SGerald Schaefer 
3208f75582aSVasily Gorbik 	if (!IS_ENABLED(CONFIG_KERNEL_UNCOMPRESSED)) {
321369f91c3SVasily Gorbik 		img = decompress_kernel();
322369f91c3SVasily Gorbik 		memmove((void *)vmlinux.default_lma, img, vmlinux.image_size);
323b2d24b97SGerald Schaefer 	} else if (__kaslr_offset)
324b2d24b97SGerald Schaefer 		memcpy((void *)vmlinux.default_lma, img, vmlinux.image_size);
325b2d24b97SGerald Schaefer 
3262e83e0ebSVasily Gorbik 	clear_bss_section();
327d1b52a43SVasily Gorbik 	copy_bootdata();
328805bc0bcSGerald Schaefer 	if (IS_ENABLED(CONFIG_RELOCATABLE))
329b2d24b97SGerald Schaefer 		handle_relocs(__kaslr_offset);
330b2d24b97SGerald Schaefer 
331b2d24b97SGerald Schaefer 	if (__kaslr_offset) {
332a9f2f686SGerald Schaefer 		/*
333a9f2f686SGerald Schaefer 		 * Save KASLR offset for early dumps, before vmcore_info is set.
334a9f2f686SGerald Schaefer 		 * Mark as uneven to distinguish from real vmcore_info pointer.
335a9f2f686SGerald Schaefer 		 */
336a9f2f686SGerald Schaefer 		S390_lowcore.vmcore_info = __kaslr_offset | 0x1UL;
337b2d24b97SGerald Schaefer 		/* Clear non-relocated kernel */
338b2d24b97SGerald Schaefer 		if (IS_ENABLED(CONFIG_KERNEL_UNCOMPRESSED))
339b2d24b97SGerald Schaefer 			memset(img, 0, vmlinux.image_size);
340b2d24b97SGerald Schaefer 	}
341369f91c3SVasily Gorbik 	vmlinux.entry();
3428f75582aSVasily Gorbik }
343