From: Michael Ellerman <mpe@ellerman.id.au>
To: linuxppc-dev@ozlabs.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
dyoung@redhat.com, stewart@linux.vnet.ibm.com,
bauerman@linux.vnet.ibm.com
Subject: [PATCH v11 3/8] kexec_file: Factor out kexec_locate_mem_hole from kexec_add_buffer.
Date: Tue, 29 Nov 2016 23:45:49 +1100 [thread overview]
Message-ID: <1480423554-6411-4-git-send-email-mpe@ellerman.id.au> (raw)
In-Reply-To: <1480423554-6411-1-git-send-email-mpe@ellerman.id.au>
From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
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: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Acked-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
include/linux/kexec.h | 1 +
kernel/kexec_file.c | 25 ++++++++++++++++++++-----
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 437ef1b47428..a33f63351f86 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -176,6 +176,7 @@ struct kexec_buf {
int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf,
int (*func)(u64, u64, void *));
extern int kexec_add_buffer(struct kexec_buf *kbuf);
+int kexec_locate_mem_hole(struct kexec_buf *kbuf);
#endif /* CONFIG_KEXEC_FILE */
struct kimage {
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,
}
/**
+ * 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
* @kbuf: Buffer contents and memory parameters.
*
@@ -489,11 +506,9 @@ int kexec_add_buffer(struct kexec_buf *kbuf)
kbuf->buf_align = max(kbuf->buf_align, PAGE_SIZE);
/* Walk the RAM ranges and allocate a suitable range for the buffer */
- ret = arch_kexec_walk_mem(kbuf, locate_mem_hole_callback);
- if (ret != 1) {
- /* A suitable memory range could not be found for buffer */
- return -EADDRNOTAVAIL;
- }
+ ret = kexec_locate_mem_hole(kbuf);
+ if (ret)
+ return ret;
/* Found a suitable memory range */
ksegment = &kbuf->image->segment[kbuf->image->nr_segments];
--
2.7.4
next prev parent reply other threads:[~2016-11-29 12:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-29 12:45 [PATCH v11 0/8] powerpc: Implement kexec_file_load() Michael Ellerman
2016-11-29 12:45 ` [PATCH v11 1/8] kexec_file: Allow arch-specific memory walking for kexec_add_buffer Michael Ellerman
2016-11-30 19:51 ` [v11, " Michael Ellerman
2016-11-29 12:45 ` [PATCH v11 2/8] kexec_file: Change kexec_add_buffer to take kexec_buf as argument Michael Ellerman
2016-11-29 12:45 ` Michael Ellerman [this message]
2016-11-29 12:45 ` [PATCH v11 4/8] powerpc: Change places using CONFIG_KEXEC to use CONFIG_KEXEC_CORE instead Michael Ellerman
2016-11-29 12:45 ` [PATCH v11 5/8] powerpc: Add support code for kexec_file_load() Michael Ellerman
2016-11-29 12:45 ` [PATCH v11 6/8] powerpc: Add purgatory for kexec_file_load() implementation Michael Ellerman
2016-11-29 12:45 ` [PATCH v11 7/8] powerpc/kexec: Enable kexec_file_load() syscall Michael Ellerman
2016-11-29 12:45 ` [PATCH v11 8/8] powerpc: Enable CONFIG_KEXEC_FILE in powerpc server defconfigs Michael Ellerman
2016-11-29 21:45 ` [PATCH v11 0/8] powerpc: Implement kexec_file_load() Andrew Morton
2016-11-29 22:17 ` Thiago Jung Bauermann
2016-11-30 4:52 ` Michael Ellerman
2016-11-30 13:03 ` Mimi Zohar
2016-12-01 1:14 ` Mimi Zohar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1480423554-6411-4-git-send-email-mpe@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=akpm@linux-foundation.org \
--cc=bauerman@linux.vnet.ibm.com \
--cc=dyoung@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=stewart@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).