Lines Matching +full:boot +full:- +full:pages
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (C) 2002-2005 Eric Biederman <[email protected]>
27 #include <asm/kexec-bzimage64.h>
47 return kernel_ident_mapping_init(data->info, data->level4p, in mem_region_callback()
48 res->start, res->end + 1); in mem_region_callback()
62 ret = walk_iomem_res_desc(IORES_DESC_ACPI_TABLES, flags, 0, -1, in map_acpi_tables()
64 if (ret && ret != -EINVAL) in map_acpi_tables()
67 /* ACPI tables could be located in ACPI Non-volatile Storage region */ in map_acpi_tables()
68 ret = walk_iomem_res_desc(IORES_DESC_ACPI_NV_STORAGE, flags, 0, -1, in map_acpi_tables()
70 if (ret && ret != -EINVAL) in map_acpi_tables()
112 kaddr = memremap(mstart, mend - mstart, MEMREMAP_WB); in map_efi_systab()
115 return -ENOMEM; in map_efi_systab()
123 mend = mstart + sizeof(efi_config_table_64_t) * stbl->nr_tables; in map_efi_systab()
127 mend = mstart + sizeof(efi_config_table_32_t) * stbl->nr_tables; in map_efi_systab()
139 free_page((unsigned long)image->arch.p4d); in free_transition_pgtable()
140 image->arch.p4d = NULL; in free_transition_pgtable()
141 free_page((unsigned long)image->arch.pud); in free_transition_pgtable()
142 image->arch.pud = NULL; in free_transition_pgtable()
143 free_page((unsigned long)image->arch.pmd); in free_transition_pgtable()
144 image->arch.pmd = NULL; in free_transition_pgtable()
145 free_page((unsigned long)image->arch.pte); in free_transition_pgtable()
146 image->arch.pte = NULL; in free_transition_pgtable()
154 int result = -ENOMEM; in init_transition_pgtable()
172 image->arch.p4d = p4d; in init_transition_pgtable()
180 image->arch.pud = pud; in init_transition_pgtable()
188 image->arch.pmd = pmd; in init_transition_pgtable()
196 image->arch.pte = pte; in init_transition_pgtable()
237 image->arch.pgd = alloc_pgt_page(image); in init_pgtable()
238 if (!image->arch.pgd) in init_pgtable()
239 return -ENOMEM; in init_pgtable()
253 result = kernel_ident_mapping_init(&info, image->arch.pgd, in init_pgtable()
265 for (i = 0; i < image->nr_segments; i++) { in init_pgtable()
266 mstart = image->segment[i].mem; in init_pgtable()
267 mend = mstart + image->segment[i].memsz; in init_pgtable()
269 result = kernel_ident_mapping_init(&info, image->arch.pgd, in init_pgtable()
280 result = map_efi_systab(&info, image->arch.pgd); in init_pgtable()
284 result = map_acpi_tables(&info, image->arch.pgd); in init_pgtable()
289 * This must be last because the intermediate page table pages it in init_pgtable()
290 * allocates will not be control pages and may overlap the image. in init_pgtable()
292 return init_transition_pgtable(image, image->arch.pgd, control_page); in init_pgtable()
309 void *control_page = page_address(image->control_code_page); in machine_kexec_prepare()
319 kexec_pa_table_page = (unsigned long)__pa(image->arch.pgd); in machine_kexec_prepare()
321 if (image->type == KEXEC_TYPE_DEFAULT) in machine_kexec_prepare()
322 kexec_pa_swap_page = page_to_pfn(image->swap_page) << PAGE_SHIFT; in machine_kexec_prepare()
324 __memcpy(control_page, __relocate_kernel_start, reloc_end - reloc_start); in machine_kexec_prepare()
333 void *control_page = page_address(image->control_code_page); in machine_kexec_cleanup()
360 if (image->preserve_context) in machine_kexec()
371 if (image->preserve_context) { in machine_kexec()
384 control_page = page_address(image->control_code_page); in machine_kexec()
390 relocate_kernel_ptr = control_page + (unsigned long)relocate_kernel - reloc_start; in machine_kexec()
411 image->start = relocate_kernel_ptr((unsigned long)image->head, in machine_kexec()
413 image->start, in machine_kexec()
414 image->preserve_context, in machine_kexec()
418 if (image->preserve_context) in machine_kexec()
425 /* arch-dependent functionality related to kexec file-based syscall */
451 sechdrs = (void *)pi->ehdr + pi->ehdr->e_shoff; in arch_kexec_apply_relocations_add()
452 strtab = (char *)pi->ehdr + sechdrs[symtabsec->sh_link].sh_offset; in arch_kexec_apply_relocations_add()
453 shstrtab = (char *)pi->ehdr + sechdrs[pi->ehdr->e_shstrndx].sh_offset; in arch_kexec_apply_relocations_add()
455 rel = (void *)pi->ehdr + relsec->sh_offset; in arch_kexec_apply_relocations_add()
458 shstrtab + relsec->sh_name, relsec->sh_info); in arch_kexec_apply_relocations_add()
460 for (i = 0; i < relsec->sh_size / sizeof(*rel); i++) { in arch_kexec_apply_relocations_add()
469 * ->sh_addr. kexec takes care of moving it in arch_kexec_apply_relocations_add()
472 location = pi->purgatory_buf; in arch_kexec_apply_relocations_add()
473 location += section->sh_offset; in arch_kexec_apply_relocations_add()
477 address = section->sh_addr + rel[i].r_offset; in arch_kexec_apply_relocations_add()
485 sym = (void *)pi->ehdr + symtabsec->sh_offset; in arch_kexec_apply_relocations_add()
488 if (sym->st_name) in arch_kexec_apply_relocations_add()
489 name = strtab + sym->st_name; in arch_kexec_apply_relocations_add()
491 name = shstrtab + sechdrs[sym->st_shndx].sh_name; in arch_kexec_apply_relocations_add()
494 name, sym->st_info, sym->st_shndx, sym->st_value, in arch_kexec_apply_relocations_add()
495 sym->st_size); in arch_kexec_apply_relocations_add()
497 if (sym->st_shndx == SHN_UNDEF) { in arch_kexec_apply_relocations_add()
499 return -ENOEXEC; in arch_kexec_apply_relocations_add()
502 if (sym->st_shndx == SHN_COMMON) { in arch_kexec_apply_relocations_add()
504 return -ENOEXEC; in arch_kexec_apply_relocations_add()
507 if (sym->st_shndx == SHN_ABS) in arch_kexec_apply_relocations_add()
509 else if (sym->st_shndx >= pi->ehdr->e_shnum) { in arch_kexec_apply_relocations_add()
511 sym->st_shndx, name); in arch_kexec_apply_relocations_add()
512 return -ENOEXEC; in arch_kexec_apply_relocations_add()
514 sec_base = pi->sechdrs[sym->st_shndx].sh_addr; in arch_kexec_apply_relocations_add()
516 value = sym->st_value; in arch_kexec_apply_relocations_add()
538 value -= (u64)address; in arch_kexec_apply_relocations_add()
544 return -ENOEXEC; in arch_kexec_apply_relocations_add()
552 return -ENOEXEC; in arch_kexec_apply_relocations_add()
557 vfree(image->elf_headers); in arch_kimage_file_post_load_cleanup()
558 image->elf_headers = NULL; in arch_kimage_file_post_load_cleanup()
559 image->elf_headers_sz = 0; in arch_kimage_file_post_load_cleanup()
575 * crashk resource with zero-valued "end" member. in kexec_mark_range()
581 nr_pages = (end >> PAGE_SHIFT) - (start >> PAGE_SHIFT) + 1; in kexec_mark_range()
595 control = PFN_PHYS(page_to_pfn(kexec_crash_image->control_code_page)); in kexec_mark_crashkres()
596 kexec_mark_range(crashk_res.start, control - 1, protect); in kexec_mark_crashkres()
613 * During a traditional boot under SME, SME will encrypt the kernel,
614 * so the SME kexec kernel also needs to be un-encrypted in order to
615 * replicate a normal SME boot.
617 * During a traditional boot under SEV, the kernel has already been
619 * order to replicate a normal SEV boot.
621 int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, gfp_t gfp) in arch_kexec_post_alloc_pages() argument
628 * pages are not encrypted because when we boot to the new kernel the in arch_kexec_post_alloc_pages()
629 * pages won't be accessed encrypted (initially). in arch_kexec_post_alloc_pages()
631 return set_memory_decrypted((unsigned long)vaddr, pages); in arch_kexec_post_alloc_pages()
634 void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) in arch_kexec_pre_free_pages() argument
640 * If host memory encryption is active we need to reset the pages back in arch_kexec_pre_free_pages()
643 set_memory_encrypted((unsigned long)vaddr, pages); in arch_kexec_pre_free_pages()