// SPDX-License-Identifier: GPL-2.0-only1/*2* Routines for doing kexec-based kdump3*4* Copyright (C) 2017 Linaro Limited5* Author: AKASHI Takahiro <[email protected]>6*/78#include <linux/crash_dump.h>9#include <linux/errno.h>10#include <linux/io.h>11#include <linux/uio.h>12#include <asm/memory.h>1314ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn,15size_t csize, unsigned long offset)16{17void *vaddr;1819if (!csize)20return 0;2122vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB);23if (!vaddr)24return -ENOMEM;2526csize = copy_to_iter(vaddr + offset, csize, iter);2728memunmap(vaddr);2930return csize;31}3233/**34* elfcorehdr_read - read from ELF core header35* @buf: buffer where the data is placed36* @count: number of bytes to read37* @ppos: address in the memory38*39* This function reads @count bytes from elf core header which exists40* on crash dump kernel's memory.41*/42ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos)43{44memcpy(buf, phys_to_virt((phys_addr_t)*ppos), count);45*ppos += count;4647return count;48}495051