Commit 7230ced4 authored by Michael Ellerman's avatar Michael Ellerman Committed by Paul Mackerras

powerpc: Fix /dev/oldmem interface for kdump

A change to __ioremap() broke reading /dev/oldmem because we're no
longer able to ioremap pfn 0 (d177c207, "[PATCH] powerpc: IOMMU: don't
ioremap null addresses").

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: default avatarMichael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarSachin Sant <sachinp@in.ibm.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent d82bf490
...@@ -86,6 +86,19 @@ static int __init parse_savemaxmem(char *p) ...@@ -86,6 +86,19 @@ static int __init parse_savemaxmem(char *p)
} }
__setup("savemaxmem=", parse_savemaxmem); __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" * copy_oldmem_page - copy one page from "oldmem"
* @pfn: page frame number to be copied * @pfn: page frame number to be copied
...@@ -107,16 +120,16 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf, ...@@ -107,16 +120,16 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
if (!csize) if (!csize)
return 0; return 0;
vaddr = __ioremap(pfn << PAGE_SHIFT, PAGE_SIZE, 0); csize = min(csize, PAGE_SIZE);
if (userbuf) { if (pfn < max_pfn) {
if (copy_to_user((char __user *)buf, (vaddr + offset), csize)) { 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 -EFAULT;
} }
} else
memcpy(buf, (vaddr + offset), csize);
iounmap(vaddr);
return csize; return csize;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment