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 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()
146 static int kexec_image_verify_sig(struct kimage *image, void *buf, in kexec_image_verify_sig() argument
149 if (!image->fops || !image->fops->verify_sig) { in kexec_image_verify_sig()
154 return image->fops->verify_sig(buf, buf_len); in kexec_image_verify_sig()
158 kimage_validate_signature(struct kimage *image) in kimage_validate_signature() argument
162 ret = kexec_image_verify_sig(image, image->kernel_buf, in kimage_validate_signature()
163 image->kernel_buf_len); in kimage_validate_signature()
192 kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, in kimage_file_prepare_segments() argument
199 ret = kernel_read_file_from_fd(kernel_fd, 0, &image->kernel_buf, in kimage_file_prepare_segments()
204 image->kernel_buf_len = ret; in kimage_file_prepare_segments()
207 ret = arch_kexec_kernel_image_probe(image, image->kernel_buf, in kimage_file_prepare_segments()
208 image->kernel_buf_len); in kimage_file_prepare_segments()
213 ret = kimage_validate_signature(image); in kimage_file_prepare_segments()
220 ret = kernel_read_file_from_fd(initrd_fd, 0, &image->initrd_buf, in kimage_file_prepare_segments()
225 image->initrd_buf_len = ret; in kimage_file_prepare_segments()
230 image->cmdline_buf = memdup_user(cmdline_ptr, cmdline_len); in kimage_file_prepare_segments()
231 if (IS_ERR(image->cmdline_buf)) { in kimage_file_prepare_segments()
232 ret = PTR_ERR(image->cmdline_buf); in kimage_file_prepare_segments()
233 image->cmdline_buf = NULL; in kimage_file_prepare_segments()
237 image->cmdline_buf_len = cmdline_len; in kimage_file_prepare_segments()
240 if (image->cmdline_buf[cmdline_len - 1] != '\0') { in kimage_file_prepare_segments()
245 ima_kexec_cmdline(kernel_fd, image->cmdline_buf, in kimage_file_prepare_segments()
246 image->cmdline_buf_len - 1); in kimage_file_prepare_segments()
250 ima_add_kexec_buffer(image); in kimage_file_prepare_segments()
253 ldata = arch_kexec_kernel_image_load(image); in kimage_file_prepare_segments()
260 image->image_loader_data = ldata; in kimage_file_prepare_segments()
264 kimage_file_post_load_cleanup(image); in kimage_file_prepare_segments()
274 struct kimage *image; in kimage_file_alloc_init() local
277 image = do_kimage_alloc_init(); in kimage_file_alloc_init()
278 if (!image) in kimage_file_alloc_init()
281 image->file_mode = 1; in kimage_file_alloc_init()
285 image->control_page = crashk_res.start; in kimage_file_alloc_init()
286 image->type = KEXEC_TYPE_CRASH; in kimage_file_alloc_init()
289 ret = kimage_file_prepare_segments(image, kernel_fd, initrd_fd, in kimage_file_alloc_init()
294 ret = sanity_check_segment_list(image); in kimage_file_alloc_init()
299 image->control_code_page = kimage_alloc_control_pages(image, in kimage_file_alloc_init()
301 if (!image->control_code_page) { in kimage_file_alloc_init()
307 image->swap_page = kimage_alloc_control_pages(image, 0); in kimage_file_alloc_init()
308 if (!image->swap_page) { in kimage_file_alloc_init()
314 *rimage = image; in kimage_file_alloc_init()
317 kimage_free_page_list(&image->control_pages); in kimage_file_alloc_init()
319 kimage_file_post_load_cleanup(image); in kimage_file_alloc_init()
321 kfree(image); in kimage_file_alloc_init()
330 struct kimage **dest_image, *image; in SYSCALL_DEFINE5() local
340 image = NULL; in SYSCALL_DEFINE5()
363 ret = kimage_file_alloc_init(&image, kernel_fd, initrd_fd, cmdline_ptr, in SYSCALL_DEFINE5()
368 ret = machine_kexec_prepare(image); in SYSCALL_DEFINE5()
376 ret = kimage_crash_copy_vmcoreinfo(image); in SYSCALL_DEFINE5()
380 ret = kexec_calculate_store_digests(image); in SYSCALL_DEFINE5()
384 for (i = 0; i < image->nr_segments; i++) { in SYSCALL_DEFINE5()
387 ksegment = &image->segment[i]; in SYSCALL_DEFINE5()
392 ret = kimage_load_segment(image, &image->segment[i]); in SYSCALL_DEFINE5()
397 kimage_terminate(image); in SYSCALL_DEFINE5()
399 ret = machine_kexec_post_load(image); in SYSCALL_DEFINE5()
407 kimage_file_post_load_cleanup(image); in SYSCALL_DEFINE5()
409 image = xchg(dest_image, image); in SYSCALL_DEFINE5()
415 kimage_free(image); in SYSCALL_DEFINE5()
422 struct kimage *image = kbuf->image; in locate_mem_hole_top_down() local
441 if (kimage_is_destination_range(image, temp_start, temp_end)) { in locate_mem_hole_top_down()
460 struct kimage *image = kbuf->image; in locate_mem_hole_bottom_up() local
475 if (kimage_is_destination_range(image, temp_start, temp_end)) { in locate_mem_hole_bottom_up()
527 if (kbuf->image->type == KEXEC_TYPE_CRASH) in kexec_walk_memblock()
587 if (kbuf->image->type == KEXEC_TYPE_CRASH) in kexec_walk_resources()
636 if (!kbuf->image->file_mode) in kexec_add_buffer()
639 if (kbuf->image->nr_segments >= KEXEC_SEGMENT_MAX) in kexec_add_buffer()
649 if (!list_empty(&kbuf->image->control_pages)) { in kexec_add_buffer()
664 ksegment = &kbuf->image->segment[kbuf->image->nr_segments]; in kexec_add_buffer()
669 kbuf->image->nr_segments++; in kexec_add_buffer()
674 static int kexec_calculate_store_digests(struct kimage *image) in kexec_calculate_store_digests() argument
683 struct purgatory_info *pi = &image->purgatory_info; in kexec_calculate_store_digests()
723 for (j = i = 0; i < image->nr_segments; i++) { in kexec_calculate_store_digests()
726 ksegment = &image->segment[i]; in kexec_calculate_store_digests()
767 ret = kexec_purgatory_get_set_symbol(image, "purgatory_sha_regions", in kexec_calculate_store_digests()
772 ret = kexec_purgatory_get_set_symbol(image, "purgatory_sha256_digest", in kexec_calculate_store_digests()
883 kbuf->image->start = pi->ehdr->e_entry; in kexec_purgatory_setup_sechdrs()
916 !WARN_ON(kbuf->image->start != pi->ehdr->e_entry)) { in kexec_purgatory_setup_sechdrs()
917 kbuf->image->start -= sechdrs[i].sh_addr; in kexec_purgatory_setup_sechdrs()
918 kbuf->image->start += kbuf->mem + offset; in kexec_purgatory_setup_sechdrs()
933 static int kexec_apply_relocations(struct kimage *image) in kexec_apply_relocations() argument
936 struct purgatory_info *pi = &image->purgatory_info; in kexec_apply_relocations()
1004 int kexec_load_purgatory(struct kimage *image, struct kexec_buf *kbuf) in kexec_load_purgatory() argument
1006 struct purgatory_info *pi = &image->purgatory_info; in kexec_load_purgatory()
1022 ret = kexec_apply_relocations(image); in kexec_load_purgatory()
1091 void *kexec_purgatory_get_symbol_addr(struct kimage *image, const char *name) in kexec_purgatory_get_symbol_addr() argument
1093 struct purgatory_info *pi = &image->purgatory_info; in kexec_purgatory_get_symbol_addr()
1114 int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, in kexec_purgatory_get_set_symbol() argument
1117 struct purgatory_info *pi = &image->purgatory_info; in kexec_purgatory_get_set_symbol()