Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / arch / arm64 / kernel / crash_dump.c
blob670e4ce818223c2d2ba91ad76084fdd78369ac04
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Routines for doing kexec-based kdump
5 * Copyright (C) 2017 Linaro Limited
6 * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
7 */
9 #include <linux/crash_dump.h>
10 #include <linux/errno.h>
11 #include <linux/io.h>
12 #include <linux/uio.h>
13 #include <asm/memory.h>
15 ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn,
16 size_t csize, unsigned long offset)
18 void *vaddr;
20 if (!csize)
21 return 0;
23 vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB);
24 if (!vaddr)
25 return -ENOMEM;
27 csize = copy_to_iter(vaddr + offset, csize, iter);
29 memunmap(vaddr);
31 return csize;
34 /**
35 * elfcorehdr_read - read from ELF core header
36 * @buf: buffer where the data is placed
37 * @count: number of bytes to read
38 * @ppos: address in the memory
40 * This function reads @count bytes from elf core header which exists
41 * on crash dump kernel's memory.
43 ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos)
45 memcpy(buf, phys_to_virt((phys_addr_t)*ppos), count);
46 *ppos += count;
48 return count;