提交 e2e806f9 编写于 作者: T Thiago Jung Bauermann 提交者: Michael Ellerman

kexec_file: Factor out kexec_locate_mem_hole from kexec_add_buffer.

kexec_locate_mem_hole will be used by the PowerPC kexec_file_load
implementation to find free memory for the purgatory stack.
Signed-off-by: NThiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Acked-by: NDave Young <dyoung@redhat.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
上级 ec2b9bfa
...@@ -176,6 +176,7 @@ struct kexec_buf { ...@@ -176,6 +176,7 @@ struct kexec_buf {
int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf,
int (*func)(u64, u64, void *)); int (*func)(u64, u64, void *));
extern int kexec_add_buffer(struct kexec_buf *kbuf); extern int kexec_add_buffer(struct kexec_buf *kbuf);
int kexec_locate_mem_hole(struct kexec_buf *kbuf);
#endif /* CONFIG_KEXEC_FILE */ #endif /* CONFIG_KEXEC_FILE */
struct kimage { struct kimage {
......
...@@ -449,6 +449,23 @@ int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, ...@@ -449,6 +449,23 @@ int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf,
return walk_system_ram_res(0, ULONG_MAX, kbuf, func); return walk_system_ram_res(0, ULONG_MAX, kbuf, func);
} }
/**
* kexec_locate_mem_hole - find free memory for the purgatory or the next kernel
* @kbuf: Parameters for the memory search.
*
* On success, kbuf->mem will have the start address of the memory region found.
*
* Return: 0 on success, negative errno on error.
*/
int kexec_locate_mem_hole(struct kexec_buf *kbuf)
{
int ret;
ret = arch_kexec_walk_mem(kbuf, locate_mem_hole_callback);
return ret == 1 ? 0 : -EADDRNOTAVAIL;
}
/** /**
* kexec_add_buffer - place a buffer in a kexec segment * kexec_add_buffer - place a buffer in a kexec segment
* @kbuf: Buffer contents and memory parameters. * @kbuf: Buffer contents and memory parameters.
...@@ -489,11 +506,9 @@ int kexec_add_buffer(struct kexec_buf *kbuf) ...@@ -489,11 +506,9 @@ int kexec_add_buffer(struct kexec_buf *kbuf)
kbuf->buf_align = max(kbuf->buf_align, PAGE_SIZE); kbuf->buf_align = max(kbuf->buf_align, PAGE_SIZE);
/* Walk the RAM ranges and allocate a suitable range for the buffer */ /* Walk the RAM ranges and allocate a suitable range for the buffer */
ret = arch_kexec_walk_mem(kbuf, locate_mem_hole_callback); ret = kexec_locate_mem_hole(kbuf);
if (ret != 1) { if (ret)
/* A suitable memory range could not be found for buffer */ return ret;
return -EADDRNOTAVAIL;
}
/* Found a suitable memory range */ /* Found a suitable memory range */
ksegment = &kbuf->image->segment[kbuf->image->nr_segments]; ksegment = &kbuf->image->segment[kbuf->image->nr_segments];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册