On Mon, 2024-07-01 at 15:43 +0300, Kirill A. Shutemov wrote: > init_transition_pgtable() setups transitional page tables. Rewrite it > using kernel_ident_mapping_init() to avoid code duplication. setups -> sets up > > struct kimage_arch changed to track allocated page tables as a list, not > linking them to specific page table levels. This doesn't look like imperative mode. Perhaps change to: Change struct kimage_arch to track ... [...] > static int init_transition_pgtable(struct kimage *image, pgd_t *pgd) > { > - pgprot_t prot = PAGE_KERNEL_EXEC_NOENC; > - unsigned long vaddr, paddr; > - int result = -ENOMEM; > - p4d_t *p4d; > - pud_t *pud; > - pmd_t *pmd; > - pte_t *pte; > + struct x86_mapping_info info = { > + .alloc_pgt_page = alloc_transition_pgt_page, > + .context = image, > + .page_flag = __PAGE_KERNEL_LARGE_EXEC, > + .kernpg_flag = _KERNPG_TABLE_NOENC, > + .offset = __START_KERNEL_map - phys_base, > + }; > + unsigned long mstart = PAGE_ALIGN_DOWN(__pa(relocate_kernel)); > + unsigned long mend = mstart + PAGE_SIZE; > > - vaddr = (unsigned long)relocate_kernel; > - paddr = __pa(page_address(image->control_code_page)+PAGE_SIZE); Perhaps I am missing something, but this seems a functional change to me. IIUC the page after image->control_code_page is allocated when loading the kexec kernel image. It is a different page from the page where the relocate_kernel code resides in. The old code maps relocate_kernel kernel VA to the page after the control_code_page. Later in machine_kexec(), the relocate_kernel code is copied to that page so the mapping can work for that: control_page = page_address(image->control_code_page) + PAGE_SIZE; __memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE); The new code in this patch, however, seems just maps the relocate_kernel VA to the PA of the relocate_kernel, which should be different from the old mapping.