Skip to contentSkip to conversation

powerpc/kdump: Fix /dev/oldmem interface

PATCH In review Sachin P. Sant 2 participants 3 messages Jul 31, 2008 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/kdump: Fix /dev/oldmem interface

This patch fixes the /dev/oldmem interface for kdump on ppc64. The patch originally came from Michael Ellerman hence have retained the signed-off line. I just rediffed/tested against latest git. Michael has ack'ed this patch.

Ben this is not a must for 2.6.27 but would be good if it's included.

Thanks
-Sachin

---

Fix /dev/oldmem for kdump

A change to __ioremap() broke reading /dev/oldmem because we're no longer able to ioremap pfn 0 (d177c207ba16b1db31283e2d1fee7ad4a863584b).

We actually don't need to ioremap for anything that's part of the linear mapping, so just read it directly.

Also make sure we're only reading one page or less at a time.

---

arch/powerpc/kernel/crash_dump.c +22 -9
diff -Naurp 1/arch/powerpc/kernel/crash_dump.c 2/arch/powerpc/kernel/crash_dump.c
@@ -86,6 +86,19 @@ static int __init parse_savemaxmem(char 
 }
 __setup("savemaxmem=", parse_savemaxmem);
 
+
+static size_t copy_oldmem_vaddr(void *vaddr, char *buf, size_t csize,
+                               unsigned long offset, int userbuf)
+{
+	if (userbuf) {
+		if (copy_to_user((char __user *)buf, (vaddr + offset), csize))
+			return -EFAULT;
+	} else
+		memcpy(buf, (vaddr + offset), csize);
+
+	return csize;
+}
+
 /**
  * copy_oldmem_page - copy one page from "oldmem"
  * @pfn: page frame number to be copied
@@ -107,16 +120,16 @@ ssize_t copy_oldmem_page(unsigned long p
 	if (!csize)
 		return 0;
 
-	vaddr = __ioremap(pfn << PAGE_SHIFT, PAGE_SIZE, 0);
+	csize = min(csize, PAGE_SIZE);
 
-	if (userbuf) {
-		if (copy_to_user((char __user *)buf, (vaddr + offset), csize)) {
-			iounmap(vaddr);
-			return -EFAULT;
-		}
-	} else
-		memcpy(buf, (vaddr + offset), csize);
+	if (pfn < max_pfn) {
+		vaddr = __va(pfn << PAGE_SHIFT);
+		csize = copy_oldmem_vaddr(vaddr, buf, csize, offset, userbuf);
+	} else {
+		vaddr = __ioremap(pfn << PAGE_SHIFT, PAGE_SIZE, 0);
+		csize = copy_oldmem_vaddr(vaddr, buf, csize, offset, userbuf);
+		iounmap(vaddr);
+	}
 
-	iounmap(vaddr);
 	return csize;
 }
#1 lore raw
Quoted 7 lines · Sachin P. Sant

This patch fixes the /dev/oldmem interface for kdump on ppc64. The patch originally came from Michael Ellerman hence have retained the signed-off line. I just rediffed/tested against latest git. Michael has ack'ed this patch.

Ben this is not a must for 2.6.27 but would be good if it's included.

It's been broken long enough, I think it's a must for 27.

Quoted 2 lines

Heh, do I get a prize for being neurotic? ;) .. Or just stupid, ahem.

I think you should also sign off on it Sachin, see clause (c) of the developers cert (http://lwn.net/Articles/139918/)

cheers

Signature · 8 lines
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#2 lore raw
Quoted 6 lines · Michael Ellerman

Heh, do I get a prize for being neurotic? ;) .. Or just stupid, ahem.

I think you should also sign off on it Sachin, see clause (c) of the developers cert (http://lwn.net/Articles/139918/)

Here is a signed-off from me. Let me know if i need to resubmit the patch with all signed-off-by lines.

Signature · 9 lines
Thanks
-Sachin

---------------------------------
Sachin Sant
IBM Linux Technology Center
India Systems and Technology Labs
Bangalore, India
---------------------------------