Merge branch 'akpm'
[linux-2.6/next.git] / arch / s390 / kernel / crash_dump.c
blobc63dd71fa249766260d163a42bb76263f2ecdd99
1 /*
2 * S390 kdump implementation
4 * Copyright IBM Corp. 2011
5 * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com>
6 */
8 #include <linux/crash_dump.h>
9 #include <asm/lowcore.h>
12 * Copy one page from "oldmem"
14 * For the kdump reserved memory this functions performs a swap operation:
15 * - [OLDMEM_BASE - OLDMEM_BASE + OLDMEM_SIZE] is mapped to [0 - OLDMEM_SIZE].
16 * - [0 - OLDMEM_SIZE] is mapped to [OLDMEM_BASE - OLDMEM_BASE + OLDMEM_SIZE]
18 ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
19 size_t csize, unsigned long offset, int userbuf)
21 unsigned long src;
22 int rc;
24 if (!csize)
25 return 0;
27 src = (pfn << PAGE_SHIFT) + offset;
28 if (src < OLDMEM_SIZE)
29 src += OLDMEM_BASE;
30 else if (src > OLDMEM_BASE &&
31 src < OLDMEM_BASE + OLDMEM_SIZE)
32 src -= OLDMEM_BASE;
33 if (userbuf)
34 rc = copy_to_user_real((void __user *) buf, (void *) src,
35 csize);
36 else
37 rc = memcpy_real(buf, (void *) src, csize);
38 return rc < 0 ? rc : csize;