kdumpst-load/config: Add option to use crashkernel as pstore/ram memory
Currently kdumpst only allows a proper RAM buffer to be used as ramoops memory area - this is the proper way of doing that, but there are cases in which it's not trivial to have these buffers available: (a) In case it's not there by default (due to kernel alignment / device-tree) for example, there is no easy parameter to reserve such area right now (using mem= is the way to go, but a bit complex to gather the exact size). (b) The kernel parameter crashkernel= does something like this: reserve a piece of memory not to be used by the kernel. It's meant for kdump, but can be (ab)used for other purposes. So, we hereby add a way for kdumpst to make use of crash reserved area if the users wish so; the risks are exposed in the config file text. Also, since we're changing this code, take the opportunity to improve the sanitization of addresses from /proc/iomem and fix a corner case of empty RANGE in the iomem parsing routine. Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
This commit is contained in:
@ -16,9 +16,15 @@
|
|||||||
# relies in having an available RAM buffer on /proc/iomem with at least
|
# relies in having an available RAM buffer on /proc/iomem with at least
|
||||||
# PSTORE_MEM_AMOUNT (decimal, in MB) in size. Also, kernel must be able to
|
# PSTORE_MEM_AMOUNT (decimal, in MB) in size. Also, kernel must be able to
|
||||||
# allocate a contiguous memory amount of PSTORE_RECORD_SZ (decimal, MB).
|
# allocate a contiguous memory amount of PSTORE_RECORD_SZ (decimal, MB).
|
||||||
|
# If there is no such RAM buffer, there is a possibility to make use of
|
||||||
|
# the crash kernel area for that. There are risks: such memory area could
|
||||||
|
# have its address mapped differently across kernel updates; also if both
|
||||||
|
# pstore and the kdump kernel are loaded, that memory region will be for
|
||||||
|
# sure corrupted by the kexec panic load - so, kind of a last resource.
|
||||||
USE_PSTORE_RAM=1
|
USE_PSTORE_RAM=1
|
||||||
PSTORE_MEM_AMOUNT=4194304
|
PSTORE_MEM_AMOUNT=4194304
|
||||||
PSTORE_RECORD_SZ=1048576
|
PSTORE_RECORD_SZ=1048576
|
||||||
|
PSTORE_RAM_USE_CRASH_MEM=0
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Mount-related options
|
# Mount-related options
|
||||||
|
|||||||
@ -77,10 +77,14 @@ clear_all_initrds() {
|
|||||||
# Next routine parses /proc/iomem to obtain the biggest RAM buffer
|
# Next routine parses /proc/iomem to obtain the biggest RAM buffer
|
||||||
# available. Saves the results in 2 global variables: MEM_{SIZE,START}.
|
# available. Saves the results in 2 global variables: MEM_{SIZE,START}.
|
||||||
parse_ram_buffers() {
|
parse_ram_buffers() {
|
||||||
BUFFERS="$(grep "RAM buffer" /proc/iomem)"
|
BUFFERS="$(grep "$1" /proc/iomem)"
|
||||||
while read -r line
|
while read -r line
|
||||||
do
|
do
|
||||||
RANGE=$(echo "$line" | cut -f1 -d\ )
|
RANGE=$(echo "$line" | sed 's/^[[:space:]]*//g' | cut -f1 -d:)
|
||||||
|
|
||||||
|
if [ "${RANGE}" == '' ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
MEM_END=$(echo "$RANGE" | cut -f2 -d-)
|
MEM_END=$(echo "$RANGE" | cut -f2 -d-)
|
||||||
MSTART=$(echo "$RANGE" | cut -f1 -d-)
|
MSTART=$(echo "$RANGE" | cut -f1 -d-)
|
||||||
@ -155,7 +159,11 @@ if [ "${USE_PSTORE_RAM}" -eq 1 ]; then
|
|||||||
RECORD_SIZE="${PSTORE_RECORD_SZ}"
|
RECORD_SIZE="${PSTORE_RECORD_SZ}"
|
||||||
MEM_SIZE=0
|
MEM_SIZE=0
|
||||||
|
|
||||||
parse_ram_buffers
|
parse_ram_buffers "RAM buffer"
|
||||||
|
|
||||||
|
if [ "${MEM_SIZE}" -eq 0 ] && [ "${PSTORE_RAM_USE_CRASH_MEM}" -eq 1 ]; then
|
||||||
|
parse_ram_buffers "Crash kernel"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${MEM_SIZE}" -gt 0 ]; then
|
if [ "${MEM_SIZE}" -gt 0 ]; then
|
||||||
if modprobe ramoops mem_address=0x"${MEM_START}" mem_size="${MEM_REQUIRED}" record_size="${RECORD_SIZE}"; then
|
if modprobe ramoops mem_address=0x"${MEM_START}" mem_size="${MEM_REQUIRED}" record_size="${RECORD_SIZE}"; then
|
||||||
|
|||||||
Reference in New Issue
Block a user