linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Matthew McClintock <msm@freescale.com>
To: kexec@lists.infradead.org
Cc: muvarov@gmail.com, linuxppc-dev@ozlabs.org,
	Kumar Gala <kumar.gala@freescale.com>,
	Sebastian Andrzej Siewior <sebastian@breakpoint.cc>,
	Matthew McClintock <msm@freescale.com>
Subject: [PATCH v2 2/3] Prevent multiple reservations for cpu-release-addr
Date: Wed, 18 Aug 2010 23:56:50 -0500	[thread overview]
Message-ID: <1282193811-23098-3-git-send-email-msm@freescale.com> (raw)
In-Reply-To: <20100819042023.GC13965@verge.net.au>

Currently, we can add a lot of reservations over a small range, this
does a simple check to verify the previous entry is not the same
as the current one and skips it if so

Signed-off-by: Matthew McClintock <msm@freescale.com>
---
 kexec/arch/ppc/fixup_dtb.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/kexec/arch/ppc/fixup_dtb.c b/kexec/arch/ppc/fixup_dtb.c
index 09f9ac1..910a3f0 100644
--- a/kexec/arch/ppc/fixup_dtb.c
+++ b/kexec/arch/ppc/fixup_dtb.c
@@ -139,6 +139,7 @@ static void fixup_reserve_regions(struct kexec_info *info, char *blob_buf, off_t
 {
 	int ret, i;
 	int nodeoffset;
+	u64 val = 0;
 
 	/* If this is a KEXEC kernel we add all regions since they will
 	 * all need to be saved */
@@ -175,20 +176,25 @@ static void fixup_reserve_regions(struct kexec_info *info, char *blob_buf, off_t
 	while (nodeoffset != -FDT_ERR_NOTFOUND) {
 		const void *buf;
 		int sz, ret;
-		u64 val = 0;
+		u64 tmp;
 
 		buf = fdt_getprop(blob_buf, nodeoffset, "cpu-release-addr", &sz);
-		if (sz == 4) {
-			val = *(u32 *)buf;
-		} else if (sz == 8) {
-			val = *(u64 *)buf;
-		}
 
-		if (val) {
-			ret = fdt_add_mem_rsv(blob_buf, PAGE_ALIGN(val-PAGE_SIZE), PAGE_SIZE);
-			if (ret)
-				printf("%s: Unable to add reserve for cpu-release-addr!\n",
-					fdt_strerror(ret));
+		if (buf) {
+			if (sz == 4) {
+				tmp = *(u32 *)buf;
+			} else if (sz == 8) {
+				tmp = *(u64 *)buf;
+			}
+
+			/* crude check to see if last value is repeated */
+			if (_ALIGN_DOWN(tmp, PAGE_SIZE) != _ALIGN_DOWN(val, PAGE_SIZE)) {
+				val = tmp;
+				ret = fdt_add_mem_rsv(blob_buf, _ALIGN_DOWN(val, PAGE_SIZE), PAGE_SIZE);
+				if (ret)
+					printf("%s: Unable to add reserve for cpu-release-addr!\n",
+						fdt_strerror(ret));
+			}
 		}
 
 		nodeoffset = fdt_node_offset_by_prop_value(blob_buf, nodeoffset,
-- 
1.6.0.6

  parent reply	other threads:[~2010-08-19  5:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100819042023.GC13965@verge.net.au>
2010-08-19  4:56 ` [PATCH v2 0/3] Misc. bug fixes for ppc32 Matthew McClintock
2010-08-20  8:27   ` Simon Horman
2010-08-19  4:56 ` [PATCH v2 1/3] Ramdisk address was not copied correctly on kexec'ed kernel Matthew McClintock
2010-08-19  4:56 ` Matthew McClintock [this message]
2010-08-19  4:56 ` [PATCH v2 3/3] Prevent initrd-start and initrd-end from appearing multiple times Matthew McClintock

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=1282193811-23098-3-git-send-email-msm@freescale.com \
    --to=msm@freescale.com \
    --cc=kexec@lists.infradead.org \
    --cc=kumar.gala@freescale.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=muvarov@gmail.com \
    --cc=sebastian@breakpoint.cc \
    /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).