linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kdump: don't call __ioremap() for pfn = 0
@ 2006-09-21  4:37 Sachin P. Sant
  2006-09-21 11:02 ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Sachin P. Sant @ 2006-09-21  4:37 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus, Fastboot mailing list

[-- Attachment #1: Type: text/plain, Size: 517 bytes --]

Hi

While using dd command to retrive the dump from /dev/oldmem, there comes
a rare case where pfn value is zero. In this case the __ioremap() call 
returns
NULL and hence copying fails.

# dd if=/dev/oldmem of=/dev/null
dd: reading `/dev/oldmem': Bad address
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0.000121 seconds, 0.0 kB/s

Attached is a patch to fix this problem. During such rare cases don't call
__ioremap() to do the address translation, instead use __va() .

Tested with 2.6.18.

Thanks
-Sachin

[-- Attachment #2: kdump-no-ioremap-for-pfn-zero-fix --]
[-- Type: text/plain, Size: 1027 bytes --]

* During some rare cases [like using dd command with /dev/oldmem] the pfn value
  can be zero. Do not call __ioremap for zero pfn value, instead use __va to 
  calculate the virtual address.

Signed-off-by: Sachin Sant <sachinp@in.ibm.com>

diff -Naurp a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
--- a/arch/powerpc/kernel/crash_dump.c	2006-09-20 09:12:06.000000000 +0530
+++ b/arch/powerpc/kernel/crash_dump.c	2006-09-21 09:06:35.000000000 +0530
@@ -101,7 +101,15 @@ ssize_t copy_oldmem_page(unsigned long p
 	if (!csize)
 		return 0;
 
-	vaddr = __ioremap(pfn << PAGE_SHIFT, PAGE_SIZE, 0);
+	/* During some rare cases [like using dd command with /dev/oldmem] 
+	 * the pfn value can be zero. Do not call __ioremap for zero
+	 * pfn value, instead use __va to calculate the virtual address.
+	 */
+
+	if (pfn == 0)
+		vaddr = __va(pfn << PAGE_SHIFT);
+	else
+		vaddr = __ioremap(pfn << PAGE_SHIFT, PAGE_SIZE, 0);
 
 	if (userbuf) {
 		if (copy_to_user((char __user *)buf, (vaddr + offset), csize)) {

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

end of thread, other threads:[~2006-09-22  6:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-21  4:37 [PATCH] kdump: don't call __ioremap() for pfn = 0 Sachin P. Sant
2006-09-21 11:02 ` Michael Ellerman
2006-09-21 14:10   ` [Fastboot] " Vivek Goyal
2006-09-22  6:55     ` Michael Ellerman
2006-09-22  4:22   ` Sachin P. Sant

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).