aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/crash_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/crash_dump.c')
-rw-r--r--arch/powerpc/kernel/crash_dump.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index e0debcca0bfa..a323c9b32ee1 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -86,6 +86,19 @@ static int __init parse_savemaxmem(char *p)
86} 86}
87__setup("savemaxmem=", parse_savemaxmem); 87__setup("savemaxmem=", parse_savemaxmem);
88 88
89
90static size_t copy_oldmem_vaddr(void *vaddr, char *buf, size_t csize,
91 unsigned long offset, int userbuf)
92{
93 if (userbuf) {
94 if (copy_to_user((char __user *)buf, (vaddr + offset), csize))
95 return -EFAULT;
96 } else
97 memcpy(buf, (vaddr + offset), csize);
98
99 return csize;
100}
101
89/** 102/**
90 * copy_oldmem_page - copy one page from "oldmem" 103 * copy_oldmem_page - copy one page from "oldmem"
91 * @pfn: page frame number to be copied 104 * @pfn: page frame number to be copied
@@ -107,16 +120,16 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
107 if (!csize) 120 if (!csize)
108 return 0; 121 return 0;
109 122
110 vaddr = __ioremap(pfn << PAGE_SHIFT, PAGE_SIZE, 0); 123 csize = min(csize, PAGE_SIZE);
111 124
112 if (userbuf) { 125 if (pfn < max_pfn) {
113 if (copy_to_user((char __user *)buf, (vaddr + offset), csize)) { 126 vaddr = __va(pfn << PAGE_SHIFT);
114 iounmap(vaddr); 127 csize = copy_oldmem_vaddr(vaddr, buf, csize, offset, userbuf);
115 return -EFAULT; 128 } else {
116 } 129 vaddr = __ioremap(pfn << PAGE_SHIFT, PAGE_SIZE, 0);
117 } else 130 csize = copy_oldmem_vaddr(vaddr, buf, csize, offset, userbuf);
118 memcpy(buf, (vaddr + offset), csize); 131 iounmap(vaddr);
132 }
119 133
120 iounmap(vaddr);
121 return csize; 134 return csize;
122} 135}