-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch allows Linux to act as a crash kernel for use with kdump. Userspace will let the crash kernel know about the memory region it can use through linux,usable-memory property on the /memory node (overriding its reg property), and about the memory region where the elf core header of the previous kernel is saved, through a reserved-memory node with a compatible string of "linux,elfcorehdr". This approach is the least invasive and re-uses functionality already present. I tested this on riscv64 qemu and it works as expected, you may test it by retrieving the dmesg of the previous kernel through /proc/vmcore, using the vmcore-dmesg utility from kexec-tools. Signed-off-by: Nick Kossifidis <mick@ics.forth.gr> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
- Loading branch information
Nick Kossifidis
authored and
Palmer Dabbelt
committed
Apr 26, 2021
1 parent
e53d281
commit 5640975
Showing
5 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* This code comes from arch/arm64/kernel/crash_dump.c | ||
* Created by: AKASHI Takahiro <takahiro.akashi@linaro.org> | ||
* Copyright (C) 2017 Linaro Limited | ||
*/ | ||
|
||
#include <linux/crash_dump.h> | ||
#include <linux/io.h> | ||
|
||
/** | ||
* copy_oldmem_page() - copy one page from old kernel memory | ||
* @pfn: page frame number to be copied | ||
* @buf: buffer where the copied page is placed | ||
* @csize: number of bytes to copy | ||
* @offset: offset in bytes into the page | ||
* @userbuf: if set, @buf is in a user address space | ||
* | ||
* This function copies one page from old kernel memory into buffer pointed by | ||
* @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes | ||
* copied or negative error in case of failure. | ||
*/ | ||
ssize_t copy_oldmem_page(unsigned long pfn, char *buf, | ||
size_t csize, unsigned long offset, | ||
int userbuf) | ||
{ | ||
void *vaddr; | ||
|
||
if (!csize) | ||
return 0; | ||
|
||
vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB); | ||
if (!vaddr) | ||
return -ENOMEM; | ||
|
||
if (userbuf) { | ||
if (copy_to_user((char __user *)buf, vaddr + offset, csize)) { | ||
memunmap(vaddr); | ||
return -EFAULT; | ||
} | ||
} else | ||
memcpy(buf, vaddr + offset, csize); | ||
|
||
memunmap(vaddr); | ||
return csize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters