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:
@ -77,10 +77,14 @@ clear_all_initrds() {
|
||||
# Next routine parses /proc/iomem to obtain the biggest RAM buffer
|
||||
# available. Saves the results in 2 global variables: MEM_{SIZE,START}.
|
||||
parse_ram_buffers() {
|
||||
BUFFERS="$(grep "RAM buffer" /proc/iomem)"
|
||||
BUFFERS="$(grep "$1" /proc/iomem)"
|
||||
while read -r line
|
||||
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-)
|
||||
MSTART=$(echo "$RANGE" | cut -f1 -d-)
|
||||
@ -155,7 +159,11 @@ if [ "${USE_PSTORE_RAM}" -eq 1 ]; then
|
||||
RECORD_SIZE="${PSTORE_RECORD_SZ}"
|
||||
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 modprobe ramoops mem_address=0x"${MEM_START}" mem_size="${MEM_REQUIRED}" record_size="${RECORD_SIZE}"; then
|
||||
|
||||
Reference in New Issue
Block a user