Lines Matching refs:image

104 static struct page *kimage_alloc_page(struct kimage *image,
108 int sanity_check_segment_list(struct kimage *image) in sanity_check_segment_list() argument
111 unsigned long nr_segments = image->nr_segments; in sanity_check_segment_list()
131 mstart = image->segment[i].mem; in sanity_check_segment_list()
132 mend = mstart + image->segment[i].memsz; in sanity_check_segment_list()
150 mstart = image->segment[i].mem; in sanity_check_segment_list()
151 mend = mstart + image->segment[i].memsz; in sanity_check_segment_list()
155 pstart = image->segment[j].mem; in sanity_check_segment_list()
156 pend = pstart + image->segment[j].memsz; in sanity_check_segment_list()
169 if (image->segment[i].bufsz > image->segment[i].memsz) in sanity_check_segment_list()
179 if (PAGE_COUNT(image->segment[i].memsz) > nr_pages / 2) in sanity_check_segment_list()
182 total_pages += PAGE_COUNT(image->segment[i].memsz); in sanity_check_segment_list()
199 if (image->type == KEXEC_TYPE_CRASH) { in sanity_check_segment_list()
203 mstart = image->segment[i].mem; in sanity_check_segment_list()
204 mend = mstart + image->segment[i].memsz - 1; in sanity_check_segment_list()
218 struct kimage *image; in do_kimage_alloc_init() local
221 image = kzalloc(sizeof(*image), GFP_KERNEL); in do_kimage_alloc_init()
222 if (!image) in do_kimage_alloc_init()
225 image->head = 0; in do_kimage_alloc_init()
226 image->entry = &image->head; in do_kimage_alloc_init()
227 image->last_entry = &image->head; in do_kimage_alloc_init()
228 image->control_page = ~0; /* By default this does not apply */ in do_kimage_alloc_init()
229 image->type = KEXEC_TYPE_DEFAULT; in do_kimage_alloc_init()
232 INIT_LIST_HEAD(&image->control_pages); in do_kimage_alloc_init()
235 INIT_LIST_HEAD(&image->dest_pages); in do_kimage_alloc_init()
238 INIT_LIST_HEAD(&image->unusable_pages); in do_kimage_alloc_init()
241 image->hp_action = KEXEC_CRASH_HP_NONE; in do_kimage_alloc_init()
242 image->elfcorehdr_index = -1; in do_kimage_alloc_init()
243 image->elfcorehdr_updated = false; in do_kimage_alloc_init()
246 return image; in do_kimage_alloc_init()
249 int kimage_is_destination_range(struct kimage *image, in kimage_is_destination_range() argument
255 for (i = 0; i < image->nr_segments; i++) { in kimage_is_destination_range()
258 mstart = image->segment[i].mem; in kimage_is_destination_range()
259 mend = mstart + image->segment[i].memsz - 1; in kimage_is_destination_range()
318 static struct page *kimage_alloc_normal_control_pages(struct kimage *image, in kimage_alloc_normal_control_pages() argument
355 kimage_is_destination_range(image, addr, eaddr)) { in kimage_alloc_normal_control_pages()
363 list_add(&pages->lru, &image->control_pages); in kimage_alloc_normal_control_pages()
385 static struct page *kimage_alloc_crash_control_pages(struct kimage *image, in kimage_alloc_crash_control_pages() argument
414 hole_start = ALIGN(image->control_page, size); in kimage_alloc_crash_control_pages()
424 for (i = 0; i < image->nr_segments; i++) { in kimage_alloc_crash_control_pages()
427 mstart = image->segment[i].mem; in kimage_alloc_crash_control_pages()
428 mend = mstart + image->segment[i].memsz - 1; in kimage_alloc_crash_control_pages()
437 if (i == image->nr_segments) { in kimage_alloc_crash_control_pages()
439 image->control_page = hole_end + 1; in kimage_alloc_crash_control_pages()
453 struct page *kimage_alloc_control_pages(struct kimage *image, in kimage_alloc_control_pages() argument
458 switch (image->type) { in kimage_alloc_control_pages()
460 pages = kimage_alloc_normal_control_pages(image, order); in kimage_alloc_control_pages()
464 pages = kimage_alloc_crash_control_pages(image, order); in kimage_alloc_control_pages()
472 static int kimage_add_entry(struct kimage *image, kimage_entry_t entry) in kimage_add_entry() argument
474 if (*image->entry != 0) in kimage_add_entry()
475 image->entry++; in kimage_add_entry()
477 if (image->entry == image->last_entry) { in kimage_add_entry()
481 page = kimage_alloc_page(image, GFP_KERNEL, KIMAGE_NO_DEST); in kimage_add_entry()
486 *image->entry = virt_to_boot_phys(ind_page) | IND_INDIRECTION; in kimage_add_entry()
487 image->entry = ind_page; in kimage_add_entry()
488 image->last_entry = ind_page + in kimage_add_entry()
491 *image->entry = entry; in kimage_add_entry()
492 image->entry++; in kimage_add_entry()
493 *image->entry = 0; in kimage_add_entry()
498 static int kimage_set_destination(struct kimage *image, in kimage_set_destination() argument
503 return kimage_add_entry(image, destination | IND_DESTINATION); in kimage_set_destination()
507 static int kimage_add_page(struct kimage *image, unsigned long page) in kimage_add_page() argument
511 return kimage_add_entry(image, page | IND_SOURCE); in kimage_add_page()
515 static void kimage_free_extra_pages(struct kimage *image) in kimage_free_extra_pages() argument
518 kimage_free_page_list(&image->dest_pages); in kimage_free_extra_pages()
521 kimage_free_page_list(&image->unusable_pages); in kimage_free_extra_pages()
525 void kimage_terminate(struct kimage *image) in kimage_terminate() argument
527 if (*image->entry != 0) in kimage_terminate()
528 image->entry++; in kimage_terminate()
530 *image->entry = IND_DONE; in kimage_terminate()
533 #define for_each_kimage_entry(image, ptr, entry) \ argument
534 for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \
546 void kimage_free(struct kimage *image) in kimage_free() argument
551 if (!image) in kimage_free()
555 if (image->vmcoreinfo_data_copy) { in kimage_free()
557 vunmap(image->vmcoreinfo_data_copy); in kimage_free()
561 kimage_free_extra_pages(image); in kimage_free()
562 for_each_kimage_entry(image, ptr, entry) { in kimage_free()
579 machine_kexec_cleanup(image); in kimage_free()
582 kimage_free_page_list(&image->control_pages); in kimage_free()
588 if (image->file_mode) in kimage_free()
589 kimage_file_post_load_cleanup(image); in kimage_free()
591 kfree(image); in kimage_free()
594 static kimage_entry_t *kimage_dst_used(struct kimage *image, in kimage_dst_used() argument
600 for_each_kimage_entry(image, ptr, entry) { in kimage_dst_used()
613 static struct page *kimage_alloc_page(struct kimage *image, in kimage_alloc_page() argument
642 list_for_each_entry(page, &image->dest_pages, lru) { in kimage_alloc_page()
660 list_add(&page->lru, &image->unusable_pages); in kimage_alloc_page()
670 if (!kimage_is_destination_range(image, addr, in kimage_alloc_page()
679 old = kimage_dst_used(image, addr); in kimage_alloc_page()
703 list_add(&page->lru, &image->dest_pages); in kimage_alloc_page()
709 static int kimage_load_normal_segment(struct kimage *image, in kimage_load_normal_segment() argument
718 if (image->file_mode) in kimage_load_normal_segment()
726 result = kimage_set_destination(image, maddr); in kimage_load_normal_segment()
735 page = kimage_alloc_page(image, GFP_HIGHUSER, maddr); in kimage_load_normal_segment()
740 result = kimage_add_page(image, page_to_boot_pfn(page) in kimage_load_normal_segment()
755 if (image->file_mode) in kimage_load_normal_segment()
760 if (image->file_mode) in kimage_load_normal_segment()
780 static int kimage_load_crash_segment(struct kimage *image, in kimage_load_crash_segment() argument
794 if (image->file_mode) in kimage_load_crash_segment()
824 if (image->file_mode) in kimage_load_crash_segment()
829 if (image->file_mode) in kimage_load_crash_segment()
851 int kimage_load_segment(struct kimage *image, in kimage_load_segment() argument
856 switch (image->type) { in kimage_load_segment()
858 result = kimage_load_normal_segment(image, segment); in kimage_load_segment()
862 result = kimage_load_crash_segment(image, segment); in kimage_load_segment()