linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Fix /dev/oldmem for kdump
@ 2008-06-26 10:55 Sachin P. Sant
  2008-07-03  6:15 ` Michael Ellerman
  0 siblings, 1 reply; 4+ messages in thread
From: Sachin P. Sant @ 2008-06-26 10:55 UTC (permalink / raw)
  To: linuxppc-dev

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

This one has been pending for a long time. Somehow never
made it upstream.

Resending the patch which fixes /dev/oldmem interface for kdump.

Tested with 2.6.26-rc8.

Signed-off-by : Michael Ellerman <michael@ellerman.id.au>


[-- Attachment #2: fix-oldmem-interface-for-kdump --]
[-- Type: text/plain, Size: 1847 bytes --]

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.

Signed-off-by : Michael Ellerman <michael@ellerman.id.au>
---

diff -Naurp old/arch/powerpc/kernel/crash_dump.c new/arch/powerpc/kernel/crash_dump.c
--- old/arch/powerpc/kernel/crash_dump.c	2008-06-25 07:28:20.000000000 +0530
+++ new/arch/powerpc/kernel/crash_dump.c	2008-06-26 14:46:17.000000000 +0530
@@ -83,6 +83,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
@@ -104,16 +117,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;
 }

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

* Re: [PATCH] powerpc: Fix /dev/oldmem for kdump
  2008-06-26 10:55 [PATCH] powerpc: Fix /dev/oldmem for kdump Sachin P. Sant
@ 2008-07-03  6:15 ` Michael Ellerman
  2008-07-03  6:32   ` Sachin P. Sant
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2008-07-03  6:15 UTC (permalink / raw)
  To: Sachin P. Sant; +Cc: linuxppc-dev

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

On Thu, 2008-06-26 at 16:25 +0530, Sachin P. Sant wrote:
> This one has been pending for a long time. Somehow never
> made it upstream.
> 
> Resending the patch which fixes /dev/oldmem interface for kdump.
> 
> Tested with 2.6.26-rc8.
> 
> Signed-off-by : Michael Ellerman <michael@ellerman.id.au>

Even though I wrote this, it was so long ago I can't really vouch for
it. If you've tested it and it works Sachin then we should merge it. Is
this fix in distros or does it not apply?

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

It looks like the generic code ensures that I think, but it can't hurt.

cheers

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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] powerpc: Fix /dev/oldmem for kdump
  2008-07-03  6:15 ` Michael Ellerman
@ 2008-07-03  6:32   ` Sachin P. Sant
  2008-07-03  6:36     ` Michael Ellerman
  0 siblings, 1 reply; 4+ messages in thread
From: Sachin P. Sant @ 2008-07-03  6:32 UTC (permalink / raw)
  To: michael; +Cc: linuxppc-dev

Michael Ellerman wrote:
> Even though I wrote this, it was so long ago I can't really vouch for
> it. If you've tested it and it works Sachin then we should merge it. Is
> this fix in distros or does it not apply?
>   
Yes, i have tested this on couple of power boxes and the patch
works fine. [ i can copy dump using both /proc/vmcore and /dev/oldmem
interface ]

No this fix is not part of distro ATM. But yes it applies to distros
also. Once it is merged upstream, distros will eventually pick this up.

Thanks
-Sachin

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

* Re: [PATCH] powerpc: Fix /dev/oldmem for kdump
  2008-07-03  6:32   ` Sachin P. Sant
@ 2008-07-03  6:36     ` Michael Ellerman
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2008-07-03  6:36 UTC (permalink / raw)
  To: Sachin P. Sant; +Cc: linuxppc-dev, Paul Mackerras

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

On Thu, 2008-07-03 at 12:02 +0530, Sachin P. Sant wrote:
> Michael Ellerman wrote:
> > Even though I wrote this, it was so long ago I can't really vouch for
> > it. If you've tested it and it works Sachin then we should merge it. Is
> > this fix in distros or does it not apply?
> >   
> Yes, i have tested this on couple of power boxes and the patch
> works fine. [ i can copy dump using both /proc/vmcore and /dev/oldmem
> interface ]

OK great, thanks for that.

> No this fix is not part of distro ATM. But yes it applies to distros
> also. Once it is merged upstream, distros will eventually pick this up.

Crud, OK well I guess we should hurry up and merge it then :D

Paul, this has been broken for quite a while, but it would still be nice
if the fix was in 26 - sorry!

Acked-by: Michael Ellerman <michael@ellerman.id.au>

cheers

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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2008-07-03  6:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-26 10:55 [PATCH] powerpc: Fix /dev/oldmem for kdump Sachin P. Sant
2008-07-03  6:15 ` Michael Ellerman
2008-07-03  6:32   ` Sachin P. Sant
2008-07-03  6:36     ` Michael Ellerman

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