Lines Matching +full:machine +full:- +full:mode +full:- +full:visible

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (C) 2002-2005 Eric Biederman <ebiederm@xmission.com>
27 #include <asm/kexec-bzimage64.h>
48 return kernel_ident_mapping_init(data->info, data->level4p, in mem_region_callback()
49 res->start, res->end + 1); in mem_region_callback()
63 ret = walk_iomem_res_desc(IORES_DESC_ACPI_TABLES, flags, 0, -1, in map_acpi_tables()
65 if (ret && ret != -EINVAL) in map_acpi_tables()
68 /* ACPI tables could be located in ACPI Non-volatile Storage region */ in map_acpi_tables()
69 ret = walk_iomem_res_desc(IORES_DESC_ACPI_NV_STORAGE, flags, 0, -1, in map_acpi_tables()
71 if (ret && ret != -EINVAL) in map_acpi_tables()
89 pr_info("Map PCI serial at %lx - %lx\n", mstart, mend); in map_mmio_serial()
126 kaddr = memremap(mstart, mend - mstart, MEMREMAP_WB); in map_efi_systab()
129 return -ENOMEM; in map_efi_systab()
137 mend = mstart + sizeof(efi_config_table_64_t) * stbl->nr_tables; in map_efi_systab()
141 mend = mstart + sizeof(efi_config_table_32_t) * stbl->nr_tables; in map_efi_systab()
153 free_page((unsigned long)image->arch.p4d); in free_transition_pgtable()
154 image->arch.p4d = NULL; in free_transition_pgtable()
155 free_page((unsigned long)image->arch.pud); in free_transition_pgtable()
156 image->arch.pud = NULL; in free_transition_pgtable()
157 free_page((unsigned long)image->arch.pmd); in free_transition_pgtable()
158 image->arch.pmd = NULL; in free_transition_pgtable()
159 free_page((unsigned long)image->arch.pte); in free_transition_pgtable()
160 image->arch.pte = NULL; in free_transition_pgtable()
168 int result = -ENOMEM; in init_transition_pgtable()
186 image->arch.p4d = p4d; in init_transition_pgtable()
194 image->arch.pud = pud; in init_transition_pgtable()
202 image->arch.pmd = pmd; in init_transition_pgtable()
210 image->arch.pte = pte; in init_transition_pgtable()
251 image->arch.pgd = alloc_pgt_page(image); in init_pgtable()
252 if (!image->arch.pgd) in init_pgtable()
253 return -ENOMEM; in init_pgtable()
267 result = kernel_ident_mapping_init(&info, image->arch.pgd, in init_pgtable()
279 for (i = 0; i < image->nr_segments; i++) { in init_pgtable()
280 mstart = image->segment[i].mem; in init_pgtable()
281 mend = mstart + image->segment[i].memsz; in init_pgtable()
283 result = kernel_ident_mapping_init(&info, image->arch.pgd, in init_pgtable()
294 result = map_efi_systab(&info, image->arch.pgd); in init_pgtable()
298 result = map_acpi_tables(&info, image->arch.pgd); in init_pgtable()
302 result = map_mmio_serial(&info, image->arch.pgd); in init_pgtable()
310 return init_transition_pgtable(image, image->arch.pgd, control_page); in init_pgtable()
345 void *control_page = page_address(image->control_code_page); in machine_kexec_prepare()
351 * Some early TDX-capable platforms have an erratum. A kernel in machine_kexec_prepare()
354 * memory, and a subsequent read triggers a machine check. in machine_kexec_prepare()
358 * kernel may see unexpected machine check. For simplicity in machine_kexec_prepare()
363 return -EOPNOTSUPP; in machine_kexec_prepare()
371 kexec_pa_table_page = (unsigned long)__pa(image->arch.pgd); in machine_kexec_prepare()
373 if (image->type == KEXEC_TYPE_DEFAULT) in machine_kexec_prepare()
374 kexec_pa_swap_page = page_to_pfn(image->swap_page) << PAGE_SHIFT; in machine_kexec_prepare()
377 (unsigned long)kexec_debug_exc_vectors - reloc_start); in machine_kexec_prepare()
379 __memcpy(control_page, __relocate_kernel_start, reloc_end - reloc_start); in machine_kexec_prepare()
388 void *control_page = page_address(image->control_code_page); in machine_kexec_cleanup()
409 if (image->preserve_context) in machine_kexec()
420 if (image->preserve_context) { in machine_kexec()
423 * We need to put APICs in legacy mode so that we can in machine_kexec()
433 control_page = page_address(image->control_code_page); in machine_kexec()
439 relocate_kernel_ptr = control_page + (unsigned long)relocate_kernel - reloc_start; in machine_kexec()
442 if (image->preserve_context) in machine_kexec()
454 * visible and an invisible part. Whenever the visible part is in machine_kexec()
470 image->start = relocate_kernel_ptr((unsigned long)image->head, in machine_kexec()
472 image->start, in machine_kexec()
476 if (image->preserve_context) in machine_kexec()
487 /* arch-dependent functionality related to kexec file-based syscall */
513 sechdrs = (void *)pi->ehdr + pi->ehdr->e_shoff; in arch_kexec_apply_relocations_add()
514 strtab = (char *)pi->ehdr + sechdrs[symtabsec->sh_link].sh_offset; in arch_kexec_apply_relocations_add()
515 shstrtab = (char *)pi->ehdr + sechdrs[pi->ehdr->e_shstrndx].sh_offset; in arch_kexec_apply_relocations_add()
517 rel = (void *)pi->ehdr + relsec->sh_offset; in arch_kexec_apply_relocations_add()
520 shstrtab + relsec->sh_name, relsec->sh_info); in arch_kexec_apply_relocations_add()
522 for (i = 0; i < relsec->sh_size / sizeof(*rel); i++) { in arch_kexec_apply_relocations_add()
531 * ->sh_addr. kexec takes care of moving it in arch_kexec_apply_relocations_add()
534 location = pi->purgatory_buf; in arch_kexec_apply_relocations_add()
535 location += section->sh_offset; in arch_kexec_apply_relocations_add()
539 address = section->sh_addr + rel[i].r_offset; in arch_kexec_apply_relocations_add()
547 sym = (void *)pi->ehdr + symtabsec->sh_offset; in arch_kexec_apply_relocations_add()
550 if (sym->st_name) in arch_kexec_apply_relocations_add()
551 name = strtab + sym->st_name; in arch_kexec_apply_relocations_add()
553 name = shstrtab + sechdrs[sym->st_shndx].sh_name; in arch_kexec_apply_relocations_add()
556 name, sym->st_info, sym->st_shndx, sym->st_value, in arch_kexec_apply_relocations_add()
557 sym->st_size); in arch_kexec_apply_relocations_add()
559 if (sym->st_shndx == SHN_UNDEF) { in arch_kexec_apply_relocations_add()
561 return -ENOEXEC; in arch_kexec_apply_relocations_add()
564 if (sym->st_shndx == SHN_COMMON) { in arch_kexec_apply_relocations_add()
566 return -ENOEXEC; in arch_kexec_apply_relocations_add()
569 if (sym->st_shndx == SHN_ABS) in arch_kexec_apply_relocations_add()
571 else if (sym->st_shndx >= pi->ehdr->e_shnum) { in arch_kexec_apply_relocations_add()
573 sym->st_shndx, name); in arch_kexec_apply_relocations_add()
574 return -ENOEXEC; in arch_kexec_apply_relocations_add()
576 sec_base = pi->sechdrs[sym->st_shndx].sh_addr; in arch_kexec_apply_relocations_add()
578 value = sym->st_value; in arch_kexec_apply_relocations_add()
600 value -= (u64)address; in arch_kexec_apply_relocations_add()
606 return -ENOEXEC; in arch_kexec_apply_relocations_add()
614 return -ENOEXEC; in arch_kexec_apply_relocations_add()
619 vfree(image->elf_headers); in arch_kimage_file_post_load_cleanup()
620 image->elf_headers = NULL; in arch_kimage_file_post_load_cleanup()
621 image->elf_headers_sz = 0; in arch_kimage_file_post_load_cleanup()
637 * crashk resource with zero-valued "end" member. in kexec_mark_range()
643 nr_pages = (end >> PAGE_SHIFT) - (start >> PAGE_SHIFT) + 1; in kexec_mark_range()
657 control = PFN_PHYS(page_to_pfn(kexec_crash_image->control_code_page)); in kexec_mark_crashkres()
658 kexec_mark_range(crashk_res.start, control - 1, protect); in kexec_mark_crashkres()
669 if (kexec_crash_image->dm_crypt_keys_addr) { in kexec_mark_dm_crypt_keys()
670 start_paddr = kexec_crash_image->dm_crypt_keys_addr; in kexec_mark_dm_crypt_keys()
671 end_paddr = start_paddr + kexec_crash_image->dm_crypt_keys_sz - 1; in kexec_mark_dm_crypt_keys()
672 nr_pages = (PAGE_ALIGN(end_paddr) - PAGE_ALIGN_DOWN(start_paddr))/PAGE_SIZE; in kexec_mark_dm_crypt_keys()
698 * so the SME kexec kernel also needs to be un-encrypted in order to