aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kexec_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kexec_file.c')
-rw-r--r--kernel/kexec_file.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index efd2c094af7e..0c2df7f73792 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -450,6 +450,23 @@ int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf,
450} 450}
451 451
452/** 452/**
453 * kexec_locate_mem_hole - find free memory for the purgatory or the next kernel
454 * @kbuf: Parameters for the memory search.
455 *
456 * On success, kbuf->mem will have the start address of the memory region found.
457 *
458 * Return: 0 on success, negative errno on error.
459 */
460int kexec_locate_mem_hole(struct kexec_buf *kbuf)
461{
462 int ret;
463
464 ret = arch_kexec_walk_mem(kbuf, locate_mem_hole_callback);
465
466 return ret == 1 ? 0 : -EADDRNOTAVAIL;
467}
468
469/**
453 * kexec_add_buffer - place a buffer in a kexec segment 470 * kexec_add_buffer - place a buffer in a kexec segment
454 * @kbuf: Buffer contents and memory parameters. 471 * @kbuf: Buffer contents and memory parameters.
455 * 472 *
@@ -489,11 +506,9 @@ int kexec_add_buffer(struct kexec_buf *kbuf)
489 kbuf->buf_align = max(kbuf->buf_align, PAGE_SIZE); 506 kbuf->buf_align = max(kbuf->buf_align, PAGE_SIZE);
490 507
491 /* Walk the RAM ranges and allocate a suitable range for the buffer */ 508 /* Walk the RAM ranges and allocate a suitable range for the buffer */
492 ret = arch_kexec_walk_mem(kbuf, locate_mem_hole_callback); 509 ret = kexec_locate_mem_hole(kbuf);
493 if (ret != 1) { 510 if (ret)
494 /* A suitable memory range could not be found for buffer */ 511 return ret;
495 return -EADDRNOTAVAIL;
496 }
497 512
498 /* Found a suitable memory range */ 513 /* Found a suitable memory range */
499 ksegment = &kbuf->image->segment[kbuf->image->nr_segments]; 514 ksegment = &kbuf->image->segment[kbuf->image->nr_segments];