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