Lines Matching refs:kbuf
441 struct kexec_buf *kbuf) in locate_mem_hole_top_down() argument
443 struct kimage *image = kbuf->image; in locate_mem_hole_top_down()
446 temp_end = min(end, kbuf->buf_max); in locate_mem_hole_top_down()
447 temp_start = temp_end - kbuf->memsz + 1; in locate_mem_hole_top_down()
451 temp_start = ALIGN_DOWN(temp_start, kbuf->buf_align); in locate_mem_hole_top_down()
453 if (temp_start < start || temp_start < kbuf->buf_min) in locate_mem_hole_top_down()
456 temp_end = temp_start + kbuf->memsz - 1; in locate_mem_hole_top_down()
472 kbuf->mem = temp_start; in locate_mem_hole_top_down()
479 struct kexec_buf *kbuf) in locate_mem_hole_bottom_up() argument
481 struct kimage *image = kbuf->image; in locate_mem_hole_bottom_up()
484 temp_start = max(start, kbuf->buf_min); in locate_mem_hole_bottom_up()
487 temp_start = ALIGN(temp_start, kbuf->buf_align); in locate_mem_hole_bottom_up()
488 temp_end = temp_start + kbuf->memsz - 1; in locate_mem_hole_bottom_up()
490 if (temp_end > end || temp_end > kbuf->buf_max) in locate_mem_hole_bottom_up()
506 kbuf->mem = temp_start; in locate_mem_hole_bottom_up()
514 struct kexec_buf *kbuf = (struct kexec_buf *)arg; in locate_mem_hole_callback() local
524 if (sz < kbuf->memsz) in locate_mem_hole_callback()
527 if (end < kbuf->buf_min || start > kbuf->buf_max) in locate_mem_hole_callback()
534 if (kbuf->top_down) in locate_mem_hole_callback()
535 return locate_mem_hole_top_down(start, end, kbuf); in locate_mem_hole_callback()
536 return locate_mem_hole_bottom_up(start, end, kbuf); in locate_mem_hole_callback()
540 static int kexec_walk_memblock(struct kexec_buf *kbuf, in kexec_walk_memblock() argument
549 if (kbuf->image->type == KEXEC_TYPE_CRASH) in kexec_walk_memblock()
550 return func(&crashk_res, kbuf); in kexec_walk_memblock()
558 if (kbuf->top_down) { in kexec_walk_memblock()
568 ret = func(&res, kbuf); in kexec_walk_memblock()
582 ret = func(&res, kbuf); in kexec_walk_memblock()
591 static int kexec_walk_memblock(struct kexec_buf *kbuf, in kexec_walk_memblock() argument
607 static int kexec_walk_resources(struct kexec_buf *kbuf, in kexec_walk_resources() argument
611 if (kbuf->image->type == KEXEC_TYPE_CRASH) in kexec_walk_resources()
615 kbuf, func); in kexec_walk_resources()
617 if (kbuf->top_down) in kexec_walk_resources()
618 return walk_system_ram_res_rev(0, ULONG_MAX, kbuf, func); in kexec_walk_resources()
620 return walk_system_ram_res(0, ULONG_MAX, kbuf, func); in kexec_walk_resources()
631 int kexec_locate_mem_hole(struct kexec_buf *kbuf) in kexec_locate_mem_hole() argument
636 if (kbuf->mem != KEXEC_BUF_MEM_UNKNOWN) in kexec_locate_mem_hole()
640 ret = kexec_walk_resources(kbuf, locate_mem_hole_callback); in kexec_locate_mem_hole()
642 ret = kexec_walk_memblock(kbuf, locate_mem_hole_callback); in kexec_locate_mem_hole()
657 int kexec_add_buffer(struct kexec_buf *kbuf) in kexec_add_buffer() argument
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()
682 kbuf->memsz = ALIGN(kbuf->memsz, PAGE_SIZE); in kexec_add_buffer()
683 kbuf->buf_align = max(kbuf->buf_align, PAGE_SIZE); in kexec_add_buffer()
686 ret = arch_kexec_locate_mem_hole(kbuf); in kexec_add_buffer()
691 ksegment = &kbuf->image->segment[kbuf->image->nr_segments]; in kexec_add_buffer()
692 ksegment->kbuf = kbuf->buffer; in kexec_add_buffer()
693 ksegment->bufsz = kbuf->bufsz; in kexec_add_buffer()
694 ksegment->mem = kbuf->mem; in kexec_add_buffer()
695 ksegment->memsz = kbuf->memsz; in kexec_add_buffer()
696 kbuf->image->nr_segments++; in kexec_add_buffer()
764 if (ksegment->kbuf == pi->purgatory_buf) in kexec_calculate_store_digests()
767 ret = crypto_shash_update(desc, ksegment->kbuf, in kexec_calculate_store_digests()
835 struct kexec_buf *kbuf) in kexec_purgatory_setup_kbuf() argument
844 kbuf->buf_align = bss_align = 1; in kexec_purgatory_setup_kbuf()
845 kbuf->bufsz = bss_sz = 0; in kexec_purgatory_setup_kbuf()
853 if (kbuf->buf_align < align) in kexec_purgatory_setup_kbuf()
854 kbuf->buf_align = align; in kexec_purgatory_setup_kbuf()
855 kbuf->bufsz = ALIGN(kbuf->bufsz, align); in kexec_purgatory_setup_kbuf()
856 kbuf->bufsz += sechdrs[i].sh_size; in kexec_purgatory_setup_kbuf()
864 kbuf->bufsz = ALIGN(kbuf->bufsz, bss_align); in kexec_purgatory_setup_kbuf()
865 kbuf->memsz = kbuf->bufsz + bss_sz; in kexec_purgatory_setup_kbuf()
866 if (kbuf->buf_align < bss_align) in kexec_purgatory_setup_kbuf()
867 kbuf->buf_align = bss_align; in kexec_purgatory_setup_kbuf()
869 kbuf->buffer = vzalloc(kbuf->bufsz); in kexec_purgatory_setup_kbuf()
870 if (!kbuf->buffer) in kexec_purgatory_setup_kbuf()
872 pi->purgatory_buf = kbuf->buffer; in kexec_purgatory_setup_kbuf()
874 ret = kexec_add_buffer(kbuf); in kexec_purgatory_setup_kbuf()
896 struct kexec_buf *kbuf) in kexec_purgatory_setup_sechdrs() argument
916 bss_addr = kbuf->mem + kbuf->bufsz; in kexec_purgatory_setup_sechdrs()
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()
959 sechdrs[i].sh_addr = kbuf->mem + offset; in kexec_purgatory_setup_sechdrs()
1038 int kexec_load_purgatory(struct kimage *image, struct kexec_buf *kbuf) in kexec_load_purgatory() argument
1048 ret = kexec_purgatory_setup_kbuf(pi, kbuf); in kexec_load_purgatory()
1052 ret = kexec_purgatory_setup_sechdrs(pi, kbuf); in kexec_load_purgatory()