3
0
mirror of https://github.com/Qortal/Brooklyn.git synced 2025-02-01 07:42:18 +00:00
Brooklyn/arch/mips/kernel/crash_dump.c

39 lines
1012 B
C
Raw Normal View History

2021-05-26 19:09:36 +00:00
// SPDX-License-Identifier: GPL-2.0
#include <linux/highmem.h>
#include <linux/crash_dump.h>
/**
* copy_oldmem_page - copy one page from "oldmem"
* @pfn: page frame number to be copied
* @buf: target memory address for the copy; this can be in kernel address
* space or user address space (see @userbuf)
* @csize: number of bytes to copy
* @offset: offset in bytes into the page (based on pfn) to begin the copy
* @userbuf: if set, @buf is in user address space, use copy_to_user(),
* otherwise @buf is in kernel address space, use memcpy().
*
* Copy a page from "oldmem". For this page, there is no pte mapped
* in the current kernel.
*/
ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
size_t csize, unsigned long offset, int userbuf)
{
void *vaddr;
if (!csize)
return 0;
2021-10-02 16:09:28 +00:00
vaddr = kmap_local_pfn(pfn);
2021-05-26 19:09:36 +00:00
if (!userbuf) {
2021-10-02 16:09:28 +00:00
memcpy(buf, vaddr + offset, csize);
2021-05-26 19:09:36 +00:00
} else {
2021-10-02 16:09:28 +00:00
if (copy_to_user(buf, vaddr + offset, csize))
csize = -EFAULT;
2021-09-23 16:59:15 +00:00
}
2021-05-26 19:09:36 +00:00
2021-10-02 16:09:28 +00:00
kunmap_local(vaddr);
2021-09-23 16:59:15 +00:00
2021-10-02 16:09:28 +00:00
return csize;
2021-09-23 16:59:15 +00:00
}