startup.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/string.h>
  3. #include <linux/elf.h>
  4. #include <asm/page-states.h>
  5. #include <asm/boot_data.h>
  6. #include <asm/extmem.h>
  7. #include <asm/sections.h>
  8. #include <asm/maccess.h>
  9. #include <asm/cpu_mf.h>
  10. #include <asm/setup.h>
  11. #include <asm/kasan.h>
  12. #include <asm/kexec.h>
  13. #include <asm/sclp.h>
  14. #include <asm/diag.h>
  15. #include <asm/uv.h>
  16. #include <asm/abs_lowcore.h>
  17. #include <asm/physmem_info.h>
  18. #include "decompressor.h"
  19. #include "boot.h"
  20. #include "uv.h"
  21. struct vm_layout __bootdata_preserved(vm_layout);
  22. unsigned long __bootdata_preserved(__abs_lowcore);
  23. unsigned long __bootdata_preserved(__memcpy_real_area);
  24. pte_t *__bootdata_preserved(memcpy_real_ptep);
  25. unsigned long __bootdata_preserved(VMALLOC_START);
  26. unsigned long __bootdata_preserved(VMALLOC_END);
  27. struct page *__bootdata_preserved(vmemmap);
  28. unsigned long __bootdata_preserved(vmemmap_size);
  29. unsigned long __bootdata_preserved(MODULES_VADDR);
  30. unsigned long __bootdata_preserved(MODULES_END);
  31. unsigned long __bootdata_preserved(max_mappable);
  32. int __bootdata_preserved(relocate_lowcore);
  33. u64 __bootdata_preserved(stfle_fac_list[16]);
  34. struct oldmem_data __bootdata_preserved(oldmem_data);
  35. struct machine_info machine;
  36. void error(char *x)
  37. {
  38. boot_printk("\n\n%s\n\n -- System halted", x);
  39. disabled_wait();
  40. }
  41. static void detect_facilities(void)
  42. {
  43. if (test_facility(8)) {
  44. machine.has_edat1 = 1;
  45. local_ctl_set_bit(0, CR0_EDAT_BIT);
  46. }
  47. if (test_facility(78))
  48. machine.has_edat2 = 1;
  49. if (test_facility(130))
  50. machine.has_nx = 1;
  51. }
  52. static int cmma_test_essa(void)
  53. {
  54. unsigned long reg1, reg2, tmp = 0;
  55. int rc = 1;
  56. psw_t old;
  57. /* Test ESSA_GET_STATE */
  58. asm volatile(
  59. " mvc 0(16,%[psw_old]),0(%[psw_pgm])\n"
  60. " epsw %[reg1],%[reg2]\n"
  61. " st %[reg1],0(%[psw_pgm])\n"
  62. " st %[reg2],4(%[psw_pgm])\n"
  63. " larl %[reg1],1f\n"
  64. " stg %[reg1],8(%[psw_pgm])\n"
  65. " .insn rrf,0xb9ab0000,%[tmp],%[tmp],%[cmd],0\n"
  66. " la %[rc],0\n"
  67. "1: mvc 0(16,%[psw_pgm]),0(%[psw_old])\n"
  68. : [reg1] "=&d" (reg1),
  69. [reg2] "=&a" (reg2),
  70. [rc] "+&d" (rc),
  71. [tmp] "=&d" (tmp),
  72. "+Q" (get_lowcore()->program_new_psw),
  73. "=Q" (old)
  74. : [psw_old] "a" (&old),
  75. [psw_pgm] "a" (&get_lowcore()->program_new_psw),
  76. [cmd] "i" (ESSA_GET_STATE)
  77. : "cc", "memory");
  78. return rc;
  79. }
  80. static void cmma_init(void)
  81. {
  82. if (!cmma_flag)
  83. return;
  84. if (cmma_test_essa()) {
  85. cmma_flag = 0;
  86. return;
  87. }
  88. if (test_facility(147))
  89. cmma_flag = 2;
  90. }
  91. static void setup_lpp(void)
  92. {
  93. get_lowcore()->current_pid = 0;
  94. get_lowcore()->lpp = LPP_MAGIC;
  95. if (test_facility(40))
  96. lpp(&get_lowcore()->lpp);
  97. }
  98. #ifdef CONFIG_KERNEL_UNCOMPRESSED
  99. static unsigned long mem_safe_offset(void)
  100. {
  101. return (unsigned long)_compressed_start;
  102. }
  103. static void deploy_kernel(void *output)
  104. {
  105. void *uncompressed_start = (void *)_compressed_start;
  106. if (output == uncompressed_start)
  107. return;
  108. memmove(output, uncompressed_start, vmlinux.image_size);
  109. memset(uncompressed_start, 0, vmlinux.image_size);
  110. }
  111. #endif
  112. static void rescue_initrd(unsigned long min, unsigned long max)
  113. {
  114. unsigned long old_addr, addr, size;
  115. if (!IS_ENABLED(CONFIG_BLK_DEV_INITRD))
  116. return;
  117. if (!get_physmem_reserved(RR_INITRD, &addr, &size))
  118. return;
  119. if (addr >= min && addr + size <= max)
  120. return;
  121. old_addr = addr;
  122. physmem_free(RR_INITRD);
  123. addr = physmem_alloc_top_down(RR_INITRD, size, 0);
  124. memmove((void *)addr, (void *)old_addr, size);
  125. }
  126. static void copy_bootdata(void)
  127. {
  128. if (__boot_data_end - __boot_data_start != vmlinux.bootdata_size)
  129. error(".boot.data section size mismatch");
  130. memcpy((void *)vmlinux.bootdata_off, __boot_data_start, vmlinux.bootdata_size);
  131. if (__boot_data_preserved_end - __boot_data_preserved_start != vmlinux.bootdata_preserved_size)
  132. error(".boot.preserved.data section size mismatch");
  133. memcpy((void *)vmlinux.bootdata_preserved_off, __boot_data_preserved_start, vmlinux.bootdata_preserved_size);
  134. }
  135. static void kaslr_adjust_relocs(unsigned long min_addr, unsigned long max_addr,
  136. unsigned long offset, unsigned long phys_offset)
  137. {
  138. int *reloc;
  139. long loc;
  140. /* Adjust R_390_64 relocations */
  141. for (reloc = (int *)__vmlinux_relocs_64_start; reloc < (int *)__vmlinux_relocs_64_end; reloc++) {
  142. loc = (long)*reloc + phys_offset;
  143. if (loc < min_addr || loc > max_addr)
  144. error("64-bit relocation outside of kernel!\n");
  145. *(u64 *)loc += offset;
  146. }
  147. }
  148. static void kaslr_adjust_got(unsigned long offset)
  149. {
  150. u64 *entry;
  151. /*
  152. * Adjust GOT entries, except for ones for undefined weak symbols
  153. * that resolved to zero. This also skips the first three reserved
  154. * entries on s390x that are zero.
  155. */
  156. for (entry = (u64 *)vmlinux.got_start; entry < (u64 *)vmlinux.got_end; entry++) {
  157. if (*entry)
  158. *entry += offset;
  159. }
  160. }
  161. /*
  162. * Merge information from several sources into a single ident_map_size value.
  163. * "ident_map_size" represents the upper limit of physical memory we may ever
  164. * reach. It might not be all online memory, but also include standby (offline)
  165. * memory. "ident_map_size" could be lower then actual standby or even online
  166. * memory present, due to limiting factors. We should never go above this limit.
  167. * It is the size of our identity mapping.
  168. *
  169. * Consider the following factors:
  170. * 1. max_physmem_end - end of physical memory online or standby.
  171. * Always >= end of the last online memory range (get_physmem_online_end()).
  172. * 2. CONFIG_MAX_PHYSMEM_BITS - the maximum size of physical memory the
  173. * kernel is able to support.
  174. * 3. "mem=" kernel command line option which limits physical memory usage.
  175. * 4. OLDMEM_BASE which is a kdump memory limit when the kernel is executed as
  176. * crash kernel.
  177. * 5. "hsa" size which is a memory limit when the kernel is executed during
  178. * zfcp/nvme dump.
  179. */
  180. static void setup_ident_map_size(unsigned long max_physmem_end)
  181. {
  182. unsigned long hsa_size;
  183. ident_map_size = max_physmem_end;
  184. if (memory_limit)
  185. ident_map_size = min(ident_map_size, memory_limit);
  186. ident_map_size = min(ident_map_size, 1UL << MAX_PHYSMEM_BITS);
  187. #ifdef CONFIG_CRASH_DUMP
  188. if (oldmem_data.start) {
  189. __kaslr_enabled = 0;
  190. ident_map_size = min(ident_map_size, oldmem_data.size);
  191. } else if (ipl_block_valid && is_ipl_block_dump()) {
  192. __kaslr_enabled = 0;
  193. if (!sclp_early_get_hsa_size(&hsa_size) && hsa_size)
  194. ident_map_size = min(ident_map_size, hsa_size);
  195. }
  196. #endif
  197. }
  198. #define FIXMAP_SIZE round_up(MEMCPY_REAL_SIZE + ABS_LOWCORE_MAP_SIZE, sizeof(struct lowcore))
  199. static unsigned long get_vmem_size(unsigned long identity_size,
  200. unsigned long vmemmap_size,
  201. unsigned long vmalloc_size,
  202. unsigned long rte_size)
  203. {
  204. unsigned long max_mappable, vsize;
  205. max_mappable = max(identity_size, MAX_DCSS_ADDR);
  206. vsize = round_up(SZ_2G + max_mappable, rte_size) +
  207. round_up(vmemmap_size, rte_size) +
  208. FIXMAP_SIZE + MODULES_LEN + KASLR_LEN;
  209. if (IS_ENABLED(CONFIG_KMSAN))
  210. vsize += MODULES_LEN * 2;
  211. return size_add(vsize, vmalloc_size);
  212. }
  213. static unsigned long setup_kernel_memory_layout(unsigned long kernel_size)
  214. {
  215. unsigned long vmemmap_start;
  216. unsigned long kernel_start;
  217. unsigned long asce_limit;
  218. unsigned long rte_size;
  219. unsigned long pages;
  220. unsigned long vsize;
  221. unsigned long vmax;
  222. pages = ident_map_size / PAGE_SIZE;
  223. /* vmemmap contains a multiple of PAGES_PER_SECTION struct pages */
  224. vmemmap_size = SECTION_ALIGN_UP(pages) * sizeof(struct page);
  225. /* choose kernel address space layout: 4 or 3 levels. */
  226. BUILD_BUG_ON(!IS_ALIGNED(TEXT_OFFSET, THREAD_SIZE));
  227. BUILD_BUG_ON(!IS_ALIGNED(__NO_KASLR_START_KERNEL, THREAD_SIZE));
  228. BUILD_BUG_ON(__NO_KASLR_END_KERNEL > _REGION1_SIZE);
  229. vsize = get_vmem_size(ident_map_size, vmemmap_size, vmalloc_size, _REGION3_SIZE);
  230. if (IS_ENABLED(CONFIG_KASAN) || __NO_KASLR_END_KERNEL > _REGION2_SIZE ||
  231. (vsize > _REGION2_SIZE && kaslr_enabled())) {
  232. asce_limit = _REGION1_SIZE;
  233. if (__NO_KASLR_END_KERNEL > _REGION2_SIZE) {
  234. rte_size = _REGION2_SIZE;
  235. vsize = get_vmem_size(ident_map_size, vmemmap_size, vmalloc_size, _REGION2_SIZE);
  236. } else {
  237. rte_size = _REGION3_SIZE;
  238. }
  239. } else {
  240. asce_limit = _REGION2_SIZE;
  241. rte_size = _REGION3_SIZE;
  242. }
  243. /*
  244. * Forcing modules and vmalloc area under the ultravisor
  245. * secure storage limit, so that any vmalloc allocation
  246. * we do could be used to back secure guest storage.
  247. *
  248. * Assume the secure storage limit always exceeds _REGION2_SIZE,
  249. * otherwise asce_limit and rte_size would have been adjusted.
  250. */
  251. vmax = adjust_to_uv_max(asce_limit);
  252. #ifdef CONFIG_KASAN
  253. BUILD_BUG_ON(__NO_KASLR_END_KERNEL > KASAN_SHADOW_START);
  254. /* force vmalloc and modules below kasan shadow */
  255. vmax = min(vmax, KASAN_SHADOW_START);
  256. #endif
  257. vsize = min(vsize, vmax);
  258. if (kaslr_enabled()) {
  259. unsigned long kernel_end, kaslr_len, slots, pos;
  260. kaslr_len = max(KASLR_LEN, vmax - vsize);
  261. slots = DIV_ROUND_UP(kaslr_len - kernel_size, THREAD_SIZE);
  262. if (get_random(slots, &pos))
  263. pos = 0;
  264. kernel_end = vmax - pos * THREAD_SIZE;
  265. kernel_start = round_down(kernel_end - kernel_size, THREAD_SIZE);
  266. } else if (vmax < __NO_KASLR_END_KERNEL || vsize > __NO_KASLR_END_KERNEL) {
  267. kernel_start = round_down(vmax - kernel_size, THREAD_SIZE);
  268. boot_printk("The kernel base address is forced to %lx\n", kernel_start);
  269. } else {
  270. kernel_start = __NO_KASLR_START_KERNEL;
  271. }
  272. __kaslr_offset = kernel_start;
  273. MODULES_END = round_down(kernel_start, _SEGMENT_SIZE);
  274. MODULES_VADDR = MODULES_END - MODULES_LEN;
  275. VMALLOC_END = MODULES_VADDR;
  276. if (IS_ENABLED(CONFIG_KMSAN))
  277. VMALLOC_END -= MODULES_LEN * 2;
  278. /* allow vmalloc area to occupy up to about 1/2 of the rest virtual space left */
  279. vsize = (VMALLOC_END - FIXMAP_SIZE) / 2;
  280. vsize = round_down(vsize, _SEGMENT_SIZE);
  281. vmalloc_size = min(vmalloc_size, vsize);
  282. if (IS_ENABLED(CONFIG_KMSAN)) {
  283. /* take 2/3 of vmalloc area for KMSAN shadow and origins */
  284. vmalloc_size = round_down(vmalloc_size / 3, _SEGMENT_SIZE);
  285. VMALLOC_END -= vmalloc_size * 2;
  286. }
  287. VMALLOC_START = VMALLOC_END - vmalloc_size;
  288. __memcpy_real_area = round_down(VMALLOC_START - MEMCPY_REAL_SIZE, PAGE_SIZE);
  289. __abs_lowcore = round_down(__memcpy_real_area - ABS_LOWCORE_MAP_SIZE,
  290. sizeof(struct lowcore));
  291. /* split remaining virtual space between 1:1 mapping & vmemmap array */
  292. pages = __abs_lowcore / (PAGE_SIZE + sizeof(struct page));
  293. pages = SECTION_ALIGN_UP(pages);
  294. /* keep vmemmap_start aligned to a top level region table entry */
  295. vmemmap_start = round_down(__abs_lowcore - pages * sizeof(struct page), rte_size);
  296. /* make sure identity map doesn't overlay with vmemmap */
  297. ident_map_size = min(ident_map_size, vmemmap_start);
  298. vmemmap_size = SECTION_ALIGN_UP(ident_map_size / PAGE_SIZE) * sizeof(struct page);
  299. /* make sure vmemmap doesn't overlay with absolute lowcore area */
  300. if (vmemmap_start + vmemmap_size > __abs_lowcore) {
  301. vmemmap_size = SECTION_ALIGN_DOWN(ident_map_size / PAGE_SIZE) * sizeof(struct page);
  302. ident_map_size = vmemmap_size / sizeof(struct page) * PAGE_SIZE;
  303. }
  304. vmemmap = (struct page *)vmemmap_start;
  305. /* maximum address for which linear mapping could be created (DCSS, memory) */
  306. BUILD_BUG_ON(MAX_DCSS_ADDR > (1UL << MAX_PHYSMEM_BITS));
  307. max_mappable = max(ident_map_size, MAX_DCSS_ADDR);
  308. max_mappable = min(max_mappable, vmemmap_start);
  309. if (IS_ENABLED(CONFIG_RANDOMIZE_IDENTITY_BASE))
  310. __identity_base = round_down(vmemmap_start - max_mappable, rte_size);
  311. return asce_limit;
  312. }
  313. /*
  314. * This function clears the BSS section of the decompressed Linux kernel and NOT the decompressor's.
  315. */
  316. static void clear_bss_section(unsigned long kernel_start)
  317. {
  318. memset((void *)kernel_start + vmlinux.image_size, 0, vmlinux.bss_size);
  319. }
  320. /*
  321. * Set vmalloc area size to an 8th of (potential) physical memory
  322. * size, unless size has been set by kernel command line parameter.
  323. */
  324. static void setup_vmalloc_size(void)
  325. {
  326. unsigned long size;
  327. if (vmalloc_size_set)
  328. return;
  329. size = round_up(ident_map_size / 8, _SEGMENT_SIZE);
  330. vmalloc_size = max(size, vmalloc_size);
  331. }
  332. static void kaslr_adjust_vmlinux_info(long offset)
  333. {
  334. vmlinux.bootdata_off += offset;
  335. vmlinux.bootdata_preserved_off += offset;
  336. vmlinux.got_start += offset;
  337. vmlinux.got_end += offset;
  338. vmlinux.init_mm_off += offset;
  339. vmlinux.swapper_pg_dir_off += offset;
  340. vmlinux.invalid_pg_dir_off += offset;
  341. vmlinux.alt_instructions += offset;
  342. vmlinux.alt_instructions_end += offset;
  343. #ifdef CONFIG_KASAN
  344. vmlinux.kasan_early_shadow_page_off += offset;
  345. vmlinux.kasan_early_shadow_pte_off += offset;
  346. vmlinux.kasan_early_shadow_pmd_off += offset;
  347. vmlinux.kasan_early_shadow_pud_off += offset;
  348. vmlinux.kasan_early_shadow_p4d_off += offset;
  349. #endif
  350. }
  351. void startup_kernel(void)
  352. {
  353. unsigned long vmlinux_size = vmlinux.image_size + vmlinux.bss_size;
  354. unsigned long nokaslr_text_lma, text_lma = 0, amode31_lma = 0;
  355. unsigned long kernel_size = TEXT_OFFSET + vmlinux_size;
  356. unsigned long kaslr_large_page_offset;
  357. unsigned long max_physmem_end;
  358. unsigned long asce_limit;
  359. unsigned long safe_addr;
  360. psw_t psw;
  361. setup_lpp();
  362. /*
  363. * Non-randomized kernel physical start address must be _SEGMENT_SIZE
  364. * aligned (see blow).
  365. */
  366. nokaslr_text_lma = ALIGN(mem_safe_offset(), _SEGMENT_SIZE);
  367. safe_addr = PAGE_ALIGN(nokaslr_text_lma + vmlinux_size);
  368. /*
  369. * Reserve decompressor memory together with decompression heap,
  370. * buffer and memory which might be occupied by uncompressed kernel
  371. * (if KASLR is off or failed).
  372. */
  373. physmem_reserve(RR_DECOMPRESSOR, 0, safe_addr);
  374. if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && parmarea.initrd_size)
  375. physmem_reserve(RR_INITRD, parmarea.initrd_start, parmarea.initrd_size);
  376. oldmem_data.start = parmarea.oldmem_base;
  377. oldmem_data.size = parmarea.oldmem_size;
  378. store_ipl_parmblock();
  379. read_ipl_report();
  380. uv_query_info();
  381. sclp_early_read_info();
  382. setup_boot_command_line();
  383. parse_boot_command_line();
  384. detect_facilities();
  385. cmma_init();
  386. sanitize_prot_virt_host();
  387. max_physmem_end = detect_max_physmem_end();
  388. setup_ident_map_size(max_physmem_end);
  389. setup_vmalloc_size();
  390. asce_limit = setup_kernel_memory_layout(kernel_size);
  391. /* got final ident_map_size, physmem allocations could be performed now */
  392. physmem_set_usable_limit(ident_map_size);
  393. detect_physmem_online_ranges(max_physmem_end);
  394. save_ipl_cert_comp_list();
  395. rescue_initrd(safe_addr, ident_map_size);
  396. /*
  397. * __kaslr_offset_phys must be _SEGMENT_SIZE aligned, so the lower
  398. * 20 bits (the offset within a large page) are zero. Copy the last
  399. * 20 bits of __kaslr_offset, which is THREAD_SIZE aligned, to
  400. * __kaslr_offset_phys.
  401. *
  402. * With this the last 20 bits of __kaslr_offset_phys and __kaslr_offset
  403. * are identical, which is required to allow for large mappings of the
  404. * kernel image.
  405. */
  406. kaslr_large_page_offset = __kaslr_offset & ~_SEGMENT_MASK;
  407. if (kaslr_enabled()) {
  408. unsigned long size = vmlinux_size + kaslr_large_page_offset;
  409. text_lma = randomize_within_range(size, _SEGMENT_SIZE, TEXT_OFFSET, ident_map_size);
  410. }
  411. if (!text_lma)
  412. text_lma = nokaslr_text_lma;
  413. text_lma |= kaslr_large_page_offset;
  414. /*
  415. * [__kaslr_offset_phys..__kaslr_offset_phys + TEXT_OFFSET] region is
  416. * never accessed via the kernel image mapping as per the linker script:
  417. *
  418. * . = TEXT_OFFSET;
  419. *
  420. * Therefore, this region could be used for something else and does
  421. * not need to be reserved. See how it is skipped in setup_vmem().
  422. */
  423. __kaslr_offset_phys = text_lma - TEXT_OFFSET;
  424. kaslr_adjust_vmlinux_info(__kaslr_offset_phys);
  425. physmem_reserve(RR_VMLINUX, text_lma, vmlinux_size);
  426. deploy_kernel((void *)text_lma);
  427. /* vmlinux decompression is done, shrink reserved low memory */
  428. physmem_reserve(RR_DECOMPRESSOR, 0, (unsigned long)_decompressor_end);
  429. /*
  430. * In case KASLR is enabled the randomized location of .amode31
  431. * section might overlap with .vmlinux.relocs section. To avoid that
  432. * the below randomize_within_range() could have been called with
  433. * __vmlinux_relocs_64_end as the lower range address. However,
  434. * .amode31 section is written to by the decompressed kernel - at
  435. * that time the contents of .vmlinux.relocs is not needed anymore.
  436. * Conversly, .vmlinux.relocs is read only by the decompressor, even
  437. * before the kernel started. Therefore, in case the two sections
  438. * overlap there is no risk of corrupting any data.
  439. */
  440. if (kaslr_enabled()) {
  441. unsigned long amode31_min;
  442. amode31_min = (unsigned long)_decompressor_end;
  443. amode31_lma = randomize_within_range(vmlinux.amode31_size, PAGE_SIZE, amode31_min, SZ_2G);
  444. }
  445. if (!amode31_lma)
  446. amode31_lma = text_lma - vmlinux.amode31_size;
  447. physmem_reserve(RR_AMODE31, amode31_lma, vmlinux.amode31_size);
  448. /*
  449. * The order of the following operations is important:
  450. *
  451. * - kaslr_adjust_relocs() must follow clear_bss_section() to establish
  452. * static memory references to data in .bss to be used by setup_vmem()
  453. * (i.e init_mm.pgd)
  454. *
  455. * - setup_vmem() must follow kaslr_adjust_relocs() to be able using
  456. * static memory references to data in .bss (i.e init_mm.pgd)
  457. *
  458. * - copy_bootdata() must follow setup_vmem() to propagate changes
  459. * to bootdata made by setup_vmem()
  460. */
  461. clear_bss_section(text_lma);
  462. kaslr_adjust_relocs(text_lma, text_lma + vmlinux.image_size,
  463. __kaslr_offset, __kaslr_offset_phys);
  464. kaslr_adjust_got(__kaslr_offset);
  465. setup_vmem(__kaslr_offset, __kaslr_offset + kernel_size, asce_limit);
  466. copy_bootdata();
  467. __apply_alternatives((struct alt_instr *)_vmlinux_info.alt_instructions,
  468. (struct alt_instr *)_vmlinux_info.alt_instructions_end,
  469. ALT_CTX_EARLY);
  470. /*
  471. * Save KASLR offset for early dumps, before vmcore_info is set.
  472. * Mark as uneven to distinguish from real vmcore_info pointer.
  473. */
  474. get_lowcore()->vmcore_info = __kaslr_offset_phys ? __kaslr_offset_phys | 0x1UL : 0;
  475. /*
  476. * Jump to the decompressed kernel entry point and switch DAT mode on.
  477. */
  478. psw.addr = __kaslr_offset + vmlinux.entry;
  479. psw.mask = PSW_KERNEL_BITS;
  480. __load_psw(psw);
  481. }