Lines Matching refs:image
41 static int kexec_calculate_store_digests(struct kimage *image);
51 int kexec_image_probe_default(struct kimage *image, void *buf, in kexec_image_probe_default() argument
60 image->fops = *fops; in kexec_image_probe_default()
68 static void *kexec_image_load_default(struct kimage *image) in kexec_image_load_default() argument
70 if (!image->fops || !image->fops->load) in kexec_image_load_default()
73 return image->fops->load(image, image->kernel_buf, in kexec_image_load_default()
74 image->kernel_buf_len, image->initrd_buf, in kexec_image_load_default()
75 image->initrd_buf_len, image->cmdline_buf, in kexec_image_load_default()
76 image->cmdline_buf_len); in kexec_image_load_default()
79 int kexec_image_post_load_cleanup_default(struct kimage *image) in kexec_image_post_load_cleanup_default() argument
81 if (!image->fops || !image->fops->cleanup) in kexec_image_post_load_cleanup_default()
84 return image->fops->cleanup(image->image_loader_data); in kexec_image_post_load_cleanup_default()
92 void kimage_file_post_load_cleanup(struct kimage *image) in kimage_file_post_load_cleanup() argument
94 struct purgatory_info *pi = &image->purgatory_info; in kimage_file_post_load_cleanup()
96 vfree(image->kernel_buf); in kimage_file_post_load_cleanup()
97 image->kernel_buf = NULL; in kimage_file_post_load_cleanup()
99 vfree(image->initrd_buf); in kimage_file_post_load_cleanup()
100 image->initrd_buf = NULL; in kimage_file_post_load_cleanup()
102 kfree(image->cmdline_buf); in kimage_file_post_load_cleanup()
103 image->cmdline_buf = NULL; in kimage_file_post_load_cleanup()
112 vfree(image->ima_buffer); in kimage_file_post_load_cleanup()
113 image->ima_buffer = NULL; in kimage_file_post_load_cleanup()
117 arch_kimage_file_post_load_cleanup(image); in kimage_file_post_load_cleanup()
124 kfree(image->image_loader_data); in kimage_file_post_load_cleanup()
125 image->image_loader_data = NULL; in kimage_file_post_load_cleanup()
148 static int kexec_image_verify_sig(struct kimage *image, void *buf, in kexec_image_verify_sig() argument
151 if (!image->fops || !image->fops->verify_sig) { in kexec_image_verify_sig()
156 return image->fops->verify_sig(buf, buf_len); in kexec_image_verify_sig()
160 kimage_validate_signature(struct kimage *image) in kimage_validate_signature() argument
164 ret = kexec_image_verify_sig(image, image->kernel_buf, in kimage_validate_signature()
165 image->kernel_buf_len); in kimage_validate_signature()
194 kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, in kimage_file_prepare_segments() argument
201 ret = kernel_read_file_from_fd(kernel_fd, 0, &image->kernel_buf, in kimage_file_prepare_segments()
206 image->kernel_buf_len = ret; in kimage_file_prepare_segments()
208 image->kernel_buf, image->kernel_buf_len); in kimage_file_prepare_segments()
211 ret = arch_kexec_kernel_image_probe(image, image->kernel_buf, in kimage_file_prepare_segments()
212 image->kernel_buf_len); in kimage_file_prepare_segments()
217 ret = kimage_validate_signature(image); in kimage_file_prepare_segments()
224 ret = kernel_read_file_from_fd(initrd_fd, 0, &image->initrd_buf, in kimage_file_prepare_segments()
229 image->initrd_buf_len = ret; in kimage_file_prepare_segments()
234 image->cmdline_buf = memdup_user(cmdline_ptr, cmdline_len); in kimage_file_prepare_segments()
235 if (IS_ERR(image->cmdline_buf)) { in kimage_file_prepare_segments()
236 ret = PTR_ERR(image->cmdline_buf); in kimage_file_prepare_segments()
237 image->cmdline_buf = NULL; in kimage_file_prepare_segments()
241 image->cmdline_buf_len = cmdline_len; in kimage_file_prepare_segments()
244 if (image->cmdline_buf[cmdline_len - 1] != '\0') { in kimage_file_prepare_segments()
249 ima_kexec_cmdline(kernel_fd, image->cmdline_buf, in kimage_file_prepare_segments()
250 image->cmdline_buf_len - 1); in kimage_file_prepare_segments()
254 ima_add_kexec_buffer(image); in kimage_file_prepare_segments()
257 ldata = kexec_image_load_default(image); in kimage_file_prepare_segments()
264 image->image_loader_data = ldata; in kimage_file_prepare_segments()
268 kimage_file_post_load_cleanup(image); in kimage_file_prepare_segments()
278 struct kimage *image; in kimage_file_alloc_init() local
281 image = do_kimage_alloc_init(); in kimage_file_alloc_init()
282 if (!image) in kimage_file_alloc_init()
286 image->file_mode = 1; in kimage_file_alloc_init()
291 image->control_page = crashk_res.start; in kimage_file_alloc_init()
292 image->type = KEXEC_TYPE_CRASH; in kimage_file_alloc_init()
296 ret = kimage_file_prepare_segments(image, kernel_fd, initrd_fd, in kimage_file_alloc_init()
301 ret = sanity_check_segment_list(image); in kimage_file_alloc_init()
306 image->control_code_page = kimage_alloc_control_pages(image, in kimage_file_alloc_init()
308 if (!image->control_code_page) { in kimage_file_alloc_init()
314 image->swap_page = kimage_alloc_control_pages(image, 0); in kimage_file_alloc_init()
315 if (!image->swap_page) { in kimage_file_alloc_init()
321 *rimage = image; in kimage_file_alloc_init()
324 kimage_free_page_list(&image->control_pages); in kimage_file_alloc_init()
326 kimage_file_post_load_cleanup(image); in kimage_file_alloc_init()
328 kfree(image); in kimage_file_alloc_init()
338 struct kimage **dest_image, *image; in SYSCALL_DEFINE5() local
349 image = NULL; in SYSCALL_DEFINE5()
374 ret = kimage_file_alloc_init(&image, kernel_fd, initrd_fd, cmdline_ptr, in SYSCALL_DEFINE5()
380 if ((flags & KEXEC_FILE_ON_CRASH) && arch_crash_hotplug_support(image, flags)) in SYSCALL_DEFINE5()
381 image->hotplug_support = 1; in SYSCALL_DEFINE5()
384 ret = machine_kexec_prepare(image); in SYSCALL_DEFINE5()
392 ret = kimage_crash_copy_vmcoreinfo(image); in SYSCALL_DEFINE5()
396 ret = kexec_calculate_store_digests(image); in SYSCALL_DEFINE5()
400 kexec_dprintk("nr_segments = %lu\n", image->nr_segments); in SYSCALL_DEFINE5()
401 for (i = 0; i < image->nr_segments; i++) { in SYSCALL_DEFINE5()
404 ksegment = &image->segment[i]; in SYSCALL_DEFINE5()
409 ret = kimage_load_segment(image, &image->segment[i]); in SYSCALL_DEFINE5()
414 kimage_terminate(image); in SYSCALL_DEFINE5()
416 ret = machine_kexec_post_load(image); in SYSCALL_DEFINE5()
421 image->type, image->start, image->head, flags); in SYSCALL_DEFINE5()
426 kimage_file_post_load_cleanup(image); in SYSCALL_DEFINE5()
428 image = xchg(dest_image, image); in SYSCALL_DEFINE5()
436 kimage_free(image); in SYSCALL_DEFINE5()
443 struct kimage *image = kbuf->image; in locate_mem_hole_top_down() local
462 if (kimage_is_destination_range(image, temp_start, temp_end)) { in locate_mem_hole_top_down()
481 struct kimage *image = kbuf->image; in locate_mem_hole_bottom_up() local
496 if (kimage_is_destination_range(image, temp_start, temp_end)) { in locate_mem_hole_bottom_up()
549 if (kbuf->image->type == KEXEC_TYPE_CRASH) in kexec_walk_memblock()
611 if (kbuf->image->type == KEXEC_TYPE_CRASH) in kexec_walk_resources()
663 if (!kbuf->image->file_mode) in kexec_add_buffer()
666 if (kbuf->image->nr_segments >= KEXEC_SEGMENT_MAX) in kexec_add_buffer()
676 if (!list_empty(&kbuf->image->control_pages)) { in kexec_add_buffer()
691 ksegment = &kbuf->image->segment[kbuf->image->nr_segments]; in kexec_add_buffer()
696 kbuf->image->nr_segments++; in kexec_add_buffer()
701 static int kexec_calculate_store_digests(struct kimage *image) in kexec_calculate_store_digests() argument
710 struct purgatory_info *pi = &image->purgatory_info; in kexec_calculate_store_digests()
750 for (j = i = 0; i < image->nr_segments; i++) { in kexec_calculate_store_digests()
755 if (i == image->elfcorehdr_index) in kexec_calculate_store_digests()
759 ksegment = &image->segment[i]; in kexec_calculate_store_digests()
800 ret = kexec_purgatory_get_set_symbol(image, "purgatory_sha_regions", in kexec_calculate_store_digests()
805 ret = kexec_purgatory_get_set_symbol(image, "purgatory_sha256_digest", in kexec_calculate_store_digests()
917 kbuf->image->start = pi->ehdr->e_entry; in kexec_purgatory_setup_sechdrs()
950 !WARN_ON(kbuf->image->start != pi->ehdr->e_entry)) { in kexec_purgatory_setup_sechdrs()
951 kbuf->image->start -= sechdrs[i].sh_addr; in kexec_purgatory_setup_sechdrs()
952 kbuf->image->start += kbuf->mem + offset; in kexec_purgatory_setup_sechdrs()
967 static int kexec_apply_relocations(struct kimage *image) in kexec_apply_relocations() argument
970 struct purgatory_info *pi = &image->purgatory_info; in kexec_apply_relocations()
1038 int kexec_load_purgatory(struct kimage *image, struct kexec_buf *kbuf) in kexec_load_purgatory() argument
1040 struct purgatory_info *pi = &image->purgatory_info; in kexec_load_purgatory()
1056 ret = kexec_apply_relocations(image); in kexec_load_purgatory()
1125 void *kexec_purgatory_get_symbol_addr(struct kimage *image, const char *name) in kexec_purgatory_get_symbol_addr() argument
1127 struct purgatory_info *pi = &image->purgatory_info; in kexec_purgatory_get_symbol_addr()
1148 int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, in kexec_purgatory_get_set_symbol() argument
1151 struct purgatory_info *pi = &image->purgatory_info; in kexec_purgatory_get_set_symbol()