crash_dump.c (818b26588994d9d95743fca0a427f08ec6c1c41d) | crash_dump.c (5d8de293c224896a4da99763fce4f9794308caf4) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Routines for doing kexec-based kdump 4 * 5 * Copyright (C) 2017 Linaro Limited 6 * Author: AKASHI Takahiro <takahiro.akashi@linaro.org> 7 */ 8 9#include <linux/crash_dump.h> 10#include <linux/errno.h> 11#include <linux/io.h> | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Routines for doing kexec-based kdump 4 * 5 * Copyright (C) 2017 Linaro Limited 6 * Author: AKASHI Takahiro <takahiro.akashi@linaro.org> 7 */ 8 9#include <linux/crash_dump.h> 10#include <linux/errno.h> 11#include <linux/io.h> |
12#include <linux/memblock.h> 13#include <linux/uaccess.h> | 12#include <linux/uio.h> |
14#include <asm/memory.h> 15 | 13#include <asm/memory.h> 14 |
16/** 17 * copy_oldmem_page() - copy one page from old kernel memory 18 * @pfn: page frame number to be copied 19 * @buf: buffer where the copied page is placed 20 * @csize: number of bytes to copy 21 * @offset: offset in bytes into the page 22 * @userbuf: if set, @buf is in a user address space 23 * 24 * This function copies one page from old kernel memory into buffer pointed by 25 * @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes 26 * copied or negative error in case of failure. 27 */ 28ssize_t copy_oldmem_page(unsigned long pfn, char *buf, 29 size_t csize, unsigned long offset, 30 int userbuf) | 15ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn, 16 size_t csize, unsigned long offset) |
31{ 32 void *vaddr; 33 34 if (!csize) 35 return 0; 36 37 vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB); 38 if (!vaddr) 39 return -ENOMEM; 40 | 17{ 18 void *vaddr; 19 20 if (!csize) 21 return 0; 22 23 vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB); 24 if (!vaddr) 25 return -ENOMEM; 26 |
41 if (userbuf) { 42 if (copy_to_user((char __user *)buf, vaddr + offset, csize)) { 43 memunmap(vaddr); 44 return -EFAULT; 45 } 46 } else { 47 memcpy(buf, vaddr + offset, csize); 48 } | 27 csize = copy_to_iter(vaddr + offset, csize, iter); |
49 50 memunmap(vaddr); 51 52 return csize; 53} 54 55/** 56 * elfcorehdr_read - read from ELF core header --- 14 unchanged lines hidden --- | 28 29 memunmap(vaddr); 30 31 return csize; 32} 33 34/** 35 * elfcorehdr_read - read from ELF core header --- 14 unchanged lines hidden --- |