Compare commits

...

9 Commits

Author SHA1 Message Date
CentOS Sources b0cb23d8bd import kexec-tools-2.0.25-5.el8 2023-05-17 01:53:38 +00:00
CentOS Sources 7f841f0070 import kexec-tools-2.0.24-6.el8 2022-11-08 13:12:54 +00:00
CentOS Sources f572fac7ad import kexec-tools-2.0.20-68.el8 2022-05-10 10:38:08 +00:00
CentOS Sources 6b51ad8c27 import kexec-tools-2.0.20-57.el8_5.1 2021-12-21 09:09:51 +00:00
CentOS Sources 2793b39ac3 import kexec-tools-2.0.20-57.el8 2021-11-09 09:54:56 +00:00
CentOS Sources 0d79822752 import kexec-tools-2.0.20-46.el8_4.2 2021-09-09 19:42:53 +00:00
CentOS Sources 2a129b2686 import kexec-tools-2.0.20-46.el8_4.1 2021-09-09 19:42:50 +00:00
CentOS Sources 523401d3d4 import kexec-tools-2.0.20-46.el8 2021-09-09 19:42:46 +00:00
CentOS Sources 44d9734f29 import kexec-tools-2.0.20-34.el8_3.2 2021-09-09 19:42:44 +00:00
53 changed files with 2719 additions and 2577 deletions

4
.gitignore vendored
View File

@ -1,3 +1,3 @@
SOURCES/1.7.1.tar.gz
SOURCES/eppic_050615.tar.gz
SOURCES/kexec-tools-2.0.20.tar.xz
SOURCES/makedumpfile-1.6.7.tar.gz
SOURCES/kexec-tools-2.0.25.tar.xz

View File

@ -1,3 +1,3 @@
8f8485c2a1edbc730f4fa1b96ae3ec8d8f1f9761 SOURCES/1.7.1.tar.gz
a096c8e0892b559f40b01916aae240652f75b68a SOURCES/eppic_050615.tar.gz
5d9acd2e741d356d4a48fe4f2d63f66ba431051d SOURCES/kexec-tools-2.0.20.tar.xz
42941a0219d57d99909616778835e5d9ba890711 SOURCES/makedumpfile-1.6.7.tar.gz
78d5d4f7e9d358ca234db9c84a551d9d411eb0b5 SOURCES/kexec-tools-2.0.25.tar.xz

36
SOURCES/60-kdump.install Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/bash
COMMAND="$1"
KERNEL_VERSION="$2"
KDUMP_INITRD_DIR_ABS="$3"
KERNEL_IMAGE="$4"
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
exit 0
fi
if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then
KDUMP_INITRD="initrdkdump"
else
# If `KDUMP_BOOTDIR` is not writable, then the kdump
# initrd must have been placed at `/var/lib/kdump`
if [[ ! -w "/boot" ]]; then
KDUMP_INITRD_DIR_ABS="/var/lib/kdump"
else
KDUMP_INITRD_DIR_ABS="/boot"
fi
KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img"
fi
ret=0
case "$COMMAND" in
add)
# Do nothing, kdump initramfs is strictly host only
# and managed by kdump service
;;
remove)
rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD"
ret=$?
;;
esac
exit $ret

View File

@ -1,15 +1,22 @@
SUBSYSTEM=="cpu", ACTION=="online", GOTO="kdump_reload"
SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload"
SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload"
SUBSYSTEM=="cpu", ACTION=="online", GOTO="kdump_reload_cpu"
SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload_mem"
SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload_mem"
GOTO="kdump_reload_end"
LABEL="kdump_reload"
# If kdump is not loaded, calling kdump-udev-throttle will end up
# doing nothing, but systemd-run will always generate extra logs for
# each call, so trigger the kdump-udev-throttler only if kdump
# service is active to avoid unnecessary logs
LABEL="kdump_reload_mem"
RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'"
GOTO="kdump_reload_end"
LABEL="kdump_reload_cpu"
RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; ! test -f /sys/kernel/fadump_enabled || cat /sys/kernel/fadump_enabled | grep 0 || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'"
LABEL="kdump_reload_end"

View File

@ -1,7 +1,6 @@
#!/bin/bash
. /etc/sysconfig/kdump
. /lib/kdump/kdump-lib.sh
KDUMP_KERNEL=""
KDUMP_INITRD=""
@ -21,18 +20,15 @@ depends() {
}
prepare_kernel_initrd() {
KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}")
if [ -z "$KDUMP_KERNELVER" ]; then
kdump_kver=`uname -r`
if [ "$kernel" != "$kdump_kver" ]; then
dwarn "Using current kernel version '$kdump_kver' for early kdump," \
"but the initramfs is generated for kernel version '$kernel'"
fi
else
kdump_kver=$KDUMP_KERNELVER
. /lib/kdump/kdump-lib.sh
prepare_kdump_bootinfo
# $kernel is a variable from dracut
if [ "$KDUMP_KERNELVER" != $kernel ]; then
dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \
"but the initramfs is generated for kernel version '$kernel'"
fi
KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}"
KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img"
}
install() {
@ -53,13 +49,16 @@ install() {
inst_simple "/etc/sysconfig/kdump"
inst_binary "/usr/sbin/kexec"
inst_binary "/usr/bin/gawk" "/usr/bin/awk"
inst_binary "/usr/bin/logger" "/usr/bin/logger"
inst_binary "/usr/bin/printf" "/usr/bin/printf"
inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
inst_script "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
inst_hook cmdline 00 "$moddir/early-kdump.sh"
inst_binary "$KDUMP_KERNEL"
inst_binary "$KDUMP_INITRD"
ln_r "$KDUMP_KERNEL" "${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}"
ln_r "$KDUMP_INITRD" "${KDUMP_BOOTDIR}/initramfs-earlykdump.img"
ln_r "$KDUMP_KERNEL" "/boot/kernel-earlykdump"
ln_r "$KDUMP_INITRD" "/boot/initramfs-earlykdump"
chmod -x "${initdir}/$KDUMP_KERNEL"
}

View File

@ -12,14 +12,20 @@ EARLY_KEXEC_ARGS=""
. /etc/sysconfig/kdump
. /lib/dracut-lib.sh
. /lib/kdump-lib.sh
. /lib/kdump-logger.sh
#initiate the kdump logger
dlog_init
if [ $? -ne 0 ]; then
echo "failed to initiate the kdump logger."
exit 1
fi
prepare_parameters()
{
EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}")
KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}")
EARLY_KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}"
EARLY_KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-earlykdump.img"
EARLY_KDUMP_KERNEL="/boot/kernel-earlykdump"
EARLY_KDUMP_INITRD="/boot/initramfs-earlykdump"
}
early_kdump_load()
@ -30,7 +36,7 @@ early_kdump_load()
fi
if is_fadump_capable; then
echo "WARNING: early kdump doesn't support fadump."
dwarn "WARNING: early kdump doesn't support fadump."
return 1
fi
@ -44,18 +50,25 @@ early_kdump_load()
EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}")
if is_secure_boot_enforced; then
echo "Secure Boot is enabled. Using kexec file based syscall."
dinfo "Secure Boot is enabled. Using kexec file based syscall."
EARLY_KEXEC_ARGS="$EARLY_KEXEC_ARGS -s"
fi
# Here, only output the messages, but do not save these messages
# to a file because the target disk may not be mounted yet, the
# earlykdump is too early.
ddebug "earlykdump: $KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \
--command-line=$EARLY_KDUMP_CMDLINE --initrd=$EARLY_KDUMP_INITRD \
$EARLY_KDUMP_KERNEL"
$KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \
--command-line="$EARLY_KDUMP_CMDLINE" \
--initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL
if [ $? == 0 ]; then
echo "kexec: loaded early-kdump kernel"
dinfo "kexec: loaded early-kdump kernel"
return 0
else
echo "kexec: failed to load early-kdump kernel"
derror "kexec: failed to load early-kdump kernel"
return 1
fi
}
@ -63,10 +76,10 @@ early_kdump_load()
set_early_kdump()
{
if getargbool 0 rd.earlykdump; then
echo "early-kdump is enabled."
dinfo "early-kdump is enabled."
early_kdump_load
else
echo "early-kdump is disabled."
dinfo "early-kdump is disabled."
fi
return 0

View File

@ -0,0 +1,48 @@
#!/bin/sh
export PATH=/usr/bin:/usr/sbin
export SYSTEMD_IN_INITRD=lenient
[ -e /proc/mounts ] ||
(mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
grep -q '^sysfs /sys sysfs' /proc/mounts ||
(mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
grep -q '^none / ' /proc/mounts || grep -q '^rootfs / ' /proc/mounts && ROOTFS_IS_RAMFS=1
if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
mkdir /newroot
mount -t ramfs ramfs /newroot
if [ $ROOTFS_IS_RAMFS ]; then
for FILE in $(ls -A /fadumproot/); do
mv /fadumproot/$FILE /newroot/
done
exec switch_root /newroot /init
else
mkdir /newroot/sys /newroot/proc /newroot/dev /newroot/run /newroot/oldroot
grep -q '^devtmpfs /dev devtmpfs' /proc/mounts && mount --move /dev /newroot/dev
grep -q '^tmpfs /run tmpfs' /proc/mounts && mount --move /run /newroot/run
mount --move /sys /newroot/sys
mount --move /proc /newroot/proc
cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/
cd /newroot && pivot_root . oldroot
loop=1
while [ $loop ]; do
unset loop
while read -r _ mp _; do
case $mp in
/oldroot/*) umount -d "$mp" && loop=1 ;;
esac
done </proc/mounts
done
umount -d -l oldroot
exec /init
fi
else
exec /init.dracut
fi

View File

@ -0,0 +1,23 @@
#!/bin/bash
check() {
return 255
}
depends() {
return 0
}
install() {
mv -f "$initdir/init" "$initdir/init.dracut"
inst_script "$moddir/init-fadump.sh" /init
chmod a+x "$initdir/init"
# Install required binaries for the init script (init-fadump.sh)
inst_multiple sh modprobe grep mkdir mount
if dracut_module_included "squash"; then
inst_multiple cp pivot_root umount
else
inst_multiple ls mv switch_root
fi
}

View File

@ -5,7 +5,6 @@ if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump
exit 0
fi
exec &> /dev/console
. /lib/dracut-lib.sh
. /lib/kdump-lib-initramfs.sh
@ -22,7 +21,7 @@ do_dump()
_ret=$?
if [ $_ret -ne 0 ]; then
echo "kdump: saving vmcore failed"
derror "saving vmcore failed"
fi
return $_ret
@ -36,7 +35,7 @@ do_kdump_pre()
"$KDUMP_PRE"
_ret=$?
if [ $_ret -ne 0 ]; then
echo "kdump: $KDUMP_PRE exited with $_ret status"
derror "$KDUMP_PRE exited with $_ret status"
return $_ret
fi
fi
@ -47,7 +46,7 @@ do_kdump_pre()
"$file"
_ret=$?
if [ $_ret -ne 0 ]; then
echo "kdump: $file exited with $_ret status"
derror "$file exited with $_ret status"
fi
done
fi
@ -63,7 +62,7 @@ do_kdump_post()
"$file" "$1"
_ret=$?
if [ $_ret -ne 0 ]; then
echo "kdump: $file exited with $_ret status"
derror "$file exited with $_ret status"
fi
done
fi
@ -72,7 +71,7 @@ do_kdump_post()
"$KDUMP_POST" "$1"
_ret=$?
if [ $_ret -ne 0 ]; then
echo "kdump: $KDUMP_POST exited with $_ret status"
derror "$KDUMP_POST exited with $_ret status"
fi
fi
}
@ -88,7 +87,7 @@ dump_raw()
[ -b "$_raw" ] || return 1
echo "kdump: saving to raw disk $_raw"
dinfo "saving to raw disk $_raw"
if ! $(echo -n $CORE_COLLECTOR|grep -q makedumpfile); then
_src_size=`ls -l /proc/vmcore | cut -d' ' -f5`
@ -96,21 +95,25 @@ dump_raw()
monitor_dd_progress $_src_size_mb &
fi
echo "kdump: saving vmcore"
dinfo "saving vmcore"
$CORE_COLLECTOR /proc/vmcore | dd of=$_raw bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1
sync
echo "kdump: saving vmcore complete"
dinfo "saving vmcore complete"
return 0
}
dump_ssh()
{
local _ret=0
local _exitcode=0 _exitcode2=0
local _opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes"
local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR"
local _host=$2
local _vmcore="vmcore"
local _ipv6_addr="" _username=""
echo "kdump: saving to $_host:$_dir"
dinfo "saving to $_host:$_dir"
cat /var/lib/random-seed > /dev/urandom
ssh -q $_opt $_host mkdir -p $_dir || return 1
@ -118,17 +121,54 @@ dump_ssh()
save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" $_host
save_opalcore_ssh ${_dir} "${_opt}" $_host
echo "kdump: saving vmcore"
dinfo "saving vmcore"
if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then
scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete" || return 1
ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/vmcore" || return 1
else
$CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "dd bs=512 of=$_dir/vmcore-incomplete" || return 1
ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/vmcore.flat" || return 1
if is_ipv6_address "$_host"; then
_username=${_host%@*}
_ipv6_addr="[${_host#*@}]"
fi
if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then
if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then
scp -q $_opt /proc/vmcore "$_username@$_ipv6_addr:$_dir/vmcore-incomplete"
else
scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete"
fi
_exitcode=$?
else
$CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "umask 0077 && dd bs=512 of=$_dir/vmcore-incomplete"
_exitcode=$?
_vmcore="vmcore.flat"
fi
if [ $_exitcode -eq 0 ]; then
ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/$_vmcore"
_exitcode2=$?
if [ $_exitcode2 -ne 0 ]; then
derror "moving vmcore failed, _exitcode:$_exitcode2"
else
dinfo "saving vmcore complete"
fi
else
derror "saving vmcore failed, _exitcode:$_exitcode"
fi
dinfo "saving the $KDUMP_LOG_FILE to $_host:$_dir/"
save_log
if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then
scp -q $_opt $KDUMP_LOG_FILE "$_username@$_ipv6_addr:$_dir/"
else
scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/"
fi
_ret=$?
if [ $_ret -ne 0 ]; then
derror "saving log file failed, _exitcode:$_ret"
fi
if [ $_exitcode -ne 0 ] || [ $_exitcode2 -ne 0 ];then
return 1
fi
echo "kdump: saving vmcore complete"
return 0
}
@ -136,6 +176,9 @@ save_opalcore_ssh() {
local _path=$1
local _opts="$2"
local _location=$3
local _user_name="" _ipv6addr=""
ddebug "_path=$_path _opts=$_opts _location=$_location"
if [ ! -f $OPALCORE ]; then
# Check if we are on an old kernel that uses a different path
@ -146,15 +189,25 @@ save_opalcore_ssh() {
fi
fi
echo "kdump: saving opalcore"
scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete
if is_ipv6_address "$_host"; then
_user_name=${_location%@*}
_ipv6addr="[${_location#*@}]"
fi
dinfo "saving opalcore:$OPALCORE to $_location:$_path"
if [ -n "$_user_name" ] && [ -n "$_ipv6addr" ]; then
scp $_opts $OPALCORE $_user_name@$_ipv6addr:$_path/opalcore-incomplete
else
scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete
fi
if [ $? -ne 0 ]; then
echo "kdump: saving opalcore failed"
derror "saving opalcore failed"
return 1
fi
ssh $_opts $_location mv $_path/opalcore-incomplete $_path/opalcore
echo "kdump: saving opalcore complete"
dinfo "saving opalcore complete"
return 0
}
@ -164,15 +217,15 @@ save_vmcore_dmesg_ssh() {
local _opts="$3"
local _location=$4
echo "kdump: saving vmcore-dmesg.txt"
$_dmesg_collector /proc/vmcore | ssh $_opts $_location "dd of=$_path/vmcore-dmesg-incomplete.txt"
dinfo "saving vmcore-dmesg.txt to $_location:$_path"
$_dmesg_collector /proc/vmcore | ssh $_opts $_location "umask 0077 && dd of=$_path/vmcore-dmesg-incomplete.txt"
_exitcode=$?
if [ $_exitcode -eq 0 ]; then
ssh -q $_opts $_location mv $_path/vmcore-dmesg-incomplete.txt $_path/vmcore-dmesg.txt
echo "kdump: saving vmcore-dmesg.txt complete"
dinfo "saving vmcore-dmesg.txt complete"
else
echo "kdump: saving vmcore-dmesg.txt failed"
derror "saving vmcore-dmesg.txt failed"
fi
}
@ -182,12 +235,12 @@ get_host_ip()
if is_nfs_dump_target || is_ssh_dump_target
then
kdumpnic=$(getarg kdumpnic=)
[ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1
[ -z "$kdumpnic" ] && derror "failed to get kdumpnic!" && return 1
_host=`ip addr show dev $kdumpnic|grep '[ ]*inet'`
[ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
[ $? -ne 0 ] && derror "wrong kdumpnic: $kdumpnic" && return 1
_host=`echo $_host | head -n 1 | cut -d' ' -f2`
_host="${_host%%/*}"
[ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
[ -z "$_host" ] && derror "wrong kdumpnic: $kdumpnic" && return 1
HOST_IP=$_host
fi
return 0
@ -196,7 +249,7 @@ get_host_ip()
read_kdump_conf()
{
if [ ! -f "$KDUMP_CONF" ]; then
echo "kdump: $KDUMP_CONF not found"
derror "$KDUMP_CONF not found"
return
fi
@ -240,7 +293,7 @@ fence_kdump_notify
get_host_ip
if [ $? -ne 0 ]; then
echo "kdump: get_host_ip exited with non-zero status!"
derror "get_host_ip exited with non-zero status!"
exit 1
fi
@ -250,7 +303,7 @@ fi
do_kdump_pre
if [ $? -ne 0 ]; then
echo "kdump: kdump_pre script exited with non-zero status!"
derror "kdump_pre script exited with non-zero status!"
do_final_action
# During systemd service to reboot the machine, stop this shell script running
exit 1
@ -261,7 +314,7 @@ DUMP_RETVAL=$?
do_kdump_post $DUMP_RETVAL
if [ $? -ne 0 ]; then
echo "kdump: kdump_post script exited with non-zero status!"
derror "kdump_post script exited with non-zero status!"
fi
if [ $DUMP_RETVAL -ne 0 ]; then

View File

@ -1,11 +1,27 @@
#!/bin/bash
. $dracutfunctions
. /lib/kdump/kdump-lib.sh
_save_kdump_netifs() {
local _name
if ! [[ -d "${initdir}/tmp" ]]; then
mkdir -p "${initdir}/tmp"
fi
if [[ -n $2 ]]; then
_name=$2
else
_name=$1
fi
unique_netifs[$1]=$_name
}
_get_kdump_netifs() {
echo -n "${!unique_netifs[@]}"
}
kdump_module_init() {
if ! [[ -d "${initdir}/tmp" ]]; then
mkdir -p "${initdir}/tmp"
fi
. /lib/kdump/kdump-lib.sh
}
check() {
[[ $debug ]] && set -x
@ -20,24 +36,41 @@ check() {
depends() {
local _dep="base shutdown"
is_squash_available() {
for kmodule in squashfs overlay loop; do
if [ -z "$KDUMP_KERNELVER" ]; then
modprobe --dry-run $kmodule &>/dev/null || return 1
else
modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1
fi
done
kdump_module_init
add_opt_module() {
[[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1"
}
if is_squash_available && ! is_fadump_capable; then
_dep="$_dep squash"
if is_squash_available; then
add_opt_module squash
else
dwarning "Required modules to build a squashed kdump image is missing!"
fi
add_opt_module watchdog-modules
if is_wdt_active; then
add_opt_module watchdog
fi
if is_ssh_dump_target; then
_dep="$_dep ssh-client"
fi
if is_lvm2_thinp_dump_target; then
if grep -q lvmthinpool-monitor <<< $(dracut --list-modules); then
add_opt_module lvmthinpool-monitor
else
dwarning "Required lvmthinpool-monitor modules is missing! Please upgrade dracut >= 057."
fi
fi
if [ "$(uname -m)" = "s390x" ]; then
_dep="$_dep znet"
fi
if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then
_dep="$_dep drm"
add_opt_module drm
fi
if is_generic_fence_kdump || is_pcs_fence_kdump; then
@ -45,7 +78,6 @@ depends() {
fi
echo $_dep
return 0
}
kdump_is_bridge() {
@ -100,12 +132,122 @@ kdump_setup_dns() {
done < "/etc/resolv.conf"
}
# $1: repeat times
# $2: string to be repeated
# $3: separator
repeatedly_join_str() {
local _count="$1"
local _str="$2"
local _separator="$3"
local i _res
if [[ "$_count" -le 0 ]]; then
echo -n ""
return
fi
i=0
_res="$_str"
((_count--))
while [[ "$i" -lt "$_count" ]]; do
((i++))
_res="${_res}${_separator}${_str}"
done
echo -n "$_res"
}
# $1: prefix
# $2: ipv6_flag="-6" indicates it's IPv6
# Given a prefix, calculate the netmask (equivalent of "ipcalc -m")
# by concatenating three parts,
# 1) the groups with all bits set 1
# 2) a group with partial bits set to 0
# 3) the groups with all bits set to 0
cal_netmask_by_prefix() {
local _prefix="$1"
local _ipv6_flag="$2" _ipv6
local _bits_per_octet=8
local _count _res _octets_per_group _octets_total _seperator _total_groups
local _max_group_value _max_group_value_repr _bits_per_group _tmp _zero_bits
if [[ "$_ipv6_flag" == "-6" ]]; then
_ipv6=1
else
_ipv6=0
fi
if [[ "$_prefix" -lt 0 || "$_prefix" -gt 128 ]] || \
( ((!_ipv6)) && [[ "$_prefix" -gt 32 ]] ); then
derror "Bad prefix:$_prefix for calculating netmask"
exit 1
fi
if ((_ipv6)); then
_octets_per_group=2
_octets_total=16
_seperator=":"
else
_octets_per_group=1
_octets_total=4
_seperator="."
fi
_total_groups=$((_octets_total/_octets_per_group))
_bits_per_group=$((_octets_per_group * _bits_per_octet))
_max_group_value=$(((1 << _bits_per_group) - 1))
if ((_ipv6)); then
_max_group_value_repr=$(printf "%x" $_max_group_value)
else
_max_group_value_repr="$_max_group_value"
fi
_count=$((_prefix/_octets_per_group/_bits_per_octet))
_first_part=$(repeatedly_join_str "$_count" "$_max_group_value_repr" "$_seperator")
_res="$_first_part"
_tmp=$((_octets_total*_bits_per_octet-_prefix))
_zero_bits=$(expr $_tmp % $_bits_per_group)
if [[ "$_zero_bits" -ne 0 ]]; then
_second_part=$((_max_group_value >> _zero_bits << _zero_bits))
if ((_ipv6)); then
_second_part=$(printf "%x" $_second_part)
fi
((_count++))
if [[ -z "$_first_part" ]]; then
_res="$_second_part"
else
_res="${_first_part}${_seperator}${_second_part}"
fi
fi
_count=$((_total_groups-_count))
if [[ "$_count" -eq 0 ]]; then
echo -n "$_res"
return
fi
if ((_ipv6)) && [[ "$_count" -gt 1 ]] ; then
# use condensed notion for IPv6
_third_part=":"
else
_third_part=$(repeatedly_join_str "$_count" "0" "$_seperator")
fi
if [[ -z "$_res" ]] && ((!_ipv6)) ; then
echo -n "${_third_part}"
else
echo -n "${_res}${_seperator}${_third_part}"
fi
}
#$1: netdev name
#$2: srcaddr
#if it use static ip echo it, or echo null
kdump_static_ip() {
local _netdev="$1" _srcaddr="$2" _ipv6_flag
local _netmask _gateway _ipaddr _target _nexthop
local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag
local _netmask _gateway _ipaddr _target _nexthop _prefix
_ipaddr=$(ip addr show dev $_netdev permanent | awk "/ $_srcaddr\/.* /{print \$2}")
@ -123,7 +265,12 @@ kdump_static_ip() {
_srcaddr="[$_srcaddr]"
_gateway="[$_gateway]"
else
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
_prefix=$(cut -d'/' -f2 <<< "$_ipaddr")
_netmask=$(cal_netmask_by_prefix "$_prefix" "$_ipv6_flag")
if [[ "$?" -ne 0 ]]; then
derror "Failed to calculate netmask for $_ipaddr"
exit 1
fi
fi
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fi
@ -136,7 +283,7 @@ kdump_static_ip() {
_target="[$_target]"
_nexthop="[$_nexthop]"
fi
echo "rd.route=$_target:$_nexthop:$_netdev"
echo "rd.route=$_target:$_nexthop:$kdumpnic"
done >> ${initdir}/etc/cmdline.d/45route-static.conf
}
@ -176,11 +323,35 @@ kdump_setup_ifname() {
echo "$_ifname"
}
kdump_install_nm_netif_allowlist() {
local _netif _except_netif _netif_allowlist _netif_allowlist_nm_conf
for _netif in $1; do
_per_mac=$(kdump_get_perm_addr "$_netif")
if [[ "$_per_mac" != 'not set' ]]; then
_except_netif="mac:$_per_mac"
else
_except_netif="interface-name:${unique_netifs[${_netif}]}"
fi
_netif_allowlist="${_netif_allowlist}except:${_except_netif};"
done
_netif_allowlist_nm_conf=${initdir}/tmp/netif_allowlist_nm_conf
cat << EOF > "$_netif_allowlist_nm_conf"
[device-others]
match-device=${_netif_allowlist}
managed=false
EOF
inst "$_netif_allowlist_nm_conf" "/etc/NetworkManager/conf.d/10-kdump-netif_allowlist.conf"
rm -f "$_netif_allowlist_nm_conf"
}
kdump_setup_bridge() {
local _netdev=$1
local _brif _dev _mac _kdumpdev
for _dev in `ls /sys/class/net/$_netdev/brif/`; do
_kdumpdev=$_dev
_kdumpdev=""
if kdump_is_bond "$_dev"; then
kdump_setup_bond "$_dev"
elif kdump_is_team "$_dev"; then
@ -192,6 +363,8 @@ kdump_setup_bridge() {
_kdumpdev=$(kdump_setup_ifname $_dev)
echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/41bridge.conf
fi
_save_kdump_netifs "$_dev" "$_kdumpdev"
[[ -z $_kdumpdev ]] && _kdumpdev=$_dev
_brif+="$_kdumpdev,"
done
echo " bridge=$_netdev:$(echo $_brif | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/41bridge.conf
@ -203,6 +376,7 @@ kdump_setup_bond() {
for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do
_mac=$(kdump_get_perm_addr $_dev)
_kdumpdev=$(kdump_setup_ifname $_dev)
_save_kdump_netifs "$_dev" "$_kdumpdev"
echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf
_slaves+="$_kdumpdev,"
done
@ -221,6 +395,7 @@ kdump_setup_team() {
for _dev in `teamnl $_netdev ports | awk -F':' '{print $2}'`; do
_mac=$(kdump_get_perm_addr $_dev)
_kdumpdev=$(kdump_setup_ifname $_dev)
_save_kdump_netifs "$_dev" "$_kdumpdev"
echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf
_slaves+="$_kdumpdev,"
done
@ -244,14 +419,10 @@ kdump_setup_vlan() {
local _netmac="$(kdump_get_mac_addr $_phydev)"
local _kdumpdev
#Just support vlan over bond, it is not easy
#to support all other complex setup
#Just support vlan over bond and team
if kdump_is_bridge "$_phydev"; then
derror "Vlan over bridge is not supported!"
exit 1
elif kdump_is_team "$_phydev"; then
derror "Vlan over team is not supported!"
exit 1
elif kdump_is_bond "$_phydev"; then
kdump_setup_bond "$_phydev"
echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf
@ -259,6 +430,38 @@ kdump_setup_vlan() {
_kdumpdev="$(kdump_setup_ifname $_phydev)"
echo " vlan=$(kdump_setup_ifname $_netdev):$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf
fi
_save_kdump_netifs "$_phydev" "$_kdumpdev"
}
# find online znet device
# return ifname (_netdev)
# code reaped from the list_configured function of
# https://github.com/hreinecke/s390-tools/blob/master/zconf/znetconf
find_online_znet_device() {
local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices"
local NETWORK_DEVICES d ifname ONLINE
[ ! -d "$CCWGROUPBUS_DEVICEDIR" ] && return
NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR)
for d in $NETWORK_DEVICES
do
[ ! -f "$d/online" ] && continue
read ONLINE < $d/online
if [ $ONLINE -ne 1 ]; then
continue
fi
# determine interface name, if there (only for qeth and if
# device is online)
if [ -f $d/if_name ]
then
read ifname < $d/if_name
elif [ -d $d/net ]
then
ifname=$(ls $d/net/)
fi
[ -n "$ifname" ] && break
done
echo -n "$ifname"
}
# setup s390 znet cmdline
@ -269,33 +472,44 @@ kdump_setup_znet() {
source_ifcfg_file $_netdev
[[ -z "$NETTYPE" ]] && return
[[ -z "$SUBCHANNELS" ]] && return
for i in $OPTIONS; do
_options=${_options},$i
done
echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS} > ${initdir}/etc/cmdline.d/30znet.conf
echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} rd.znet_ifname=$(kdump_setup_ifname $_netdev):${SUBCHANNELS} > ${initdir}/etc/cmdline.d/30znet.conf
}
# Setup dracut to bringup a given network interface
kdump_setup_netdev() {
local _netdev=$1 _srcaddr=$2
local _static _proto _ip_conf _ip_opts _ifname_opts
local _static _proto _ip_conf _ip_opts _ifname_opts kdumpnic
local _netmac=$(kdump_get_mac_addr $_netdev)
local _znet_netdev
if [ "$(uname -m)" = "s390x" ]; then
kdump_setup_znet $_netdev
kdumpnic=$(kdump_setup_ifname $_netdev)
_znet_netdev=$(find_online_znet_device)
if [[ -n "$_znet_netdev" ]]; then
$(kdump_setup_znet "$_znet_netdev")
if [[ $? != 0 ]]; then
derror "Failed to set up znet"
exit 1
fi
fi
_static=$(kdump_static_ip $_netdev $_srcaddr)
_static=$(kdump_static_ip $_netdev $_srcaddr $kdumpnic)
if [ -n "$_static" ]; then
_proto=none
elif is_ipv6_address $_srcaddr; then
_proto=either6
_proto=auto6
else
_proto=dhcp
fi
_ip_conf="${initdir}/etc/cmdline.d/40ip.conf"
_ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}"
_ip_opts=" ip=${_static}$kdumpnic:${_proto}"
# dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same.
# so we have to avoid adding duplicates
@ -315,9 +529,10 @@ kdump_setup_netdev() {
elif kdump_is_vlan "$_netdev"; then
kdump_setup_vlan "$_netdev"
else
_ifname_opts=" ifname=$(kdump_setup_ifname $_netdev):$_netmac"
_ifname_opts=" ifname=$kdumpnic:$_netmac"
echo "$_ifname_opts" >> $_ip_conf
fi
_save_kdump_netifs "$_netdev" "$_kdumpdev"
kdump_setup_dns "$_netdev"
@ -606,7 +821,7 @@ kdump_check_iscsi_targets () {
# If our prerequisites are not met, fail anyways.
type -P iscsistart >/dev/null || return 1
kdump_check_setup_iscsi() (
kdump_check_setup_iscsi() {
local _dev
_dev=$1
@ -616,7 +831,7 @@ kdump_check_iscsi_targets () {
cd ..
done
[[ -d iscsi_session ]] && kdump_setup_iscsi_device "$PWD"
)
}
[[ $hostonly ]] || [[ $mount_needs ]] && {
for_each_host_dev_and_slaves_all kdump_check_setup_iscsi
@ -759,9 +974,33 @@ remove_cpu_online_rule() {
sed -i '/SUBSYSTEM=="cpu"/d' $file
}
install() {
local arch
kdump_install_systemd_conf() {
local failure_action=$(get_option_value "failure_action")
# Kdump turns out to require longer default systemd mount timeout
# than 1st kernel(90s by default), we use default 300s for kdump.
grep -r "^[[:space:]]*DefaultTimeoutStartSec=" ${initdir}/etc/systemd/system.conf* &>/dev/null
if [ $? -ne 0 ]; then
mkdir -p ${initdir}/etc/systemd/system.conf.d
echo "[Manager]" > ${initdir}/etc/systemd/system.conf.d/kdump.conf
echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf
fi
# Forward logs to console directly, and don't read Kmsg, this avoids
# unneccessary memory consumption and make console output more useful.
# Only do so for non fadump image.
mkdir -p ${initdir}/etc/systemd/journald.conf.d
echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf
echo "Storage=volatile" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
echo "ReadKMsg=no" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
}
install() {
declare -A unique_netifs
local arch _netifs
kdump_module_init
kdump_install_conf
remove_sysctl_conf
@ -789,11 +1028,15 @@ install() {
inst "/bin/head" "/bin/head"
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
inst "/usr/bin/printf" "/sbin/printf"
inst "/usr/bin/logger" "/sbin/logger"
inst "/usr/bin/chmod" "/sbin/chmod"
inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh"
inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
inst "$moddir/kdump.sh" "/usr/bin/kdump.sh"
inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service"
ln_r "$systemdsystemunitdir/kdump-capture.service" "$systemdsystemunitdir/initrd.target.wants/kdump-capture.service"
systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service
inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh"
inst "$moddir/kdump-error-handler.service" "$systemdsystemunitdir/kdump-error-handler.service"
# Replace existing emergency service and emergency target
@ -807,6 +1050,13 @@ install() {
# at some point of time.
kdump_check_iscsi_targets
_netifs=$(_get_kdump_netifs)
if [[ -n "$_netifs" ]]; then
kdump_install_nm_netif_allowlist "$_netifs"
fi
kdump_install_systemd_conf
# For the lvm type target under kdump, in /etc/lvm/lvm.conf we can
# safely replace "reserved_memory=XXXX"(default value is 8192) with
# "reserved_memory=1024" to lower memory pressure under kdump. We do
@ -816,25 +1066,6 @@ install() {
's/\(^[[:space:]]*reserved_memory[[:space:]]*=\)[[:space:]]*[[:digit:]]*/\1 1024/' \
${initdir}/etc/lvm/lvm.conf &>/dev/null
# Kdump turns out to require longer default systemd mount timeout
# than 1st kernel(90s by default), we use default 300s for kdump.
grep -r "^[[:space:]]*DefaultTimeoutStartSec=" ${initdir}/etc/systemd/system.conf* &>/dev/null
if [ $? -ne 0 ]; then
mkdir -p ${initdir}/etc/systemd/system.conf.d
echo "[Manager]" > ${initdir}/etc/systemd/system.conf.d/kdump.conf
echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf
fi
if ! is_fadump_capable; then
# Forward logs to console directly, this avoids unneccessary memory
# consumption and make console output more useful.
# Only do so for non fadump image.
mkdir -p ${initdir}/etc/systemd/journald.conf.d
echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf
echo "Storage=none" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
# Save more memory by dropping switch root capability
dracut_no_switch_root
fi
# Save more memory by dropping switch root capability
dracut_no_switch_root
}

View File

@ -104,6 +104,11 @@ For the recommended value of X, see 'FADump Memory Requirements' section.
# grubby --args="fadump=on crashkernel=6G" --update-kernel=/boot/vmlinuz-`uname -r`
By default, FADump reserved memory will be initialized as CMA area to make the
memory available through CMA allocator on the production kernel. We can opt out
of this, making reserved memory unavailable to production kernel, by booting the
linux kernel with 'fadump=nocma' instead of 'fadump=on'.
The term 'boot memory' means size of the low memory chunk that is required for
a kernel to boot successfully when booted with restricted memory. By default,
the boot memory size will be the larger of 5% of system RAM or 256MB.
@ -219,12 +224,16 @@ Things to remember:
dracut_args --add "network"
4) If FADump is configured to capture vmcore to a remote dump target using SSH
or NFS protocol, the network interface is renamed to kdump-<interface-name>
if <interface-name> is generic, for example, *eth#, or net#. This problem
occurs because the vmcore capture scripts in the initial RAM disk (initrd)
add the kdump- prefix to the network interface name to secure persistent
naming. As the same initrd is used for production kernel boot, the interface
name is changed for the production kernel too.
or NFS protocol, the corresponding network interface '<interface-name>' is
renamed to 'kdump-<interface-name>', if it is generic (like *eth# or net#).
It happens because vmcore capture scripts in the initial RAM disk (initrd)
add the 'kdump-' prefix to the network interface name to secure persistent
naming. And as capture kernel and production kernel use the same initrd in
case of FADump, the interface name is changed for the production kernel too.
This is likely to impact network configuration setup for production kernel.
So, it is recommended to use a non-generic name for a network interface,
before setting up FADump to capture vmcore to a remote dump target based on
that network interface, to avoid running into network configuration issues.
Dump Triggering methods:
@ -326,9 +335,14 @@ the original command line completely.
How to disable FADump:
Remove "fadump=on" from kernel cmdline parameters:
Remove "fadump=on"/"fadump=nocma" from kernel cmdline parameters OR replace
it with "fadump=off" kernel cmdline parameter:
# grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="fadump=on"
or
# grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="fadump=nocma"
OR
# grubby --update-kernel=/boot/vmlinuz-`uname -r` --args="fadump=off"
If KDump is to be used as the dump capturing mechanism, update the crashkernel
parameter (Else, remove "crashkernel=" parameter too, using grubby):

48
SOURCES/kdump.conf → SOURCES/gen-kdump-conf.sh Normal file → Executable file
View File

@ -1,3 +1,12 @@
#!/bin/bash
# $1: target arch
SED_EXP=""
generate()
{
sed "$SED_EXP" << EOF
# This file contains a series of commands to perform (in order) in the kdump
# kernel after a kernel crash in the crash kernel(1st kernel) has happened.
#
@ -21,7 +30,7 @@
# <mnt>/<path>/%HOST-%DATE/, supports DNS.
#
# ssh <user@server>
# - Will scp /proc/vmcore to <user@server>:<path>/%HOST-%DATE/,
# - Will save /proc/vmcore to <user@server>:<path>/%HOST-%DATE/,
# supports DNS.
# NOTE: make sure the user has write permissions on the server.
#
@ -62,9 +71,9 @@
# as the initrd will automatically be populated with a
# config file appropriate for the running kernel.
# The default core_collector for raw/ssh dump is:
# "makedumpfile -F -l --message-level 1 -d 31".
# "makedumpfile -F -l --message-level 7 -d 31".
# The default core_collector for other targets is:
# "makedumpfile -l --message-level 1 -d 31".
# "makedumpfile -l --message-level 7 -d 31".
#
# "makedumpfile -F" will create a flattened vmcore.
# You need to use "makedumpfile -R" to rearrange the dump data to
@ -166,10 +175,12 @@
#ext4 LABEL=/boot
#ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937
#nfs my.server.com:/export/tmp
#nfs [2001:db8::1:2:3:4]:/export/tmp
#ssh user@my.server.com
#ssh user@2001:db8::1:2:3:4
#sshkey /root/.ssh/kdump_id_rsa
path /var/crash
core_collector makedumpfile -l --message-level 1 -d 31
core_collector makedumpfile -l --message-level 7 -d 31
#core_collector scp
#kdump_post /var/crash/scripts/kdump-post.sh
#kdump_pre /var/crash/scripts/kdump-pre.sh
@ -181,3 +192,32 @@ core_collector makedumpfile -l --message-level 1 -d 31
#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"
#fence_kdump_args -p 7410 -f auto -c 0 -i 10
#fence_kdump_nodes node1 node2
EOF
}
update_param()
{
SED_EXP="${SED_EXP}s/^$1.*$/$1 $2/;"
}
case "$1" in
aarch64)
;;
i386)
;;
ppc64)
;;
ppc64le)
;;
s390x)
update_param core_collector \
"makedumpfile -c --message-level 7 -d 31"
;;
x86_64)
;;
*)
echo "Warning: Unknown architecture '$1', using default kdump.conf template."
;;
esac
generate

View File

@ -4,6 +4,7 @@
# http://www.freedesktop.org/wiki/Software/systemd/Generators/
. /usr/lib/kdump/kdump-lib.sh
. /usr/lib/kdump/kdump-logger.sh
# If invokded with no arguments for testing purpose, output to /tmp to
# avoid overriding the existing.

View File

@ -1,10 +1,12 @@
# These variables and functions are useful in 2nd kernel
. /lib/kdump-lib.sh
. /lib/kdump-logger.sh
KDUMP_PATH="/var/crash"
KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log"
CORE_COLLECTOR=""
DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31"
DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 7 -d 31"
DMESG_COLLECTOR="/sbin/vmcore-dmesg"
FAILURE_ACTION="systemctl reboot -f"
DATEDIR=`date +%Y-%m-%d-%T`
@ -20,6 +22,13 @@ KDUMP_POST=""
NEWROOT="/sysroot"
OPALCORE="/sys/firmware/opal/mpipl/core"
#initiate the kdump logger
dlog_init
if [ $? -ne 0 ]; then
echo "failed to initiate the kdump logger."
exit 1
fi
get_kdump_confs()
{
local config_opt config_val
@ -94,34 +103,37 @@ get_kdump_confs()
fi
}
# store the kexec kernel log to a file.
save_log()
{
dmesg -T > $KDUMP_LOG_FILE
if command -v journalctl > /dev/null; then
journalctl -ab >> $KDUMP_LOG_FILE
fi
chmod 600 $KDUMP_LOG_FILE
}
# dump_fs <mount point>
dump_fs()
{
local _exitcode
local _mp=$1
local _dev=$(get_mount_info SOURCE target $_mp -f)
local _op=$(get_mount_info OPTIONS target $_mp -f)
ddebug "dump_fs _mp=$_mp"
# If dump path have a corresponding device entry but not mounted, mount it.
if [ -n "$_dev" ] || [ "$_dev" == "rootfs" ]; then
if ! is_mounted "$_mp"; then
echo "kdump: dump target $_dev is not mounted, trying to mount..."
mkdir -p $_mp
mount -o $_op $_dev $_mp
if [ $? -ne 0 ]; then
echo "kdump: mounting failed (mount point: $_mp, option: $_op)"
return 1
fi
if ! is_mounted "$_mp"; then
dinfo "dump path \"$_mp\" is not mounted, trying to mount..."
mount --target $_mp
if [ $? -ne 0 ]; then
derror "failed to dump to \"$_mp\", it's not a mount point!"
return 1
fi
else
echo "kdump: failed to dump to \"$_mp\", it's not a mount point!"
return 1
fi
# Remove -F in makedumpfile case. We don't want a flat format dump here.
[[ $CORE_COLLECTOR = *makedumpfile* ]] && CORE_COLLECTOR=`echo $CORE_COLLECTOR | sed -e "s/-F//g"`
echo "kdump: saving to $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
dinfo "saving to $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
mount -o remount,rw $_mp || return 1
mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
@ -129,12 +141,29 @@ dump_fs()
save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
save_opalcore_fs "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
echo "kdump: saving vmcore"
$CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete || return 1
mv $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore
sync
dinfo "saving vmcore"
$CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete
_exitcode=$?
if [ $_exitcode -eq 0 ]; then
sync -f "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete"
_sync_exitcode=$?
if [ $_sync_exitcode -eq 0 ]; then
mv "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete" "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore"
dinfo "saving vmcore complete"
else
derror "sync vmcore failed, _exitcode:$_sync_exitcode"
return 1
fi
else
derror "saving vmcore failed, _exitcode:$_exitcode"
fi
echo "kdump: saving vmcore complete"
dinfo "saving the $KDUMP_LOG_FILE to $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
save_log
mv $KDUMP_LOG_FILE $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/
if [ $_exitcode -ne 0 ]; then
return 1
fi
# improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure
return 0
@ -144,19 +173,20 @@ save_vmcore_dmesg_fs() {
local _dmesg_collector=$1
local _path=$2
echo "kdump: saving vmcore-dmesg.txt"
dinfo "saving vmcore-dmesg.txt to ${_path}"
$_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt
_exitcode=$?
if [ $_exitcode -eq 0 ]; then
mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt
chmod 600 ${_path}/vmcore-dmesg.txt
# Make sure file is on disk. There have been instances where later
# saving vmcore failed and system rebooted without sync and there
# was no vmcore-dmesg.txt available.
sync
echo "kdump: saving vmcore-dmesg.txt complete"
dinfo "saving vmcore-dmesg.txt complete"
else
echo "kdump: saving vmcore-dmesg.txt failed"
derror "saving vmcore-dmesg.txt failed"
fi
}
@ -172,43 +202,47 @@ save_opalcore_fs() {
fi
fi
echo "kdump: saving opalcore"
dinfo "saving opalcore:$OPALCORE to ${_path}/opalcore"
cp $OPALCORE ${_path}/opalcore
if [ $? -ne 0 ]; then
echo "kdump: saving opalcore failed"
derror "saving opalcore failed"
return 1
fi
sync
echo "kdump: saving opalcore complete"
dinfo "saving opalcore complete"
return 0
}
dump_to_rootfs()
{
echo "Kdump: trying to bring up rootfs device"
dinfo "Trying to bring up rootfs device"
systemctl start dracut-initqueue
echo "Kdump: waiting for rootfs mount, will timeout after 90 seconds"
dinfo "Waiting for rootfs mount, will timeout after 90 seconds"
systemctl start sysroot.mount
ddebug "NEWROOT=$NEWROOT"
dump_fs $NEWROOT
}
kdump_emergency_shell()
{
echo "PS1=\"kdump:\\\${PWD}# \"" >/etc/profile
ddebug "Switching to dracut emergency..."
/bin/dracut-emergency
rm -f /etc/profile
}
do_failure_action()
{
echo "Kdump: Executing failure action $FAILURE_ACTION"
dinfo "Executing failure action $FAILURE_ACTION"
eval $FAILURE_ACTION
}
do_final_action()
{
dinfo "Executing final action $FINAL_ACTION"
eval $FINAL_ACTION
}

View File

@ -7,6 +7,7 @@ DEFAULT_PATH="/var/crash/"
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled"
LVM_CONF="/etc/lvm/lvm.conf"
is_fadump_capable()
{
@ -19,13 +20,19 @@ is_fadump_capable()
return 1
}
perror_exit() {
echo $@ >&2
exit 1
is_squash_available() {
for kmodule in squashfs overlay loop; do
if [ -z "$KDUMP_KERNELVER" ]; then
modprobe --dry-run $kmodule &>/dev/null || return 1
else
modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1
fi
done
}
perror() {
echo $@ >&2
perror_exit() {
derror "$@"
exit 1
}
is_ssh_dump_target()
@ -56,6 +63,15 @@ is_fs_dump_target()
egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf
}
is_lvm2_thinp_device()
{
_device_path=$1
_lvm2_thin_device=$(lvm lvs -S 'lv_layout=sparse && lv_layout=thin' \
--nosuffix --noheadings -o vg_name,lv_name "$_device_path" 2> /dev/null)
[ -n "$_lvm2_thin_device" ]
}
strip_comments()
{
echo $@ | sed -e 's/\(.*\)#.*/\1/'
@ -155,6 +171,12 @@ is_dump_to_rootfs()
grep -E "^(failure_action|default)[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null
}
is_lvm2_thinp_dump_target()
{
_target=$(get_block_dump_target)
[ -n "$_target" ] && is_lvm2_thinp_device "$_target"
}
get_failure_action_target()
{
local _target
@ -309,9 +331,9 @@ kdump_get_persistent_dev() {
echo $(get_persistent_dev "$dev")
}
is_atomic()
is_ostree()
{
grep -q "ostree" /proc/cmdline
test -f /run/ostree-booted
}
# fixme, try the best to decide whether the ipv6 addr is allocated by slaac or dhcp6
@ -458,28 +480,33 @@ get_ifcfg_filename() {
echo -n "${ifcfg_file}"
}
# returns 0 when omission of watchdog module is desired in dracut_args
# returns 0 when omission of a module is desired in dracut_args
# returns 1 otherwise
is_wdt_mod_omitted() {
local dracut_args
local ret=1
is_dracut_mod_omitted() {
local dracut_args dracut_mod=$1
dracut_args=$(grep "^dracut_args" /etc/kdump.conf)
[[ -z $dracut_args ]] && return $ret
set -- $(grep "^dracut_args" /etc/kdump.conf)
while [ $# -gt 0 ]; do
case $1 in
-o|--omit)
[[ " ${2//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0
esac
shift
done
eval set -- $dracut_args
while :; do
[[ -z $1 ]] && break
case $1 in
-o|--omit)
echo $2 | grep -qw "watchdog"
[[ $? == 0 ]] && ret=0
break
esac
shift
done
return 1
}
return $ret
is_wdt_active() {
local active
[ -d /sys/class/watchdog ] || return 1
for dir in /sys/class/watchdog/*; do
[ -f "$dir/state" ] || continue
active=$(< "$dir/state")
[ "$active" = "active" ] && return 0
done
return 1
}
# If "dracut_args" contains "--mount" information, use it
@ -508,7 +535,7 @@ check_crash_mem_reserved()
mem_reserved=$(cat /sys/kernel/kexec_crash_size)
if [ $mem_reserved -eq 0 ]; then
echo "No memory reserved for crash kernel"
derror "No memory reserved for crash kernel"
return 1
fi
@ -518,7 +545,7 @@ check_crash_mem_reserved()
check_kdump_feasibility()
{
if [ ! -e /sys/kernel/kexec_crash_loaded ]; then
echo "Kdump is not supported on this kernel"
derror "Kdump is not supported on this kernel"
return 1
fi
check_crash_mem_reserved
@ -528,7 +555,7 @@ check_kdump_feasibility()
check_current_kdump_status()
{
if [ ! -f /sys/kernel/kexec_crash_loaded ];then
echo "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel"
derror "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel"
return 1
fi
@ -611,11 +638,16 @@ is_secure_boot_enforced()
local secure_boot_file setup_mode_file
local secure_boot_byte setup_mode_byte
# On powerpc, os-secureboot-enforcing DT property indicates whether secureboot
# is enforced. Return success, if it is found.
# On powerpc, secure boot is enforced if:
# host secure boot: /ibm,secure-boot/os-secureboot-enforcing DT property exists
# guest secure boot: /ibm,secure-boot >= 2
if [ -f /proc/device-tree/ibm,secureboot/os-secureboot-enforcing ]; then
return 0
fi
if [ -f /proc/device-tree/ibm,secure-boot ] && \
[ $(lsprop /proc/device-tree/ibm,secure-boot | tail -1) -ge 2 ]; then
return 0
fi
# Detect secure boot on x86 and arm64
secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null)
@ -656,8 +688,7 @@ prepare_kexec_args()
found_elf_args=`echo $kexec_args | grep elf32-core-headers`
if [ -n "$found_elf_args" ]
then
echo -n "Warning: elf32-core-headers overrides correct elf64 setting"
echo
dwarn "Warning: elf32-core-headers overrides correct elf64 setting"
else
kexec_args="$kexec_args --elf64-core-headers"
fi
@ -672,24 +703,139 @@ prepare_kexec_args()
echo $kexec_args
}
check_boot_dir()
# prepare_kdump_kernel <kdump_kernelver>
# This function return kdump_kernel given a kernel version.
prepare_kdump_kernel()
{
local kdump_bootdir=$1
#If user specify a boot dir for kdump kernel, let's use it. Otherwise
#check whether it's a atomic host. If yes parse the subdirectory under
#/boot; If not just find it under /boot.
if [ -n "$kdump_bootdir" ]; then
echo "$kdump_bootdir"
return
local kdump_kernelver=$1
local dir img boot_dirlist boot_imglist kdump_kernel machine_id
read -r machine_id < /etc/machine-id
boot_dirlist=${KDUMP_BOOTDIR:-"/boot /boot/efi /efi /"}
boot_imglist="$KDUMP_IMG-$kdump_kernelver$KDUMP_IMG_EXT $machine_id/$kdump_kernelver/$KDUMP_IMG"
# The kernel of OSTree based systems is not in the standard locations.
if is_ostree; then
boot_dirlist="$(echo /boot/ostree/*) $boot_dirlist"
fi
if ! is_atomic || [ "$(uname -m)" = "s390x" ]; then
kdump_bootdir="/boot"
else
eval $(cat /proc/cmdline| grep "BOOT_IMAGE" | cut -d' ' -f1)
kdump_bootdir="/boot"$(dirname $BOOT_IMAGE)
# Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format
boot_img="$(grep -P -o '^BOOT_IMAGE=(\S+)' /proc/cmdline | sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\)/\2/")"
if [[ "$boot_img" == *"$kdump_kernelver" ]]; then
boot_imglist="$boot_img $boot_imglist"
fi
echo $kdump_bootdir
for dir in $boot_dirlist; do
for img in $boot_imglist; do
if [[ -f "$dir/$img" ]]; then
kdump_kernel=$(echo "$dir/$img" | tr -s '/')
break 2
fi
done
done
echo "$kdump_kernel"
}
#
# Detect initrd and kernel location, results are stored in global enviromental variables:
# KDUMP_BOOTDIR, KDUMP_KERNELVER, KDUMP_KERNEL, DEFAULT_INITRD, and KDUMP_INITRD
#
# Expectes KDUMP_BOOTDIR, KDUMP_IMG, KDUMP_IMG_EXT, KDUMP_KERNELVER to be loaded from config already
# and will prefer already set values so user can specify custom kernel/initramfs location
#
prepare_kdump_bootinfo()
{
local boot_initrdlist nondebug_kernelver debug_kernelver
local default_initrd_base var_target_initrd_dir
if [[ -z $KDUMP_KERNELVER ]]; then
KDUMP_KERNELVER=$(uname -r)
# Fadump uses the regular bootloader, unlike kdump. So, use the same version
# for default kernel and capture kernel unless specified explicitly with
# KDUMP_KERNELVER option.
if ! is_fadump_capable; then
nondebug_kernelver=$(sed -n -e 's/\(.*\)+debug$/\1/p' <<< "$KDUMP_KERNELVER")
fi
fi
# Use nondebug kernel if possible, because debug kernel will consume more memory and may oom.
if [[ -n $nondebug_kernelver ]]; then
dinfo "Trying to use $nondebug_kernelver."
debug_kernelver=$KDUMP_KERNELVER
KDUMP_KERNELVER=$nondebug_kernelver
fi
KDUMP_KERNEL=$(prepare_kdump_kernel "$KDUMP_KERNELVER")
if ! [[ -e $KDUMP_KERNEL ]]; then
if [[ -n $debug_kernelver ]]; then
dinfo "Fallback to using debug kernel"
KDUMP_KERNELVER=$debug_kernelver
KDUMP_KERNEL=$(prepare_kdump_kernel "$KDUMP_KERNELVER")
fi
fi
if ! [[ -e $KDUMP_KERNEL ]]; then
derror "Failed to detect kdump kernel location"
return 1
fi
if [[ "$KDUMP_KERNEL" == *"+debug" ]]; then
dwarn "Using debug kernel, you may need to set a larger crashkernel than the default value."
fi
# Set KDUMP_BOOTDIR to where kernel image is stored
KDUMP_BOOTDIR=$(dirname "$KDUMP_KERNEL")
# Default initrd should just stay aside of kernel image, try to find it in KDUMP_BOOTDIR
boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd"
for initrd in $boot_initrdlist; do
if [[ -f "$KDUMP_BOOTDIR/$initrd" ]]; then
default_initrd_base="$initrd"
DEFAULT_INITRD="$KDUMP_BOOTDIR/$default_initrd_base"
break
fi
done
# Create kdump initrd basename from default initrd basename
# initramfs-5.7.9-200.fc32.x86_64.img => initramfs-5.7.9-200.fc32.x86_64kdump.img
# initrd => initrdkdump
if [[ -z $default_initrd_base ]]; then
kdump_initrd_base=initramfs-${KDUMP_KERNELVER}kdump.img
elif [[ $default_initrd_base == *.* ]]; then
kdump_initrd_base=${default_initrd_base%.*}kdump.${DEFAULT_INITRD##*.}
else
kdump_initrd_base=${default_initrd_base}kdump
fi
# Place kdump initrd in $(/var/lib/kdump) if $(KDUMP_BOOTDIR) not writable
if [[ ! -w $KDUMP_BOOTDIR ]]; then
var_target_initrd_dir="/var/lib/kdump"
mkdir -p "$var_target_initrd_dir"
KDUMP_INITRD="$var_target_initrd_dir/$kdump_initrd_base"
else
KDUMP_INITRD="$KDUMP_BOOTDIR/$kdump_initrd_base"
fi
}
get_watchdog_drvs()
{
local _wdtdrvs _drv _dir
for _dir in /sys/class/watchdog/*; do
# device/modalias will return driver of this device
[[ -f "$_dir/device/modalias" ]] || continue
_drv=$(< "$_dir/device/modalias")
_drv=$(modprobe --set-version "$KDUMP_KERNELVER" -R $_drv 2>/dev/null)
for i in $_drv; do
if ! [[ " $_wdtdrvs " == *" $i "* ]]; then
_wdtdrvs="$_wdtdrvs $i"
fi
done
done
echo $_wdtdrvs
}
#
@ -734,12 +880,212 @@ prepare_cmdline()
cmdline=$(append_cmdline "${cmdline}" disable_cpu_apicid ${id})
fi
# Disable efifb if hyperv_fb is in use, hyperv_fb will relocate the framebuffer
# but kexec_file_load always use original screen_info and in second kernel efifb
# will try to access an invalid framebuffer address
if [ -d /sys/module/hyperv_fb ]; then
cmdline=$(append_cmdline "$cmdline" "video=efifb:off")
fi
# If any watchdog is used, set it's pretimeout to 0. pretimeout let
# watchdog panic the kernel first, and reset the system after the
# panic. If the system is already in kdump, panic is not helpful
# and only increase the chance of watchdog failure.
for i in $(get_watchdog_drvs); do
cmdline+=" $i.pretimeout=0"
if [[ $i == hpwdt ]]; then
# hpwdt have a special parameter kdumptimeout, is's only suppose
# to be set to non-zero in first kernel. In kdump, non-zero
# value could prevent the watchdog from resetting the system.
cmdline+=" $i.kdumptimeout=0"
fi
done
echo ${cmdline}
}
#get system memory size in the unit of GB
get_system_size()
{
result=$(cat /proc/iomem | grep "System RAM" | awk -F ":" '{ print $1 }' | tr [:lower:] [:upper:] | paste -sd+)
result="+$result"
# replace '-' with '+0x' and '+' with '-0x'
sum=$( echo $result | sed -e 's/-/K0x/g' | sed -e 's/+/-0x/g' | sed -e 's/K/+/g' )
size=$(printf "%d\n" $(($sum)))
# in MB unit
let size=$size/1024/1024
# since RHEL-8.5 kernel round up total memory to 128M, so should user space
let size=($size+127)/128
let size=$size*128
# in GB unit
let size=$size/1024
echo $size
}
get_recommend_size()
{
local mem_size=$1
local _ck_cmdline=$2
local OLDIFS="$IFS"
last_sz=""
last_unit=""
start=${_ck_cmdline: :1}
if [ $mem_size -lt $start ]; then
echo "0M"
return
fi
IFS=','
for i in $_ck_cmdline; do
end=$(echo $i | awk -F "-" '{ print $2 }' | awk -F ":" '{ print $1 }')
recommend=$(echo $i | awk -F "-" '{ print $2 }' | awk -F ":" '{ print $2 }')
size=${end: : -1}
unit=${end: -1}
if [ $unit == 'T' ]; then
let size=$size*1024
fi
if [ $mem_size -lt $size ]; then
echo $recommend
IFS="$OLDIFS"
return
fi
done
IFS="$OLDIFS"
}
# return recommended size based on current system RAM size
kdump_get_arch_recommend_size()
{
if ! [[ -r "/proc/iomem" ]] ; then
echo "Error, can not access /proc/iomem."
return 1
fi
arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr [:lower:] [:upper:])
if [ $arch == "X86_64" ] || [ $arch == "S390X" ]; then
ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M"
elif [ $arch == "AARCH64" ]; then
ck_cmdline="2G-:448M"
elif [ $arch == "PPC64LE" ]; then
if is_fadump_capable; then
ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G"
else
ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G"
fi
fi
ck_cmdline=$(echo $ck_cmdline | sed -e 's/-:/-102400T:/g')
sys_mem=$(get_system_size)
result=$(get_recommend_size $sys_mem "$ck_cmdline")
echo $result
return 0
}
# Print all underlying crypt devices of a block device
# print nothing if device is not on top of a crypt device
# $1: the block device to be checked in maj:min format
get_luks_crypt_dev()
{
local _type
[[ -b /dev/block/$1 ]] || return 1
_type=$(blkid -u filesystem,crypto -o export -- "/dev/block/$1" | \
sed -n -E "s/^TYPE=(.*)$/\1/p")
[[ $_type == "crypto_LUKS" ]] && echo $1
for _x in /sys/dev/block/$1/slaves/*; do
[[ -f $_x/dev ]] || continue
[[ $_x/subsystem -ef /sys/class/block ]] || continue
get_luks_crypt_dev "$(< "$_x/dev")"
done
}
# kdump_get_maj_min <device>
# Prints the major and minor of a device node.
# Example:
# $ get_maj_min /dev/sda2
# 8:2
kdump_get_maj_min() {
local _majmin
_majmin="$(stat -L -c '%t:%T' "$1" 2> /dev/null)"
printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))"
}
get_all_kdump_crypt_dev()
{
local _dev _crypt
for _dev in $(get_block_dump_target); do
_crypt=$(get_luks_crypt_dev $(kdump_get_maj_min "$_dev"))
[[ -n "$_crypt" ]] && echo $_crypt
done
}
check_vmlinux()
{
# Use readelf to check if it's a valid ELF
readelf -h $1 &>/dev/null || return 1
}
get_vmlinux_size()
{
local size=0
while read _type _offset _virtaddr _physaddr _fsize _msize _flg _aln; do
size=$(( $size + $_msize ))
done <<< $(readelf -l -W $1 | grep "^ LOAD" 2>/dev/stderr)
echo $size
}
try_decompress()
{
# The obscure use of the "tr" filter is to work around older versions of
# "grep" that report the byte offset of the line instead of the pattern.
# Try to find the header ($1) and decompress from here
for pos in `tr "$1\n$2" "\n$2=" < "$4" | grep -abo "^$2"`
do
if ! type -P $3 > /dev/null; then
ddebug "Signiature detected but '$3' is missing, skip this decompressor"
break
fi
pos=${pos%%:*}
tail -c+$pos "$img" | $3 > $5 2> /dev/null
if check_vmlinux $5; then
ddebug "Kernel is extracted with '$3'"
return 0
fi
done
return 1
}
# Borrowed from linux/scripts/extract-vmlinux
get_kernel_size()
{
# Prepare temp files:
local img=$1 tmp=$(mktemp /tmp/vmlinux-XXX)
trap "rm -f $tmp" 0
# Try to check if it's a vmlinux already
check_vmlinux $img && get_vmlinux_size $img && return 0
# That didn't work, so retry after decompression.
try_decompress '\037\213\010' xy gunzip $img $tmp || \
try_decompress '\3757zXZ\000' abcde unxz $img $tmp || \
try_decompress 'BZh' xy bunzip2 $img $tmp || \
try_decompress '\135\0\0\0' xxx unlzma $img $tmp || \
try_decompress '\211\114\132' xy 'lzop -d' $img $tmp || \
try_decompress '\002!L\030' xxx 'lz4 -d' $img $tmp || \
try_decompress '(\265/\375' xxx unzstd $img $tmp
# Finally check for uncompressed images or objects:
[[ $? -eq 0 ]] && get_vmlinux_size $tmp && return 0
# Fallback to use iomem
local _size=0
for _seg in $(cat /proc/iomem | grep -E "Kernel (code|rodata|data|bss)" | cut -d ":" -f 1); do
_size=$(( $_size + 0x${_seg#*-} - 0x${_seg%-*} ))
done
echo $_size
}

348
SOURCES/kdump-logger.sh Executable file
View File

@ -0,0 +1,348 @@
#!/bin/bash
#
# This comes from the dracut-logger.sh
#
# The logger defined 4 logging levels:
# - ddebug (4)
# The DEBUG Level designates fine-grained informational events that are most
# useful to debug an application.
# - dinfo (3)
# The INFO level designates informational messages that highlight the
# progress of the application at coarse-grained level.
# - dwarn (2)
# The WARN level designates potentially harmful situations.
# - derror (1)
# The ERROR level designates error events that might still allow the
# application to continue running.
#
# Logging is controlled by following global variables:
# - @var kdump_stdloglvl - logging level to standard error (console output)
# - @var kdump_sysloglvl - logging level to syslog (by logger command)
# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time)
#
# If any of the variables is not set, the function dlog_init() sets it to default:
# - In the first kernel:
# - @var kdump_stdloglvl = 3 (info)
# - @var kdump_sysloglvl = 0 (no logging)
# - @var kdump_kmsgloglvl = 0 (no logging)
#
# -In the second kernel:
# - @var kdump_stdloglvl = 0 (no logging)
# - @var kdump_sysloglvl = 3 (info)
# - @var kdump_kmsgloglvl = 0 (no logging)
#
# First of all you have to start with dlog_init() function which initializes
# required variables. Don't call any other logging function before that one!
#
# Define vairables for the log levels in this module.
kdump_stdloglvl=""
kdump_sysloglvl=""
kdump_kmsgloglvl=""
# The dracut-lib.sh is only available in the second kernel, and it won't
# be used in the first kernel because the dracut-lib.sh is invisible in
# the first kernel.
if [ -f /lib/dracut-lib.sh ]; then
. /lib/dracut-lib.sh
fi
# @brief Get the log level from kernel command line.
# @retval 1 if something has gone wrong
# @retval 0 on success.
#
get_kdump_loglvl()
{
(type -p getarg) && kdump_sysloglvl=$(getarg rd.kdumploglvl)
[ -z "$kdump_sysloglvl" ] && return 1;
(type -p isdigit) && isdigit $kdump_sysloglvl
[ $? -ne 0 ] && return 1;
return 0
}
# @brief Check the log level.
# @retval 1 if something has gone wrong
# @retval 0 on success.
#
check_loglvl()
{
case "$1" in
0|1|2|3|4)
return 0
;;
*)
return 1
;;
esac
}
# @brief Initializes Logger.
# @retval 1 if something has gone wrong
# @retval 0 on success.
#
dlog_init() {
local ret=0; local errmsg
if [ -s /proc/vmcore ];then
get_kdump_loglvl
if [ $? -ne 0 ];then
logger -t "kdump[$$]" -p warn -- "Kdump is using the default log level(3)."
kdump_sysloglvl=3
fi
kdump_stdloglvl=0
kdump_kmsgloglvl=0
else
kdump_stdloglvl=$KDUMP_STDLOGLVL
kdump_sysloglvl=$KDUMP_SYSLOGLVL
kdump_kmsgloglvl=$KDUMP_KMSGLOGLVL
fi
[ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=3
[ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=0
[ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0
for loglvl in "$kdump_stdloglvl" "$kdump_kmsgloglvl" "$kdump_sysloglvl"; do
check_loglvl "$loglvl"
if [ $? -ne 0 ]; then
echo "Illegal log level: $kdump_stdloglvl $kdump_kmsgloglvl $kdump_sysloglvl"
return 1
fi
done
# Skip initialization if it's already done.
[ -n "$kdump_maxloglvl" ] && return 0
if [[ $UID -ne 0 ]]; then
kdump_kmsgloglvl=0
kdump_sysloglvl=0
fi
if [[ $kdump_sysloglvl -gt 0 ]]; then
if [[ -d /run/systemd/journal ]] \
&& type -P systemd-cat &>/dev/null \
&& systemctl --quiet is-active systemd-journald.socket &>/dev/null; then
readonly _systemdcatfile="/var/tmp/systemd-cat"
mkfifo "$_systemdcatfile" &>/dev/null
readonly _dlogfd=15
systemd-cat -t 'kdump' --level-prefix=true <"$_systemdcatfile" &
exec 15>"$_systemdcatfile"
elif ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null; then
# We cannot log to syslog, so turn this facility off.
kdump_kmsgloglvl=$kdump_sysloglvl
kdump_sysloglvl=0
ret=1
errmsg="No '/dev/log' or 'logger' included for syslog logging"
fi
fi
local lvl; local maxloglvl_l=0
for lvl in $kdump_stdloglvl $kdump_sysloglvl $kdump_kmsgloglvl; do
[[ $lvl -gt $maxloglvl_l ]] && maxloglvl_l=$lvl
done
readonly kdump_maxloglvl=$maxloglvl_l
export kdump_maxloglvl
if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then
unset ddebug
ddebug() { :; };
fi
if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then
unset dinfo
dinfo() { :; };
fi
if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then
unset dwarn
dwarn() { :; };
unset dwarning
dwarning() { :; };
fi
if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then
unset derror
derror() { :; };
fi
[ -n "$errmsg" ] && derror "$errmsg"
return $ret
}
## @brief Converts numeric level to logger priority defined by POSIX.2.
#
# @param lvl Numeric logging level in range from 1 to 4.
# @retval 1 if @a lvl is out of range.
# @retval 0 if @a lvl is correct.
# @result Echoes logger priority.
_lvl2syspri() {
case "$1" in
1) echo error;;
2) echo warning;;
3) echo info;;
4) echo debug;;
*) return 1;;
esac
}
## @brief Converts logger numeric level to syslog log level
#
# @param lvl Numeric logging level in range from 1 to 4.
# @retval 1 if @a lvl is out of range.
# @retval 0 if @a lvl is correct.
# @result Echoes kernel console numeric log level
#
# Conversion is done as follows:
#
# <tt>
# none -> LOG_EMERG (0)
# none -> LOG_ALERT (1)
# none -> LOG_CRIT (2)
# ERROR(1) -> LOG_ERR (3)
# WARN(2) -> LOG_WARNING (4)
# none -> LOG_NOTICE (5)
# INFO(3) -> LOG_INFO (6)
# DEBUG(4) -> LOG_DEBUG (7)
# </tt>
#
# @see /usr/include/sys/syslog.h
_dlvl2syslvl() {
local lvl
case "$1" in
1) lvl=3;;
2) lvl=4;;
3) lvl=6;;
4) lvl=7;;
*) return 1;;
esac
# The number is constructed by multiplying the facility by 8 and then
# adding the level.
# About The Syslog Protocol, please refer to the RFC5424 for more details.
echo $((24+$lvl))
}
## @brief Prints to stderr, to syslog and/or /dev/kmsg given message with
# given level (priority).
#
# @param lvl Numeric logging level.
# @param msg Message.
# @retval 0 It's always returned, even if logging failed.
#
# @note This function is not supposed to be called manually. Please use
# dinfo(), ddebug(), or others instead which wrap this one.
#
# This is core logging function which logs given message to standard error
# and/or syslog (with POSIX shell command <tt>logger</tt>) and/or to /dev/kmsg.
# The format is following:
#
# <tt>X: some message</tt>
#
# where @c X is the first letter of logging level. See module description for
# details on that.
#
# Message to syslog is sent with tag @c kdump. Priorities are mapped as
# following:
# - @c ERROR to @c error
# - @c WARN to @c warning
# - @c INFO to @c info
# - @c DEBUG to @c debug
_do_dlog() {
local lvl="$1"; shift
local msg="$*"
[[ $lvl -le $kdump_stdloglvl ]] && printf -- 'kdump: %s\n' "$msg" >&2
if [[ $lvl -le $kdump_sysloglvl ]]; then
if [[ "$_dlogfd" ]]; then
printf -- "<%s>%s\n" "$(($(_dlvl2syslvl $lvl) & 7))" "$msg" >&$_dlogfd
else
logger -t "kdump[$$]" -p $(_lvl2syspri $lvl) -- "$msg"
fi
fi
[[ $lvl -le $kdump_kmsgloglvl ]] && \
echo "<$(_dlvl2syslvl $lvl)>kdump[$$] $msg" >/dev/kmsg
}
## @brief Internal helper function for _do_dlog()
#
# @param lvl Numeric logging level.
# @param msg Message.
# @retval 0 It's always returned, even if logging failed.
#
# @note This function is not supposed to be called manually. Please use
# dinfo(), ddebug(), or others instead which wrap this one.
#
# This function calls _do_dlog() either with parameter msg, or if
# none is given, it will read standard input and will use every line as
# a message.
#
# This enables:
# dwarn "This is a warning"
# echo "This is a warning" | dwarn
dlog() {
[ -z "$kdump_maxloglvl" ] && return 0
[[ $1 -le $kdump_maxloglvl ]] || return 0
if [[ $# -gt 1 ]]; then
_do_dlog "$@"
else
while read line || [ -n "$line" ]; do
_do_dlog "$1" "$line"
done
fi
}
## @brief Logs message at DEBUG level (4)
#
# @param msg Message.
# @retval 0 It's always returned, even if logging failed.
ddebug() {
set +x
dlog 4 "$@"
[ -n "$debug" ] && set -x || :
}
## @brief Logs message at INFO level (3)
#
# @param msg Message.
# @retval 0 It's always returned, even if logging failed.
dinfo() {
set +x
dlog 3 "$@"
[ -n "$debug" ] && set -x || :
}
## @brief Logs message at WARN level (2)
#
# @param msg Message.
# @retval 0 It's always returned, even if logging failed.
dwarn() {
set +x
dlog 2 "$@"
[ -n "$debug" ] && set -x || :
}
## @brief It's an alias to dwarn() function.
#
# @param msg Message.
# @retval 0 It's always returned, even if logging failed.
dwarning() {
set +x
dwarn "$@"
[ -n "$debug" ] && set -x || :
}
## @brief Logs message at ERROR level (1)
#
# @param msg Message.
# @retval 0 It's always returned, even if logging failed.
derror() {
set +x
dlog 1 "$@"
[ -n "$debug" ] && set -x || :
}

View File

@ -0,0 +1,8 @@
#!/bin/sh
systemctl is-active kdump
if [ $? -ne 0 ]; then
exit 0
fi
/usr/lib/kdump/kdump-restart.sh

8
SOURCES/kdump-restart.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
export PATH="$PATH:/usr/bin:/usr/sbin"
exec >>/var/log/kdump-migration.log 2>&1
echo "kdump: Partition Migration detected. Rebuilding initramfs image to reload."
/usr/bin/kdumpctl rebuild
/usr/bin/kdumpctl reload

View File

@ -85,9 +85,9 @@ for the running kernel.
.PP
Note 1: About default core collector:
The default core_collector for raw/ssh dump is:
"makedumpfile -F -l --message-level 1 -d 31".
"makedumpfile -F -l --message-level 7 -d 31".
The default core_collector for other targets is:
"makedumpfile -l --message-level 1 -d 31".
"makedumpfile -l --message-level 7 -d 31".
Even if core_collector option is commented out in kdump.conf, makedumpfile
is the default core collector and kdump uses it internally.
If one does not want makedumpfile as default core_collector, then they
@ -98,6 +98,11 @@ vmcore.flat, you will need to use "makedumpfile -R" to rearrange the
dump data from standard input to a normal dumpfile (readable with analysis
tools).
ie. "makedumpfile -R vmcore < vmcore.flat"
.PP
Note 3: If specified core_collector simply copy the vmcore file to the
dump target (eg: cp, scp), the vmcore could be significantly large.
Please make sure the dump target has enough space, at leaset larger
than the system's RAM.
.RE
@ -113,8 +118,11 @@ All files under /etc/kdump/post.d are collectively sorted
and executed in lexical order, before binary or script
specified kdump_post parameter is executed.
.PP
Note that scripts written for use with this directive must use
the /bin/bash interpreter.
Note that scripts written for use with this directive must use the /bin/bash
interpreter. And since these scripts run in kdump enviroment, the reference to
the storage or network device in the scripts should adhere to the section
\'Supported dump target types and requirements\' in kexec-kdump-howto.txt.
.RE
.B kdump_pre <binary | script>
@ -134,8 +142,11 @@ kdump_pre parameter is executed.
Even if the binary or script in /etc/kdump/pre.d directory
returns non 0 exit status, the processing is continued.
.PP
Note that scripts written for this directive must use
the /bin/bash interpreter.
Note that scripts written for use with this directive must use the /bin/bash
interpreter. And since these scripts run in kdump enviroment, the reference to
the storage or network device in the scripts should adhere to the section
\'Supported dump target types and requirements\' in kexec-kdump-howto.txt.
.RE
.B extra_bins <binaries | shell scripts>
@ -307,11 +318,11 @@ Above will effectively be translated to:
cp --sparse=always /proc/vmcore <dest-path>/vmcore
.TP
ex2.
core_collector "makedumpfile -l --message-level 1 -d 31"
core_collector "makedumpfile -l --message-level 7 -d 31"
Above will effectively be translated to:
makedumpfile -l --message-level 1 -d 31 /proc/vmcore <dest-path>/vmcore
makedumpfile -l --message-level 7 -d 31 /proc/vmcore <dest-path>/vmcore
.PP
For dump targets like raw and ssh, in general, core collector should expect
one argument (source file) and should output the processed core on standard
@ -328,11 +339,11 @@ Above will effectively be translated to.
cat /proc/vmcore | dd of=<target-device>
.TP
ex4.
core_collector "makedumpfile -F -l --message-level 1 -d 31"
core_collector "makedumpfile -F -l --message-level 7 -d 31"
Above will effectively be translated to.
makedumpfile -F -l --message-level 1 -d 31 | dd of=<target-device>
makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device>
.PP
ssh dumps examples
.TP
@ -344,11 +355,11 @@ Above will effectively be translated to.
cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore"
.TP
ex6.
core_collector "makedumpfile -F -l --message-level 1 -d 31"
core_collector "makedumpfile -F -l --message-level 7 -d 31"
Above will effectively be translated to.
makedumpfile -F -l --message-level 1 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
makedumpfile -F -l --message-level 7 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
There is one exception to standard output rule for ssh dumps. And that is
scp. As scp can handle ssh destinations for file transfers, one can

View File

@ -2,6 +2,7 @@
Description=Crash recovery kernel arming
After=network.target network-online.target remote-fs.target basic.target
DefaultDependencies=no
ConditionKernelCommandLine=crashkernel
[Service]
Type=oneshot

View File

@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len"
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
@ -35,3 +35,19 @@ KEXEC_ARGS=""
#What is the image type used for kdump
KDUMP_IMG="vmlinuz"
# Logging is controlled by following variables in the first kernel:
# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
#
# In the second kernel, kdump will use the rd.kdumploglvl option to set the
# log level in the above KDUMP_COMMANDLINE_APPEND.
# - @var rd.kdumploglvl - logging level to syslog (by logger command)
# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
#
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
#
# KDUMP_STDLOGLVL=3
# KDUMP_SYSLOGLVL=0
# KDUMP_KMSGLOGLVL=0

View File

@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb"
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
@ -28,10 +28,26 @@ KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory
#
# Example:
# KEXEC_ARGS="--elf32-core-headers"
KEXEC_ARGS=""
KEXEC_ARGS="-s"
#Where to find the boot image
#KDUMP_BOOTDIR="/boot"
#What is the image type used for kdump
KDUMP_IMG="vmlinuz"
# Logging is controlled by following variables in the first kernel:
# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
#
# In the second kernel, kdump will use the rd.kdumploglvl option to set the
# log level in the above KDUMP_COMMANDLINE_APPEND.
# - @var rd.kdumploglvl - logging level to syslog (by logger command)
# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
#
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
#
# KDUMP_STDLOGLVL=3
# KDUMP_SYSLOGLVL=0
# KDUMP_KMSGLOGLVL=0

View File

@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb"
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
@ -38,3 +38,19 @@ KDUMP_IMG="vmlinuz"
#What is the images extension. Relocatable kernels don't have one
KDUMP_IMG_EXT=""
# Logging is controlled by following variables in the first kernel:
# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
#
# In the second kernel, kdump will use the rd.kdumploglvl option to set the
# log level in the above KDUMP_COMMANDLINE_APPEND.
# - @var rd.kdumploglvl - logging level to syslog (by logger command)
# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
#
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
#
# KDUMP_STDLOGLVL=3
# KDUMP_SYSLOGLVL=0
# KDUMP_KMSGLOGLVL=0

View File

@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb"
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
@ -40,3 +40,19 @@ KDUMP_IMG="vmlinuz"
KDUMP_IMG_EXT=""
#Specify the action after failure
# Logging is controlled by following variables in the first kernel:
# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
#
# In the second kernel, kdump will use the rd.kdumploglvl option to set the
# log level in the above KDUMP_COMMANDLINE_APPEND.
# - @var rd.kdumploglvl - logging level to syslog (by logger command)
# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
#
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
#
# KDUMP_STDLOGLVL=3
# KDUMP_SYSLOGLVL=0
# KDUMP_KMSGLOGLVL=0

View File

@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb"
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
@ -40,3 +40,19 @@ KDUMP_IMG="vmlinuz"
KDUMP_IMG_EXT=""
#Specify the action after failure
# Logging is controlled by following variables in the first kernel:
# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
#
# In the second kernel, kdump will use the rd.kdumploglvl option to set the
# log level in the above KDUMP_COMMANDLINE_APPEND.
# - @var rd.kdumploglvl - logging level to syslog (by logger command)
# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
#
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
#
# KDUMP_STDLOGLVL=3
# KDUMP_SYSLOGLVL=0
# KDUMP_KMSGLOGLVL=0

View File

@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb"
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb prot_virt ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
@ -31,7 +31,7 @@ MKDUMPRD_ARGS=""
#
# Example:
# KEXEC_ARGS="--elf32-core-headers"
KEXEC_ARGS=""
KEXEC_ARGS="-s"
#Where to find the boot image
#KDUMP_BOOTDIR="/boot"
@ -41,3 +41,19 @@ KDUMP_IMG="vmlinuz"
#What is the images extension. Relocatable kernels don't have one
KDUMP_IMG_EXT=""
# Logging is controlled by following variables in the first kernel:
# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
#
# In the second kernel, kdump will use the rd.kdumploglvl option to set the
# log level in the above KDUMP_COMMANDLINE_APPEND.
# - @var rd.kdumploglvl - logging level to syslog (by logger command)
# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
#
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
#
# KDUMP_STDLOGLVL=3
# KDUMP_SYSLOGLVL=0
# KDUMP_KMSGLOGLVL=0

View File

@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb"
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
@ -38,3 +38,19 @@ KDUMP_IMG="vmlinuz"
#What is the images extension. Relocatable kernels don't have one
KDUMP_IMG_EXT=""
# Logging is controlled by following variables in the first kernel:
# - @var KDUMP_STDLOGLVL - logging level to standard error (console output)
# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command)
# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time)
#
# In the second kernel, kdump will use the rd.kdumploglvl option to set the
# log level in the above KDUMP_COMMANDLINE_APPEND.
# - @var rd.kdumploglvl - logging level to syslog (by logger command)
# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
#
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
#
# KDUMP_STDLOGLVL=3
# KDUMP_SYSLOGLVL=0
# KDUMP_KMSGLOGLVL=0

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,11 @@ impossible to use password authentication during kdump.
.TP
.I showmem
Prints the size of reserved memory for crash kernel in megabytes.
.TP
.I estimate
Estimate a suitable crashkernel value for current machine. This is a
best-effort estimate. It will print a recommanded crashkernel value
based on current kdump setup, and list some details of memory usage.
.SH "SEE ALSO"
.BR kdump.conf (5),

View File

@ -524,17 +524,91 @@ to send over the necessary ssh key file. Restart the kdump service via
Advanced Setups
===============
Kdump boot directory
--------------------
About /etc/sysconfig/kdump
------------------------------
Currently, there are a few options in /etc/sysconfig/kdump, which are
usually used to control the behavior of kdump kernel. Basically, all of
these options have default values, usually we do not need to change them,
but sometimes, we may modify them in order to better control the behavior
of kdump kernel such as debug, etc.
-KDUMP_BOOTDIR
Usually kdump kernel is the same as 1st kernel. So kdump will try to find
kdump kernel under /boot according to /proc/cmdline. E.g we execute below
command and get an output:
cat /proc/cmdline
BOOT_IMAGE=/xxx/vmlinuz-3.yyy.zzz root=xxxx .....
Then kdump kernel will be /boot/xxx/vmlinuz-3.yyy.zzz.
However a variable KDUMP_BOOTDIR in /etc/sysconfig/kdump is provided to
user if kdump kernel is put in a different directory.
Then kdump kernel will be /boot/xxx/vmlinuz-3.yyy.zzz. However, this option
is provided to user if kdump kernel is put in a different directory.
-KDUMP_IMG
This represents the image type used for kdump. The default value is "vmlinuz".
-KDUMP_IMG_EXT
This represents the images extension. Relocatable kernels don't have one.
Currently, it is a null string by default.
-KEXEC_ARGS
Any additional kexec arguments required. For example:
KEXEC_ARGS="--elf32-core-headers".
In most situations, this should be left empty. But, sometimes we hope to get
additional kexec loading debugging information, we can add the '-d' option
for the debugging.
-KDUMP_KERNELVER
This is a kernel version string for the kdump kernel. If the version is not
specified, the init script will try to find a kdump kernel with the same
version number as the running kernel.
-KDUMP_COMMANDLINE
The value of 'KDUMP_COMMANDLINE' will be passed to kdump kernel as command
line parameters, this will likely match the contents of the grub kernel line.
In general, if a command line is not specified, which means that it is a null
string such as KDUMP_COMMANDLINE="", the default will be taken automatically
from the '/proc/cmdline'.
-KDUMP_COMMANDLINE_REMOVE
This option allows us to remove arguments from the current kdump command line.
If we don't specify any parameters for the KDUMP_COMMANDLINE, it will inherit
all values from the '/proc/cmdline', which is not expected. As you know, some
default kernel parameters could affect kdump, furthermore, that could cause
the failure of kdump kernel boot.
In addition, the option is also helpful to debug the kdump kernel, we can use
this option to change kdump kernel command line.
For more kernel parameters, please refer to kernel document.
-KDUMP_COMMANDLINE_APPEND
This option allows us to append arguments to the current kdump command line
after processed by the KDUMP_COMMANDLINE_REMOVE. For kdump kernel, some
specific modules require to be disabled like the mce, cgroup, numa, hest_disable,
etc. Those modules may waste memory or kdump kernel doesn't need them,
furthermore, there may affect kdump kernel boot.
Just like above option, it can be used to disable or enable some kernel
modules so that we can exclude any errors for kdump kernel, this is very
meaningful for debugging.
-KDUMP_STDLOGLVL | KDUMP_SYSLOGLVL | KDUMP_KMSGLOGLVL
These variables are used to control the kdump log level in the first kernel.
In the second kernel, kdump will use the rd.kdumploglvl option to set the log
level in the above KDUMP_COMMANDLINE_APPEND.
Logging levels: no logging(0), error(1), warn(2), info(3), debug(4)
Kdump Post-Capture Executable
-----------------------------
@ -547,6 +621,9 @@ If /etc/kdump/post.d directory exist, All files in the directory are
collectively sorted and executed in lexical order, before binary or script
specified kdump_post parameter is executed.
In these scripts, the reference to the storage or network device should adhere
to the section 'Supported dump target types and requirements'
Kdump Pre-Capture Executable
----------------------------
@ -560,6 +637,9 @@ kdump_pre parameter is executed.
Even if the binary or script in /etc/kdump/pre.d directory returns non 0
exit status, the processing is continued.
In these scripts, the reference to the storage or network device should adhere
to the section 'Supported dump target types and requirements'
Extra Binaries
--------------
@ -613,7 +693,7 @@ is a dump filtering and compression utility provided with kexec-tools. On
some architectures, it can drastically reduce the size of your vmcore files,
which becomes very useful on systems with large amounts of memory.
A typical setup is 'core_collector makedumpfile -F -l --message-level 1 -d 31',
A typical setup is 'core_collector makedumpfile -F -l --message-level 7 -d 31',
but check the output of '/sbin/makedumpfile --help' for a list of all available
options (-i and -g don't need to be specified, they're automatically taken care
of). Note that use of makedumpfile requires that the kernel-debuginfo package
@ -633,11 +713,11 @@ First one is source file and second one is target file. For ex.
- ex2.
core_collector "makedumpfile -l --message-level 1 -d 31"
core_collector "makedumpfile -l --message-level 7 -d 31"
Above will effectively be translated to:
makedumpfile -l --message-level 1 -d 31 /proc/vmcore <dest-path>/vmcore
makedumpfile -l --message-level 7 -d 31 /proc/vmcore <dest-path>/vmcore
For dump targets like raw and ssh, in general, core collector should expect
one argument (source file) and should output the processed core on standard
@ -656,11 +736,11 @@ raw dumps core_collector examples:
- ex4.
core_collector "makedumpfile -F -l --message-level 1 -d 31"
core_collector "makedumpfile -F -l --message-level 7 -d 31"
Above will effectively be translated to.
makedumpfile -F -l --message-level 1 -d 31 | dd of=<target-device>
makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device>
ssh dumps core_collector examples:
@ -674,11 +754,11 @@ ssh dumps core_collector examples:
- ex6.
core_collector "makedumpfile -F -l --message-level 1 -d 31"
core_collector "makedumpfile -F -l --message-level 7 -d 31"
Above will effectively be translated to.
makedumpfile -F -l --message-level 1 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
makedumpfile -F -l --message-level 7 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
There is one exception to standard output rule for ssh dumps. And that is
scp. As scp can handle ssh destinations for file transfers, one can
@ -696,9 +776,9 @@ About default core collector
----------------------------
Default core_collector for ssh/raw dump is:
"makedumpfile -F -l --message-level 1 -d 31".
"makedumpfile -F -l --message-level 7 -d 31".
Default core_collector for other targets is:
"makedumpfile -l --message-level 1 -d 31".
"makedumpfile -l --message-level 7 -d 31".
Even if core_collector option is commented out in kdump.conf, makedumpfile
is default core collector and kdump uses it internally.
@ -885,3 +965,83 @@ Debugging Tips
minicom -C /tmp/console-logs
Now minicom should be logging serial console in file console-logs.
- Using the logger to output kdump log messages
You can configure the kdump log level for the first kernel in the
/etc/sysconfig/kdump. For example:
KDUMP_STDLOGLVL=3
KDUMP_SYSLOGLVL=0
KDUMP_KMSGLOGLVL=0
The above configurations indicate that kdump messages will be printed
to the console, and the KDUMP_STDLOGLVL is set to 3(info), but the
KDUMP_SYSLOGLVL and KDUMP_KMSGLOGLVL are set to 0(no logging). This
is also the current default log levels in the first kernel.
In the second kernel, you can add the 'rd.kdumploglvl=X' option to the
KDUMP_COMMANDLINE_APPEND in the /etc/sysconfig/kdump so that you can also
set the log levels for the second kernel. The 'X' represents the logging
levels, the default log level is 3(info) in the second kernel, for example:
# cat /etc/sysconfig/kdump |grep rd.kdumploglvl
KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd rd.kdumploglvl=3"
Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
The ERROR level designates error events that might still allow the application
to continue running.
The WARN level designates potentially harmful situations.
The INFO level designates informational messages that highlight the progress
of the application at coarse-grained level.
The DEBUG level designates fine-grained informational events that are most
useful to debug an application.
Note: if you set the log level to 0, that will disable the logs at the
corresponding log level, which indicates that it has no log output.
At present, the logger works in both the first kernel(kdump service debugging)
and the second kernel.
In the first kernel, you can find the historical logs with the journalctl
command and check kdump service debugging information. In addition, the
'kexec -d' debugging messages are also saved to /var/log/kdump.log in the
first kernel. For example:
[root@ibm-z-109 ~]# ls -al /var/log/kdump.log
-rw-r--r--. 1 root root 63238 Oct 28 06:40 /var/log/kdump.log
If you want to get the debugging information of building kdump initramfs, you
can enable the '--debug' option for the dracut_args in the /etc/kdump.conf, and
then rebuild the kdump initramfs as below:
# systemctl restart kdump.service
That will rebuild the kdump initramfs and gerenate some logs to journald, you
can find the dracut logs with the journalctl command.
In the second kernel, kdump will automatically put the kexec-dmesg.log to a same
directory with the vmcore, the log file includes the debugging messages like dmesg
and journald logs. For example:
[root@ibm-z-109 ~]# ls -al /var/crash/127.0.0.1-2020-10-28-02\:01\:23/
drwxr-xr-x. 2 root root 67 Oct 28 02:02 .
drwxr-xr-x. 6 root root 154 Oct 28 02:01 ..
-rw-r--r--. 1 root root 21164 Oct 28 02:01 kexec-dmesg.log
-rw-------. 1 root root 74238698 Oct 28 02:01 vmcore
-rw-r--r--. 1 root root 17532 Oct 28 02:01 vmcore-dmesg.txt
If you want to get more debugging information in the second kernel, you can add
the 'rd.debug' option to the KDUMP_COMMANDLINE_APPEND in the /etc/sysconfig/kdump,
and then reload them in order to make the changes take effect.
In addition, you can also add the 'rd.memdebug=X' option to the KDUMP_COMMANDLINE_APPEND
in the /etc/sysconfig/kdump in order to output the additional information about
kernel module memory consumption during loading.
For more details, please refer to the /etc/sysconfig/kdump, or the man page of
dracut.cmdline and kdump.conf.

View File

@ -1,181 +0,0 @@
From a7c4cb8e998571cb3dd62e907935a1e052b15d6c Mon Sep 17 00:00:00 2001
From: Lianbo Jiang <lijiang@redhat.com>
Date: Fri, 23 Aug 2019 20:05:38 +0800
Subject: [PATCH 3/5] Cleanup: move it back from util_lib/elf_info.c
Some code related to vmcore-dmesg.c is put into the util_lib, which
is not very reasonable, so lets move it back and tidy up those code.
In addition, that will also help to limit the size of vmcore-dmesg.txt
in vmcore-dmesg.c instead of elf_info.c.
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
util_lib/elf_info.c | 48 +++++++++----------------------------
util_lib/include/elf_info.h | 2 +-
vmcore-dmesg/vmcore-dmesg.c | 30 ++++++++++++++++++++++-
3 files changed, 41 insertions(+), 39 deletions(-)
diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c
index 5d0efaafab53..2bce5cb1713c 100644
--- a/util_lib/elf_info.c
+++ b/util_lib/elf_info.c
@@ -531,19 +531,7 @@ static int32_t read_file_s32(int fd, uint64_t addr)
return read_file_u32(fd, addr);
}
-static void write_to_stdout(char *buf, unsigned int nr)
-{
- ssize_t ret;
-
- ret = write(STDOUT_FILENO, buf, nr);
- if (ret != nr) {
- fprintf(stderr, "Failed to write out the dmesg log buffer!:"
- " %s\n", strerror(errno));
- exit(54);
- }
-}
-
-static void dump_dmesg_legacy(int fd)
+static void dump_dmesg_legacy(int fd, void (*handler)(char*, unsigned int))
{
uint64_t log_buf, log_buf_offset;
unsigned log_end, logged_chars, log_end_wrapped;
@@ -604,7 +592,8 @@ static void dump_dmesg_legacy(int fd)
*/
logged_chars = log_end < log_buf_len ? log_end : log_buf_len;
- write_to_stdout(buf + (log_buf_len - logged_chars), logged_chars);
+ if (handler)
+ handler(buf + (log_buf_len - logged_chars), logged_chars);
}
static inline uint16_t struct_val_u16(char *ptr, unsigned int offset)
@@ -623,7 +612,7 @@ static inline uint64_t struct_val_u64(char *ptr, unsigned int offset)
}
/* Read headers of log records and dump accordingly */
-static void dump_dmesg_structured(int fd)
+static void dump_dmesg_structured(int fd, void (*handler)(char*, unsigned int))
{
#define OUT_BUF_SIZE 4096
uint64_t log_buf, log_buf_offset, ts_nsec;
@@ -733,7 +722,8 @@ static void dump_dmesg_structured(int fd)
out_buf[len++] = c;
if (len >= OUT_BUF_SIZE - 64) {
- write_to_stdout(out_buf, len);
+ if (handler)
+ handler(out_buf, len);
len = 0;
}
}
@@ -752,16 +742,16 @@ static void dump_dmesg_structured(int fd)
current_idx += loglen;
}
free(buf);
- if (len)
- write_to_stdout(out_buf, len);
+ if (len && handler)
+ handler(out_buf, len);
}
-static void dump_dmesg(int fd)
+void dump_dmesg(int fd, void (*handler)(char*, unsigned int))
{
if (log_first_idx_vaddr)
- dump_dmesg_structured(fd);
+ dump_dmesg_structured(fd, handler);
else
- dump_dmesg_legacy(fd);
+ dump_dmesg_legacy(fd, handler);
}
int read_elf(int fd)
@@ -808,22 +798,6 @@ int read_elf(int fd)
return 0;
}
-int read_elf_vmcore(int fd)
-{
- int ret;
-
- ret = read_elf(fd);
- if (ret > 0) {
- fprintf(stderr, "Unable to read ELF information"
- " from vmcore\n");
- return ret;
- }
-
- dump_dmesg(fd);
-
- return 0;
-}
-
int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off)
{
int ret;
diff --git a/util_lib/include/elf_info.h b/util_lib/include/elf_info.h
index c328a1b0ecf2..4bc9279ba603 100644
--- a/util_lib/include/elf_info.h
+++ b/util_lib/include/elf_info.h
@@ -30,6 +30,6 @@ int get_pt_load(int idx,
unsigned long long *virt_end);
int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off);
int read_elf(int fd);
-int read_elf_vmcore(int fd);
+void dump_dmesg(int fd, void (*handler)(char*, unsigned int));
#endif /* ELF_INFO_H */
diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
index bebc348a657e..fe7df8ec372c 100644
--- a/vmcore-dmesg/vmcore-dmesg.c
+++ b/vmcore-dmesg/vmcore-dmesg.c
@@ -5,6 +5,34 @@ typedef Elf32_Nhdr Elf_Nhdr;
extern const char *fname;
+static void write_to_stdout(char *buf, unsigned int nr)
+{
+ ssize_t ret;
+
+ ret = write(STDOUT_FILENO, buf, nr);
+ if (ret != nr) {
+ fprintf(stderr, "Failed to write out the dmesg log buffer!:"
+ " %s\n", strerror(errno));
+ exit(54);
+ }
+}
+
+static int read_vmcore_dmesg(int fd, void (*handler)(char*, unsigned int))
+{
+ int ret;
+
+ ret = read_elf(fd);
+ if (ret > 0) {
+ fprintf(stderr, "Unable to read ELF information"
+ " from vmcore\n");
+ return ret;
+ }
+
+ dump_dmesg(fd, handler);
+
+ return 0;
+}
+
int main(int argc, char **argv)
{
ssize_t ret;
@@ -23,7 +51,7 @@ int main(int argc, char **argv)
return 2;
}
- ret = read_elf_vmcore(fd);
+ ret = read_vmcore_dmesg(fd, write_to_stdout);
close(fd);
--
2.17.1

View File

@ -1,84 +0,0 @@
From 545c811050a375f79e0fa0e107cb35b9ae3a1599 Mon Sep 17 00:00:00 2001
From: Lianbo Jiang <lijiang@redhat.com>
Date: Fri, 23 Aug 2019 20:05:36 +0800
Subject: [PATCH 1/5] Cleanup: remove the read_elf_kcore()
Here, no need to wrap the read_elf() again, lets invoke it directly.
So remove the read_elf_kcore() and clean up redundant code.
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
kexec/arch/arm64/kexec-arm64.c | 2 +-
util_lib/elf_info.c | 15 ++-------------
util_lib/include/elf_info.h | 2 +-
3 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
index eb3a3a37307c..6ad3b0a134b3 100644
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -889,7 +889,7 @@ int get_phys_base_from_pt_load(unsigned long *phys_offset)
return EFAILED;
}
- read_elf_kcore(fd);
+ read_elf(fd);
for (i = 0; get_pt_load(i,
&phys_start, NULL, &virt_start, NULL);
diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c
index 90a3b21662e7..d9397ecd8626 100644
--- a/util_lib/elf_info.c
+++ b/util_lib/elf_info.c
@@ -764,7 +764,7 @@ static void dump_dmesg(int fd)
dump_dmesg_legacy(fd);
}
-static int read_elf(int fd)
+int read_elf(int fd)
{
int ret;
@@ -824,24 +824,13 @@ int read_elf_vmcore(int fd)
return 0;
}
-int read_elf_kcore(int fd)
-{
- int ret;
-
- ret = read_elf(fd);
- if (ret != 0)
- return ret;
-
- return 0;
-}
-
int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off)
{
int ret;
*phys_off = UINT64_MAX;
- ret = read_elf_kcore(fd);
+ ret = read_elf(fd);
if (!ret) {
/* If we have a valid 'PHYS_OFFSET' by now,
* return it to the caller now.
diff --git a/util_lib/include/elf_info.h b/util_lib/include/elf_info.h
index 1a4debd2d4ba..c328a1b0ecf2 100644
--- a/util_lib/include/elf_info.h
+++ b/util_lib/include/elf_info.h
@@ -29,7 +29,7 @@ int get_pt_load(int idx,
unsigned long long *virt_start,
unsigned long long *virt_end);
int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off);
-int read_elf_kcore(int fd);
+int read_elf(int fd);
int read_elf_vmcore(int fd);
#endif /* ELF_INFO_H */
--
2.17.1

View File

@ -1,47 +0,0 @@
From 14ad054e7baa788a6629385ffe5e0f1996b7de02 Mon Sep 17 00:00:00 2001
From: Lianbo Jiang <lijiang@redhat.com>
Date: Fri, 23 Aug 2019 20:05:37 +0800
Subject: [PATCH 2/5] Fix an error definition about the variable 'fname'
The variable 'fname' is mistakenly defined two twice, the first definition
is in the vmcore-dmesg.c, and the second definition is in the elf_info.c.
That is confused and incorrect although it's a static type, because the
value of variable 'fname' is not assigned(set) in elf_info.c. Anyway, its
value will be always 'null' when printing an error information.
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
util_lib/elf_info.c | 2 +-
vmcore-dmesg/vmcore-dmesg.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c
index d9397ecd8626..5d0efaafab53 100644
--- a/util_lib/elf_info.c
+++ b/util_lib/elf_info.c
@@ -20,7 +20,7 @@
/* The 32bit and 64bit note headers make it clear we don't care */
typedef Elf32_Nhdr Elf_Nhdr;
-static const char *fname;
+const char *fname;
static Elf64_Ehdr ehdr;
static Elf64_Phdr *phdr;
static int num_pt_loads;
diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
index 7a386b380291..bebc348a657e 100644
--- a/vmcore-dmesg/vmcore-dmesg.c
+++ b/vmcore-dmesg/vmcore-dmesg.c
@@ -3,7 +3,7 @@
/* The 32bit and 64bit note headers make it clear we don't care */
typedef Elf32_Nhdr Elf_Nhdr;
-static const char *fname;
+extern const char *fname;
int main(int argc, char **argv)
{
--
2.17.1

View File

@ -1,55 +0,0 @@
From fa3f0ed47f3e6dbee485722d13713ad495571b7e Mon Sep 17 00:00:00 2001
From: Lianbo Jiang <lijiang@redhat.com>
Date: Fri, 23 Aug 2019 20:05:39 +0800
Subject: [PATCH 4/5] Limit the size of vmcore-dmesg.txt to 2G
With some corrupted vmcore files, the vmcore-dmesg.txt file may grow
forever till the kdump disk becomes full, and also probably causes
the disk error messages as follow:
...
sd 0:0:0:0: [sda] tag#6 FAILED Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
sd 0:0:0:0: [sda] tag#6 CDB: Read(10) 28 00 08 06 4c 98 00 00 08 00
blk_update_request: I/O error, dev sda, sector 134630552
sd 0:0:0:0: [sda] tag#7 FAILED Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
sd 0:0:0:0: [sda] tag#7 CDB: Read(10) 28 00 08 06 4c 98 00 00 08 00
blk_update_request: I/O error, dev sda, sector 134630552
...
If vmcore-dmesg.txt occupies the whole disk, the vmcore can not be
saved, this is also a problem.
Lets limit the size of vmcore-dmesg.txt to avoid such problems.
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
vmcore-dmesg/vmcore-dmesg.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
index fe7df8ec372c..81c2a58c9d86 100644
--- a/vmcore-dmesg/vmcore-dmesg.c
+++ b/vmcore-dmesg/vmcore-dmesg.c
@@ -5,9 +5,19 @@ typedef Elf32_Nhdr Elf_Nhdr;
extern const char *fname;
+/* stole this macro from kernel printk.c */
+#define LOG_BUF_LEN_MAX (uint32_t)(1 << 31)
+
static void write_to_stdout(char *buf, unsigned int nr)
{
ssize_t ret;
+ static uint32_t n_bytes = 0;
+
+ n_bytes += nr;
+ if (n_bytes > LOG_BUF_LEN_MAX) {
+ fprintf(stderr, "The vmcore-dmesg.txt over 2G in size is not supported.\n");
+ exit(53);
+ }
ret = write(STDOUT_FILENO, buf, nr);
if (ret != nr) {
--
2.17.1

View File

@ -1,82 +0,0 @@
From 2572b8d702e452624bdb8d7b7c39f458e7dcf2ce Mon Sep 17 00:00:00 2001
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
Date: Wed, 18 Dec 2019 11:42:32 -0500
Subject: [PATCH 3/3] arm64: kdump: deal with a lot of resource entries in
/proc/iomem
As described in the commit ("arm64: kexec: allocate memory space avoiding
reserved regions"), /proc/iomem now has a lot of "reserved" entries, and
it's not just enough to have a fixed size of memory range array.
With this patch, kdump is allowed to handle arbitrary number of memory
ranges, using mem_regions_alloc_and_xxx() functions.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Tested-by: Bhupesh Sharma <bhsharma@redhat.com>
Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
kexec/arch/arm64/crashdump-arm64.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
index 4fd7aa8fd43c..38d1a0f3000d 100644
--- a/kexec/arch/arm64/crashdump-arm64.c
+++ b/kexec/arch/arm64/crashdump-arm64.c
@@ -23,13 +23,8 @@
#include "kexec-elf.h"
#include "mem_regions.h"
-/* memory ranges on crashed kernel */
-static struct memory_range system_memory_ranges[CRASH_MAX_MEMORY_RANGES];
-static struct memory_ranges system_memory_rgns = {
- .size = 0,
- .max_size = CRASH_MAX_MEMORY_RANGES,
- .ranges = system_memory_ranges,
-};
+/* memory ranges of crashed kernel */
+static struct memory_ranges system_memory_rgns;
/* memory range reserved for crashkernel */
struct memory_range crash_reserved_mem;
@@ -82,7 +77,7 @@ static uint64_t get_kernel_page_offset(void)
*
* This function is called once for each memory region found in /proc/iomem.
* It locates system RAM and crashkernel reserved memory and places these to
- * variables, respectively, system_memory_ranges and crash_reserved_mem.
+ * variables, respectively, system_memory_rgns and usablemem_rgns.
*/
static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
@@ -90,11 +85,11 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
unsigned long long length)
{
if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0)
- return mem_regions_add(&usablemem_rgns,
- base, length, RANGE_RAM);
+ return mem_regions_alloc_and_add(&usablemem_rgns,
+ base, length, RANGE_RAM);
else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0)
- return mem_regions_add(&system_memory_rgns,
- base, length, RANGE_RAM);
+ return mem_regions_alloc_and_add(&system_memory_rgns,
+ base, length, RANGE_RAM);
else if (strncmp(str, KERNEL_CODE, strlen(KERNEL_CODE)) == 0)
elf_info.kern_paddr_start = base;
else if (strncmp(str, KERNEL_DATA, strlen(KERNEL_DATA)) == 0)
@@ -135,9 +130,9 @@ static int crash_get_memory_ranges(void)
dbgprint_mem_range("Reserved memory range", &crash_reserved_mem, 1);
- if (mem_regions_exclude(&system_memory_rgns, &crash_reserved_mem)) {
- fprintf(stderr,
- "Error: Number of crash memory ranges excedeed the max limit\n");
+ if (mem_regions_alloc_and_exclude(&system_memory_rgns,
+ &crash_reserved_mem)) {
+ fprintf(stderr, "Cannot allocate memory for ranges\n");
return -ENOMEM;
}
--
2.7.4

View File

@ -1,248 +0,0 @@
From f736104f533290b4ce6fbfbca74abde9ffd3888c Mon Sep 17 00:00:00 2001
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
Date: Wed, 18 Dec 2019 11:42:31 -0500
Subject: [PATCH 2/3] arm64: kexec: allocate memory space avoiding reserved
regions
On UEFI/ACPI-only system, some memory regions, including but not limited
to UEFI memory map and ACPI tables, must be preserved across kexec'ing.
Otherwise, they can be corrupted and result in early failure in booting
a new kernel.
In recent kernels, /proc/iomem now has an extended file format like:
40000000-5871ffff : System RAM
41800000-426affff : Kernel code
426b0000-42aaffff : reserved
42ab0000-42c64fff : Kernel data
54400000-583fffff : Crash kernel
58590000-585effff : reserved
58700000-5871ffff : reserved
58720000-58b5ffff : reserved
58b60000-5be3ffff : System RAM
58b61000-58b61fff : reserved
where the "reserved" entries at the top level or under System RAM (and
its descendant resources) are ones of such kind and should not be regarded
as usable memory ranges where several free spaces for loading kexec data
will be allocated.
With this patch, get_memory_ranges() will handle this format of file
correctly. Note that, for safety, unknown regions, in addition to
"reserved" ones, will also be excluded.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Tested-by: Bhupesh Sharma <bhsharma@redhat.com>
Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
kexec/arch/arm64/kexec-arm64.c | 153 +++++++++++++++++++++++++----------------
1 file changed, 94 insertions(+), 59 deletions(-)
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
index 6ad3b0a134b3..45ebc54a9b6f 100644
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -10,7 +10,9 @@
#include <inttypes.h>
#include <libfdt.h>
#include <limits.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
#include <linux/elf-em.h>
#include <elf.h>
@@ -29,6 +31,7 @@
#include "fs2dt.h"
#include "iomem.h"
#include "kexec-syscall.h"
+#include "mem_regions.h"
#include "arch/options.h"
#define ROOT_NODE_ADDR_CELLS_DEFAULT 1
@@ -905,19 +908,33 @@ int get_phys_base_from_pt_load(unsigned long *phys_offset)
return 0;
}
+static bool to_be_excluded(char *str)
+{
+ if (!strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) ||
+ !strncmp(str, KERNEL_CODE, strlen(KERNEL_CODE)) ||
+ !strncmp(str, KERNEL_DATA, strlen(KERNEL_DATA)) ||
+ !strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)))
+ return false;
+ else
+ return true;
+}
+
/**
- * get_memory_ranges_iomem_cb - Helper for get_memory_ranges_iomem.
+ * get_memory_ranges - Try to get the memory ranges from
+ * /proc/iomem.
*/
-
-static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
- unsigned long long base, unsigned long long length)
+int get_memory_ranges(struct memory_range **range, int *ranges,
+ unsigned long kexec_flags)
{
- int ret;
unsigned long phys_offset = UINT64_MAX;
- struct memory_range *r;
-
- if (nr >= KEXEC_SEGMENT_MAX)
- return -1;
+ FILE *fp;
+ const char *iomem = proc_iomem();
+ char line[MAX_LINE], *str;
+ unsigned long long start, end;
+ int n, consumed;
+ struct memory_ranges memranges;
+ struct memory_range *last, excl_range;
+ int ret;
if (!try_read_phys_offset_from_kcore) {
/* Since kernel version 4.19, 'kcore' contains
@@ -951,17 +968,72 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
try_read_phys_offset_from_kcore = true;
}
- r = (struct memory_range *)data + nr;
+ fp = fopen(iomem, "r");
+ if (!fp)
+ die("Cannot open %s\n", iomem);
+
+ memranges.ranges = NULL;
+ memranges.size = memranges.max_size = 0;
+
+ while (fgets(line, sizeof(line), fp) != 0) {
+ n = sscanf(line, "%llx-%llx : %n", &start, &end, &consumed);
+ if (n != 2)
+ continue;
+ str = line + consumed;
+
+ if (!strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM))) {
+ ret = mem_regions_alloc_and_add(&memranges,
+ start, end - start + 1, RANGE_RAM);
+ if (ret) {
+ fprintf(stderr,
+ "Cannot allocate memory for ranges\n");
+ fclose(fp);
+ return -ENOMEM;
+ }
- if (!strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)))
- r->type = RANGE_RAM;
- else if (!strncmp(str, IOMEM_RESERVED, strlen(IOMEM_RESERVED)))
- r->type = RANGE_RESERVED;
- else
- return 1;
+ dbgprintf("%s:+[%d] %016llx - %016llx\n", __func__,
+ memranges.size - 1,
+ memranges.ranges[memranges.size - 1].start,
+ memranges.ranges[memranges.size - 1].end);
+ } else if (to_be_excluded(str)) {
+ if (!memranges.size)
+ continue;
+
+ /*
+ * Note: mem_regions_exclude() doesn't guarantee
+ * that the ranges are sorted out, but as long as
+ * we cope with /proc/iomem, we only operate on
+ * the last entry and so it is safe.
+ */
- r->start = base;
- r->end = base + length - 1;
+ /* The last System RAM range */
+ last = &memranges.ranges[memranges.size - 1];
+
+ if (last->end < start)
+ /* New resource outside of System RAM */
+ continue;
+ if (end < last->start)
+ /* Already excluded by parent resource */
+ continue;
+
+ excl_range.start = start;
+ excl_range.end = end;
+ ret = mem_regions_alloc_and_exclude(&memranges, &excl_range);
+ if (ret) {
+ fprintf(stderr,
+ "Cannot allocate memory for ranges (exclude)\n");
+ fclose(fp);
+ return -ENOMEM;
+ }
+ dbgprintf("%s:- %016llx - %016llx\n",
+ __func__, start, end);
+ }
+ }
+
+ fclose(fp);
+
+ *range = memranges.ranges;
+ *ranges = memranges.size;
/* As a fallback option, we can try determining the PHYS_OFFSET
* value from the '/proc/iomem' entries as well.
@@ -982,52 +1054,15 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
* between the user-space and kernel space 'PHYS_OFFSET'
* value.
*/
- set_phys_offset(r->start, "iomem");
-
- dbgprintf("%s: %016llx - %016llx : %s", __func__, r->start,
- r->end, str);
-
- return 0;
-}
-
-/**
- * get_memory_ranges_iomem - Try to get the memory ranges from
- * /proc/iomem.
- */
+ if (memranges.size)
+ set_phys_offset(memranges.ranges[0].start, "iomem");
-static int get_memory_ranges_iomem(struct memory_range *array,
- unsigned int *count)
-{
- *count = kexec_iomem_for_each_line(NULL,
- get_memory_ranges_iomem_cb, array);
-
- if (!*count) {
- dbgprintf("%s: failed: No RAM found.\n", __func__);
- return EFAILED;
- }
+ dbgprint_mem_range("System RAM ranges;",
+ memranges.ranges, memranges.size);
return 0;
}
-/**
- * get_memory_ranges - Try to get the memory ranges some how.
- */
-
-int get_memory_ranges(struct memory_range **range, int *ranges,
- unsigned long kexec_flags)
-{
- static struct memory_range array[KEXEC_SEGMENT_MAX];
- unsigned int count;
- int result;
-
- result = get_memory_ranges_iomem(array, &count);
-
- *range = result ? NULL : array;
- *ranges = result ? 0 : count;
-
- return result;
-}
-
int arch_compat_trampoline(struct kexec_info *info)
{
return 0;
--
2.7.4

View File

@ -1,89 +0,0 @@
From cf977b1af9ec67fabcc6a625589c49c52d07b11d Mon Sep 17 00:00:00 2001
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
Date: Wed, 18 Dec 2019 11:42:30 -0500
Subject: [PATCH 1/3] kexec: add variant helper functions for handling memory
regions
mem_regions_alloc_and_add() and mem_regions_alloc_and_exclude() are
functionally equivalent to, respectively, mem_regions_add() and
mem_regions_exclude() except the formers will re-allocate memory
dynamically when no more entries are available in 'ranges' array.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Tested-by: Bhupesh Sharma <bhsharma@redhat.com>
Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
kexec/mem_regions.c | 42 ++++++++++++++++++++++++++++++++++++++++++
kexec/mem_regions.h | 7 +++++++
2 files changed, 49 insertions(+)
diff --git a/kexec/mem_regions.c b/kexec/mem_regions.c
index 50c8abccb93a..ad7d3f13fd84 100644
--- a/kexec/mem_regions.c
+++ b/kexec/mem_regions.c
@@ -125,3 +125,45 @@ int mem_regions_exclude(struct memory_ranges *ranges,
}
return 0;
}
+
+#define KEXEC_MEMORY_RANGES 16
+
+int mem_regions_alloc_and_add(struct memory_ranges *ranges,
+ unsigned long long base,
+ unsigned long long length, int type)
+{
+ void *new_ranges;
+
+ if (ranges->size >= ranges->max_size) {
+ new_ranges = realloc(ranges->ranges,
+ sizeof(struct memory_range) *
+ (ranges->max_size + KEXEC_MEMORY_RANGES));
+ if (!new_ranges)
+ return -1;
+
+ ranges->ranges = new_ranges;
+ ranges->max_size += KEXEC_MEMORY_RANGES;
+ }
+
+ return mem_regions_add(ranges, base, length, type);
+}
+
+int mem_regions_alloc_and_exclude(struct memory_ranges *ranges,
+ const struct memory_range *range)
+{
+ void *new_ranges;
+
+ /* for safety, we should have at least one free entry in ranges */
+ if (ranges->size >= ranges->max_size) {
+ new_ranges = realloc(ranges->ranges,
+ sizeof(struct memory_range) *
+ (ranges->max_size + KEXEC_MEMORY_RANGES));
+ if (!new_ranges)
+ return -1;
+
+ ranges->ranges = new_ranges;
+ ranges->max_size += KEXEC_MEMORY_RANGES;
+ }
+
+ return mem_regions_exclude(ranges, range);
+}
diff --git a/kexec/mem_regions.h b/kexec/mem_regions.h
index ae9e972b0206..e306d67e3261 100644
--- a/kexec/mem_regions.h
+++ b/kexec/mem_regions.h
@@ -12,4 +12,11 @@ int mem_regions_exclude(struct memory_ranges *ranges,
int mem_regions_add(struct memory_ranges *ranges, unsigned long long base,
unsigned long long length, int type);
+int mem_regions_alloc_and_exclude(struct memory_ranges *ranges,
+ const struct memory_range *range);
+
+int mem_regions_alloc_and_add(struct memory_ranges *ranges,
+ unsigned long long base,
+ unsigned long long length, int type);
+
#endif
--
2.7.4

View File

@ -1,36 +0,0 @@
From 7242ae4cb5288df626f464ced0a8b60fd669100b Mon Sep 17 00:00:00 2001
From: Michal Suchanek <msuchanek@suse.de>
Date: Mon, 16 Mar 2020 19:39:58 +0100
Subject: [PATCH 6/7] [PATCH] Align PMD_SECTION_MASK with PHYS_MASK
Reportedly on some arm64 systems makedumpfile loops forever exhausting
all memory when filtering kernel core. It turns out the reason is it
cannot resolve some addresses because the PMD mask is wrong. When
physical address mask allows up to 48bits pmd mask should allow the
same.
I suppose you would need a system that needs physical addresses over 1TB
to be able to reproduce this. This may be either because you have a lot
of memory or because the firmware mapped some memory above 1TB for some
reason.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
arch/arm64.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/makedumpfile-1.6.7/arch/arm64.c b/makedumpfile-1.6.7/arch/arm64.c
index 43164cc..54d60b4 100644
--- a/makedumpfile-1.6.7/arch/arm64.c
+++ b/makedumpfile-1.6.7/arch/arm64.c
@@ -81,7 +81,7 @@ static unsigned long kimage_voffset;
* Remove the highest order bits that are not a part of the
* physical address in a section
*/
-#define PMD_SECTION_MASK ((1UL << 40) - 1)
+#define PMD_SECTION_MASK ((1UL << PHYS_MASK_SHIFT) - 1)
#define PMD_TYPE_MASK 3
#define PMD_TYPE_SECT 1
--
2.7.5

View File

@ -1,80 +0,0 @@
From 81b79c514ff6fc881f1df4cb04ecb2d7cb22badc Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Wed, 19 Feb 2020 12:48:13 -0500
Subject: [PATCH] [PATCH] Avoid false-positive failure in mem_seciton
validation
Currently in get_mem_section(), we check whether SYMBOL(mem_section)
is a pointer to the array or a pointer to the pointer to the array
for some cases.
However, with commit e113f1c974c8 ("[PATCH] cope with not-present
mem section") relaxing the check, there was a report that the function
failed because both of two validate_mem_section() calls return TRUE.
Avoid the false-positive failure by not calling the second one if the
first one returns TRUE.
Reported-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
makedumpfile.c | 29 ++++++-----------------------
1 file changed, 6 insertions(+), 23 deletions(-)
diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c
index f5860a1..4c4251e 100644
--- a/makedumpfile-1.6.7/makedumpfile.c
+++ b/makedumpfile-1.6.7/makedumpfile.c
@@ -3472,7 +3472,6 @@ static int
get_mem_section(unsigned int mem_section_size, unsigned long *mem_maps,
unsigned int num_section)
{
- unsigned long mem_section_ptr;
int ret = FALSE;
unsigned long *mem_sec = NULL;
@@ -3484,34 +3483,18 @@ get_mem_section(unsigned int mem_section_size, unsigned long *mem_maps,
ret = validate_mem_section(mem_sec, SYMBOL(mem_section),
mem_section_size, mem_maps, num_section);
- if (is_sparsemem_extreme()) {
- int symbol_valid = ret;
- int pointer_valid;
- int mem_maps_size = sizeof(*mem_maps) * num_section;
- unsigned long *mem_maps_ex = NULL;
+ if (!ret && is_sparsemem_extreme()) {
+ unsigned long mem_section_ptr;
+
if (!readmem(VADDR, SYMBOL(mem_section), &mem_section_ptr,
sizeof(mem_section_ptr)))
goto out;
- if ((mem_maps_ex = malloc(mem_maps_size)) == NULL) {
- ERRMSG("Can't allocate memory for the mem_maps. %s\n",
- strerror(errno));
- goto out;
- }
+ ret = validate_mem_section(mem_sec, mem_section_ptr,
+ mem_section_size, mem_maps, num_section);
- pointer_valid = validate_mem_section(mem_sec,
- mem_section_ptr,
- mem_section_size,
- mem_maps_ex,
- num_section);
- if (pointer_valid)
- memcpy(mem_maps, mem_maps_ex, mem_maps_size);
- if (mem_maps_ex)
- free(mem_maps_ex);
- ret = symbol_valid ^ pointer_valid;
- if (!ret) {
+ if (!ret)
ERRMSG("Could not validate mem_section.\n");
- }
}
out:
if (mem_sec != NULL)
--
2.7.5

View File

@ -1,42 +0,0 @@
From 6e4b2dfaed5e5e5c617e0e45f969c1f571c13e27 Mon Sep 17 00:00:00 2001
From: Jialong Chen <chenjialong@huawei.com>
Date: Mon, 23 Mar 2020 16:42:01 -0400
Subject: [PATCH 7/7] [PATCH] Fix cd_header offset overflow with large pfn
In function write_kdump_pages_and_bitmap_cyclic(), cd_header->offset is
calculated by the following formula:
cd_header->offset
= (DISKDUMP_HEADER_BLOCKS + dh->sub_hdr_size + dh->bitmap_blocks)
* dh->block_size;
However, the variables of the right side are only int and unsigned int,
so if dh->bitmap_blocks is very large, it causes an interger overflow.
As a result, makedumpfile created a broken vmcore in a system with a
physical address range from 0x602770ecf000 to 0x6027ffffffff, and the
crash utility failed during session initialization, ending with the
error message "crash: vmlinux and vmcore do not match!".
Signed-off-by: Jialong Chen <chenjialong@huawei.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
diskdump_mod.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/makedumpfile-1.6.7/diskdump_mod.h b/makedumpfile-1.6.7/diskdump_mod.h
index 2676817..3733953 100644
--- a/makedumpfile-1.6.7/diskdump_mod.h
+++ b/makedumpfile-1.6.7/diskdump_mod.h
@@ -22,7 +22,7 @@
#define DISK_DUMP_SIGNATURE "DISKDUMP"
#define KDUMP_SIGNATURE "KDUMP "
#define SIG_LEN (sizeof(DUMP_PARTITION_SIGNATURE) - 1)
-#define DISKDUMP_HEADER_BLOCKS (1)
+#define DISKDUMP_HEADER_BLOCKS (1UL)
/*
* These are all remnants of the old "diskdump" facility,
--
2.7.5

View File

@ -1,255 +0,0 @@
From 989152e113bfcb4fbfbad6f3aed6f43be4455919 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Tue, 25 Feb 2020 16:04:55 -0500
Subject: [PATCH 4/7] [PATCH] Introduce --check-params option
Currently it's difficult to check whether a makedumpfile command-line
is valid or not without an actual panic. This is inefficient and if
a wrong configuration is not tested, you will miss the vmcore when an
actual panic occurs.
In order for kdump facilities like kexec-tools to be able to check
the specified command-line parameters in advance, introduce the
--check-params option that only checks them and exits immediately.
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
makedumpfile.8 | 5 ++++
makedumpfile.c | 75 +++++++++++++++++++++++++++++++++++++++++++++-------------
makedumpfile.h | 2 ++
print_info.c | 4 ++++
4 files changed, 69 insertions(+), 17 deletions(-)
diff --git a/makedumpfile-1.6.7/makedumpfile.8 b/makedumpfile-1.6.7/makedumpfile.8
index bf156a8..c5d4806 100644
--- a/makedumpfile-1.6.7/makedumpfile.8
+++ b/makedumpfile-1.6.7/makedumpfile.8
@@ -632,6 +632,11 @@ Show help message and LZO/snappy support status (enabled/disabled).
\fB\-v\fR
Show the version of makedumpfile.
+.TP
+\fB\-\-check-params\fR
+Only check whether the command-line parameters are valid or not, and exit.
+Preferable to be given as the first parameter.
+
.SH ENVIRONMENT VARIABLES
.TP 8
diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c
index 607e07f..f5860a1 100644
--- a/makedumpfile-1.6.7/makedumpfile.c
+++ b/makedumpfile-1.6.7/makedumpfile.c
@@ -10972,12 +10972,6 @@ check_param_for_creating_dumpfile(int argc, char *argv[])
if (info->flag_generate_vmcoreinfo || info->flag_rearrange)
return FALSE;
- if ((message_level < MIN_MSG_LEVEL)
- || (MAX_MSG_LEVEL < message_level)) {
- message_level = DEFAULT_MSG_LEVEL;
- MSG("Message_level is invalid.\n");
- return FALSE;
- }
if ((info->flag_compress && info->flag_elf_dumpfile)
|| (info->flag_read_vmcoreinfo && info->name_vmlinux)
|| (info->flag_read_vmcoreinfo && info->name_xen_syms))
@@ -11007,6 +11001,11 @@ check_param_for_creating_dumpfile(int argc, char *argv[])
if (info->flag_partial_dmesg && !info->flag_dmesg)
return FALSE;
+ if (info->flag_excludevm && !info->working_dir) {
+ MSG("-%c requires --work-dir\n", OPT_EXCLUDE_UNUSED_VM);
+ return FALSE;
+ }
+
if ((argc == optind + 2) && !info->flag_flatten
&& !info->flag_split
&& !info->flag_sadump_diskset) {
@@ -11402,6 +11401,23 @@ int show_mem_usage(void)
return TRUE;
}
+static int set_message_level(char *str_ml)
+{
+ int ml;
+
+ ml = atoi(str_ml);
+ if ((ml < MIN_MSG_LEVEL) || (MAX_MSG_LEVEL < ml)) {
+ message_level = DEFAULT_MSG_LEVEL;
+ MSG("Message_level(%d) is invalid.\n", ml);
+ return FALSE;
+ }
+
+ if (info->flag_check_params)
+ return TRUE;
+
+ message_level = ml;
+ return TRUE;
+}
static struct option longopts[] = {
{"split", no_argument, NULL, OPT_SPLIT},
@@ -11423,6 +11439,7 @@ static struct option longopts[] = {
{"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE},
{"work-dir", required_argument, NULL, OPT_WORKING_DIR},
{"num-threads", required_argument, NULL, OPT_NUM_THREADS},
+ {"check-params", no_argument, NULL, OPT_CHECK_PARAMS},
{0, 0, 0, 0}
};
@@ -11521,7 +11538,8 @@ main(int argc, char *argv[])
info->flag_compress = DUMP_DH_COMPRESSED_LZO;
break;
case OPT_MESSAGE_LEVEL:
- message_level = atoi(optarg);
+ if (!set_message_level(optarg))
+ goto out;
break;
case OPT_DUMP_DMESG:
info->flag_dmesg = 1;
@@ -11584,6 +11602,10 @@ main(int argc, char *argv[])
case OPT_NUM_THREADS:
info->num_threads = MAX(atoi(optarg), 0);
break;
+ case OPT_CHECK_PARAMS:
+ info->flag_check_params = TRUE;
+ message_level = DEFAULT_MSG_LEVEL;
+ break;
case '?':
MSG("Commandline parameter is invalid.\n");
MSG("Try `makedumpfile --help' for more information.\n");
@@ -11593,11 +11615,9 @@ main(int argc, char *argv[])
if (flag_debug)
message_level |= ML_PRINT_DEBUG_MSG;
- if (info->flag_excludevm && !info->working_dir) {
- ERRMSG("Error: -%c requires --work-dir\n", OPT_EXCLUDE_UNUSED_VM);
- ERRMSG("Try `makedumpfile --help' for more information\n");
- return COMPLETED;
- }
+ if (info->flag_check_params)
+ /* suppress debugging messages */
+ message_level = DEFAULT_MSG_LEVEL;
if (info->flag_show_usage) {
print_usage();
@@ -11628,6 +11648,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (!open_files_for_generating_vmcoreinfo())
goto out;
@@ -11651,6 +11674,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (!check_dump_file(info->name_dumpfile))
goto out;
@@ -11671,6 +11697,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (!check_dump_file(info->name_dumpfile))
goto out;
@@ -11684,6 +11713,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (!check_dump_file(info->name_dumpfile))
goto out;
if (!dump_dmesg())
@@ -11697,6 +11729,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (!populate_kernel_version())
goto out;
@@ -11715,6 +11750,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (info->flag_split) {
for (i = 0; i < info->num_dumpfile; i++) {
SPLITTING_FD_BITMAP(i) = -1;
@@ -11742,13 +11780,16 @@ main(int argc, char *argv[])
MSG("The dumpfile is saved to %s.\n", info->name_dumpfile);
}
}
+check_ok:
retcd = COMPLETED;
out:
- MSG("\n");
- if (retcd != COMPLETED)
- MSG("makedumpfile Failed.\n");
- else if (!info->flag_mem_usage)
- MSG("makedumpfile Completed.\n");
+ if (!info->flag_check_params) {
+ MSG("\n");
+ if (retcd != COMPLETED)
+ MSG("makedumpfile Failed.\n");
+ else if (!info->flag_mem_usage)
+ MSG("makedumpfile Completed.\n");
+ }
free_for_parallel();
diff --git a/makedumpfile-1.6.7/makedumpfile.h b/makedumpfile-1.6.7/makedumpfile.h
index 7217407..03fb4ce 100644
--- a/makedumpfile-1.6.7/makedumpfile.h
+++ b/makedumpfile-1.6.7/makedumpfile.h
@@ -1301,6 +1301,7 @@ struct DumpInfo {
int flag_read_vmcoreinfo; /* flag of reading vmcoreinfo file */
int flag_show_usage; /* flag of showing usage */
int flag_show_version; /* flag of showing version */
+ int flag_check_params; /* only check parameters */
int flag_flatten; /* flag of outputting flattened
format to a standard out */
int flag_rearrange; /* flag of creating dumpfile from
@@ -2362,6 +2363,7 @@ struct elf_prstatus {
#define OPT_WORKING_DIR OPT_START+15
#define OPT_NUM_THREADS OPT_START+16
#define OPT_PARTIAL_DMESG OPT_START+17
+#define OPT_CHECK_PARAMS OPT_START+18
/*
* Function Prototype.
diff --git a/makedumpfile-1.6.7/print_info.c b/makedumpfile-1.6.7/print_info.c
index 0be12ea..e0c38b4 100644
--- a/makedumpfile-1.6.7/print_info.c
+++ b/makedumpfile-1.6.7/print_info.c
@@ -321,6 +321,10 @@ print_usage(void)
MSG(" [-v]:\n");
MSG(" Show the version of makedumpfile.\n");
MSG("\n");
+ MSG(" [--check-params]:\n");
+ MSG(" Only check whether the command-line parameters are valid or not, and exit.\n");
+ MSG(" Preferable to be given as the first parameter.\n");
+ MSG("\n");
MSG(" VMLINUX:\n");
MSG(" This is a pathname to the first kernel's vmlinux.\n");
MSG(" This file must have the debug information of the first kernel to analyze\n");
--
2.7.5

View File

@ -1,65 +0,0 @@
From 12250baa02584dc713cdb1a12fb366f643fdc8b3 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Mon, 9 Mar 2020 17:17:31 -0400
Subject: [PATCH 5/7] [PATCH] Makefile: Fix build errors in static build
When building makedumpfile statically (without LINKTYPE=dynamic),
the following error is observed:
/usr/bin/ld: /usr/lib/makedumpfile-1.6.7/gcc/x86_64-redhat-linux/9/../../../../lib64/libdw.a(lzma.o): in function `__libdw_unlzma':
(.text+0xbd): undefined reference to `lzma_auto_decoder'
/usr/bin/ld: (.text+0x23a): undefined reference to `lzma_code'
/usr/bin/ld: (.text+0x269): undefined reference to `lzma_end'
/usr/bin/ld: (.text+0x2aa): undefined reference to `lzma_end'
/usr/bin/ld: (.text+0x3ac): undefined reference to `lzma_end'
/usr/bin/ld: (.text+0x427): undefined reference to `lzma_end'
/usr/bin/ld: (.text+0x62b): undefined reference to `lzma_end'
collect2: error: ld returned 1 exit status
make: *** [Makefile:97: makedumpfile] Error 1
Also, when doing it with USESNAPPY=on:
/usr/bin/ld: /usr/local/lib64/libsnappy.a(snappy.cc.o): in function `snappy::internal::WorkingMemory::WorkingMemory(unsigned long)':
snappy.cc:(.text+0x7d4): undefined reference to `std::allocator<char>::allocator()'
/usr/bin/ld: snappy.cc:(.text+0x803): undefined reference to `std::allocator<char>::~allocator()'
/usr/bin/ld: snappy.cc:(.text+0x853): undefined reference to `std::allocator<char>::~allocator()'
/usr/bin/ld: /usr/local/lib64/libsnappy.a(snappy.cc.o): in function `snappy::internal::WorkingMemory::~WorkingMemory()':
snappy.cc:(.text+0x87e): undefined reference to `std::allocator<char>::allocator()'
/usr/bin/ld: snappy.cc:(.text+0x8a8): undefined reference to `std::allocator<char>::~allocator()'
...
Fix these errors by adding -llzma and -lstd++ to LIBS respectively
if LINKTYPE=dynamic is not specified.
Reported-by: Prabhakar Kushwaha <prabhakar.pkin@gmail.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
Makefile | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/makedumpfile-1.6.7/Makefile b/makedumpfile-1.6.7/Makefile
index 868eea6..ef20672 100644
--- a/makedumpfile-1.6.7/Makefile
+++ b/makedumpfile-1.6.7/Makefile
@@ -52,7 +52,7 @@ OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH))
LIBS = -ldw -lbz2 -ldl -lelf -lz
ifneq ($(LINKTYPE), dynamic)
-LIBS := -static $(LIBS)
+LIBS := -static $(LIBS) -llzma
endif
ifeq ($(USELZO), on)
@@ -62,6 +62,9 @@ endif
ifeq ($(USESNAPPY), on)
LIBS := -lsnappy $(LIBS)
+ifneq ($(LINKTYPE), dynamic)
+LIBS := $(LIBS) -lstdc++
+endif
CFLAGS += -DUSESNAPPY
endif
--
2.7.5

View File

@ -1,103 +0,0 @@
From 399f2c9a3acd5bd913e50a4dde52dee6527b297e Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Wed, 29 Jan 2020 13:37:13 +0800
Subject: [PATCH 2/7] [PATCH] Remove duplicated variable definitions
When building on Fedora 32 (with GCC 10), following error is observed:
/usr/bin/ld: erase_info.o:/tmp/makedumpfile/makedumpfile.h:2010: multiple definition of
`crash_reserved_mem_nr'; elf_info.o:/tmp/makedumpfile/makedumpfile.h:2010: first defined here
/usr/bin/ld: erase_info.o:/tmp/makedumpfile/makedumpfile.h:2009: multiple definition of
`crash_reserved_mem'; elf_info.o:/tmp/makedumpfile/makedumpfile.h:2009: first defined here
/usr/bin/ld: erase_info.o:/tmp/makedumpfile/makedumpfile.h:1278: multiple definition of
`parallel_info_t'; elf_info.o:/tmp/makedumpfile/makedumpfile.h:1278: first defined here
/usr/bin/ld: erase_info.o:/tmp/makedumpfile/makedumpfile.h:1265: multiple definition of
`splitting_info_t'; elf_info.o:/tmp/makedumpfile/makedumpfile.h:1265: first defined here
...
collect2: error: ld returned 1 exit status
make: *** [Makefile:97: makedumpfile] Error 1
These variables are wrongly defined multiple times. So remove the
duplicated definitions.
Signed-off-by: Kairui Song <kasong@redhat.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
makedumpfile.c | 8 ++++----
makedumpfile.h | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c
index e290fbd..ae7336a 100644
--- a/makedumpfile-1.6.7/makedumpfile.c
+++ b/makedumpfile-1.6.7/makedumpfile.c
@@ -10954,7 +10954,7 @@ check_param_for_reassembling_dumpfile(int argc, char *argv[])
return FALSE;
if ((info->splitting_info
- = malloc(sizeof(splitting_info_t) * info->num_dumpfile))
+ = malloc(sizeof(struct splitting_info) * info->num_dumpfile))
== NULL) {
MSG("Can't allocate memory for splitting_info.\n");
return FALSE;
@@ -11042,7 +11042,7 @@ check_param_for_creating_dumpfile(int argc, char *argv[])
return FALSE;
}
if ((info->splitting_info
- = malloc(sizeof(splitting_info_t) * info->num_dumpfile))
+ = malloc(sizeof(struct splitting_info) * info->num_dumpfile))
== NULL) {
MSG("Can't allocate memory for splitting_info.\n");
return FALSE;
@@ -11077,13 +11077,13 @@ check_param_for_creating_dumpfile(int argc, char *argv[])
if (info->num_threads) {
if ((info->parallel_info =
- malloc(sizeof(parallel_info_t) * info->num_threads))
+ malloc(sizeof(struct parallel_info) * info->num_threads))
== NULL) {
MSG("Can't allocate memory for parallel_info.\n");
return FALSE;
}
- memset(info->parallel_info, 0, sizeof(parallel_info_t)
+ memset(info->parallel_info, 0, sizeof(struct parallel_info)
* info->num_threads);
}
diff --git a/makedumpfile-1.6.7/makedumpfile.h b/makedumpfile-1.6.7/makedumpfile.h
index 68d9691..7217407 100644
--- a/makedumpfile-1.6.7/makedumpfile.h
+++ b/makedumpfile-1.6.7/makedumpfile.h
@@ -1262,7 +1262,7 @@ struct splitting_info {
mdf_pfn_t end_pfn;
off_t offset_eraseinfo;
unsigned long size_eraseinfo;
-} splitting_info_t;
+};
struct parallel_info {
int fd_memory;
@@ -1275,7 +1275,7 @@ struct parallel_info {
#ifdef USELZO
lzo_bytep wrkmem;
#endif
-} parallel_info_t;
+};
struct ppc64_vmemmap {
unsigned long phys;
@@ -2006,8 +2006,8 @@ struct memory_range {
};
#define CRASH_RESERVED_MEM_NR 8
-struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR];
-int crash_reserved_mem_nr;
+extern struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR];
+extern int crash_reserved_mem_nr;
unsigned long read_vmcoreinfo_symbol(char *str_symbol);
int readmem(int type_addr, unsigned long long addr, void *bufptr, size_t size);
--
2.7.5

View File

@ -1,65 +0,0 @@
From e113f1c974c820f9633dc0073eda525d7575f365 Mon Sep 17 00:00:00 2001
From: Pingfan Liu <piliu@redhat.com>
Date: Mon, 20 Jan 2020 10:25:24 +0800
Subject: [PATCH 3/7] [PATCH] cope with not-present mem section
After kernel commit ba72b4c8cf60 ("mm/sparsemem: support sub-section
hotplug"), when hot-removed, section_mem_map is still encoded with section
start pfn, not NULL. This break the current makedumpfile.
# makedumpfile -x vmlinux -l -d 31 vmcore vmcore.dump
get_mem_section: Could not validate mem_section.
get_mm_sparsemem: Can't get the address of mem_section.
makedumpfile Failed.
Whatever section_mem_map coding info after hot-removed, it is reliable
just to work on SECTION_MARKED_PRESENT bit. Fixing makedumpfile by this
way.
[ This issue occurs on kernel 5.3 through 5.5, and should be fixed by
commit 1f503443e7df ("mm/sparse.c: reset section's mem_map when fully
deactivated") in 5.6-rc1, 5.5.3 and 5.4.19. ]
Signed-off-by: Pingfan Liu <piliu@redhat.com>
To: kexec@lists.infradead.org
Cc: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Qian Cai <cai@lca.pw>
---
makedumpfile.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c
index ae7336a..607e07f 100644
--- a/makedumpfile-1.6.7/makedumpfile.c
+++ b/makedumpfile-1.6.7/makedumpfile.c
@@ -3406,8 +3406,6 @@ section_mem_map_addr(unsigned long addr, unsigned long *map_mask)
map = ULONG(mem_section + OFFSET(mem_section.section_mem_map));
mask = SECTION_MAP_MASK;
*map_mask = map & ~mask;
- if (map == 0x0)
- *map_mask |= SECTION_MARKED_PRESENT;
map &= mask;
free(mem_section);
@@ -3453,10 +3451,8 @@ validate_mem_section(unsigned long *mem_sec,
mem_map = NOT_MEMMAP_ADDR;
} else {
mem_map = section_mem_map_addr(section, &map_mask);
+ /* for either no mem_map or hot-removed */
if (!(map_mask & SECTION_MARKED_PRESENT)) {
- return FALSE;
- }
- if (mem_map == 0) {
mem_map = NOT_MEMMAP_ADDR;
} else {
mem_map = sparse_decode_mem_map(mem_map,
--
2.7.5

View File

@ -1,213 +0,0 @@
From 3c0cf7a93cff83f1e711e241eb47fcb096a451c5 Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date: Thu, 9 Jul 2020 18:27:49 +0900
Subject: [PATCH] [PATCH] sadump, kaslr: fix failure of calculating
kaslr_offset due to an sadump format restriction
We faced recently a memory dump collected by sadump where unused part
of register values are non-zero. For the crash dump, calculating
kaslr_offset fails because it is based on the assumption that unused
part of register values in the sadump format are always zero cleared.
The problem is that used and unused part of register values are
rigorously indistinguishable in the sadump format. Although there is
kernel data structure that represents a map between logical cpu
numbers and lapic ids, they cannot be used in order to calculate
kaslr_offset.
To fix this, we have no choice but use a trial-and-error approach: try
to use each entry of register values in order until we find a good
pair of cr3 and idtr by which we can refer to linux_banner symbol as
expected.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
---
sadump_info.c | 129 +++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 91 insertions(+), 38 deletions(-)
diff --git a/makedumpfile-1.6.7/sadump_info.c b/makedumpfile-1.6.7/sadump_info.c
index 72a077b4f408..410c6bc2a909 100644
--- a/makedumpfile-1.6.7/sadump_info.c
+++ b/makedumpfile-1.6.7/sadump_info.c
@@ -101,6 +101,7 @@ static int lookup_diskset(unsigned long long whole_offset, int *diskid,
unsigned long long *disk_offset);
static int max_mask_cpu(void);
static int cpu_online_mask_init(void);
+static int linux_banner_sanity_check(ulong cr3);
static int per_cpu_init(void);
static int get_data_from_elf_note_desc(const char *note_buf, uint32_t n_descsz,
char *name, uint32_t n_type, char **data);
@@ -1293,6 +1294,30 @@ finish:
return ret;
}
+static int linux_banner_sanity_check(ulong cr3)
+{
+ unsigned long linux_banner_paddr;
+ char buf[sizeof("Linux version")];
+
+ linux_banner_paddr = vtop4_x86_64_pagetable(SYMBOL(linux_banner), cr3);
+ if (linux_banner_paddr == NOT_PADDR) {
+ DEBUG_MSG("sadump: linux_banner address translation failed\n");
+ return FALSE;
+ }
+
+ if (!readmem(PADDR, linux_banner_paddr, &buf, sizeof(buf))) {
+ DEBUG_MSG("sadump: reading linux_banner failed\n");
+ return FALSE;
+ }
+
+ if (!STRNEQ(buf, "Linux version")) {
+ DEBUG_MSG("sadump: linux_banner sanity check failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/*
* Calculate kaslr_offset and phys_base
*
@@ -1370,59 +1395,85 @@ calc_kaslr_offset(void)
{
struct sadump_header *sh = si->sh_memory;
uint64_t idtr = 0, cr3 = 0, idtr_paddr;
- struct sadump_smram_cpu_state smram, zero;
+ struct sadump_smram_cpu_state smram;
int apicid;
unsigned long divide_error_vmcore, divide_error_vmlinux;
unsigned long kaslr_offset, phys_base;
unsigned long kaslr_offset_kdump, phys_base_kdump;
+ int sanity_check_passed = FALSE;
- memset(&zero, 0, sizeof(zero));
for (apicid = 0; apicid < sh->nr_cpus; ++apicid) {
+
+ DEBUG_MSG("sadump: apicid: %d\n", apicid);
+
if (!get_smram_cpu_state(apicid, &smram)) {
ERRMSG("get_smram_cpu_state error\n");
return FALSE;
}
- if (memcmp(&smram, &zero, sizeof(smram)) != 0)
- break;
- }
- if (apicid >= sh->nr_cpus) {
- ERRMSG("Can't get smram state\n");
- return FALSE;
- }
+ idtr = ((uint64_t)smram.IdtUpper)<<32|(uint64_t)smram.IdtLower;
- idtr = ((uint64_t)smram.IdtUpper)<<32 | (uint64_t)smram.IdtLower;
- if ((SYMBOL(pti_init) != NOT_FOUND_SYMBOL) ||
- (SYMBOL(kaiser_init) != NOT_FOUND_SYMBOL))
- cr3 = smram.Cr3 & ~(CR3_PCID_MASK|PTI_USER_PGTABLE_MASK);
- else
- cr3 = smram.Cr3 & ~CR3_PCID_MASK;
+ if (!smram.Cr3 || !idtr) {
+ DEBUG_MSG("sadump: cr3: %lx idt: %lx, skipped\n",
+ smram.Cr3, idtr);
+ continue;
+ }
- /* Convert virtual address of IDT table to physical address */
- if ((idtr_paddr = vtop4_x86_64_pagetable(idtr, cr3)) == NOT_PADDR)
- return FALSE;
+ if ((SYMBOL(pti_init) != NOT_FOUND_SYMBOL) ||
+ (SYMBOL(kaiser_init) != NOT_FOUND_SYMBOL))
+ cr3 = smram.Cr3 & ~(CR3_PCID_MASK|PTI_USER_PGTABLE_MASK);
+ else
+ cr3 = smram.Cr3 & ~CR3_PCID_MASK;
- /* Now we can calculate kaslr_offset and phys_base */
- divide_error_vmlinux = SYMBOL(divide_error);
- divide_error_vmcore = get_vec0_addr(idtr_paddr);
- kaslr_offset = divide_error_vmcore - divide_error_vmlinux;
- phys_base = idtr_paddr -
- (SYMBOL(idt_table) + kaslr_offset - __START_KERNEL_map);
+ /* Convert virtual address of IDT table to physical address */
+ idtr_paddr = vtop4_x86_64_pagetable(idtr, cr3);
+ if (idtr_paddr == NOT_PADDR) {
+ DEBUG_MSG("sadump: converting IDT physical address "
+ "failed.\n");
+ continue;
+ }
- info->kaslr_offset = kaslr_offset;
- info->phys_base = phys_base;
+ /* Now we can calculate kaslr_offset and phys_base */
+ divide_error_vmlinux = SYMBOL(divide_error);
+ divide_error_vmcore = get_vec0_addr(idtr_paddr);
+ kaslr_offset = divide_error_vmcore - divide_error_vmlinux;
+ phys_base = idtr_paddr -
+ (SYMBOL(idt_table)+kaslr_offset-__START_KERNEL_map);
- DEBUG_MSG("sadump: idtr=%" PRIx64 "\n", idtr);
- DEBUG_MSG("sadump: cr3=%" PRIx64 "\n", cr3);
- DEBUG_MSG("sadump: idtr(phys)=%" PRIx64 "\n", idtr_paddr);
- DEBUG_MSG("sadump: devide_error(vmlinux)=%lx\n",
- divide_error_vmlinux);
- DEBUG_MSG("sadump: devide_error(vmcore)=%lx\n",
- divide_error_vmcore);
+ info->kaslr_offset = kaslr_offset;
+ info->phys_base = phys_base;
- /* Reload symbol */
- if (!get_symbol_info())
- return FALSE;
+ DEBUG_MSG("sadump: idtr=%" PRIx64 "\n", idtr);
+ DEBUG_MSG("sadump: cr3=%" PRIx64 "\n", cr3);
+ DEBUG_MSG("sadump: idtr(phys)=%" PRIx64 "\n", idtr_paddr);
+ DEBUG_MSG("sadump: devide_error(vmlinux)=%lx\n",
+ divide_error_vmlinux);
+ DEBUG_MSG("sadump: devide_error(vmcore)=%lx\n",
+ divide_error_vmcore);
+
+ /* Reload symbol */
+ if (!get_symbol_info()) {
+ ERRMSG("Reading symbol table failed\n");
+ return FALSE;
+ }
+
+ /* Sanity check */
+ if (linux_banner_sanity_check(cr3)) {
+ sanity_check_passed = TRUE;
+ break;
+ }
+
+ info->kaslr_offset = 0;
+ info->phys_base = 0;
+ }
+
+ if (!sanity_check_passed) {
+ ERRMSG("failed to calculate kaslr_offset and phys_base; "
+ "default to 0\n");
+ info->kaslr_offset = 0;
+ info->phys_base = 0;
+ return TRUE;
+ }
/*
* Check if current kaslr_offset/phys_base is for 1st kernel or 2nd
@@ -1430,13 +1481,15 @@ calc_kaslr_offset(void)
* from vmcoreinfo
*/
if (get_kaslr_offset_from_vmcoreinfo(cr3, &kaslr_offset_kdump,
- &phys_base_kdump)) {
+ &phys_base_kdump)) {
info->kaslr_offset = kaslr_offset_kdump;
info->phys_base = phys_base_kdump;
/* Reload symbol */
- if (!get_symbol_info())
+ if (!get_symbol_info()) {
+ ERRMSG("Reading symbol table failed\n");
return FALSE;
+ }
}
DEBUG_MSG("sadump: kaslr_offset=%lx\n", info->kaslr_offset);
--
2.7.4

View File

@ -1,38 +0,0 @@
From a46c686f615a86933134c0924c3391ba598a02b8 Mon Sep 17 00:00:00 2001
From: Bhupesh Sharma <bhsharma@redhat.com>
Date: Tue, 10 Sep 2019 15:51:49 +0530
Subject: [PATCH 5/5] vmcore-dmesg/vmcore-dmesg.c: Fix shifting error reported
by cppcheck
Running 'cppcheck' static code analyzer (see cppcheck(1))
on 'vmcore-dmesg/vmcore-dmesg.c' shows the following
shifting error:
$ cppcheck --enable=all vmcore-dmesg/vmcore-dmesg.c
Checking vmcore-dmesg/vmcore-dmesg.c ...
[vmcore-dmesg/vmcore-dmesg.c:17]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
Fix the same via this patch.
Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
vmcore-dmesg/vmcore-dmesg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
index 81c2a58c9d86..122e53672e01 100644
--- a/vmcore-dmesg/vmcore-dmesg.c
+++ b/vmcore-dmesg/vmcore-dmesg.c
@@ -6,7 +6,7 @@ typedef Elf32_Nhdr Elf_Nhdr;
extern const char *fname;
/* stole this macro from kernel printk.c */
-#define LOG_BUF_LEN_MAX (uint32_t)(1 << 31)
+#define LOG_BUF_LEN_MAX (uint32_t)(1U << 31)
static void write_to_stdout(char *buf, unsigned int nr)
{
--
2.17.1

View File

@ -0,0 +1,76 @@
commit 6d0d95ecc04a70f8448d562ff0fbbae237f5c929
Author: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Thu Apr 21 08:58:29 2022 +0900
[PATCH] Avoid false-positive mem_section validation with vmlinux
Currently get_mem_section() validates if SYMBOL(mem_section) is the address
of the mem_section array first. But there was a report that the first
validation wrongly returned TRUE with -x vmlinux and SPARSEMEM_EXTREME
(4.15+) on s390x. This leads to crash failing statup with the following
seek error:
crash: seek error: kernel virtual address: 67fffc2800 type: "memory section root table"
Skip the first validation when satisfying the conditions.
Reported-by: Dave Wysochanski <dwysocha@redhat.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
Reviewed-and-Tested-by: Philipp Rudo <prudo@redhat.com>
Reviewed-by: Pingfan Liu <piliu@redhat.com>
diff --git a/makedumpfile-1.7.1/makedumpfile.c b/makedumpfile-1.7.1/makedumpfile.c
index a2f45c84cee3ba57ce3d3cf3f1905e6a03f4fd09..65d1c7c2f02c9ae8ead9de0f0217235fe72b3ca7 100644
--- a/makedumpfile-1.7.1/makedumpfile.c
+++ b/makedumpfile-1.7.1/makedumpfile.c
@@ -3698,6 +3698,22 @@ validate_mem_section(unsigned long *mem_sec,
return ret;
}
+/*
+ * SYMBOL(mem_section) varies with the combination of memory model and
+ * its source:
+ *
+ * SPARSEMEM
+ * vmcoreinfo: address of mem_section root array
+ * -x vmlinux: address of mem_section root array
+ *
+ * SPARSEMEM_EXTREME v1
+ * vmcoreinfo: address of mem_section root array
+ * -x vmlinux: address of mem_section root array
+ *
+ * SPARSEMEM_EXTREME v2 (with 83e3c48729d9 and a0b1280368d1) 4.15+
+ * vmcoreinfo: address of mem_section root array
+ * -x vmlinux: address of pointer to mem_section root array
+ */
static int
get_mem_section(unsigned int mem_section_size, unsigned long *mem_maps,
unsigned int num_section)
@@ -3710,12 +3726,27 @@ get_mem_section(unsigned int mem_section_size, unsigned long *mem_maps,
strerror(errno));
return FALSE;
}
+
+ /*
+ * There was a report that the first validation wrongly returned TRUE
+ * with -x vmlinux and SPARSEMEM_EXTREME v2 on s390x, so skip it.
+ * Howerver, leave the fallback validation as it is for the -i option.
+ */
+ if (is_sparsemem_extreme() && info->name_vmlinux) {
+ unsigned long flag = 0;
+ if (get_symbol_type_name("mem_section", DWARF_INFO_GET_SYMBOL_TYPE,
+ NULL, &flag)
+ && !(flag & TYPE_ARRAY))
+ goto skip_1st_validation;
+ }
+
ret = validate_mem_section(mem_sec, SYMBOL(mem_section),
mem_section_size, mem_maps, num_section);
if (!ret && is_sparsemem_extreme()) {
unsigned long mem_section_ptr;
+skip_1st_validation:
if (!readmem(VADDR, SYMBOL(mem_section), &mem_section_ptr,
sizeof(mem_section_ptr)))
goto out;

View File

@ -6,18 +6,30 @@
# Written by Cong Wang <amwang@redhat.com>
#
if [ -f /etc/sysconfig/kdump ]; then
. /etc/sysconfig/kdump
fi
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
. $dracutbasedir/dracut-functions.sh
. /lib/kdump/kdump-lib.sh
. /lib/kdump/kdump-logger.sh
export IN_KDUMP=1
#initiate the kdump logger
dlog_init
if [ $? -ne 0 ]; then
echo "failed to initiate the kdump logger."
exit 1
fi
conf_file="/etc/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
SAVE_PATH=$(get_save_path)
OVERRIDE_RESETTABLE=0
extra_modules=""
dracut_args="--quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o \"plymouth dash resume ifcfg earlykdump\""
dracut_args="--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o \"plymouth dash resume ifcfg earlykdump\" --compress=xz"
readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)"
[ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed."
@ -33,28 +45,10 @@ trap '
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
is_wdt_addition_needed() {
local active
is_wdt_mod_omitted
[[ $? -eq 0 ]] && return 1
[[ -d /sys/class/watchdog/ ]] || return 1
for dir in /sys/class/watchdog/*; do
[[ -f "$dir/state" ]] || continue
active=$(< "$dir/state")
[[ "$active" = "active" ]] && return 0
done
return 1
}
add_dracut_arg() {
dracut_args="$dracut_args $@"
}
add_dracut_module() {
add_dracut_arg "--add" "\"$1\""
}
add_dracut_mount() {
add_dracut_arg "--mount" "\"$1\""
}
@ -74,8 +68,8 @@ to_mount() {
if [[ "$_fstype" == "nfs"* ]]; then
_pdev=$_target
_options=$(echo $_options | sed 's/,addr=[^,]*//')
_options=$(echo $_options | sed 's/,proto=[^,]*//')
_options=$(echo $_options | sed 's/,\(mount\)\?addr=[^,]*//g')
_options=$(echo $_options | sed 's/,\(mount\)\?proto=[^,]*//g')
_options=$(echo $_options | sed 's/,clientaddr=[^,]*//')
else
# for non-nfs _target converting to use udev persistent name
@ -177,8 +171,8 @@ check_size() {
fi
if [ $avail -lt $memtotal ]; then
echo "Warning: There might not be enough space to save a vmcore."
echo " The size of $2 should be greater than $memtotal kilo bytes."
dwarn "Warning: There might not be enough space to save a vmcore."
dwarn " The size of $2 should be greater than $memtotal kilo bytes."
fi
}
@ -250,7 +244,7 @@ verify_core_collector() {
if [ "$_cmd" != "makedumpfile" ]; then
if is_raw_dump_target; then
echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
fi
return
fi
@ -311,7 +305,6 @@ get_override_resettable()
fi
}
# $1: function name
for_each_block_target()
{
@ -326,8 +319,6 @@ for_each_block_target()
return 0
}
#judge if a specific device with $1 is unresettable
#return false if unresettable.
is_unresettable()
@ -340,7 +331,7 @@ is_unresettable()
resettable="$(cat $path)"
[ $resettable -eq 0 -a "$OVERRIDE_RESETTABLE" -eq 0 ] && {
local device=$(udevadm info --query=all --path=/sys/dev/block/$1 | awk -F= '/DEVNAME/{print $2}')
echo "Error: Can not save vmcore because device $device is unresettable"
derror "Error: Can not save vmcore because device $device is unresettable"
return 0
}
fi
@ -364,32 +355,15 @@ check_resettable()
return 1
}
# $1: maj:min
is_crypt()
{
local majmin=$1 dev line ID_FS_TYPE=""
line=$(udevadm info --query=property --path=/sys/dev/block/$majmin \
| grep "^ID_FS_TYPE")
eval "$line"
[[ "$ID_FS_TYPE" = "crypto_LUKS" ]] && {
dev=$(udevadm info --query=all --path=/sys/dev/block/$majmin | awk -F= '/DEVNAME/{print $2}')
echo "Device $dev is encrypted."
return 0
}
return 1
}
check_crypt()
{
local _ret _target
local _dev
for_each_block_target is_crypt
_ret=$?
[ $_ret -eq 0 ] && return
return 1
for _dev in $(get_kdump_targets); do
if [[ -n $(get_luks_crypt_dev "$(get_maj_min "$_dev")") ]]; then
derror "Device $_dev is encrypted." && return 1
fi
done
}
if ! check_resettable; then
@ -397,7 +371,7 @@ if ! check_resettable; then
fi
if ! check_crypt; then
echo "Warning: Encrypted device is in dump path. User will prompted for password during second kernel boot."
dwarn "Warning: Encrypted device is in dump path. User will prompted for password during second kernel boot."
fi
# firstly get right SSH_KEY_LOCATION
@ -407,14 +381,6 @@ if [ -f "$keyfile" ]; then
SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile)
fi
if [ "$(uname -m)" = "s390x" ]; then
add_dracut_module "znet"
fi
if is_wdt_addition_needed; then
add_dracut_arg "-a" "watchdog"
fi
while read config_opt config_val;
do
# remove inline comments after the end of a directive.
@ -443,7 +409,6 @@ do
then
mkdir_save_path_ssh $config_val
check_size ssh $config_val
add_dracut_module "ssh-client"
add_dracut_sshkey "$SSH_KEY_LOCATION"
else
perror_exit "Bad ssh dump target $config_val"
@ -467,6 +432,11 @@ then
add_dracut_arg "--add-drivers" \"$extra_modules\"
fi
# TODO: The below check is not needed anymore with the introduction of
# 'zz-fadumpinit' module, that isolates fadump's capture kernel initrd,
# but still sysroot.mount unit gets generated based on 'root=' kernel
# parameter available in fadump case. So, find a way to fix that first
# before removing this check.
if ! is_fadump_capable; then
# The 2nd rootfs mount stays behind the normal dump target mount,
# so it doesn't affect the logic of check_dump_fs_modified().
@ -476,7 +446,3 @@ if ! is_fadump_capable; then
fi
echo "$dracut_args $@" | xargs dracut
_rc=$?
sync
exit $_rc

View File

@ -15,7 +15,13 @@ be loaded in the initramfs (based on configuration retrieved from
\fI/etc/kdump.conf)\fR
\fBmkdumprd\fR add a new \fBdracut\fR module 99kdumpbase and use \fBdracut\fR
utility to generate the initramfs.
utility to generate the initramfs. When generating a kdump initramfs, \fBmkdumprd\fR
will determine how much disk space is available, if the dump target's available
space is not greater than the total system memory, \fBmkdumprd\fR will print a
warning to remind that there might not be enough space to save a vmcore. The
warning covers extreme scenarios such as the slab explodes with non-zero data or
a full vmcore, etc. Therefore, need to prevent users from having minimum disk
space for crash dump.
\fBmkdumprd\fR was not intended for casual use outside of the service
initialization script for the kdump utility, and should not be run manually. If

64
SOURCES/mkfadumprd Normal file
View File

@ -0,0 +1,64 @@
#!/bin/bash --norc
# Generate an initramfs image that isolates dump capture capability within
# the default initramfs using zz-fadumpinit dracut module.
if [ -f /etc/sysconfig/kdump ]; then
. /etc/sysconfig/kdump
fi
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
. $dracutbasedir/dracut-functions.sh
. /lib/kdump/kdump-lib.sh
. /lib/kdump/kdump-logger.sh
#initiate the kdump logger
if ! dlog_init; then
echo "mkfadumprd: failed to initiate the kdump logger."
exit 1
fi
readonly MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)"
[ -d "$MKFADUMPRD_TMPDIR" ] || perror_exit "mkfadumprd: mktemp -d -t mkfadumprd.XXXXXX failed."
trap '
ret=$?;
[[ -d $MKFADUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKFADUMPRD_TMPDIR";
exit $ret;
' EXIT
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
MKDUMPRD="/sbin/mkdumprd -f"
# Default boot initramfs to be rebuilt
REBUILD_INITRD="$1" && shift
TARGET_INITRD="$1" && shift
FADUMP_INITRD="$MKFADUMPRD_TMPDIR/fadump.img"
### First build an initramfs with dump capture capability
# this file tells the initrd is fadump enabled
touch "$MKFADUMPRD_TMPDIR/fadump.initramfs"
ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER"
if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs; then
perror_exit "mkfadumprd: failed to build image with dump capture support"
fi
### Unpack the initramfs having dump capture capability
mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot"
if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$FADUMP_INITRD" && \
popd > /dev/null); then
derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'"
exit 1
fi
### Pack it into the normal boot initramfs with zz-fadumpinit module
_dracut_isolate_args="--rebuild $REBUILD_INITRD --add zz-fadumpinit \
-i $MKFADUMPRD_TMPDIR/fadumproot /fadumproot \
-i $MKFADUMPRD_TMPDIR/fadumproot/usr/lib/dracut/loaded-kernel-modules.txt
/usr/lib/dracut/fadump-kernel-modules.txt"
if is_squash_available; then
_dracut_isolate_args="$_dracut_isolate_args --add squash"
fi
if ! dracut --force --quiet $_dracut_isolate_args $@ "$TARGET_INITRD"; then
perror_exit "mkfadumprd: failed to setup '$TARGET_INITRD' with dump capture capability"
fi

View File

@ -0,0 +1,88 @@
From 0f632fa180e5a44219ab6bbe0879c3583f8c65cf Mon Sep 17 00:00:00 2001
From: Pingfan Liu <piliu@redhat.com>
Date: Tue, 9 Nov 2021 11:24:22 +0800
Subject: [PATCH] RHEL-only
Cope with RHEL8 kernel
Signed-off-by: Pingfan Liu <piliu@redhat.com>
---
arch/arm64.c | 14 +++++++++++++-
makedumpfile.c | 2 ++
makedumpfile.h | 1 +
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/makedumpfile-1.7.1/arch/arm64.c b/makedumpfile-1.7.1/arch/arm64.c
index 1072178..95beae6 100644
--- a/makedumpfile-1.7.1/arch/arm64.c
+++ b/makedumpfile-1.7.1/arch/arm64.c
@@ -50,6 +50,7 @@ static int va_bits;
static int vabits_actual;
static int flipped_va;
static unsigned long kimage_voffset;
+static int max_user_va_bits;
#define SZ_4K 4096
#define SZ_16K 16384
@@ -108,7 +109,7 @@ typedef unsigned long pgdval_t;
#define PGDIR_SHIFT ARM64_HW_PGTABLE_LEVEL_SHIFT(4 - (pgtable_level))
#define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT)
#define PGDIR_MASK (~(PGDIR_SIZE-1))
-#define PTRS_PER_PGD (1 << ((va_bits) - PGDIR_SHIFT))
+#define PTRS_PER_PGD (1 << ((max_user_va_bits) - PGDIR_SHIFT))
/*
* Section address mask and size definitions.
@@ -449,6 +450,17 @@ get_machdep_info_arm64(void)
ERRMSG("Can't determine platform config values\n");
return FALSE;
}
+ if (NUMBER(MAX_USER_VA_BITS) != NOT_FOUND_NUMBER) {
+ max_user_va_bits = NUMBER(MAX_USER_VA_BITS);
+ DEBUG_MSG("max_user_va_bits : %d (vmcoreinfo)\n",
+ max_user_va_bits);
+ }
+ if (!max_user_va_bits) {
+ max_user_va_bits = va_bits;
+ DEBUG_MSG("max_user_va_bits : %d (default = va_bits)\n",
+ max_user_va_bits);
+ }
+
kimage_voffset = NUMBER(kimage_voffset);
info->section_size_bits = SECTIONS_SIZE_BITS;
diff --git a/makedumpfile-1.7.1/makedumpfile.c b/makedumpfile-1.7.1/makedumpfile.c
index 3ad4443..018ea4c 100644
--- a/makedumpfile-1.7.1/makedumpfile.c
+++ b/makedumpfile-1.7.1/makedumpfile.c
@@ -2417,6 +2417,7 @@ write_vmcoreinfo_data(void)
WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
#ifdef __aarch64__
+ WRITE_NUMBER("MAX_USER_VA_BITS", MAX_USER_VA_BITS);
WRITE_NUMBER("VA_BITS", VA_BITS);
/* WRITE_NUMBER("TCR_EL1_T1SZ", TCR_EL1_T1SZ); should not exists */
WRITE_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET);
@@ -2863,6 +2864,7 @@ read_vmcoreinfo(void)
READ_NUMBER("phys_base", phys_base);
READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
#ifdef __aarch64__
+ READ_NUMBER("MAX_USER_VA_BITS", MAX_USER_VA_BITS);
READ_NUMBER("VA_BITS", VA_BITS);
READ_NUMBER("TCR_EL1_T1SZ", TCR_EL1_T1SZ);
READ_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET);
diff --git a/makedumpfile-1.7.1/makedumpfile.h b/makedumpfile-1.7.1/makedumpfile.h
index e59239d..b6236dd 100644
--- a/makedumpfile-1.7.1/makedumpfile.h
+++ b/makedumpfile-1.7.1/makedumpfile.h
@@ -2064,6 +2064,7 @@ struct number_table {
long phys_base;
long KERNEL_IMAGE_SIZE;
#ifdef __aarch64__
+ long MAX_USER_VA_BITS;
long VA_BITS;
long TCR_EL1_T1SZ;
unsigned long PHYS_OFFSET;
--
2.31.1

View File

@ -1,235 +0,0 @@
From: Bhupesh Sharma <bhsharma@redhat.com>
Date: Wed, 6 Feb 2019 12:31:29 +0530
Subject: [PATCH] makedumpfile/arm64: Add support for ARMv8.2-LVA (52-bit
user-space VA support)
With ARMv8.2-LVA architecture extension availability, arm64 hardware
which supports this extension can support upto 52-bit virtual
addresses. It is specially useful for having a 52-bit user-space virtual
address space while the kernel can still retain 48-bit virtual
addresses.
Since at the moment we enable the support of this extension in the
kernel via a CONFIG flag (CONFIG_ARM64_USER_VA_BITS_52), so there are
no clear mechanisms in user-space to determine this CONFIG
flag value and use it to determine the user-space VA address range
values.
'makedumpfile' can instead use 'MAX_USER_VA_BITS' value to
determine the maximum virtual physical address supported by user-space.
If 'MAX_USER_VA_BITS' value is greater than 'VA_BITS' than we are
running a use-case where user-space is 52-bit and underlying kernel is
still 48-bit. The increased 'PTRS_PER_PGD' value for such cases can then
be calculated as is done by the underlying kernel (see kernel file
'arch/arm64/include/asm/pgtable-hwdef.h' for details):
#define PTRS_PER_PGD (1 << (MAX_USER_VA_BITS - PGDIR_SHIFT))
I have sent a kernel patch upstream to add 'MAX_USER_VA_BITS' to
vmcoreinfo for arm64 (see [0]).
This patch is in accordance with ARMv8 Architecture Reference Manual
version D.a
[0].
http://lists.infradead.org/pipermail/kexec/2019-February/022411.html
Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
---
arch/arm64.c | 109 ++++++++++++++++++++++++++++++++++++++++++---------------
makedumpfile.c | 2 ++
makedumpfile.h | 1 +
3 files changed, 83 insertions(+), 29 deletions(-)
diff --git a/makedumpfile-1.6.7/arch/arm64.c b/makedumpfile-1.6.7/arch/arm64.c
index 0535193..5fcf59d 100644
--- a/makedumpfile-1.6.7/arch/arm64.c
+++ b/makedumpfile-1.6.7/arch/arm64.c
@@ -41,6 +41,7 @@ typedef struct {
static int pgtable_level;
static int va_bits;
+static int max_user_va_bits;
static unsigned long kimage_voffset;
#define SZ_4K (4 * 1024)
@@ -61,7 +62,7 @@ static unsigned long kimage_voffset;
#define PAGE_MASK (~(PAGESIZE() - 1))
#define PGDIR_SHIFT ((PAGESHIFT() - 3) * pgtable_level + 3)
-#define PTRS_PER_PGD (1 << (va_bits - PGDIR_SHIFT))
+#define PTRS_PER_PGD (1 << ((max_user_va_bits) - PGDIR_SHIFT))
#define PUD_SHIFT get_pud_shift_arm64()
#define PUD_SIZE (1UL << PUD_SHIFT)
#define PUD_MASK (~(PUD_SIZE - 1))
@@ -73,6 +74,10 @@ static unsigned long kimage_voffset;
#define PTRS_PER_PMD PTRS_PER_PTE
#define PAGE_PRESENT (1 << 0)
+
+/*
+ * Section address mask and size definitions.
+ */
#define SECTIONS_SIZE_BITS 30
/* Highest possible physical address supported */
#define PHYS_MASK_SHIFT 48
@@ -284,14 +289,83 @@ get_stext_symbol(void)
return(found ? kallsym : FALSE);
}
+static int
+get_va_bits_from_stext_arm64(void)
+{
+ ulong _stext;
+
+ _stext = get_stext_symbol();
+ if (!_stext) {
+ ERRMSG("Can't get the symbol of _stext.\n");
+ return FALSE;
+ }
+
+ /* Derive va_bits as per arch/arm64/Kconfig */
+ if ((_stext & PAGE_OFFSET_36) == PAGE_OFFSET_36) {
+ va_bits = 36;
+ } else if ((_stext & PAGE_OFFSET_39) == PAGE_OFFSET_39) {
+ va_bits = 39;
+ } else if ((_stext & PAGE_OFFSET_42) == PAGE_OFFSET_42) {
+ va_bits = 42;
+ } else if ((_stext & PAGE_OFFSET_47) == PAGE_OFFSET_47) {
+ va_bits = 47;
+ } else if ((_stext & PAGE_OFFSET_48) == PAGE_OFFSET_48) {
+ va_bits = 48;
+ } else {
+ ERRMSG("Cannot find a proper _stext for calculating VA_BITS\n");
+ return FALSE;
+ }
+
+ DEBUG_MSG("va_bits : %d\n", va_bits);
+
+ return TRUE;
+}
+
+static void
+get_page_offset_arm64(void)
+{
+ info->page_offset = (0xffffffffffffffffUL) << (va_bits - 1);
+
+ DEBUG_MSG("page_offset : %lx\n", info->page_offset);
+}
+
int
get_machdep_info_arm64(void)
{
/* Check if va_bits is still not initialized. If still 0, call
* get_versiondep_info() to initialize the same.
*/
+ if (NUMBER(VA_BITS) != NOT_FOUND_NUMBER) {
+ va_bits = NUMBER(VA_BITS);
+ DEBUG_MSG("va_bits : %d (vmcoreinfo)\n",
+ va_bits);
+ }
+
+ /* Check if va_bits is still not initialized. If still 0, call
+ * get_versiondep_info() to initialize the same from _stext
+ * symbol.
+ */
if (!va_bits)
- get_versiondep_info_arm64();
+ if (get_va_bits_from_stext_arm64() == ERROR)
+ return ERROR;
+
+ get_page_offset_arm64();
+
+ if (NUMBER(MAX_USER_VA_BITS) != NOT_FOUND_NUMBER) {
+ max_user_va_bits = NUMBER(MAX_USER_VA_BITS);
+ DEBUG_MSG("max_user_va_bits : %d (vmcoreinfo)\n",
+ max_user_va_bits);
+ }
+
+ /* Check if max_user_va_bits is still not initialized.
+ * If still 0, its not available in vmcoreinfo and its
+ * safe to initialize it with va_bits.
+ */
+ if (!max_user_va_bits) {
+ max_user_va_bits = va_bits;
+ DEBUG_MSG("max_user_va_bits : %d (default = va_bits)\n",
+ max_user_va_bits);
+ }
if (!calculate_plat_config()) {
ERRMSG("Can't determine platform config values\n");
@@ -330,34 +404,11 @@ get_xen_info_arm64(void)
int
get_versiondep_info_arm64(void)
{
- ulong _stext;
-
- _stext = get_stext_symbol();
- if (!_stext) {
- ERRMSG("Can't get the symbol of _stext.\n");
- return FALSE;
- }
-
- /* Derive va_bits as per arch/arm64/Kconfig */
- if ((_stext & PAGE_OFFSET_36) == PAGE_OFFSET_36) {
- va_bits = 36;
- } else if ((_stext & PAGE_OFFSET_39) == PAGE_OFFSET_39) {
- va_bits = 39;
- } else if ((_stext & PAGE_OFFSET_42) == PAGE_OFFSET_42) {
- va_bits = 42;
- } else if ((_stext & PAGE_OFFSET_47) == PAGE_OFFSET_47) {
- va_bits = 47;
- } else if ((_stext & PAGE_OFFSET_48) == PAGE_OFFSET_48) {
- va_bits = 48;
- } else {
- ERRMSG("Cannot find a proper _stext for calculating VA_BITS\n");
- return FALSE;
- }
-
- info->page_offset = (0xffffffffffffffffUL) << (va_bits - 1);
+ if (!va_bits)
+ if (get_va_bits_from_stext_arm64() == ERROR)
+ return ERROR;
- DEBUG_MSG("va_bits : %d\n", va_bits);
- DEBUG_MSG("page_offset : %lx\n", info->page_offset);
+ get_page_offset_arm64();
return TRUE;
}
diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c
index d76a435..c8906b5 100644
--- a/makedumpfile-1.6.7/makedumpfile.c
+++ b/makedumpfile-1.6.7/makedumpfile.c
@@ -2313,6 +2313,7 @@ write_vmcoreinfo_data(void)
WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
#ifdef __aarch64__
+ WRITE_NUMBER("MAX_USER_VA_BITS", MAX_USER_VA_BITS);
WRITE_NUMBER("VA_BITS", VA_BITS);
WRITE_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET);
WRITE_NUMBER_UNSIGNED("kimage_voffset", kimage_voffset);
@@ -2719,6 +2720,7 @@ read_vmcoreinfo(void)
READ_NUMBER("phys_base", phys_base);
READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
#ifdef __aarch64__
+ READ_NUMBER("MAX_USER_VA_BITS", MAX_USER_VA_BITS);
READ_NUMBER("VA_BITS", VA_BITS);
READ_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET);
READ_NUMBER_UNSIGNED("kimage_voffset", kimage_voffset);
diff --git a/makedumpfile-1.6.7/makedumpfile.h b/makedumpfile-1.6.7/makedumpfile.h
index 24b2f69..cccb52a 100644
--- a/makedumpfile-1.6.7/makedumpfile.h
+++ b/makedumpfile-1.6.7/makedumpfile.h
@@ -1937,6 +1937,7 @@ struct number_table {
long phys_base;
long KERNEL_IMAGE_SIZE;
#ifdef __aarch64__
+ long MAX_USER_VA_BITS;
long VA_BITS;
unsigned long PHYS_OFFSET;
unsigned long kimage_voffset;
--
2.7.5

View File

@ -1,6 +1,6 @@
Name: kexec-tools
Version: 2.0.20
Release: 34%{?dist}.1
Version: 2.0.25
Release: 5%{?dist}
License: GPLv2
Group: Applications/System
Summary: The kexec/kdump userspace component
@ -12,8 +12,8 @@ Source3: kdump.sysconfig.x86_64
Source4: kdump.sysconfig.i386
Source5: kdump.sysconfig.ppc64
Source7: mkdumprd
Source8: kdump.conf
Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.7/makedumpfile-1.6.7.tar.gz
Source8: gen-kdump-conf.sh
Source9: https://github.com/makedumpfile/makedumpfile/archive/1.7.1.tar.gz
Source10: kexec-kdump-howto.txt
Source12: mkdumprd.8
Source13: 98-kexec.rules
@ -34,6 +34,11 @@ Source28: supported-kdump-targets.txt
Source29: kdump-udev-throttler
Source30: kdump.sysconfig.aarch64
Source31: fadump-howto.txt
Source32: 60-kdump.install
Source33: kdump-logger.sh
Source34: kdump-migrate-action.sh
Source35: kdump-restart.sh
Source36: mkfadumprd
#######################################
# These are sources for mkdumpramfs
@ -50,15 +55,23 @@ Source107: dracut-kdump-emergency.target
Source108: dracut-early-kdump.sh
Source109: dracut-early-kdump-module-setup.sh
Source200: dracut-fadump-init-fadump.sh
Source201: dracut-fadump-module-setup.sh
%ifarch ppc64 ppc64le
Requires(post): servicelog
Recommends: keyutils
%endif
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
Requires(pre): coreutils sed zlib
Requires: dracut >= 049-24
Requires: dracut >= 049-129
Requires: dracut-network >= 049
Requires: dracut-squash >= 049
Requires: ethtool
BuildRequires: zlib-devel zlib zlib-static elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel
BuildRequires: zlib-devel zlib zlib-static elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel
BuildRequires: pkgconfig intltool gettext
BuildRequires: systemd-units
BuildRequires: automake autoconf libtool
@ -85,6 +98,7 @@ ExcludeArch: i686
#
# Patches 401 through 500 are meant for s390 kexec-tools enablement
#
#
# Patches 501 through 600 are meant for ARM kexec-tools enablement
#
@ -94,26 +108,10 @@ ExcludeArch: i686
#
Patch601: rhelonly-kexec-tools-2.0.16-koji-build-fail-workaround.patch
Patch602: rhelonly-kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch
Patch603: rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch
Patch604: kexec-tools-2.0.20-Cleanup-remove-the-read_elf_kcore.patch
Patch605: kexec-tools-2.0.20-Fix-an-error-definition-about-the-variable-fname.patch
Patch606: kexec-tools-2.0.20-Cleanup-move-it-back-from-util_lib-elf_info.c.patch
Patch607: kexec-tools-2.0.20-Limit-the-size-of-vmcore-dmesg.txt-to-2G.patch
Patch608: kexec-tools-2.0.20-vmcore-dmesg-vmcore-dmesg.c-Fix-shifting-error-repor.patch
Patch609: kexec-tools-2.0.20-kexec-add-variant-helper-functions-for-handling-memo.patch
Patch610: kexec-tools-2.0.20-arm64-kexec-allocate-memory-space-avoiding-reserved-.patch
Patch611: kexec-tools-2.0.20-arm64-kdump-deal-with-a-lot-of-resource-entries-in-p.patch
# Patches 701 onward for makedumpfile
Patch701: kexec-tools-2.0.20-makedumpfile-PATCH-Remove-duplicated-variable-definitions.patch
Patch702: kexec-tools-2.0.20-makedumpfile-PATCH-cope-with-not-present-mem-section.patch
Patch703: kexec-tools-2.0.20-makedumpfile-PATCH-Introduce-check-params-option.patch
Patch704: kexec-tools-2.0.20-makedumpfile-PATCH-Makefile-Fix-build-errors-in-static-build.patch
Patch705: kexec-tools-2.0.20-makedumpfile-PATCH-Align-PMD_SECTION_MASK-with-PHYS_MASK.patch
Patch706: kexec-tools-2.0.20-makedumpfile-PATCH-Fix-cd_header-offset-overflow-with-large-pfn.patch
Patch707: kexec-tools-2.0.20-makedumpfile-PATCH-Avoid-false-positive-failure-in-mem_seciton-va.patch
Patch708: kexec-tools-2.0.20-makedumpfile-PATCH-sadump-kaslr-fix-failure-of-calculating-kaslr.patch
Patch701: rhelonly-kexec-tools-2.0.20-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch
Patch702: kexec-tools-2.0.24-makedumpfile-Avoid_false_positive_mem_section_validation_with_vmlinux.patch
%description
kexec-tools provides /usr/sbin/kexec binary that facilitates a new
@ -131,23 +129,9 @@ tar -z -x -v -f %{SOURCE19}
%patch601 -p1
%patch602 -p1
%patch603 -p1
%patch604 -p1
%patch605 -p1
%patch606 -p1
%patch607 -p1
%patch608 -p1
%patch609 -p1
%patch610 -p1
%patch611 -p1
%patch701 -p1
%patch702 -p1
%patch703 -p1
%patch704 -p1
%patch705 -p1
%patch706 -p1
%patch707 -p1
%patch708 -p1
%ifarch ppc
%define archdef ARCH=ppc
@ -174,11 +158,14 @@ cp %{SOURCE27} .
cp %{SOURCE28} .
cp %{SOURCE31} .
# Generate sysconfig file
%{SOURCE8} %{_target_cpu} > kdump.conf
make
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
make -C eppic/libeppic
make -C makedumpfile-1.6.7 LINKTYPE=dynamic USELZO=on USESNAPPY=on
make -C makedumpfile-1.6.7 LDFLAGS="$LDFLAGS -I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so
make -C makedumpfile-1.7.1 LINKTYPE=dynamic USELZO=on USESNAPPY=on USEZSTD=on
make -C makedumpfile-1.7.1 LDFLAGS="$LDFLAGS -I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so
%endif
%install
@ -197,6 +184,7 @@ mkdir -p $RPM_BUILD_ROOT%{_unitdir}
mkdir -p -m755 $RPM_BUILD_ROOT%{_bindir}
mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir}
mkdir -p -m755 $RPM_BUILD_ROOT%{_prefix}/lib/kdump
mkdir -p -m755 $RPM_BUILD_ROOT%{_sharedstatedir}/kdump
install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl
install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/usr/sbin/kexec
@ -210,12 +198,14 @@ SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu}
install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf
install -m 755 %{SOURCE36} $RPM_BUILD_ROOT/usr/sbin/mkfadumprd
install -m 644 kdump.conf $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf
install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8
install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8
install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8
install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh
install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh
install -m 755 %{SOURCE33} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-logger.sh
%ifnarch s390x ppc64 ppc64le
# For s390x the ELF header is created in the kdump kernel and therefore kexec
# udev rules are not required
@ -223,6 +213,8 @@ install -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules
%endif
%ifarch ppc64 ppc64le
install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules
install -m 755 %{SOURCE34} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-migrate-action.sh
install -m 755 %{SOURCE35} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-restart.sh
%endif
%ifnarch s390x
install -m 755 %{SOURCE29} $RPM_BUILD_ROOT%{_udevrulesdir}/../kdump-udev-throttler
@ -230,19 +222,22 @@ install -m 755 %{SOURCE29} $RPM_BUILD_ROOT%{_udevrulesdir}/../kdump-udev-throttl
install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5
install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service
install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh
install -m 755 -D %{SOURCE32} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-kdump.install
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
install -m 755 makedumpfile-1.6.7/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile
install -m 644 makedumpfile-1.6.7/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz
install -m 644 makedumpfile-1.6.7/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz
install -m 644 makedumpfile-1.6.7/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample
install -m 755 makedumpfile-1.6.7/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so
install -m 755 makedumpfile-1.7.1/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile
install -m 644 makedumpfile-1.7.1/makedumpfile.8 $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8
install -m 644 makedumpfile-1.7.1/makedumpfile.conf.5 $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5
install -m 644 makedumpfile-1.7.1/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample
install -m 755 makedumpfile-1.7.1/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so
mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/
install -m 644 makedumpfile-1.6.7/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/
install -m 644 makedumpfile-1.7.1/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/
%endif
%define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g')
%define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g')
%define remove_dracut_fadump_prefix() %(echo -n %1|sed 's/.*dracut-fadump-//g')
# deal with dracut modules
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase
@ -261,6 +256,13 @@ cp %{SOURCE108} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlyk
cp %{SOURCE109} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
%ifarch ppc64 ppc64le
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit
cp %{SOURCE200} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
cp %{SOURCE201} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
%endif
%define dracutlibdir %{_prefix}/lib/dracut
@ -273,6 +275,13 @@ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{d
%systemd_post kdump.service
touch /etc/kdump.conf
%ifarch ppc64 ppc64le
servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh 2>/dev/null
servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin
%endif
# This portion of the script is temporary. Its only here
# to fix up broken boxes that require special settings
# in /etc/sysconfig/kdump. It will be removed when
@ -300,6 +309,9 @@ fi
%systemd_postun_with_restart kdump.service
%preun
%ifarch ppc64 ppc64le
servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh
%endif
# Package removal, not upgrade
%systemd_preun kdump.service
@ -340,6 +352,7 @@ done
/usr/sbin/kexec
/usr/sbin/makedumpfile
/usr/sbin/mkdumprd
/usr/sbin/mkfadumprd
/usr/sbin/vmcore-dmesg
%{_bindir}/*
%{_datadir}/kdump
@ -358,6 +371,7 @@ done
%dir %{_sysconfdir}/kdump
%dir %{_sysconfdir}/kdump/pre.d
%dir %{_sysconfdir}/kdump/post.d
%dir %{_sharedstatedir}/kdump
%{_mandir}/man8/kdumpctl.8.gz
%{_mandir}/man8/kexec.8.gz
%{_mandir}/man8/makedumpfile.8.gz
@ -366,6 +380,7 @@ done
%{_mandir}/man5/*
%{_unitdir}/kdump.service
%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh
%{_prefix}/lib/kernel/install.d/60-kdump.install
%doc News
%license COPYING
%doc TODO
@ -381,8 +396,249 @@ done
%endif
%changelog
* Wed Oct 28 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-34.1
* Wed Jan 18 2023 Pingfan Liu <piliu@redhat.com> - 2.0.25-5
dracut-module-setup: Fix invalid rd.znet command line entry
dracut-module-setup: Fix persistent nic name on s390
* Mon Jan 9 2023 Pingfan Liu <piliu@redhat.com> - 2.0.25-4
- Don't check fs modified when dump target is lvm2 thinp
- Add dependency of dracut lvmthinpool-monitor module
- lvm.conf should be check modified if lvm2 thinp enabled
- Add lvm2 thin provision dump target checker
- Fix the sync issue for dump_fs
* Fri Dec 2 2022 Pingfan Liu <piliu@redhat.com> - 2.0.25-3
- kdump.conf: use a simple generator script to maintain
- Reduce kdump memory consumption by not letting NetworkManager manage unneeded network interfaces
* Mon Oct 17 2022 Pingfan Liu <piliu@redhat.com> - 2.0.25-2
- mkdumprd: Improve error messages on non-existing NFS target directories
- fadump: avoid non-debug kernel use for fadump case
* Sun Sep 18 2022 Pingfan Liu <piliu@redhat.com> - 2.0.24-7
- kdumpctl: make the kdump.log root-readable-only
* Mon Jul 18 2022 Pingfan Liu <piliu@redhat.com> - 2.0.24-6
- kdump-lib: Add the CoreOS kernel dir to the boot_dirlist
- kdump-lib: attempt to fix BOOT_IMAGE detection
- kdump-lib: change how ostree based systems are detected
- kdump-lib: clear up references to Atomic/CoreOS
* Mon Jul 4 2022 Pingfan Liu <piliu@redhat.com> - 2.0.24-5
- kdump-lib: use non-debug kernels first
* Tue Jun 21 2022 Pingfan Liu <piliu@redhat.com> - 2.0.24-4
- kdump-lib.sh: Check the output of blkid with sed instead of eval
* Fri Jun 10 2022 Pingfan Liu <piliu@redhat.com> - 2.0.24-3
- kdump.sysconfig*: add ignition.firstboot to KDUMP_COMMANDLINE_REMOVE
* Fri May 27 2022 Pingfan Liu <piliu@redhat.com> - 2.0.24-2
- kdumpctl: fix missed dollar sign
* Thu May 5 2022 Pingfan Liu <piliu@redhat.com> - 2.0.24-1
- kdumpctl: sync the $TARGET_INITRD after rebuild
- Avoid false-positive mem_section validation with vmlinux
- Rebase kexec-tools to 2.0.24
- Rebase makedumpfile to 1.7.1
* Fri Apr 15 2022 Pingfan Liu <piliu@redhat.com> - 2.0.20-69
- s390: add support for --reuse-cmdline
- use slurp_proc_file() in get_command_line()
- add slurp_proc_file()
- s390: use KEXEC_ALL_OPTIONS
- s390: add variable command line size
- util_lib/elf_info: harden parsing of printk buffer
- print error when reading with unsupported compression
- use cycle detection when parsing the prink log_buf
- use pointer arithmetics for dump_dmesg
- add generic cycle detection
* Thu Jan 27 2022 Pingfan Liu <piliu@redhat.com> - 2.0.20-68
- Revert "Remove trace_buf_size and trace_event from the kernel bootparameters of the kdump kernel"
* Fri Dec 24 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-67
- Remove trace_buf_size and trace_event from the kernel bootparameters of the kdump kernel
* Fri Dec 10 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-66
- kdump/ppc64: suppress the error message "Could not find a registered notification tool" from servicelog_notify
- Enable zstd compression for makedumpfile in kexec-tools.spec
* Thu Dec 2 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-65
- mkdumprd: drop mountaddr/mountproto nfs mount options
* Fri Nov 26 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-64
- add keytuils as a weak dependency for POWER
* Fri Nov 19 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-63
- Document/kexec-kdump-howto.txt: fix escape
* Wed Nov 17 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-62
- Document/kexec-kdump-howto.txt: improve notes for kdump_pre and kdump_post scripts
* Tue Nov 9 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-61
- rebase makedumpfile to 1.7.0
* Fri Oct 22 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-60
- fadump-init: clean up mount points properly
- fadump: kdumpctl should check the modules used by the fadump initramfs
- fadump: isolate fadump initramfs image within the default one
- mkdumprd: Use xz for squash image compression
* Mon Oct 18 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-59
- makedumpfile: printk: use committed/finalized state values
- makedumpfile: printk: add support for lockless ringbuffer
- kexec-tools: printk: Use %zu to format size_t
- kexec-tools: printk: Use ULL suffix for 64-bit constants
- kexec-tools: printk: add support for lockless ringbuffer
* Sun Oct 17 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-58
- kdumpctl: fix fragile loops over find output
* Fri Aug 27 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-57
- kdumpctl: enable secure boot on ppc64le LPARs
* Fri Aug 6 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-56
- kdumpctl: fix a typo
* Mon Aug 2 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-55
- kdump/ppc64: migration action registration clean up
* Fri Jul 23 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-54
- kdump/ppc64: rebuild initramfs image after migration
- Check the existence of /sys/bus/ccwgroup/devices/*/online beforehand
- kdump.sysconfig.s390: Remove "prot_virt" from kdump kernel cmdline
* Fri Jul 2 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-53
- check for invalid physical address of /proc/kcore when making ELF dumpfile
- check for invalid physical address of /proc/kcore when finding max_paddr
- fix format issue in find_online_znet_device
- check the existence of /sys/bus/ccwgroup/devices before trying to find online network device
- kdump-lib.sh: fix a warning in prepare_kdump_bootinfo()
* Thu Jun 17 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-52
- Write to `/var/lib/kdump` if $KDUMP_BOOTDIR not writable
- Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet
- mkdumprd: display the absolute path of dump location in the check_user_configured_target()
* Wed Jun 2 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-51
- Stop reloading kdump service on CPU hotplug event for FADump
- fadump: improve fadump-howto.txt about remote dump target setup
* Tue May 25 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-50
- rd.route should use the name from kdump_setup_ifname
- get kdump ifname once in kdump_install_netdev
* Tue May 25 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-49
- kdump-lib.sh: fix the case if no enough total RAM for kdump in get_recommend_size()
* Thu May 20 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-48
- kdumpctl: Add kdumpctl estimate
- mkdumprd: make use of the new get_luks_crypt_dev helper
- kdump-lib.sh: introduce a helper to get all crypt dev used by kdump
- kdump-lib.sh: introduce a helper to get underlying crypt device
- RHEL-only: keep total memory size coherent to RHEL-only kernel patch
- Show write byte size in report messages
- Add shorthand --show-stats option to show report stats
- Add --dry-run option to prevent writing the dumpfile
- kdump-lib.sh: introduce functions to return recommened mem size
* Mon May 10 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-47
- Implement IP netmask calculation to replace "ipcalc -m"
- kdumpctl: fix check_config error when kdump.conf is empty
- Fix incorrect vmcore permissions when dumped through ssh
- Fix incorrect permissions on kdump dmesg file
* Mon Jan 25 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-45
- origin/rhel-8.4.0) Revert "Revert "Append both nofail and x-systemd.before to kdump mount target""
- kdump.conf: add ipv6 example for nfs and ssh dump
- fix kdump failure of saving vmcore with the scp + ipv6 method
* Fri Jan 22 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-44
- module-setup.sh: don't polute the namespace unnecessarily
- module-setup.sh: don't source $dracutfunctions
- logger: source the logger file individually
- dracut-module-setup.sh: enable ForwardToConsole=yes in fadump mode
* Fri Jan 15 2021 Pingfan Liu <piliu@redhat.com> - 2.0.20-43
- Always include watchdog-modules
- mkdumprd: Ensure kdumpbase is added
- Move watchdog detect and install code to module-setup.sh
- Add a helper to omit non-mandatory dracut module
- Move some dracut module dependencies checks to module-setup.sh
- Set watchdog's pretimeout to zero in kdump kernel
- kdump-lib.sh: Use a more generic helper to detect omitted dracut module
- Fix the watchdog drivers detection code
- Add a helper for detecting watchdog drivers
- Remove a redundant nfs check
- kdumpctl: split the driver detection from fs dection function
- kdump.service: use ConditionKernelCommandLine=crashkernel
- Revert "Append both nofail and x-systemd.before to kdump mount target"
- Revert "Don's try to restart dracut-initqueue if it's already failed"
- Fix dump_fs mount point detection and fallback mount
- kdump.conf: Update doc about core_collector for ssh target
- Save the final failure information to log file if saving vmcore failed
- Doc: Improve the kdump sysconfig document
- kdumpctl: fix a variable expansion in check_fence_kdump_config()
- Fedora 33 rhpkg build bug
* Tue Dec 22 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-42
- makedumpfile: add support for ARMv8.2 LVA 52 bits
* Fri Dec 18 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-41
- Doc: improve mkdumprd man page
* Tue Dec 15 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-40
- Rework on dracut-module-setup.sh: Use systemctl call to replace ln_r
* Tue Dec 15 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-39
- dracut-module-setup.sh: Use systemctl call to replace ln_r
* Fri Dec 11 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-38
- Don's try to restart dracut-initqueue if it's already failed
- fadump-howto: update about 'nocma' and 'off' options for 'fadump=' parameter
- dracut-module-setup.sh: use auto6 for ipv6
- module-setup.sh: enable vlan on team interface
- Fix rootfs detection in dump_fs
- Remove RHEL-only patch: kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch
- Rebase to makedumpfile-1.6.8 (step1)
* Fri Nov 13 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-37
- Doc: improve the usage documentation of the logger
- Update the kdump sysconfig
- Capitalize the configuration name of log level
- Add the rd.kdumploglvl option to control log level in the second kernel
- Appropriately converts logger numeric level to syslog log level
- Remove unused log levels for kdump logger
- Add sanity checks for the log levels
- Add code comments to help better understanding
- Doc: add a documentation for the usage of logger
- Improve debugging in the kdump kernel
- kdumpctl: add the '-d' option to enable the kexec loading debugging messages
- kdump.sysconfig: add the kdump logger configurations
- enable the logger for kdump
- introduce the kdump logger from the dracut
* Fri Nov 6 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-36
- arm64: Enable 'kexec_file_load' by default
- Fix, Add a kernel install hook to clean up kdump initramfs
* Fri Oct 30 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-35
- module-setup.sh: Instead of drop journalctl log, just don't read kmsg
- s390x: enable the kexec file load by default
- increase makdumpfile default message level to 7
- Rework check_config and warn on any duplicated option
- kdumpctl: Error out if path is set more than once.
- Don't drop journalctl content if failure action is "shell"
- dracut-module-install: Move systemd conf install code to a function
- kdump-lib.sh: Remove is_atomic
- Refactor kernel image and initrd detection code
- early-kdump: Use consistent symbol link for kernel and initramfs
- kdump-lib: strip grub device from kdump_bootdir
- kdumpctl: fix driver change detection on latest Fedora
- Revert "kdump-lib: disable efifb if hyperv_fb is in use"
- kdump-lib.sh: detect secure boot on s390
- Add a kernel install hook to clean up kdump initramfs
* Wed Aug 19 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-34
- kdump-lib: disable efifb if hyperv_fb is in use