1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/crash_dump.h>
3 #include <linux/io.h>
4 #include <linux/uio.h>
5
copy_oldmem_page(struct iov_iter * iter,unsigned long pfn,size_t csize,unsigned long offset)6 ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn,
7 size_t csize, unsigned long offset)
8 {
9 void *vaddr;
10
11 if (!csize)
12 return 0;
13
14 vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB);
15 if (!vaddr)
16 return -ENOMEM;
17
18 csize = copy_to_iter(vaddr + offset, csize, iter);
19
20 memunmap(vaddr);
21
22 return csize;
23 }
24