Lines Matching refs:kbuf
423 struct kexec_buf *kbuf) in locate_mem_hole_top_down() argument
425 struct kimage *image = kbuf->image; in locate_mem_hole_top_down()
428 temp_end = min(end, kbuf->buf_max); in locate_mem_hole_top_down()
429 temp_start = temp_end - kbuf->memsz; in locate_mem_hole_top_down()
433 temp_start = temp_start & (~(kbuf->buf_align - 1)); in locate_mem_hole_top_down()
435 if (temp_start < start || temp_start < kbuf->buf_min) in locate_mem_hole_top_down()
438 temp_end = temp_start + kbuf->memsz - 1; in locate_mem_hole_top_down()
454 kbuf->mem = temp_start; in locate_mem_hole_top_down()
461 struct kexec_buf *kbuf) in locate_mem_hole_bottom_up() argument
463 struct kimage *image = kbuf->image; in locate_mem_hole_bottom_up()
466 temp_start = max(start, kbuf->buf_min); in locate_mem_hole_bottom_up()
469 temp_start = ALIGN(temp_start, kbuf->buf_align); in locate_mem_hole_bottom_up()
470 temp_end = temp_start + kbuf->memsz - 1; in locate_mem_hole_bottom_up()
472 if (temp_end > end || temp_end > kbuf->buf_max) in locate_mem_hole_bottom_up()
488 kbuf->mem = temp_start; in locate_mem_hole_bottom_up()
496 struct kexec_buf *kbuf = (struct kexec_buf *)arg; in locate_mem_hole_callback() local
506 if (sz < kbuf->memsz) in locate_mem_hole_callback()
509 if (end < kbuf->buf_min || start > kbuf->buf_max) in locate_mem_hole_callback()
516 if (kbuf->top_down) in locate_mem_hole_callback()
517 return locate_mem_hole_top_down(start, end, kbuf); in locate_mem_hole_callback()
518 return locate_mem_hole_bottom_up(start, end, kbuf); in locate_mem_hole_callback()
522 static int kexec_walk_memblock(struct kexec_buf *kbuf, in kexec_walk_memblock() argument
530 if (kbuf->image->type == KEXEC_TYPE_CRASH) in kexec_walk_memblock()
531 return func(&crashk_res, kbuf); in kexec_walk_memblock()
538 if (kbuf->top_down) { in kexec_walk_memblock()
548 ret = func(&res, kbuf); in kexec_walk_memblock()
562 ret = func(&res, kbuf); in kexec_walk_memblock()
571 static int kexec_walk_memblock(struct kexec_buf *kbuf, in kexec_walk_memblock() argument
587 static int kexec_walk_resources(struct kexec_buf *kbuf, in kexec_walk_resources() argument
590 if (kbuf->image->type == KEXEC_TYPE_CRASH) in kexec_walk_resources()
594 kbuf, func); in kexec_walk_resources()
596 return walk_system_ram_res(0, ULONG_MAX, kbuf, func); in kexec_walk_resources()
607 int kexec_locate_mem_hole(struct kexec_buf *kbuf) in kexec_locate_mem_hole() argument
612 if (kbuf->mem != KEXEC_BUF_MEM_UNKNOWN) in kexec_locate_mem_hole()
616 ret = kexec_walk_resources(kbuf, locate_mem_hole_callback); in kexec_locate_mem_hole()
618 ret = kexec_walk_memblock(kbuf, locate_mem_hole_callback); in kexec_locate_mem_hole()
633 int kexec_add_buffer(struct kexec_buf *kbuf) in kexec_add_buffer() argument
639 if (!kbuf->image->file_mode) in kexec_add_buffer()
642 if (kbuf->image->nr_segments >= KEXEC_SEGMENT_MAX) in kexec_add_buffer()
652 if (!list_empty(&kbuf->image->control_pages)) { in kexec_add_buffer()
658 kbuf->memsz = ALIGN(kbuf->memsz, PAGE_SIZE); in kexec_add_buffer()
659 kbuf->buf_align = max(kbuf->buf_align, PAGE_SIZE); in kexec_add_buffer()
662 ret = arch_kexec_locate_mem_hole(kbuf); in kexec_add_buffer()
667 ksegment = &kbuf->image->segment[kbuf->image->nr_segments]; in kexec_add_buffer()
668 ksegment->kbuf = kbuf->buffer; in kexec_add_buffer()
669 ksegment->bufsz = kbuf->bufsz; in kexec_add_buffer()
670 ksegment->mem = kbuf->mem; in kexec_add_buffer()
671 ksegment->memsz = kbuf->memsz; in kexec_add_buffer()
672 kbuf->image->nr_segments++; in kexec_add_buffer()
740 if (ksegment->kbuf == pi->purgatory_buf) in kexec_calculate_store_digests()
743 ret = crypto_shash_update(desc, ksegment->kbuf, in kexec_calculate_store_digests()
811 struct kexec_buf *kbuf) in kexec_purgatory_setup_kbuf() argument
820 kbuf->buf_align = bss_align = 1; in kexec_purgatory_setup_kbuf()
821 kbuf->bufsz = bss_sz = 0; in kexec_purgatory_setup_kbuf()
829 if (kbuf->buf_align < align) in kexec_purgatory_setup_kbuf()
830 kbuf->buf_align = align; in kexec_purgatory_setup_kbuf()
831 kbuf->bufsz = ALIGN(kbuf->bufsz, align); in kexec_purgatory_setup_kbuf()
832 kbuf->bufsz += sechdrs[i].sh_size; in kexec_purgatory_setup_kbuf()
840 kbuf->bufsz = ALIGN(kbuf->bufsz, bss_align); in kexec_purgatory_setup_kbuf()
841 kbuf->memsz = kbuf->bufsz + bss_sz; in kexec_purgatory_setup_kbuf()
842 if (kbuf->buf_align < bss_align) in kexec_purgatory_setup_kbuf()
843 kbuf->buf_align = bss_align; in kexec_purgatory_setup_kbuf()
845 kbuf->buffer = vzalloc(kbuf->bufsz); in kexec_purgatory_setup_kbuf()
846 if (!kbuf->buffer) in kexec_purgatory_setup_kbuf()
848 pi->purgatory_buf = kbuf->buffer; in kexec_purgatory_setup_kbuf()
850 ret = kexec_add_buffer(kbuf); in kexec_purgatory_setup_kbuf()
872 struct kexec_buf *kbuf) in kexec_purgatory_setup_sechdrs() argument
892 bss_addr = kbuf->mem + kbuf->bufsz; in kexec_purgatory_setup_sechdrs()
893 kbuf->image->start = pi->ehdr->e_entry; in kexec_purgatory_setup_sechdrs()
926 !WARN_ON(kbuf->image->start != pi->ehdr->e_entry)) { in kexec_purgatory_setup_sechdrs()
927 kbuf->image->start -= sechdrs[i].sh_addr; in kexec_purgatory_setup_sechdrs()
928 kbuf->image->start += kbuf->mem + offset; in kexec_purgatory_setup_sechdrs()
935 sechdrs[i].sh_addr = kbuf->mem + offset; in kexec_purgatory_setup_sechdrs()
1014 int kexec_load_purgatory(struct kimage *image, struct kexec_buf *kbuf) in kexec_load_purgatory() argument
1024 ret = kexec_purgatory_setup_kbuf(pi, kbuf); in kexec_load_purgatory()
1028 ret = kexec_purgatory_setup_sechdrs(pi, kbuf); in kexec_load_purgatory()