1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * This code comes from arch/arm64/kernel/crash_dump.c 4 * Created by: AKASHI Takahiro <takahiro.akashi@linaro.org> 5 * Copyright (C) 2017 Linaro Limited 6 */ 7 8 #include <linux/crash_dump.h> 9 #include <linux/io.h> 10 #include <linux/uio.h> 11 12 ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn, 13 size_t csize, unsigned long offset) 14 { 15 void *vaddr; 16 17 if (!csize) 18 return 0; 19 20 vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB); 21 if (!vaddr) 22 return -ENOMEM; 23 24 csize = copy_to_iter(vaddr + offset, csize, iter); 25 26 memunmap(vaddr); 27 return csize; 28 } 29