Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec: Fix add_usable_memory to use buf of type uint64_t.
@ 2013-12-05 19:25 Mahesh J Salgaonkar
  2013-12-06  9:25 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Mahesh J Salgaonkar @ 2013-12-05 19:25 UTC (permalink / raw)
  To: Simon Horman, Kexec-ml

From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

A switchover from /kexec/arch/ppc64/fs2dt.c to common code under
/kexec/fs2dt.c broke the kdump on ppc64. The function add_usable_memory()
assumes that 'memory@*' node exports two 32bit values and fails
to populate mem ranges correctly. On ppc64, 'memory@*' exports two 64bit
values as below:

# hexdump /proc/device-tree/memory\@0/reg
0000000 0000 0000 0000 0000 0000 0000 0800 0000
0000010
#

This patch fixes add_usable_memory() to use buf[2] of type uint64_t.

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
---
 kexec/fs2dt.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
index 5d774ae..7202dc1 100644
--- a/kexec/fs2dt.c
+++ b/kexec/fs2dt.c
@@ -285,8 +285,8 @@ static void add_dyn_reconf_usable_mem_property(struct dirent *dp, int fd) {}
 static void add_usable_mem_property(int fd, size_t len)
 {
 	char fname[MAXPATH], *bname;
-	uint32_t buf[2];
-	uint32_t *ranges;
+	uint64_t buf[2];
+	uint64_t *ranges;
 	int ranges_size = MEM_RANGE_CHUNK_SZ;
 	uint64_t base, end, loc_base, loc_end;
 	size_t range;
@@ -311,8 +311,8 @@ static void add_usable_mem_property(int fd, size_t len)
 
 	if (~0ULL - buf[0] < buf[1])
 		die("unrecoverable error: mem property overflow\n");
-	base = be32_to_cpu(buf[0]);
-	end = base + be32_to_cpu(buf[1]);
+	base = be64_to_cpu(buf[0]);
+	end = base + be64_to_cpu(buf[1]);
 
 	ranges = malloc(ranges_size * sizeof(*ranges));
 	if (!ranges)


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kexec: Fix add_usable_memory to use buf of type uint64_t.
  2013-12-05 19:25 [PATCH] kexec: Fix add_usable_memory to use buf of type uint64_t Mahesh J Salgaonkar
@ 2013-12-06  9:25 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2013-12-06  9:25 UTC (permalink / raw)
  To: Mahesh J Salgaonkar; +Cc: Kexec-ml

On Fri, Dec 06, 2013 at 12:55:30AM +0530, Mahesh J Salgaonkar wrote:
> From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
> 
> A switchover from /kexec/arch/ppc64/fs2dt.c to common code under
> /kexec/fs2dt.c broke the kdump on ppc64. The function add_usable_memory()
> assumes that 'memory@*' node exports two 32bit values and fails
> to populate mem ranges correctly. On ppc64, 'memory@*' exports two 64bit
> values as below:
> 
> # hexdump /proc/device-tree/memory\@0/reg
> 0000000 0000 0000 0000 0000 0000 0000 0800 0000
> 0000010
> #
> 
> This patch fixes add_usable_memory() to use buf[2] of type uint64_t.
> 
> Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

Thanks, applied.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-06  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-05 19:25 [PATCH] kexec: Fix add_usable_memory to use buf of type uint64_t Mahesh J Salgaonkar
2013-12-06  9:25 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox