1 // SPDX-License-Identifier: GPL-2.0
3 * This code comes from arch/arm64/kernel/crash_dump.c
5 * Copyright (C) 2017 Linaro Limited
8 #include <linux/crash_dump.h>
12 * copy_oldmem_page() - copy one page from old kernel memory
13 * @pfn: page frame number to be copied
14 * @buf: buffer where the copied page is placed
15 * @csize: number of bytes to copy
16 * @offset: offset in bytes into the page
17 * @userbuf: if set, @buf is in a user address space
19 * This function copies one page from old kernel memory into buffer pointed by
20 * @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes
21 * copied or negative error in case of failure.
23 ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
24 size_t csize, unsigned long offset,
32 vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB);
37 if (copy_to_user((char __user *)buf, vaddr + offset, csize)) {
42 memcpy(buf, vaddr + offset, csize);