From: Mahesh J Salgaonkar <mahesh@linux.vnet.ibm.com>
To: Simon Horman <horms@verge.net.au>, Kexec-ml <kexec@lists.infradead.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Laurent Dufour <ldufour@linux.vnet.ibm.com>
Subject: [PATCH] kexec/ppc64: Handle reserved memory ranges exported by OPAL firmware.
Date: Sun, 09 Feb 2014 22:25:45 +0530 [thread overview]
Message-ID: <20140209165544.29624.91745.stgit@mars> (raw)
From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
OPAL based system exports reserved memory ranges through /proc/device-tree
for the regions that are reserved by OPAL firmware. Traverse
/proc/device-tree/reserved-ranges and add them to exclude_ranges[] and
reserve them.
Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
---
kexec/arch/ppc64/kexec-ppc64.c | 44 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/kexec/arch/ppc64/kexec-ppc64.c b/kexec/arch/ppc64/kexec-ppc64.c
index 5956836..6e79f52 100644
--- a/kexec/arch/ppc64/kexec-ppc64.c
+++ b/kexec/arch/ppc64/kexec-ppc64.c
@@ -31,6 +31,7 @@
#include "../../kexec.h"
#include "../../kexec-syscall.h"
#include "kexec-ppc64.h"
+#include "../../fs2dt.h"
#include "crashdump-ppc64.h"
#include <arch/options.h>
@@ -314,6 +315,47 @@ static int sort_ranges(void)
return 0;
}
+void scan_reserved_ranges(unsigned long kexec_flags, int *range_index)
+{
+ char fname[256], buf[16];
+ FILE *file;
+ int i = *range_index;
+
+ strcpy(fname, "/proc/device-tree/reserved-ranges");
+
+ file = fopen(fname, "r");
+ if (file == NULL) {
+ if (errno != ENOENT) {
+ perror(fname);
+ return;
+ }
+ errno = 0;
+ /* File not present. Non PowerKVM system. */
+ return;
+ }
+
+ /*
+ * Each reserved range is an (address,size) pair, 2 cells each,
+ * totalling 4 cells per range.
+ */
+ while (fread(buf, sizeof(uint64_t) * 2, 1, file) == 1) {
+ uint64_t base, size;
+
+ base = be64_to_cpu(((uint64_t *)buf)[0]);
+ size = be64_to_cpu(((uint64_t *)buf)[1]);
+
+ exclude_range[i].start = base;
+ exclude_range[i].end = base + size;
+ i++;
+ if (i >= max_memory_ranges)
+ realloc_memory_ranges();
+
+ reserve(base, size);
+ }
+ fclose(file);
+ *range_index = i;
+}
+
/* Get devtree details and create exclude_range array
* Also create usablemem_ranges for KEXEC_ON_CRASH
*/
@@ -339,6 +381,8 @@ static int get_devtree_details(unsigned long kexec_flags)
return -1;
}
+ scan_reserved_ranges(kexec_flags, &i);
+
while ((dentry = readdir(dir)) != NULL) {
if (strncmp(dentry->d_name, "chosen", 6) &&
strncmp(dentry->d_name, "memory@", 7) &&
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next reply other threads:[~2014-02-09 16:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-09 16:55 Mahesh J Salgaonkar [this message]
2014-05-10 23:51 ` [PATCH] kexec/ppc64: Handle reserved memory ranges exported by OPAL firmware Simon Horman
2014-05-12 4:34 ` Mahesh Jagannath Salgaonkar
2014-05-15 4:54 ` Simon Horman
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=20140209165544.29624.91745.stgit@mars \
--to=mahesh@linux.vnet.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=horms@verge.net.au \
--cc=kexec@lists.infradead.org \
--cc=ldufour@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