mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
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: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Sachin Sant <sachinp@in.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
d82bf49094
commit
7230ced492
1 changed files with 22 additions and 9 deletions
|
@ -86,6 +86,19 @@ static int __init parse_savemaxmem(char *p)
|
|||
}
|
||||
__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 pfn, char *buf,
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue