Compare commits

...

No commits in common. "imports/c8-beta/kexec-tools-2.0.19-7.el8" and "c8" have entirely different histories.

46 changed files with 4056 additions and 1803 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.19.tar.xz
SOURCES/makedumpfile-1.6.5.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
5d080337da7a1603e542fc3db1f08cf8685eda02 SOURCES/kexec-tools-2.0.19.tar.xz
700f2ff13f75d97a0df2303ff9f580cdddadf7b0 SOURCES/makedumpfile-1.6.5.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

@ -21,7 +21,6 @@ Environment=DRACUT_SYSTEMD=1
Environment=NEWROOT=/sysroot
WorkingDirectory=/
ExecStart=/bin/kdump-error-handler.sh
ExecStopPost=-/usr/bin/systemctl --fail --no-block default
Type=oneshot
StandardInput=tty-force
StandardOutput=inherit

View File

@ -1,11 +1,10 @@
#!/bin/sh
# continue here only if we have to save dump.
if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ]; then
exit 0
if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
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
@ -30,15 +29,50 @@ do_dump()
do_kdump_pre()
{
local _ret
if [ -n "$KDUMP_PRE" ]; then
"$KDUMP_PRE"
_ret=$?
if [ $_ret -ne 0 ]; then
derror "$KDUMP_PRE exited with $_ret status"
return $_ret
fi
fi
# if any script fails, it just raises warning and continues
if [ -d /etc/kdump/pre.d ]; then
for file in /etc/kdump/pre.d/*; do
"$file"
_ret=$?
if [ $_ret -ne 0 ]; then
derror "$file exited with $_ret status"
fi
done
fi
return 0
}
do_kdump_post()
{
local _ret
if [ -d /etc/kdump/post.d ]; then
for file in /etc/kdump/post.d/*; do
"$file" "$1"
_ret=$?
if [ $_ret -ne 0 ]; then
derror "$file exited with $_ret status"
fi
done
fi
if [ -n "$KDUMP_POST" ]; then
"$KDUMP_POST" "$1"
_ret=$?
if [ $_ret -ne 0 ]; then
derror "$KDUMP_POST exited with $_ret status"
fi
fi
}
@ -53,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`
@ -61,38 +95,119 @@ 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
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
echo "kdump: saving vmcore complete"
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
return 0
}
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
if [ -f /sys/firmware/opal/core ]; then
OPALCORE="/sys/firmware/opal/core"
else
return 0
fi
fi
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
derror "saving opalcore failed"
return 1
fi
ssh $_opts $_location mv $_path/opalcore-incomplete $_path/opalcore
dinfo "saving opalcore complete"
return 0
}
@ -102,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
}
@ -120,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
@ -134,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
@ -147,9 +262,13 @@ read_kdump_conf()
case "$config_opt" in
dracut_args)
config_val=$(get_dracut_args_target "$config_val")
[ -n "$config_val" ] && add_dump_code "dump_fs $config_val"
if [ -n "$config_val" ]; then
config_val=$(get_mntpoint_from_target "$config_val")
add_dump_code "dump_fs $config_val"
fi
;;
ext[234]|xfs|btrfs|minix|nfs)
config_val=$(get_mntpoint_from_target "$config_val")
add_dump_code "dump_fs $config_val"
;;
raw)
@ -174,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
@ -184,8 +303,10 @@ 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
fi
make_trace_mem "kdump saving vmcore" '1:shortmem' '2+:mem' '3+:slab'
do_dump
@ -193,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,46 +36,48 @@ 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; then
_dep="$_dep squash"
add_opt_module squash
else
dwarning "Required modules to build a squashed kdump image is missing!"
fi
if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then
_dep="$_dep drm"
add_opt_module watchdog-modules
if is_wdt_active; then
add_opt_module watchdog
fi
if is_generic_fence_kdump -o is_pcs_fence_kdump; then
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
add_opt_module drm
fi
if is_generic_fence_kdump || is_pcs_fence_kdump; then
_dep="$_dep network"
fi
echo $_dep
return 0
}
kdump_get_persistent_dev() {
local dev="${1//\"/}"
case "$dev" in
UUID=*)
dev=`blkid -U "${dev#UUID=}"`
;;
LABEL=*)
dev=`blkid -L "${dev#LABEL=}"`
;;
esac
echo $(get_persistent_dev "$dev")
}
kdump_is_bridge() {
@ -114,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}")
@ -137,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
@ -150,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
}
@ -190,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
@ -206,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
@ -217,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
@ -225,7 +385,7 @@ kdump_setup_bond() {
source_ifcfg_file $_netdev
bondoptions="$(echo :$BONDING_OPTS | sed 's/\s\+/,/')"
bondoptions=":$(echo $BONDING_OPTS | xargs echo | tr " " ",")"
echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf
}
@ -235,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
@ -258,57 +419,97 @@ 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=$_netdev:$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf
echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf
else
_kdumpdev="$(kdump_setup_ifname $_phydev)"
echo " vlan=$_netdev:$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf
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
# $1: netdev name
kdump_setup_znet() {
local _options=""
local _netdev=$1
source_ifcfg_file $1
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} > ${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
@ -328,11 +529,17 @@ 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"
if [ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]; then
# network-manager module needs this parameter
echo "rd.neednet" >> ${initdir}/etc/cmdline.d/50neednet.conf
fi
}
get_ip_route_field()
@ -382,6 +589,29 @@ kdump_install_net() {
fi
}
# install etc/kdump/pre.d and /etc/kdump/post.d
kdump_install_pre_post_conf() {
if [ -d /etc/kdump/pre.d ]; then
for file in /etc/kdump/pre.d/*; do
if [ -x "$file" ]; then
dracut_install $file
elif [ $file != "/etc/kdump/pre.d/*" ]; then
echo "$file is not executable"
fi
done
fi
if [ -d /etc/kdump/post.d ]; then
for file in /etc/kdump/post.d/*; do
if [ -x "$file" ]; then
dracut_install $file
elif [ $file != "/etc/kdump/post.d/*" ]; then
echo "$file is not executable"
fi
done
fi
}
default_dump_target_install_conf()
{
local _target _fstype
@ -389,24 +619,9 @@ default_dump_target_install_conf()
is_user_configured_dump_target && return
_save_path=$(get_option_value "path")
[ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
# strip the duplicated "/"
_save_path=$(echo $_save_path | tr -s /)
_mntpoint=$(get_mntpoint_from_path $_save_path)
_save_path=$(get_bind_mount_source $(get_save_path))
_target=$(get_target_from_path $_save_path)
if is_atomic && is_bind_mount $_mntpoint; then
_save_path=${_save_path##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
_save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path
_mntpoint=$(get_mntpoint_from_target $_target)
# the absolute path in the 1st kernel
_save_path=$_mntpoint/$_save_path
fi
_mntpoint=$(get_mntpoint_from_target $_target)
_fstype=$(get_fs_type_from_target $_target)
if is_fs_type_nfs $_fstype; then
@ -418,8 +633,6 @@ default_dump_target_install_conf()
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
# strip the duplicated "/"
_save_path=$(echo $_save_path | tr -s /)
# don't touch the path under root mount
if [ "$_mntpoint" != "/" ]; then
_save_path=${_save_path##"$_mntpoint"}
@ -430,30 +643,6 @@ default_dump_target_install_conf()
echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf
}
adjust_bind_mount_path()
{
local _target=$1
local _save_path=$(get_option_value "path")
[ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
# strip the duplicated "/"
_save_path=$(echo $_save_path | tr -s /)
local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path
_absolute_save_path=$(echo "$_absolute_save_path" | tr -s /)
local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
if is_bind_mount $_mntpoint; then
_save_path=${_absolute_save_path##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
_save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path
#erase the old path line, then insert the parsed path
sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf
echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf
fi
}
#install kdump.conf and what user specifies in kdump.conf
kdump_install_conf() {
local _opt _val _pdev
@ -470,9 +659,6 @@ kdump_install_conf() {
ext[234]|xfs|btrfs|minix)
_pdev=$(kdump_get_persistent_dev $_val)
sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf
if is_atomic; then
adjust_bind_mount_path "$_val"
fi
;;
ssh|nfs)
kdump_install_net "$_val"
@ -491,6 +677,8 @@ kdump_install_conf() {
esac
done <<< "$(read_strip_comments /etc/kdump.conf)"
kdump_install_pre_post_conf
default_dump_target_install_conf
kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf"
@ -633,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
@ -643,13 +831,48 @@ 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
}
}
# hostname -a is deprecated, do it by ourself
get_alias() {
local ips
local entries
local alias_set
ips=$(hostname -I)
for ip in $ips
do
# in /etc/hosts, alias can come at the 2nd column
entries=$(grep $ip /etc/hosts | awk '{ $1=""; print $0 }')
if [ $? -eq 0 ]; then
alias_set="$alias_set $entries"
fi
done
echo $alias_set
}
is_localhost() {
local hostnames=$(hostname -A)
local shortnames=$(hostname -A -s)
local aliasname=$(get_alias)
local nodename=$1
hostnames="$hostnames $shortnames $aliasname"
for name in ${hostnames}; do
if [ "$name" == "$nodename" ]; then
return 0
fi
done
return 1
}
# retrieves fence_kdump nodes from Pacemaker cluster configuration
get_pcs_fence_kdump_nodes() {
local nodes
@ -681,6 +904,21 @@ get_pcs_fence_kdump_args() {
fi
}
get_generic_fence_kdump_nodes() {
local filtered
local nodes
nodes=$(get_option_value "fence_kdump_nodes")
for node in ${nodes}; do
# Skip its own node name
if is_localhost $node; then
continue
fi
filtered="$filtered $node"
done
echo $filtered
}
# setup fence_kdump in cluster
# setup proper network and install needed files
kdump_configure_fence_kdump () {
@ -689,7 +927,7 @@ kdump_configure_fence_kdump () {
local args
if is_generic_fence_kdump; then
nodes=$(get_option_value "fence_kdump_nodes")
nodes=$(get_generic_fence_kdump_nodes)
elif is_pcs_fence_kdump; then
nodes=$(get_pcs_fence_kdump_nodes)
@ -736,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
@ -766,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
@ -784,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
@ -793,12 +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
# Save more memory by dropping switch root capability
dracut_no_switch_root
}

View File

@ -3,12 +3,17 @@ Early Kdump HOWTO
Introduction
------------
Kdump service starts too late, so early crashes will have no chance to get
kdump kernel booting, this will cause crash information to be lost. It is
necessary to add a dracut module in order to load crash kernel and initramfs
as early as possible. You can provide "rd.earlykdump" in grub commandline
to enable, then the early kdump will load those files like the normal kdump,
which is disabled by default.
Early kdump is a mechanism to make kdump operational earlier than normal kdump
service. The kdump service starts early enough for general crash cases, but
there are some cases where it has no chance to make kdump operational in boot
sequence, such as detecting devices and starting early services. If you hit
such a case, early kdump may allow you to get more information of it.
Early kdump is implemented as a dracut module. It adds a kernel (vmlinuz) and
initramfs for kdump to your system's initramfs in order to load them as early
as possible. After that, if you provide "rd.earlykdump" in kernel command line,
then in the initramfs, early kdump will load those files like the normal kdump
service. This is disabled by default.
For the normal kdump service, it can check whether the early kdump has loaded
the crash kernel and initramfs. It has no conflict with the early kdump.
@ -20,7 +25,9 @@ We assume if you're reading this document, you should already have kexec-tools
installed.
You can rebuild the initramfs with earlykdump support with below steps:
1. start kdump service to make sure kdump initramfs is created.
# systemctl start kdump
NOTE: If a crash occurs during boot process, early kdump captures a vmcore
@ -34,21 +41,14 @@ You can rebuild the initramfs with earlykdump support with below steps:
For the failure_action, you can choose anything other than "reboot".
2. rebuild system initramfs with earlykdump support.
# dracut --add earlykdump
# dracut --force --add earlykdump
NOTE: Recommend to backup the original system initramfs before performing
this step to put it back if something happens during boot-up.
3. add rd.earlykdump in grub kernel command line.
Note:
[1]. Early kdump initramfs size will be large because it includes vmlinuz and
kdump initramfs. And for step 2 if you are sure to overwrite system initramfs
you can backup the original initramfs and use "--force" option.
[2]. Early kdump inherits the settings of normal kdump, so any changes that
caused normal kdump rebuilding also require rebuilding the system initramfs
to make sure that the changes take effect for early kdump. Therefore, after
the rebuilding of kdump initramfs is completed, provide a prompt message to
tell the fact.
After making said changes, reboot your system to take effect. Of course, if you
want to disable early kdump, you can simply remove "rd.earlykdump" from kernel
boot parameters in grub, and reboot system like above.
@ -56,19 +56,40 @@ boot parameters in grub, and reboot system like above.
Once the boot is completed, you can check the status of the early kdump support
on the command prompt:
# journalctl -x|grep early-kdump
# journalctl -b | grep early-kdump
Then, you will see some useful logs, for exapmle:
Then, you will see some useful logs, for example:
1. if early kdump is successful.
Mar 09 09:57:56 localhost.localdomain dracut-cmdline[190]: early-kdump is enabled.
Mar 09 09:57:56 localhost.localdomain dracut-cmdline[190]: kexec: loaded early-
kdump kernel
- if early kdump is successful.
2. if early kdump is disabled.
Mar 09 10:02:47 localhost.localdomain dracut-cmdline[189]: early-kdump is disabled.
Mar 09 09:57:56 localhost dracut-cmdline[190]: early-kdump is enabled.
Mar 09 09:57:56 localhost dracut-cmdline[190]: kexec: loaded early-kdump kernel
- if early kdump is disabled.
Mar 09 10:02:47 localhost dracut-cmdline[189]: early-kdump is disabled.
Notes
-----
- The size of early kdump initramfs will be large because it includes vmlinuz
and kdump initramfs.
- Early kdump inherits the settings of normal kdump, so any changes that
caused normal kdump rebuilding also require rebuilding the system initramfs
to make sure that the changes take effect for early kdump. Therefore, after
the rebuilding of kdump initramfs is completed, provide a prompt message to
tell the fact.
- If you install an updated kernel and reboot the system with it, the early
kdump will be disabled by default. To enable it with the new kernel, you
need to take the above steps again.
Limitation
----------
At present, early kdump doesn't support fadump.
- At present, early kdump doesn't support fadump.
- Early kdump loads a crash kernel and initramfs at the beginning of the
process in system's initramfs, so a crash at earlier than that (e.g. in
kernel initialization) cannot be captured even with the early kdump.

352
SOURCES/fadump-howto.txt Normal file
View File

@ -0,0 +1,352 @@
Firmware assisted dump (fadump) HOWTO
Introduction
Firmware assisted dump is a new feature in the 3.4 mainline kernel supported
only on powerpc architecture. The goal of firmware-assisted dump is to enable
the dump of a crashed system, and to do so from a fully-reset system, and to
minimize the total elapsed time until the system is back in production use. A
complete documentation on implementation can be found at
Documentation/powerpc/firmware-assisted-dump.txt in upstream linux kernel tree
from 3.4 version and above.
Please note that the firmware-assisted dump feature is only available on Power6
and above systems with recent firmware versions.
Overview
Fadump
Fadump is a robust kernel crash dumping mechanism to get reliable kernel crash
dump with assistance from firmware. This approach does not use kexec, instead
firmware assists in booting the kdump kernel while preserving memory contents.
Unlike kdump, the system is fully reset, and loaded with a fresh copy of the
kernel. In particular, PCI and I/O devices are reinitialized and are in a
clean, consistent state. This second kernel, often called a capture kernel,
boots with very little memory and captures the dump image.
The first kernel registers the sections of memory with the Power firmware for
dump preservation during OS initialization. These registered sections of memory
are reserved by the first kernel during early boot. When a system crashes, the
Power firmware fully resets the system, preserves all the system memory
contents, save the low memory (boot memory of size larger of 5% of system
RAM or 256MB) of RAM to the previous registered region. It will also save
system registers, and hardware PTE's.
Fadump is supported only on ppc64 platform. The standard kernel and capture
kernel are one and the same on ppc64.
If you're reading this document, you should already have kexec-tools
installed. If not, you install it via the following command:
# yum install kexec-tools
Fadump Operational Flow:
Like kdump, fadump also exports the ELF formatted kernel crash dump through
/proc/vmcore. Hence existing kdump infrastructure can be used to capture fadump
vmcore. The idea is to keep the functionality transparent to end user. From
user perspective there is no change in the way kdump init script works.
However, unlike kdump, fadump does not pre-load kdump kernel and initrd into
reserved memory, instead it always uses default OS initrd during second boot
after crash. Hence, for fadump, we rebuild the new kdump initrd and replace it
with default initrd. Before replacing existing default initrd we take a backup
of original default initrd for user's reference. The dracut package has been
enhanced to rebuild the default initrd with vmcore capture steps. The initrd
image is rebuilt as per the configuration in /etc/kdump.conf file.
The control flow of fadump works as follows:
01. System panics.
02. At the crash, kernel informs power firmware that kernel has crashed.
03. Firmware takes the control and reboots the entire system preserving
only the memory (resets all other devices).
04. The reboot follows the normal booting process (non-kexec).
05. The boot loader loads the default kernel and initrd from /boot
06. The default initrd loads and runs /init
07. dracut-kdump.sh script present in fadump aware default initrd checks if
'/proc/device-tree/rtas/ibm,kernel-dump' file exists before executing
steps to capture vmcore.
(This check will help to bypass the vmcore capture steps during normal boot
process.)
09. Captures dump according to /etc/kdump.conf
10. Is dump capture successful (yes goto 12, no goto 11)
11. Perform the failure action specified in /etc/kdump.conf
(The default failure action is reboot, if unspecified)
12. Perform the final action specified in /etc/kdump.conf
(The default final action is reboot, if unspecified)
How to configure fadump:
Again, we assume if you're reading this document, you should already have
kexec-tools installed. If not, you install it via the following command:
# yum install kexec-tools
Make the kernel to be configured with FADump as the default boot entry, if
it isn't already:
# grubby --set-default=/boot/vmlinuz-<kver>
Boot into the kernel to be configured for FADump. To be able to do much of
anything interesting in the way of debug analysis, you'll also need to install
the kernel-debuginfo package, of the same arch as your running kernel, and the
crash utility:
# yum --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash
Next up, we need to modify some boot parameters to enable firmware assisted
dump. With the help of grubby, it's very easy to append "fadump=on" to the end
of your kernel boot parameters. To reserve the appropriate amount of memory
for boot memory preservation, pass 'crashkernel=X' kernel cmdline parameter.
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.
Alternatively, user can also specify boot memory size through boot parameter
'fadump_reserve_mem=' which will override the default calculated size. Use this
option if default boot memory size is not sufficient for second kernel to boot
successfully.
After making said changes, reboot your system, so that the specified memory is
reserved and left untouched by the normal system. Take note that the output of
'free -m' will show X MB less memory than without this parameter, which is
expected. If you see OOM (Out Of Memory) error messages while loading capture
kernel, then you should bump up the memory reservation size.
Now that you've got that reserved memory region set up, you want to turn on
the kdump init script:
# systemctl enable kdump.service
Then, start up kdump as well:
# systemctl start kdump.service
This should turn on the firmware assisted functionality in kernel by
echo'ing 1 to /sys/kernel/fadump_registered, leaving the system ready
to capture a vmcore upon crashing. For journaling filesystems like XFS an
additional step is required to ensure bootloader does not pick the
older initrd (without vmcore capture scripts):
* If /boot is a separate partition, run the below commands as the root user,
or as a user with CAP_SYS_ADMIN rights:
# fsfreeze -f
# fsfreeze -u
* If /boot is not a separate partition, reboot the system.
After reboot check if the kdump service is up and running with:
# systemctl status kdump.service
To test out whether FADump is configured properly, you can force-crash your
system by echo'ing a 'c' into /proc/sysrq-trigger:
# echo c > /proc/sysrq-trigger
You should see some panic output, followed by the system reset and booting into
fresh copy of kernel. When default initrd loads and runs /init, vmcore should
be copied out to disk (by default, in /var/crash/<YYYY.MM.DD-HH:MM:SS>/vmcore),
then the system rebooted back into your normal kernel.
Once back to your normal kernel, you can use the previously installed crash
kernel in conjunction with the previously installed kernel-debuginfo to
perform postmortem analysis:
# crash /usr/lib/debug/lib/modules/2.6.17-1.2621.el5/vmlinux
/var/crash/2006-08-23-15:34/vmcore
crash> bt
and so on...
Saving vmcore-dmesg.txt
-----------------------
Kernel log bufferes are one of the most important information available
in vmcore. Now before saving vmcore, kernel log bufferes are extracted
from /proc/vmcore and saved into a file vmcore-dmesg.txt. After
vmcore-dmesg.txt, vmcore is saved. Destination disk and directory for
vmcore-dmesg.txt is same as vmcore. Note that kernel log buffers will
not be available if dump target is raw device.
FADump Memory Requirements:
System Memory Recommended memory
--------------------- ----------------------
4 GB - 16 GB : 768 MB
16 GB - 64 GB : 1024 MB
64 GB - 128 GB : 2 GB
128 GB - 1 TB : 4 GB
1 TB - 2 TB : 6 GB
2 TB - 4 TB : 12 GB
4 TB - 8 TB : 20 GB
8 TB - 16 TB : 36 GB
16 TB - 32 TB : 64 GB
32 TB - 64 TB : 128 GB
64 TB & above : 180 GB
Things to remember:
1) The memory required to boot capture Kernel is a moving target that depends
on many factors like hardware attached to the system, kernel and modules in
use, packages installed and services enabled, there is no one-size-fits-all.
But the above recommendations are based on system memory. So, the above
recommendations for FADump come with a few assumptions, based on available
system memory, about the resources the system could have. So, please take
the recommendations with a pinch of salt and remember to try capturing dump
a few times to confirm that the system is configured successfully with dump
capturing support.
2) Though the memory requirements for FADump seem high, this memory is not
completely set aside but made available for userspace applications to use,
through the CMA allocator.
3) As the same initrd is used for booting production kernel as well as capture
kernel and with dump being captured in a restricted memory environment, few
optimizations (like not inclding network dracut module, disabling multipath
and such) are applied while building the initrd. In case, the production
environment needs these optimizations to be avoided, dracut_args option in
/etc/kdump.conf file could be leveraged. For example, if a user wishes for
network module to be included in the initrd, adding the below entry in
/etc/kdump.conf file and restarting kdump service would take care of it.
dracut_args --add "network"
4) If FADump is configured to capture vmcore to a remote dump target using SSH
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:
This section talks about the various ways, other than a Kernel Panic, in which
fadump can be triggered. The following methods assume that fadump is configured
on your system, with the scripts enabled as described in the section above.
1) AltSysRq C
FAdump can be triggered with the combination of the 'Alt','SysRq' and 'C'
keyboard keys. Please refer to the following link for more details:
https://fedoraproject.org/wiki/QA/Sysrq
In addition, on PowerPC boxes, fadump can also be triggered via Hardware
Management Console(HMC) using 'Ctrl', 'O' and 'C' keyboard keys.
2) Kernel OOPs
If we want to generate a dump everytime the Kernel OOPses, we can achieve this
by setting the 'Panic On OOPs' option as follows:
# echo 1 > /proc/sys/kernel/panic_on_oops
3) PowerPC specific methods:
On IBM PowerPC machines, issuing a soft reset invokes the XMON debugger(if
XMON is configured). To configure XMON one needs to compile the kernel with
the CONFIG_XMON and CONFIG_XMON_DEFAULT options, or by compiling with
CONFIG_XMON and booting the kernel with xmon=on option.
Following are the ways to remotely issue a soft reset on PowerPC boxes, which
would drop you to XMON. Pressing a 'X' (capital alphabet X) followed by an
'Enter' here will trigger the dump.
3.1) HMC
Hardware Management Console(HMC) available on Power4 and Power5 machines allow
partitions to be reset remotely. This is specially useful in hang situations
where the system is not accepting any keyboard inputs.
Once you have HMC configured, the following steps will enable you to trigger
fadump via a soft reset:
On Power4
Using GUI
* In the right pane, right click on the partition you wish to dump.
* Select "Operating System->Reset".
* Select "Soft Reset".
* Select "Yes".
Using HMC Commandline
# reset_partition -m <machine> -p <partition> -t soft
On Power5
Using GUI
* In the right pane, right click on the partition you wish to dump.
* Select "Restart Partition".
* Select "Dump".
* Select "OK".
Using HMC Commandline
# chsysstate -m <managed system name> -n <lpar name> -o dumprestart -r lpar
3.2) Blade Management Console for Blade Center
To initiate a dump operation, go to Power/Restart option under "Blade Tasks" in
the Blade Management Console. Select the corresponding blade for which you want
to initate the dump and then click "Restart blade with NMI". This issues a
system reset and invokes xmon debugger.
Advanced Setups & Failure action:
Kdump and fadump exhibit similar behavior in terms of setup & failure action.
For fadump advanced setup related information see section "Advanced Setups" in
"kexec-kdump-howto.txt" document. Refer to "Failure action" section in "kexec-
kdump-howto.txt" document for fadump failure action related information.
Compression and filtering
Refer "Compression and filtering" section in "kexec-kdump-howto.txt" document.
Compression and filtering are same for kdump & fadump.
Notes on rootfs mount:
Dracut is designed to mount rootfs by default. If rootfs mounting fails it
will refuse to go on. So fadump leaves rootfs mounting to dracut currently.
We make the assumtion that proper root= cmdline is being passed to dracut
initramfs for the time being. If you need modify "KDUMP_COMMANDLINE=" in
/etc/sysconfig/kdump, you will need to make sure that appropriate root=
options are copied from /proc/cmdline. In general it is best to append
command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing
the original command line completely.
How to disable FADump:
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):
# grubby --update-kernel=/boot/vmlinuz-$kver --args="crashkernl=auto"
Reboot the system for the settings to take effect.

60
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
@ -79,13 +88,21 @@
# or script after the vmcore dump process terminates.
# The exit status of the current dump process is fed to
# the executable binary or script as its first argument.
# 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.
#
# kdump_pre <binary | script>
# - Works like the "kdump_post" directive, but instead of running
# after the dump process, runs immediately before it.
# Exit status of this binary is interpreted as follows:
# 0 - continue with dump process as usual
# non 0 - reboot the system
# 0 - continue with dump process as usual
# non 0 - run the final action (reboot/poweroff/halt)
# All files under /etc/kdump/pre.d are collectively sorted and
# executed in lexical order, after binary or script specified
# 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.
#
# extra_bins <binaries | shell scripts>
# - This directive allows you to specify additional binaries or
@ -158,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
@ -173,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`
@ -18,6 +20,14 @@ KDUMP_CONF="/etc/kdump.conf"
KDUMP_PRE=""
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()
{
@ -56,13 +66,13 @@ get_kdump_confs()
FAILURE_ACTION="kdump_emergency_shell"
;;
reboot)
FAILURE_ACTION="systemctl reboot -f"
FAILURE_ACTION="systemctl reboot -f && exit"
;;
halt)
FAILURE_ACTION="halt"
FAILURE_ACTION="halt && exit"
;;
poweroff)
FAILURE_ACTION="systemctl poweroff -f"
FAILURE_ACTION="systemctl poweroff -f && exit"
;;
dump_to_rootfs)
FAILURE_ACTION="dump_to_rootfs"
@ -93,36 +103,68 @@ get_kdump_confs()
fi
}
# dump_fs <mount point| device>
# 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
ddebug "dump_fs _mp=$_mp"
local _dev=$(findmnt -k -f -n -r -o SOURCE $1)
local _mp=$(findmnt -k -f -n -r -o TARGET $1)
echo "kdump: dump target is $_dev"
if [ -z "$_mp" ]; then
echo "kdump: error: Dump target $_dev is not mounted."
return 1
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
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
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
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
echo "kdump: saving vmcore complete"
# improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure
return 0
}
@ -131,47 +173,76 @@ 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
}
save_opalcore_fs() {
local _path=$1
if [ ! -f $OPALCORE ]; then
# Check if we are on an old kernel that uses a different path
if [ -f /sys/firmware/opal/core ]; then
OPALCORE="/sys/firmware/opal/core"
else
return 0
fi
fi
dinfo "saving opalcore:$OPALCORE to ${_path}/opalcore"
cp $OPALCORE ${_path}/opalcore
if [ $? -ne 0 ]; then
derror "saving opalcore failed"
return 1
fi
sync
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/'
@ -121,21 +137,16 @@ get_user_configured_dump_disk()
get_root_fs_device()
{
local _target
_target=$(findmnt -k -f -n -o SOURCE /)
[ -n "$_target" ] && echo $_target
return
findmnt -k -f -n -o SOURCE /
}
get_save_path()
{
local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}')
if [ -z "$_save_path" ]; then
_save_path=$DEFAULT_PATH
fi
local _save_path=$(awk '$1 == "path" {print $2}' /etc/kdump.conf)
[ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
echo $_save_path
# strip the duplicated "/"
echo $_save_path | tr -s /
}
get_block_dump_target()
@ -160,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
@ -197,44 +214,39 @@ get_kdump_targets()
echo "$kdump_targets"
}
# Return the bind mount source path, return the path itself if it's not bind mounted
# Eg. if /path/to/src is bind mounted to /mnt/bind, then:
# /mnt/bind -> /path/to/src, /mnt/bind/dump -> /path/to/src/dump
#
# findmnt uses the option "-v, --nofsroot" to exclusive the [/dir]
# in the SOURCE column for bind-mounts, then if $_mntpoint equals to
# $_mntpoint_nofsroot, the mountpoint is not bind mounted directory.
is_bind_mount()
{
local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}')
if [[ $_mntpoint = $_mntpoint_nofsroot ]]; then
return 1
else
return 0
fi
}
#
# Below is just an example for mount info
# /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the
# directory is bind mounted. The former part represents the device path, rest
# part is the bind mounted directory which quotes by bracket "[]".
get_bind_mount_directory()
get_bind_mount_source()
{
local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}')
local _path=$1
# In case it's a sub path in a mount point, get the mount point first
local _mnt_top=$(df $_path | tail -1 | awk '{print $NF}')
local _mntpoint=$(findmnt $_mnt_top | tail -n 1 | awk '{print $2}')
local _mntpoint_nofsroot=$(findmnt -v $_mnt_top | tail -n 1 | awk '{print $2}')
if [[ "$_mntpoint" = $_mntpoint_nofsroot ]]; then
echo $_path && return
fi
_mntpoint=${_mntpoint#*$_mntpoint_nofsroot}
_mntpoint=${_mntpoint#[}
_mntpoint=${_mntpoint%]}
_path=${_path#$_mnt_top}
echo $_mntpoint
}
get_mntpoint_from_path()
{
echo $(df $1 | tail -1 | awk '{print $NF}')
echo $_mntpoint$_path
}
# Return the current underlaying device of a path, ignore bind mounts
get_target_from_path()
{
local _target
@ -244,78 +256,84 @@ get_target_from_path()
echo $_target
}
get_fs_type_from_target()
is_mounted()
{
echo $(findmnt -k -f -n -r -o FSTYPE $1)
findmnt -k -n $1 &>/dev/null
}
# input: device path
# output: the general mount point
# find the general mount point, not the bind mounted point in atomic
# As general system, Use the previous code
#
# ERROR and EXIT:
# the device can be umounted the general mount point, if one of the mount point is bind mounted
# For example:
# mount /dev/sda /mnt/
# mount -o bind /mnt/var /var
# umount /mnt
get_mount_info()
{
local _info_type=$1 _src_type=$2 _src=$3; shift 3
local _info=$(findmnt -k -n -r -o $_info_type --$_src_type $_src $@)
[ -z "$_info" ] && [ -e "/etc/fstab" ] && _info=$(findmnt -s -n -r -o $_info_type --$_src_type $_src $@)
echo $_info
}
get_fs_type_from_target()
{
get_mount_info FSTYPE source $1 -f
}
get_mntopt_from_target()
{
get_mount_info OPTIONS source $1 -f
}
# Find the general mount point of a dump target, not the bind mount point
get_mntpoint_from_target()
{
if is_atomic; then
for _mnt in $(findmnt -k -n -r -o TARGET $1)
do
if ! is_bind_mount $_mnt; then
echo $_mnt
return
fi
done
# Expcilitly specify --source to findmnt could ensure non-bind mount is returned
get_mount_info TARGET source $1 -f
}
echo "Mount $1 firstly, without the bind mode" >&2
exit 1
# Get the path where the target will be mounted in kdump kernel
# $1: kdump target device
get_kdump_mntpoint_from_target()
{
local _mntpoint=$(get_mntpoint_from_target $1)
# mount under /sysroot if dump to root disk or mount under
# mount under /kdumproot if dump target is not mounted in first kernel
# mount under /kdumproot/$_mntpoint in other cases in 2nd kernel.
# systemd will be in charge to umount it.
if [ -z "$_mntpoint" ];then
_mntpoint="/kdumproot"
else
echo $(findmnt -k -f -n -r -o TARGET $1)
if [ "$_mntpoint" = "/" ];then
_mntpoint="/sysroot"
else
_mntpoint="/kdumproot/$_mntpoint"
fi
fi
# strip duplicated "/"
echo $_mntpoint | tr -s "/"
}
# get_option_value <option_name>
# retrieves value of option defined in kdump.conf
get_option_value() {
echo $(strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-`)
strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-`
}
#This function compose a absolute path with the mount
#point and the relative $SAVE_PATH.
#target is passed in as argument, could be UUID, LABEL,
#block device or even nfs server export of the form of
#"my.server.com:/tmp/export"?
#And possibly this could be used for both default case
#as well as when dump taret is specified. When dump
#target is not specified, then $target would be null.
make_absolute_save_path()
{
local _target=$1
local _mnt
kdump_get_persistent_dev() {
local dev="${1//\"/}"
[ -n $_target ] && _mnt=$(get_mntpoint_from_target $1)
_mnt="${_mnt}/$SAVE_PATH"
# strip the duplicated "/"
echo "$_mnt" | tr -s /
case "$dev" in
UUID=*)
dev=`blkid -U "${dev#UUID=}"`
;;
LABEL=*)
dev=`blkid -L "${dev#LABEL=}"`
;;
esac
echo $(get_persistent_dev "$dev")
}
check_save_path_fs()
is_ostree()
{
local _path=$1
if [ ! -d $_path ]; then
perror_exit "Dump path $_path does not exist."
fi
}
is_atomic()
{
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
@ -462,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
@ -512,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
@ -522,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
@ -532,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
@ -615,6 +638,18 @@ is_secure_boot_enforced()
local secure_boot_file setup_mode_file
local secure_boot_byte setup_mode_byte
# 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)
setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null)
@ -627,6 +662,11 @@ is_secure_boot_enforced()
fi
fi
# Detect secure boot on s390x
if [[ -e "/sys/firmware/ipl/secure" && "$(cat /sys/firmware/ipl/secure)" == "1" ]]; then
return 0
fi
return 1
}
@ -648,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
@ -664,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
}
#
@ -725,5 +879,213 @@ prepare_cmdline()
if [ ! -z ${id} ] ; then
cmdline=$(append_cmdline "${cmdline}" disable_cpu_apicid ${id})
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
@ -109,8 +114,15 @@ status of the current dump process is fed to the kdump_post
executable as its first argument($1). Executable can modify
it to indicate the new exit status of succeeding dump process,
.PP
Note that scripts written for use with this directive must use
the /bin/bash interpreter.
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. 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>
@ -122,10 +134,19 @@ as follows:
.PP
0 - continue with dump process as usual
.PP
non 0 - reboot the system
non 0 - run the final action (reboot/poweroff/halt)
.PP
Note that scripts written for this directive must use
the /bin/bash interpreter.
All files under /etc/kdump/pre.d are collectively sorted and
executed in lexical order, after binary or script specified
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 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>
@ -275,7 +296,7 @@ retaining blacklist option creates more confusing behavior. It has been
deprecated.
.PP
Instead, use rd.driver.blacklist option on second kernel to blacklist
a certain module. One can edit /etc/sysconfig/kdump.conf and edit
a certain module. One can edit /etc/sysconfig/kdump and edit
KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer
to dracut.cmdline man page for more details on module blacklist option.
.RE
@ -297,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
@ -318,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
@ -334,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"
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"
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"
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"
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"
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"
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,18 +17,18 @@ 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"
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
KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never nokaslr novmcoredd"
KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never nokaslr novmcoredd hest_disable"
# Any additional kexec arguments required. In most situations, this should
# be left empty
#
# Example:
# KEXEC_ARGS="--elf32-core-headers"
KEXEC_ARGS=""
KEXEC_ARGS="-s"
#Where to find the boot image
#KDUMP_BOOTDIR="/boot"
@ -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

@ -1,15 +1,22 @@
=================
Kexec/Kdump HOWTO
=================
Introduction
============
Kexec and kdump are new features in the 2.6 mainstream kernel. These features
are included in Red Hat Enterprise Linux 5. The purpose of these features
is to ensure faster boot up and creation of reliable kernel vmcores for
diagnostic purposes.
Overview
========
Kexec
-----
Kexec is a fastboot mechanism which allows booting a Linux kernel from the
context of already running kernel without going through BIOS. BIOS can be very
@ -17,6 +24,7 @@ time consuming especially on the big servers with lots of peripherals. This can
save a lot of time for developers who end up booting a machine numerous times.
Kdump
-----
Kdump is a new kernel crash dumping mechanism and is very reliable because
the crash dump is captured from the context of a freshly booted kernel and
@ -52,7 +60,8 @@ Now reboot your system, taking note that it should bypass the BIOS:
# reboot
How to configure kdump:
How to configure kdump
======================
Again, we assume if you're reading this document, you should already have
kexec-tools installed. If not, you install it via the following command:
@ -136,7 +145,9 @@ perform postmortem analysis:
and so on...
Notes:
Notes on kdump
==============
When kdump starts, the kdump kernel is loaded together with the kdump
initramfs. To save memory usage and disk space, the kdump initramfs is
@ -152,8 +163,10 @@ recommended to rebuild the initramfs manually with following command:
# kdumpctl rebuild
Saving vmcore-dmesg.txt
----------------------
=======================
Kernel log bufferes are one of the most important information available
in vmcore. Now before saving vmcore, kernel log bufferes are extracted
from /proc/vmcore and saved into a file vmcore-dmesg.txt. After
@ -161,7 +174,9 @@ vmcore-dmesg.txt, vmcore is saved. Destination disk and directory for
vmcore-dmesg.txt is same as vmcore. Note that kernel log buffers will
not be available if dump target is raw device.
Dump Triggering methods:
Dump Triggering methods
=======================
This section talks about the various ways, other than a Kernel Panic, in which
Kdump can be triggered. The following methods assume that Kdump is configured
@ -268,7 +283,8 @@ to initate the dump and then click "Restart blade with NMI". This issues a
system reset and invokes xmon debugger.
Advanced Setups:
Dump targets
============
In addition to being able to capture a vmcore to your system's local file
system, kdump can be configured to capture a vmcore to a number of other
@ -276,7 +292,8 @@ locations, including a raw disk partition, a dedicated file system, an NFS
mounted file system, or a remote system via ssh/scp. Additional options
exist for specifying the relative path under which the dump is captured,
what to do if the capture fails, and for compressing and filtering the dump
(so as to produce smaller, more manageable, vmcore files).
(so as to produce smaller, more manageable, vmcore files, see "Advanced Setups"
for more detail on these options).
In theory, dumping to a location other than the local file system should be
safer than kdump's default setup, as its possible the default setup will try
@ -289,32 +306,133 @@ as allowing for the centralization of vmcore files, should you have several
systems from which you'd like to obtain vmcore files. Of course, note that
these configurations could present problems if your network is unreliable.
Advanced setups are configured via modifications to /etc/kdump.conf,
which out of the box, is fairly well documented itself. Any alterations to
/etc/kdump.conf should be followed by a restart of the kdump service, so
the changes can be incorporated in the kdump initrd. Restarting the kdump
service is as simple as '/sbin/systemctl restart kdump.service'.
Kdump target and advanced setups are configured via modifications to
/etc/kdump.conf, which out of the box, is fairly well documented itself.
Any alterations to /etc/kdump.conf should be followed by a restart of the
kdump service, so the changes can be incorporated in the kdump initrd.
Restarting the kdump service is as simple as '/sbin/systemctl restart kdump.service'.
There are two ways to config the dump target, config dump target only
using "path", and config dump target explicitly. Interpretation of "path"
also differs in two config styles.
Note that kdump.conf is used as a configuration mechanism for capturing dump
files from the initramfs (in the interests of safety), the root file system is
mounted, and the init process is started, only as a last resort if the
initramfs fails to capture the vmcore. As such, configuration made in
/etc/kdump.conf is only applicable to capture recorded in the initramfs. If
for any reason the init process is started on the root file system, only a
simple copying of the vmcore from /proc/vmcore to /var/crash/$DATE/vmcore will
be preformed.
Config dump target only using "path"
------------------------------------
You can change the dump target by setting "path" to a mount point where
dump target is mounted. When there is no explicitly configured dump target,
"path" in kdump.conf represents the current file system path in which vmcore
will be saved. Kdump will automatically detect the underlying device of
"path" and use that as the dump target.
In fact, upon dump, kdump creates a directory $hostip-$date with-in "path"
and saves vmcore there. So practically dump is saved in $path/$hostip-$date/.
Kdump will only check current mount status for mount entry corresponding to
"path". So please ensure the dump target is mounted on "path" before kdump
service starts.
NOTES:
- It's strongly recommanded to put an mount entry for "path" in /etc/fstab
and have it auto mounted on boot. This make sure the dump target is
reachable from the machine and kdump's configuration is stable.
EXAMPLES:
- path /var/crash/
This is the default configuration. Assuming there is no disk mounted
on /var/ or on /var/crash, dump will be saved on disk backing rootfs
in directory /var/crash.
- path /var/crash/ (A separate disk mounted on /var/crash)
Say a disk /dev/sdb is mounted on /var. In this case dump target will
become /dev/sdb and path will become "/" and dump will be saved
on "sdb:/var/crash/" directory.
- path /var/crash/ (NFS mounted on /var)
Say foo.com:/export/tmp is mounted on /var. In this case dump target is
nfs server and path will be adjusted to "/crash" and dump will be saved to
foo.com:/export/tmp/crash/ directory.
Config dump target explicitely
------------------------------
You can set the dump target explicitly in kdump.conf, and "path" will be
the relative path in the specified dump target. For example, if dump
target is "ext4 /dev/sda", then dump will be saved in "path" directory
on /dev/sda.
Same is the case for nfs dump. If user specified "nfs foo.com:/export/tmp/"
as dump target, then dump will effectively be saved in
"foo.com:/export/tmp/var/crash/" directory.
If the dump target is "raw", then "path" is ignored.
If it's a filesystem target, kdump will need to know the right mount option.
Kdump will check current mount status, and then /etc/fstab for mount options
corresponding to the specified dump target and use it. If there are
special mount option required for the dump target, it could be set by put
an entry in fstab.
If there are no related mount entry, mount option is set to "defaults".
NOTES:
- It's recommended to put an entry for the dump target in /etc/fstab
and have it auto mounted on boot. This make sure the dump target is
reachable from the machine and kdump won't fail.
- Kdump ignores some mount options, including "noauto", "ro". This
make it possible to keep the dump target unmounted or read-only
when not used.
EXAMPLES:
- ext4 /dev/sda (mounted)
path /var/crash/
In this case dump target is set to /dev/sdb, path is the absolute path
"/var/crash" in /dev/sda, vmcore path will saved on
"sda:/var/crash" directory.
- nfs foo.com:/export/tmp (mounted)
path /var/crash/
In this case dump target is nfs server, path is the absolute path
"/var/crash", vmcore path will saved on "foo.com:/export/tmp/crash/" directory.
- nfs foo.com:/export/tmp (not mounted)
path /var/crash/
Same with above case, kdump will use "defaults" as the mount option
for the dump target.
- nfs foo.com:/export/tmp (not mounted, entry with option "noauto,nolock" exists in /etc/fstab)
path /var/crash/
In this case dump target is nfs server, vmcore path will saved on
"foo.com:/export/tmp/crash/" directory, and kdump will inherit "nolock" option.
Dump target and mkdumprd
------------------------
MKdumprd is the tool used to create kdump initramfs, and it may change
the mount status of the dump target in some condition.
For both local filesystem and nfs dump the dump target must be mounted before
building kdump initramfs. That means one needs to put an entry for the dump
file system in /etc/fstab so that after reboot when kdump service starts,
it can find the dump target and build initramfs instead of failing.
Usually the dump target should be used only for kdump. If you worry about
someone uses the filesystem for something else other than dumping vmcore
you can mount it as read-only. Mkdumprd will still remount it as read-write
for creating dump directory and will move it back to read-only afterwards.
you can mount it as read-only or make it a noauto mount. Mkdumprd will
mount/remount it as read-write for creating dump directory and will
move it back to it's original state afterwards.
Raw partition
Supported dump target types and requirements
--------------------------------------------
1) Raw partition
Raw partition dumping requires that a disk partition in the system, at least
as large as the amount of memory in the system, be left unformatted. Assuming
@ -325,7 +443,7 @@ onto partition /dev/vg/lv_kdump. Restart the kdump service via
initrd. Dump target should be persistent device name, such as lvm or device
mapper canonical name.
Dedicated file system
2) Dedicated file system
Similar to raw partition dumping, you can format a partition with the file
system of your choice, Again, it should be at least as large as the amount
@ -349,7 +467,7 @@ Be careful of your filesystem selection when using this target.
It is recommended to use persistent device names or UUID/LABEL for file system
dumps. One example of persistent device is /dev/vg/<devname>.
NFS mount
3) NFS mount
Dumping over NFS requires an NFS server configured to export a file system
with full read/write access for the root user. All operations done within
@ -367,7 +485,7 @@ mount the NFS mount and copy out the vmcore to your NFS server. Restart the
kdump service via '/sbin/systemctl restart kdump.service' to commit this change
to your kdump initrd.
Special mount via "dracut_args"
4) Special mount via "dracut_args"
You can utilize "dracut_args" to pass "--mount" to kdump, see dracut manpage
about the format of "--mount" for details. If there is any "--mount" specified
@ -385,7 +503,7 @@ dracut_args --mount "192.168.1.1:/share /mnt/test nfs4 defaults"
NOTE:
- <mountpoint> must be specified as an absolute path.
Remote system via ssh/scp
5) Remote system via ssh/scp
Dumping over ssh/scp requires setting up passwordless ssh keys for every
machine you wish to have dump via this method. First up, configure kdump.conf
@ -403,73 +521,127 @@ you've connected to it, and then input the target system user's password
to send over the necessary ssh key file. Restart the kdump service via
'/sbin/systemctl restart kdump.service' to commit this change to your kdump initrd.
Path
====
"path" represents the file system path in which vmcore will be saved. In
fact kdump creates a directory $hostip-$date with-in "path" and saves
vmcore there. So practically dump is saved in $path/$hostip-$date/. To
simplify discussion further, if we say dump will be saved in $path, it
is implied that kdump will create another directory inside path and
save vmcore there.
Advanced Setups
===============
If a dump target is specified in kdump.conf, then "path" is relative to the
specified dump target. For example, if dump target is "ext4 /dev/sda", then
dump will be saved in "$path" directory on /dev/sda.
About /etc/sysconfig/kdump
------------------------------
Same is the case for nfs dump. If user specified "nfs foo.com:/export/tmp/"
as dump target, then dump will effectively be saved in
"foo.com:/export/tmp/var/crash/" directory.
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.
Interpretation of path changes a bit if user has not specified a dump
target explicitly in kdump.conf. In this case, "path" represents the
absolute path from root. And dump target and adjusted path are arrived
at automatically depending on what's mounted in the current system.
-KDUMP_BOOTDIR
Following are few examples.
path /var/crash/
----------------
Assuming there is no disk mounted on /var/ or on /var/crash, dump will
be saved on disk backing rootfs in directory /var/crash.
path /var/crash/ (A separate disk mounted on /var)
--------------------------------------------------
Say a disk /dev/sdb is mouted on /var. In this case dump target will
become /dev/sdb and path will become "/crash" and dump will be saved
on "sdb:/crash/" directory.
path /var/crash/ (NFS mounted on /var)
-------------------------------------
Say foo.com:/export/tmp is mounted on /var. In this case dump target is
nfs server and path will be adjusted to "/crash" and dump will be saved to
foo.com:/export/tmp/crash/ directory.
Kdump boot directory
====================
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
-----------------------------
It is possible to specify a custom script or binary you wish to run following
an attempt to capture a vmcore. The executable is passed an exit code from
the capture process, which can be used to trigger different actions from
within your post-capture executable.
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
----------------------------
It is possible to specify a custom script or binary you wish to run before
capturing a vmcore. Exit status of this binary is interpreted:
0 - continue with dump process as usual
non 0 - reboot the system
non 0 - run the final action (reboot/poweroff/halt)
If /etc/kdump/pre.d directory exists, all files in the directory are collectively
sorted and executed in lexical order, after binary or script specified
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
--------------
If you have specific binaries or scripts you want to have made available
within your kdump initrd, you can specify them by their full path, and they
@ -478,6 +650,7 @@ This may be particularly useful for those running post-capture scripts that
rely on other binaries.
Extra Modules
-------------
By default, only the bare minimum of kernel modules will be included in your
kdump initrd. Should you wish to capture your vmcore files to a non-boot-path
@ -486,7 +659,8 @@ need to manually specify additional kernel modules to load into your kdump
initrd.
Failure action
==============
--------------
Failure action specifies what to do when dump to configured dump target
fails. By default, failure action is "reboot" and that is system reboots
if attempt to save dump to dump target fails.
@ -494,21 +668,24 @@ if attempt to save dump to dump target fails.
There are other failure actions available though.
- dump_to_rootfs
This option tries to mount root and save dump on root filesystem
in a path specified by "path". This option will generally make
sense when dump target is not root filesystem. For example, if
dump is being saved over network using "ssh" then one can specify
failure action to "dump_to_rootfs" to try saving dump to root
filesystem if dump over network fails.
This option tries to mount root and save dump on root filesystem
in a path specified by "path". This option will generally make
sense when dump target is not root filesystem. For example, if
dump is being saved over network using "ssh" then one can specify
failure action to "dump_to_rootfs" to try saving dump to root
filesystem if dump over network fails.
- shell
Drop into a shell session inside initramfs.
Drop into a shell session inside initramfs.
- halt
Halt system after failure
Halt system after failure
- poweroff
Poweroff system after failure.
Poweroff system after failure.
Compression and filtering
-------------------------
The 'core_collector' parameter in kdump.conf allows you to specify a custom
dump capture method. The most common alternate method is makedumpfile, which
@ -516,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
@ -526,22 +703,21 @@ Core collector command format depends on dump target type. Typically for
filesystem (local/remote), core_collector should accept two arguments.
First one is source file and second one is target file. For ex.
ex1.
---
core_collector "cp --sparse=always"
- ex1.
Above will effectively be translated to:
core_collector "cp --sparse=always"
cp --sparse=always /proc/vmcore <dest-path>/vmcore
Above will effectively be translated to:
ex2.
---
core_collector "makedumpfile -l --message-level 1 -d 31"
cp --sparse=always /proc/vmcore <dest-path>/vmcore
Above will effectively be translated to:
- ex2.
makedumpfile -l --message-level 1 -d 31 /proc/vmcore <dest-path>/vmcore
core_collector "makedumpfile -l --message-level 7 -d 31"
Above will effectively be translated to:
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
@ -549,59 +725,60 @@ output (There is one exception of "scp", discussed later). This standard
output will be saved to destination using appropriate commands.
raw dumps core_collector examples:
---------
ex3.
---
core_collector "cat"
Above will effectively be translated to.
- ex3.
cat /proc/vmcore | dd of=<target-device>
core_collector "cat"
ex4.
---
core_collector "makedumpfile -F -l --message-level 1 -d 31"
Above will effectively be translated to.
Above will effectively be translated to.
cat /proc/vmcore | dd of=<target-device>
makedumpfile -F -l --message-level 1 -d 31 | dd of=<target-device>
- ex4.
core_collector "makedumpfile -F -l --message-level 7 -d 31"
Above will effectively be translated to.
makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device>
ssh dumps core_collector examples:
---------
ex5.
---
core_collector "cat"
Above will effectively be translated to.
- ex5.
cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore"
core_collector "cat"
ex6.
---
core_collector "makedumpfile -F -l --message-level 1 -d 31"
Above will effectively be translated to.
Above will effectively be translated to.
cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore"
makedumpfile -F -l --message-level 1 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
- ex6.
core_collector "makedumpfile -F -l --message-level 7 -d 31"
Above will effectively be translated to.
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
specify "scp" as core collector for ssh targets (no output on stdout).
ex7.
----
core_collector "scp"
- ex7.
Above will effectively be translated to.
core_collector "scp"
scp /proc/vmcore <user@host>:path/vmcore
Above will effectively be translated to.
scp /proc/vmcore <user@host>:path/vmcore
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.
@ -615,7 +792,9 @@ dump data from stdard input to a normal dumpfile (readable with analysis
tools).
For example: "makedumpfile -R vmcore < vmcore.flat"
Caveats:
Caveats
=======
Console frame-buffers and X are not properly supported. If you typically run
with something along the lines of "vga=791" in your kernel config line or
@ -624,7 +803,11 @@ kexec. Note that the kdump kernel should still be able to create a dump,
and when the system reboots, video should be restored to normal.
Notes
=====
Notes on resetting video:
-------------------------
Video is a notoriously difficult issue with kexec. Video cards contain ROM code
that controls their initial configuration and setup. This code is nominally
@ -646,7 +829,9 @@ Secondly, it may be worth trying to add vga15fb.ko to the extra_modules list in
/etc/kdump.conf. This will attempt to use the video card in framebuffer mode,
which can blank the screen prior to the start of a dump capture.
Notes on rootfs mount:
Notes on rootfs mount
---------------------
Dracut is designed to mount rootfs by default. If rootfs mounting fails it
will refuse to go on. So kdump leaves rootfs mounting to dracut currently.
We make the assumtion that proper root= cmdline is being passed to dracut
@ -656,7 +841,8 @@ options are copied from /proc/cmdline. In general it is best to append
command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing
the original command line completely.
Notes on watchdog module handling:
Notes on watchdog module handling
---------------------------------
If a watchdog is active in first kernel then, we must have it's module
loaded in crash kernel, so that either watchdog is deactivated or started
@ -670,7 +856,8 @@ not been written in watchdog-core framework then this option will not have
any effect and module will not be added. Please note that only systemd
watchdog daemon is supported as watchdog kick application.
Notes for disk images:
Notes for disk images
---------------------
Kdump initramfs is a critical component for capturing the crash dump.
But it's strictly generated for the machine it will run on, and have
@ -684,7 +871,8 @@ a machine with a disk image which have kdump initramfs embedded, you
should rebuild the initramfs using "kdumpctl rebuild" command manually,
or else kdump may not work as expeceted.
Notes on encrypted dump target:
Notes on encrypted dump target
------------------------------
Currently, kdump is not working well with encrypted dump target.
First, user have to give the password manually in capture kernel,
@ -698,7 +886,8 @@ crash kernel according, or update your encryption setup.
It's recommanded to use a non-encrypted target (eg. remote target)
instead.
Notes on device dump:
Notes on device dump
--------------------
Device dump allows drivers to append dump data to vmcore, so you can
collect driver specified debug info. The drivers could append the
@ -715,8 +904,10 @@ the dump target setup will be included. To ensure the device dump data
will be included in the vmcore, you need to force include related
device drivers by using "extra_modules" option in /etc/kdump.conf
Parallel Dumping Operation
==========================
Kexec allows kdump using multiple cpus. So parallel feature can accelerate
dumping substantially, especially in executing compression and filter.
For example:
@ -746,8 +937,10 @@ may lead to panic due to Out Of Memory.
hang, system reset or power-off at boot, depending on your system and runtime
situation at the time of crash.
Debugging Tips
--------------
==============
- One can drop into a shell before/after saving vmcore with the help of
using kdump_pre/kdump_post hooks. Use following in one of the pre/post
scripts to drop into a shell.
@ -773,4 +966,82 @@ Debugging Tips
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,149 +0,0 @@
From 0f9ee000904ffd1e171ba1f000a83e5ce3717e45 Mon Sep 17 00:00:00 2001
From: David Hildenbrand <david@redhat.com>
Date: Thu, 22 Nov 2018 11:09:38 +0100
Subject: [PATCH] [PATCH] exclude pages that are logically offline
Linux marks pages that are logically offline via a page flag (map count).
Such pages e.g. include pages infated as part of a balloon driver or
pages that were not actually onlined when onlining the whole section.
While the hypervisor usually allows to read such inflated memory, we
basically read and dump data that is completely irrelevant. Also, this
might result in quite some overhead in the hypervisor. In addition,
we saw some problems under Hyper-V, whereby we can crash the kernel by
dumping, when reading memory of a partially onlined memory segment
(for memory added by the Hyper-V balloon driver).
Therefore, don't read and dump pages that are marked as being logically
offline.
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Pingfan Liu <piliu@redhat.com>
---
makedumpfile.c | 34 ++++++++++++++++++++++++++++++----
makedumpfile.h | 1 +
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index 8923538..a5f2ea9 100644
--- a/makedumpfile-1.6.5/makedumpfile.c
+++ b/makedumpfile-1.6.5/makedumpfile.c
@@ -88,6 +88,7 @@ mdf_pfn_t pfn_cache_private;
mdf_pfn_t pfn_user;
mdf_pfn_t pfn_free;
mdf_pfn_t pfn_hwpoison;
+mdf_pfn_t pfn_offline;
mdf_pfn_t num_dumped;
@@ -250,6 +251,21 @@ isHugetlb(unsigned long dtor)
}
static int
+isOffline(unsigned long flags, unsigned int _mapcount)
+{
+ if (NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE) == NOT_FOUND_NUMBER)
+ return FALSE;
+
+ if (flags & (1UL << NUMBER(PG_slab)))
+ return FALSE;
+
+ if (_mapcount == (int)NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE))
+ return TRUE;
+
+ return FALSE;
+}
+
+static int
is_cache_page(unsigned long flags)
{
if (isLRU(flags))
@@ -2287,6 +2303,8 @@ write_vmcoreinfo_data(void)
WRITE_NUMBER("PG_hwpoison", PG_hwpoison);
WRITE_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
+ WRITE_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE",
+ PAGE_OFFLINE_MAPCOUNT_VALUE);
WRITE_NUMBER("phys_base", phys_base);
WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
@@ -2687,6 +2705,7 @@ read_vmcoreinfo(void)
READ_SRCFILE("pud_t", pud_t);
READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
+ READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE);
READ_NUMBER("phys_base", phys_base);
#ifdef __aarch64__
READ_NUMBER("VA_BITS", VA_BITS);
@@ -6042,6 +6061,12 @@ __exclude_unnecessary_pages(unsigned long mem_map,
pfn_counter = &pfn_hwpoison;
}
/*
+ * Exclude pages that are logically offline.
+ */
+ else if (isOffline(flags, _mapcount)) {
+ pfn_counter = &pfn_offline;
+ }
+ /*
* Unexcludable page
*/
else
@@ -7522,7 +7547,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page)
*/
if (info->flag_cyclic) {
pfn_zero = pfn_cache = pfn_cache_private = 0;
- pfn_user = pfn_free = pfn_hwpoison = 0;
+ pfn_user = pfn_free = pfn_hwpoison = pfn_offline = 0;
pfn_memhole = info->max_mapnr;
}
@@ -8804,7 +8829,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d
* Reset counter for debug message.
*/
pfn_zero = pfn_cache = pfn_cache_private = 0;
- pfn_user = pfn_free = pfn_hwpoison = 0;
+ pfn_user = pfn_free = pfn_hwpoison = pfn_offline = 0;
pfn_memhole = info->max_mapnr;
/*
@@ -9749,7 +9774,7 @@ print_report(void)
pfn_original = info->max_mapnr - pfn_memhole;
pfn_excluded = pfn_zero + pfn_cache + pfn_cache_private
- + pfn_user + pfn_free + pfn_hwpoison;
+ + pfn_user + pfn_free + pfn_hwpoison + pfn_offline;
shrinking = (pfn_original - pfn_excluded) * 100;
shrinking = shrinking / pfn_original;
@@ -9763,6 +9788,7 @@ print_report(void)
REPORT_MSG(" User process data pages : 0x%016llx\n", pfn_user);
REPORT_MSG(" Free pages : 0x%016llx\n", pfn_free);
REPORT_MSG(" Hwpoison pages : 0x%016llx\n", pfn_hwpoison);
+ REPORT_MSG(" Offline pages : 0x%016llx\n", pfn_offline);
REPORT_MSG(" Remaining pages : 0x%016llx\n",
pfn_original - pfn_excluded);
REPORT_MSG(" (The number of pages is reduced to %lld%%.)\n",
@@ -9790,7 +9816,7 @@ print_mem_usage(void)
pfn_original = info->max_mapnr - pfn_memhole;
pfn_excluded = pfn_zero + pfn_cache + pfn_cache_private
- + pfn_user + pfn_free + pfn_hwpoison;
+ + pfn_user + pfn_free + pfn_hwpoison + pfn_offline;
shrinking = (pfn_original - pfn_excluded) * 100;
shrinking = shrinking / pfn_original;
total_size = info->page_size * pfn_original;
diff --git a/makedumpfile.h b/makedumpfile.h
index 73813ed..04c903f 100644
--- a/makedumpfile-1.6.5/makedumpfile.h
+++ b/makedumpfile-1.6.5/makedumpfile.h
@@ -1927,6 +1927,7 @@ struct number_table {
long PG_hwpoison;
long PAGE_BUDDY_MAPCOUNT_VALUE;
+ long PAGE_OFFLINE_MAPCOUNT_VALUE;
long SECTION_SIZE_BITS;
long MAX_PHYSMEM_BITS;
long HUGETLB_PAGE_DTOR;
--
2.7.4

View File

@ -1,41 +0,0 @@
From 2f007b48c581a81d7e95678b6bcb77cfbe177135 Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Tue, 29 Jan 2019 11:14:15 +0800
Subject: [PATCH] [PATCH v2] honor the CFLAGS from environment variables
This makes it possible to pass in extra cflags, for example, hardening
flags could be passed in with environment variable when building a
hardened package.
Also introduce a CFLAGS_BASE to hold common CFLAGS, which simplify the
CFLAGS definition.
Suggested-by: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Signed-off-by: Kairui Song <kasong@redhat.com>
---
Makefile | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index ea3c47d..bd681d2 100644
--- a/makedumpfile-1.6.5/Makefile
+++ b/makedumpfile-1.6.5/Makefile
@@ -8,11 +8,10 @@ ifeq ($(strip $CC),)
CC = gcc
endif
-CFLAGS = -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \
- -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \
- -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"'
-CFLAGS_ARCH = -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \
- -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
+CFLAGS_BASE := $(CFLAGS) -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \
+ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
+CFLAGS := $(CFLAGS_BASE) -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"'
+CFLAGS_ARCH := $(CFLAGS_BASE)
# LDFLAGS = -L/usr/local/lib -I/usr/local/include
HOST_ARCH := $(shell uname -m)
--
2.20.1

View File

@ -1,198 +0,0 @@
From d222b01e516bba73ef9fefee4146734a5f260fa1 Mon Sep 17 00:00:00 2001
From: Lianbo Jiang <lijiang@redhat.com>
Date: Wed, 30 Jan 2019 10:48:53 +0800
Subject: [PATCH] [PATCH] x86_64: Add support for AMD Secure Memory Encryption
On AMD machine with Secure Memory Encryption (SME) feature, if SME is
enabled, page tables contain a specific attribute bit (C-bit) in their
entries to indicate whether a page is encrypted or unencrypted.
So get NUMBER(sme_mask) from vmcoreinfo, which stores the value of
the C-bit position, and drop it to obtain the true physical address.
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
---
arch/x86_64.c | 30 +++++++++++++++++++-----------
makedumpfile.c | 4 ++++
makedumpfile.h | 1 +
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/arch/x86_64.c b/arch/x86_64.c
index 9db1f8139f28..46e93366f0be 100644
--- a/makedumpfile-1.6.5/arch/x86_64.c
+++ b/makedumpfile-1.6.5/arch/x86_64.c
@@ -297,6 +297,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
unsigned long page_dir, pgd, pud_paddr, pud_pte, pmd_paddr, pmd_pte;
unsigned long pte_paddr, pte;
unsigned long p4d_paddr, p4d_pte;
+ unsigned long entry_mask = ENTRY_MASK;
/*
* Get PGD.
@@ -308,6 +309,9 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
return NOT_PADDR;
}
+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER)
+ entry_mask &= ~(NUMBER(sme_mask));
+
if (check_5level_paging()) {
page_dir += pgd5_index(vaddr) * sizeof(unsigned long);
if (!readmem(PADDR, page_dir, &pgd, sizeof pgd)) {
@@ -324,7 +328,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
/*
* Get P4D.
*/
- p4d_paddr = pgd & ENTRY_MASK;
+ p4d_paddr = pgd & entry_mask;
p4d_paddr += p4d_index(vaddr) * sizeof(unsigned long);
if (!readmem(PADDR, p4d_paddr, &p4d_pte, sizeof p4d_pte)) {
ERRMSG("Can't get p4d_pte (p4d_paddr:%lx).\n", p4d_paddr);
@@ -337,7 +341,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
ERRMSG("Can't get a valid p4d_pte.\n");
return NOT_PADDR;
}
- pud_paddr = p4d_pte & ENTRY_MASK;
+ pud_paddr = p4d_pte & entry_mask;
}else {
page_dir += pgd_index(vaddr) * sizeof(unsigned long);
if (!readmem(PADDR, page_dir, &pgd, sizeof pgd)) {
@@ -351,7 +355,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
ERRMSG("Can't get a valid pgd.\n");
return NOT_PADDR;
}
- pud_paddr = pgd & ENTRY_MASK;
+ pud_paddr = pgd & entry_mask;
}
/*
@@ -370,13 +374,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
return NOT_PADDR;
}
if (pud_pte & _PAGE_PSE) /* 1GB pages */
- return (pud_pte & ENTRY_MASK & PUD_MASK) +
+ return (pud_pte & entry_mask & PUD_MASK) +
(vaddr & ~PUD_MASK);
/*
* Get PMD.
*/
- pmd_paddr = pud_pte & ENTRY_MASK;
+ pmd_paddr = pud_pte & entry_mask;
pmd_paddr += pmd_index(vaddr) * sizeof(unsigned long);
if (!readmem(PADDR, pmd_paddr, &pmd_pte, sizeof pmd_pte)) {
ERRMSG("Can't get pmd_pte (pmd_paddr:%lx).\n", pmd_paddr);
@@ -390,13 +394,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
return NOT_PADDR;
}
if (pmd_pte & _PAGE_PSE) /* 2MB pages */
- return (pmd_pte & ENTRY_MASK & PMD_MASK) +
+ return (pmd_pte & entry_mask & PMD_MASK) +
(vaddr & ~PMD_MASK);
/*
* Get PTE.
*/
- pte_paddr = pmd_pte & ENTRY_MASK;
+ pte_paddr = pmd_pte & entry_mask;
pte_paddr += pte_index(vaddr) * sizeof(unsigned long);
if (!readmem(PADDR, pte_paddr, &pte, sizeof pte)) {
ERRMSG("Can't get pte (pte_paddr:%lx).\n", pte_paddr);
@@ -409,7 +413,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
ERRMSG("Can't get a valid pte.\n");
return NOT_PADDR;
}
- return (pte & ENTRY_MASK) + PAGEOFFSET(vaddr);
+ return (pte & entry_mask) + PAGEOFFSET(vaddr);
}
unsigned long long
@@ -642,6 +646,7 @@ find_vmemmap_x86_64()
unsigned long pmd, tpfn;
unsigned long pvaddr = 0;
unsigned long data_addr = 0, last_data_addr = 0, start_data_addr = 0;
+ unsigned long pmask = PMASK;
/*
* data_addr is the paddr of the page holding the page structs.
* We keep lists of contiguous pages and the pfn's that their
@@ -662,6 +667,9 @@ find_vmemmap_x86_64()
return FAILED;
}
+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER)
+ pmask &= ~(NUMBER(sme_mask));
+
pagestructsize = size_table.page;
hugepagesize = PTRS_PER_PMD * info->page_size;
vaddr_base = info->vmemmap_start;
@@ -692,7 +700,7 @@ find_vmemmap_x86_64()
}
/* mask the pgd entry for the address of the pud page */
- pud_addr &= PMASK;
+ pud_addr &= pmask;
if (pud_addr == 0)
continue;
/* read the entire pud page */
@@ -705,7 +713,7 @@ find_vmemmap_x86_64()
/* pudp points to an entry in the pud page */
for (pudp = (unsigned long *)pud_page, pudindex = 0;
pudindex < PTRS_PER_PUD; pudindex++, pudp++) {
- pmd_addr = *pudp & PMASK;
+ pmd_addr = *pudp & pmask;
/* read the entire pmd page */
if (pmd_addr == 0)
continue;
@@ -747,7 +755,7 @@ find_vmemmap_x86_64()
* - we discontiguous page is a string of valids
*/
if (pmd) {
- data_addr = (pmd & PMASK);
+ data_addr = (pmd & pmask);
if (start_range) {
/* first-time kludge */
start_data_addr = data_addr;
diff --git a/makedumpfile.c b/makedumpfile.c
index 7dfe70fb8792..590f759c84f1 100644
--- a/makedumpfile-1.6.5/makedumpfile.c
+++ b/makedumpfile-1.6.5/makedumpfile.c
@@ -993,6 +993,8 @@ next_page:
read_size = MIN(info->page_size - PAGEOFFSET(paddr), size);
pgaddr = PAGEBASE(paddr);
+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER)
+ pgaddr = pgaddr & ~(NUMBER(sme_mask));
pgbuf = cache_search(pgaddr, read_size);
if (!pgbuf) {
++cache_miss;
@@ -2292,6 +2294,7 @@ write_vmcoreinfo_data(void)
WRITE_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES);
WRITE_NUMBER("N_ONLINE", N_ONLINE);
WRITE_NUMBER("pgtable_l5_enabled", pgtable_l5_enabled);
+ WRITE_NUMBER("sme_mask", sme_mask);
WRITE_NUMBER("PG_lru", PG_lru);
WRITE_NUMBER("PG_private", PG_private);
@@ -2695,6 +2698,7 @@ read_vmcoreinfo(void)
READ_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES);
READ_NUMBER("N_ONLINE", N_ONLINE);
READ_NUMBER("pgtable_l5_enabled", pgtable_l5_enabled);
+ READ_NUMBER("sme_mask", sme_mask);
READ_NUMBER("PG_lru", PG_lru);
READ_NUMBER("PG_private", PG_private);
diff --git a/makedumpfile.h b/makedumpfile.h
index 2e73beca48c5..5ad38e9ae40c 100644
--- a/makedumpfile-1.6.5/makedumpfile.h
+++ b/makedumpfile-1.6.5/makedumpfile.h
@@ -1913,6 +1913,7 @@ struct number_table {
long NR_FREE_PAGES;
long N_ONLINE;
long pgtable_l5_enabled;
+ long sme_mask;
/*
* Page flags
--
2.17.1

View File

@ -1,129 +0,0 @@
From fb5a8792e6e4ee7de7ae3e06d193ea5beaaececc Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Tue, 5 Mar 2019 19:34:33 +0800
Subject: [PATCH] x86: Introduce a new option --reuse-video-type
After commit 060eee58 "x86: use old screen_info if needed", kexec-tools
will force use old screen_info and vga type if failed to determine
current vga type. But it is not always a good idea.
Currently kernel hanging is inspected on some hyper-v VMs after this
commit, because hyperv_fb will mimic EFI (or VESA) VGA on first boot
up, but after the real driver is loaded, it will switch to new mode
and no longer compatible with EFI/VESA VGA. Keep setting
orig_video_isVGA to EFI/VESA VGA flag will get wrong driver loaded and
try to manipulate the framebuffer in a wrong way.
We can't ensure this won't happen on other framebuffer drivers, But
it's a helpful feature if the framebuffer drivers just work. So this
patch introduce a --reuse-video-type options to let user decide if the
old screen_info hould be used unconditional or not.
Signed-off-by: Kairui Song <kasong@redhat.com>
Reviewed-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
kexec/arch/i386/include/arch/options.h | 2 ++
kexec/arch/i386/kexec-x86.h | 1 +
kexec/arch/i386/x86-linux-setup.c | 8 ++++++--
kexec/arch/x86_64/kexec-x86_64.c | 5 +++++
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/kexec/arch/i386/include/arch/options.h b/kexec/arch/i386/include/arch/options.h
index c113a83..0e57951 100644
--- a/kexec/arch/i386/include/arch/options.h
+++ b/kexec/arch/i386/include/arch/options.h
@@ -32,6 +32,7 @@
#define OPT_ENTRY_32BIT (OPT_ARCH_MAX+10)
#define OPT_PASS_MEMMAP_CMDLINE (OPT_ARCH_MAX+11)
#define OPT_NOEFI (OPT_ARCH_MAX+12)
+#define OPT_REUSE_VIDEO_TYPE (OPT_ARCH_MAX+13)
/* Options relevant to the architecture (excluding loader-specific ones): */
#define KEXEC_ARCH_OPTIONS \
@@ -45,6 +46,7 @@
{ "elf64-core-headers", 0, 0, OPT_ELF64_CORE }, \
{ "pass-memmap-cmdline", 0, 0, OPT_PASS_MEMMAP_CMDLINE }, \
{ "noefi", 0, 0, OPT_NOEFI}, \
+ { "reuse-video-type", 0, 0, OPT_REUSE_VIDEO_TYPE }, \
#define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""
diff --git a/kexec/arch/i386/kexec-x86.h b/kexec/arch/i386/kexec-x86.h
index 51855f8..c2bcd37 100644
--- a/kexec/arch/i386/kexec-x86.h
+++ b/kexec/arch/i386/kexec-x86.h
@@ -52,6 +52,7 @@ struct arch_options_t {
enum coretype core_header_type;
uint8_t pass_memmap_cmdline;
uint8_t noefi;
+ uint8_t reuse_video_type;
};
int multiboot_x86_probe(const char *buf, off_t len);
diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
index 1bd408b..8fad115 100644
--- a/kexec/arch/i386/x86-linux-setup.c
+++ b/kexec/arch/i386/x86-linux-setup.c
@@ -144,7 +144,7 @@ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
} else if (0 == strcmp(fix.id, "EFI VGA")) {
/* VIDEO_TYPE_EFI */
real_mode->orig_video_isVGA = 0x70;
- } else {
+ } else if (arch_options.reuse_video_type) {
int err;
off_t offset = offsetof(typeof(*real_mode), orig_video_isVGA);
@@ -152,6 +152,10 @@ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1);
if (err)
goto out;
+ } else {
+ real_mode->orig_video_isVGA = 0;
+ close(fd);
+ return 0;
}
close(fd);
@@ -844,7 +848,7 @@ void setup_linux_system_parameters(struct kexec_info *info,
setup_subarch(real_mode);
if (bzImage_support_efi_boot && !arch_options.noefi)
setup_efi_info(info, real_mode);
-
+
/* Default screen size */
real_mode->orig_x = 0;
real_mode->orig_y = 0;
diff --git a/kexec/arch/x86_64/kexec-x86_64.c b/kexec/arch/x86_64/kexec-x86_64.c
index 041b007..ccdc980 100644
--- a/kexec/arch/x86_64/kexec-x86_64.c
+++ b/kexec/arch/x86_64/kexec-x86_64.c
@@ -55,6 +55,7 @@ void arch_usage(void)
" --console-serial Enable the serial console\n"
" --pass-memmap-cmdline Pass memory map via command line in kexec on panic case\n"
" --noefi Disable efi support\n"
+ " --reuse-video-type Reuse old boot time video type blindly\n"
);
}
@@ -67,6 +68,7 @@ struct arch_options_t arch_options = {
.core_header_type = CORE_TYPE_ELF64,
.pass_memmap_cmdline = 0,
.noefi = 0,
+ .reuse_video_type = 0,
};
int arch_process_options(int argc, char **argv)
@@ -136,6 +138,9 @@ int arch_process_options(int argc, char **argv)
case OPT_NOEFI:
arch_options.noefi = 1;
break;
+ case OPT_REUSE_VIDEO_TYPE:
+ arch_options.reuse_video_type = 1;
+ break;
}
}
/* Reset getopt for the next pass; called in other source modules */
--
2.20.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,134 +6,89 @@
# 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=$(awk '/^path/ {print $2}' $conf_file)
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
# strip the duplicated "/"
SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
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
}
WDTCFG=""
is_wdt_addition_needed
[[ $? -eq 0 ]] && WDTCFG="-a watchdog"
extra_modules=""
dracut_args=("--quiet" "--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "--hostonly-mode" "strict" "-o" "plymouth dash resume ifcfg earlykdump" $WDTCFG)
SAVE_PATH=$(get_save_path)
OVERRIDE_RESETTABLE=0
add_dracut_arg() {
local arg qarg is_quoted=0
while [ $# -gt 0 ];
do
arg="${1//\'/\"}"
#Handle quoted substring properly for passing it to dracut_args array.
if [ $is_quoted -eq 0 ]; then
if [[ "$arg" == "\"" ]] || [[ $arg != ${arg#\"} ]]; then
is_quoted=1
arg=${arg#\"}
fi
fi
if [ $is_quoted -eq 1 ]; then
qarg="$qarg $arg"
if [[ "$arg" == "\"" ]] || [[ $arg != ${arg%\"} ]]; then
is_quoted=0
arg=${qarg%\"}
qarg=""
else
shift
continue
fi
fi
dracut_args+=("$arg")
shift
done
}
extra_modules=""
dracut_args="--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o \"plymouth dash resume ifcfg earlykdump\" --compress=xz"
add_dracut_module() {
add_dracut_arg "--add" "$1"
readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)"
[ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed."
readonly MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target"
trap '
ret=$?;
is_mounted $MKDUMPRD_TMPMNT && umount -f $MKDUMPRD_TMPMNT;
[[ -d $MKDUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKDUMPRD_TMPDIR";
exit $ret;
' EXIT
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
add_dracut_arg() {
dracut_args="$dracut_args $@"
}
add_dracut_mount() {
add_dracut_arg "--mount" "$1"
add_dracut_arg "--mount" "\"$1\""
}
add_dracut_sshkey() {
add_dracut_arg "--sshkey" "$1"
add_dracut_arg "--sshkey" "\"$1\""
}
# caller should ensure $1 is valid and mounted in 1st kernel
to_mount() {
local _dev=$1 _source _target _fstype _options _mntopts _pdev
local _target=$1 _fstype=$2 _options=$3 _new_mntpoint _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
_target=$(get_mntpoint_from_target $_dev)
# mount under /sysroot if dump to root disk or mount under
#/kdumproot/$_target in other cases in 2nd kernel. systemd
#will be in charge to umount it.
_new_mntpoint=$(get_kdump_mntpoint_from_target $_target)
_fstype="${_fstype:-$(get_fs_type_from_target $_target)}"
_options="${_options:-$(get_mntopt_from_target $_target)}"
_options="${_options:-defaults}"
if [ "$_target" = "/" ];then
_target="/sysroot"
if [[ "$_fstype" == "nfs"* ]]; then
_pdev=$_target
_options=$(echo $_options | sed 's/,\(mount\)\?addr=[^,]*//g')
_options=$(echo $_options | sed 's/,\(mount\)\?proto=[^,]*//g')
_options=$(echo $_options | sed 's/,clientaddr=[^,]*//')
else
_target="/kdumproot/$_target"
fi
_fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev)
[[ -e /etc/fstab ]] && _options=$(findmnt --fstab -f -n -r -o OPTIONS $_dev)
if [ -z "$_options" ]; then
_options=$(findmnt -k -f -n -r -o OPTIONS $_dev)
if [[ $_fstype == "nfs"* ]]; then
_options=$(echo $_options | sed 's/,addr=[^,]*//')
_options=$(echo $_options | sed 's/,proto=[^,]*//')
_options=$(echo $_options | sed 's/,clientaddr=[^,]*//')
# for non-nfs _target converting to use udev persistent name
_pdev="$(kdump_get_persistent_dev $_target)"
if [ -z "$_pdev" ]; then
return 1
fi
fi
#mount fs target as rw in 2nd kernel
_options=$(echo $_options | sed 's/\(^\|,\)ro\($\|,\)/\1rw\2/g')
# with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd
# kernel, filter it out here.
_options=$(echo $_options | sed 's/\(^\|,\)noauto\($\|,\)/\1/g')
# use both nofail and x-systemd.before to ensure systemd will try best to
# mount it before kdump starts, this is an attempt to improve robustness
_options="$_options,nofail,x-systemd.before=initrd-fs.target"
_mntopts="$_target $_fstype $_options"
#for non-nfs _dev converting to use udev persistent name
if [ -b "$_source" ]; then
_pdev="$(get_persistent_dev $_source)"
if [ -z "$_pdev" ]; then
return 1
fi
else
_pdev=$_dev
fi
echo "$_pdev $_mntopts"
}
is_readonly_mount() {
local _mnt
_mnt=$(findmnt -k -f -n -r -o OPTIONS $1)
#fs/proc_namespace.c: show_mountinfo():
#seq_puts(m, mnt->mnt_flags & MNT_READONLY ? " ro" : " rw");
[[ "$_mnt" =~ ^ro ]]
echo "$_pdev $_new_mntpoint $_fstype $_options"
}
#Function: get_ssh_size
@ -154,7 +109,7 @@ get_ssh_size() {
#mkdir if save path does not exist on ssh dump target
#$1=ssh dump target
#caller should ensure write permission on $DUMP_TARGET:$SAVE_PATH
#caller should ensure write permission on $1:$SAVE_PATH
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
mkdir_save_path_ssh()
{
@ -163,14 +118,14 @@ mkdir_save_path_ssh()
ssh -qn $_opt $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null
_ret=$?
if [ $_ret -ne 0 ]; then
perror_exit "mkdir failed on $DUMP_TARGET:$SAVE_PATH"
perror_exit "mkdir failed on $1:$SAVE_PATH"
fi
#check whether user has write permission on $SAVE_PATH/$DUMP_TARGET
#check whether user has write permission on $1:$SAVE_PATH
_dir=$(ssh -qn $_opt $1 mktemp -dqp $SAVE_PATH 2>/dev/null)
_ret=$?
if [ $_ret -ne 0 ]; then
perror_exit "Could not create temporary directory on $DUMP_TARGET:$SAVE_PATH. Make sure user has write permission on destination"
perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination"
fi
ssh -qn $_opt $1 rmdir $_dir
@ -216,27 +171,100 @@ 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
}
check_save_path_fs()
{
local _path=$1
if [ ! -d $_path ]; then
perror_exit "Dump path $_path does not exist."
fi
}
check_user_configured_target()
{
local _target=$1 _cfg_fs_type=$2 _mounted
local _mnt=$(get_mntpoint_from_target $_target)
local _opt=$(get_mntopt_from_target $_target)
local _fstype=$(get_fs_type_from_target $_target)
if [ -n "$_fstype" ]; then
# In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf
[[ $_fstype = "nfs"* ]] && _fstype=nfs
if [ -n "$_cfg_fs_type" ] && [ "$_fstype" != "$_cfg_fs_type" ]; then
perror_exit "\"$_target\" have a wrong type config \"$_cfg_fs_type\", expected \"$_fstype\""
fi
else
_fstype="$_cfg_fs_type"
_fstype="$_cfg_fs_type"
fi
# For noauto mount, mount it inplace with default value.
# Else use the temporary target directory
if [ -n "$_mnt" ]; then
if ! is_mounted "$_mnt"; then
if [[ $_opt = *",noauto"* ]]; then
mount $_mnt
[ $? -ne 0 ] && perror_exit "Failed to mount $_target on $_mnt for kdump preflight check."
_mounted=$_mnt
else
perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\""
fi
fi
else
_mnt=$MKDUMPRD_TMPMNT
mkdir -p $_mnt
mount $_target $_mnt -t $_fstype -o defaults
[ $? -ne 0 ] && perror_exit "Failed to mount $_target for kdump preflight check."
_mounted=$_mnt
fi
# For user configured target, use $SAVE_PATH as the dump path within the target
if [ ! -d "$_mnt/$SAVE_PATH" ]; then
perror_exit "Dump path \"$SAVE_PATH\" does not exist in dump target \"$_target\""
fi
check_size fs "$_target"
# Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway
if [ -n "$_mounted" ]; then
umount -f -- $_mounted
fi
}
# $1: core_collector config value
verify_core_collector() {
if grep -q "^raw" $conf_file && [ "${1%% *}" != "makedumpfile" ]; then
echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
fi
if is_ssh_dump_target || is_raw_dump_target; then
if [ "${1%% *}" = "makedumpfile" ]; then
! strstr "$1" "-F" && {
perror_exit "The specified dump target needs makedumpfile \"-F\" option."
}
local _cmd="${1%% *}"
local _params="${1#* }"
if [ "$_cmd" != "makedumpfile" ]; then
if is_raw_dump_target; then
dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
fi
return
fi
if is_ssh_dump_target || is_raw_dump_target; then
if ! strstr "$_params" "-F"; then
perror_exit "The specified dump target needs makedumpfile \"-F\" option."
fi
_params="$_params vmcore"
else
_params="$_params vmcore dumpfile"
fi
if ! $_cmd --check-params $_params; then
perror_exit "makedumpfile parameter check failed."
fi
}
add_mount() {
local _mnt=$(to_mount "$1")
local _mnt=$(to_mount $@)
if [ $? -ne 0 ]; then
exit 1
@ -255,20 +283,11 @@ handle_default_dump_target()
check_save_path_fs $SAVE_PATH
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH)
_target=$(get_target_from_path $SAVE_PATH)
_save_path=$(get_bind_mount_source $SAVE_PATH)
_target=$(get_target_from_path $_save_path)
_mntpoint=$(get_mntpoint_from_target $_target)
if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
_mntpoint=$(get_mntpoint_from_target $_target)
# the absolute path in the 1st kernel
SAVE_PATH=$_mntpoint/$SAVE_PATH
fi
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
SAVE_PATH=${_save_path##"$_mntpoint"}
add_mount "$_target"
check_size fs $_target
}
@ -286,7 +305,6 @@ get_override_resettable()
fi
}
# $1: function name
for_each_block_target()
{
@ -301,8 +319,6 @@ for_each_block_target()
return 0
}
#judge if a specific device with $1 is unresettable
#return false if unresettable.
is_unresettable()
@ -315,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
@ -339,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
@ -372,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
@ -382,10 +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
while read config_opt config_val;
do
# remove inline comments after the end of a directive.
@ -394,28 +389,15 @@ do
extra_modules="$extra_modules $config_val"
;;
ext[234]|xfs|btrfs|minix|nfs)
if ! findmnt $config_val >/dev/null; then
perror_exit "Dump target $config_val is probably not mounted."
fi
_absolute_save_path=$(make_absolute_save_path $config_val)
_mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=${_absolute_save_path##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
fi
add_mount "$config_val"
check_save_path_fs $_absolute_save_path
check_size fs $config_val
check_user_configured_target "$config_val" "$config_opt"
add_mount "$config_val" "$config_opt"
;;
raw)
#checking raw disk writable
# checking raw disk writable
dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || {
perror_exit "Bad raw disk $config_val"
}
_praw=$(persistent_policy="by-id" get_persistent_dev $config_val)
_praw=$(persistent_policy="by-id" kdump_get_persistent_dev $config_val)
if [ -z "$_praw" ]; then
exit 1
fi
@ -425,10 +407,9 @@ do
ssh)
if strstr "$config_val" "@";
then
check_size ssh $config_val
mkdir_save_path_ssh $config_val
add_dracut_module "ssh-client"
add_dracut_sshkey "$SSH_KEY_LOCATION"
check_size ssh $config_val
add_dracut_sshkey "$SSH_KEY_LOCATION"
else
perror_exit "Bad ssh dump target $config_val"
fi
@ -448,9 +429,14 @@ handle_default_dump_target
if [ -n "$extra_modules" ]
then
add_dracut_arg "--add-drivers" "$extra_modules"
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().
@ -459,7 +445,4 @@ if ! is_fadump_capable; then
add_dracut_arg "--no-hostonly-default-device"
fi
dracut "${dracut_args[@]}" "$@"
_rc=$?
sync
exit $_rc
echo "$dracut_args $@" | xargs dracut

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 54d6ee9d9d4ee807de32ad490040cbb9a3055a09 Mon Sep 17 00:00:00 2001
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.5/arch/arm64.c b/makedumpfile-1.6.5/arch/arm64.c
index 053519359cbc..5fcf59d36fed 100644
--- a/makedumpfile-1.6.5/arch/arm64.c
+++ b/makedumpfile-1.6.5/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.5/makedumpfile.c b/makedumpfile-1.6.5/makedumpfile.c
index 590f759c84f1..b9085247375e 100644
--- a/makedumpfile-1.6.5/makedumpfile.c
+++ b/makedumpfile-1.6.5/makedumpfile.c
@@ -2312,6 +2312,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);
@@ -2717,6 +2718,7 @@ read_vmcoreinfo(void)
READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE);
READ_NUMBER("phys_base", phys_base);
#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.5/makedumpfile.h b/makedumpfile-1.6.5/makedumpfile.h
index 5ad38e9ae40c..311ac05a28ab 100644
--- a/makedumpfile-1.6.5/makedumpfile.h
+++ b/makedumpfile-1.6.5/makedumpfile.h
@@ -1935,6 +1935,7 @@ struct number_table {
long HUGETLB_PAGE_DTOR;
long phys_base;
#ifdef __aarch64__
+ long MAX_USER_VA_BITS;
long VA_BITS;
unsigned long PHYS_OFFSET;
unsigned long kimage_voffset;
--
2.7.4

View File

@ -42,6 +42,9 @@ storage:
hardware RAID (cciss, hpsa, megaraid_sas, mpt2sas, aacraid)
SCSI/SATA disks
iSCSI HBA (all offload)
hardware FCoE (qla2xxx, lpfc)
software FCoE (bnx2fc) (Extra configuration required,
please read "Note on FCoE" section below)
network:
Hardware using kernel modules: (tg3, igb, ixgbe, sfc, e1000e, bna,
@ -104,6 +107,21 @@ hypervisor:
Hyper-V 2012
Note on FCoE
=====================
If you are trying to dump to a software FCoE target, you may encounter OOM
issue, because some software FCoE requires more memory to work. In such case,
you may need to increase the kdump reserved memory size in "crashkernel="
kernel parameter.
By default, RHEL systems have "crashkernel=auto" in kernel boot arguments.
The auto reserved memory size is designed to balance the coverage of use cases
and an acceptable memory overhead, so not every use case could fit in, software
FCoE is one of the case.
For hardware FCoE, kdump should work naturally as firmware will do the
initialization job. The capture kernel and kdump tools will run just fine.
Useful Links
============
[1] RHEL6: Enabling kdump for full-virt (HVM) Xen DomU

View File

@ -1,6 +1,6 @@
Name: kexec-tools
Version: 2.0.19
Release: 7%{?dist}
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.5/makedumpfile-1.6.5.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
@ -33,6 +33,12 @@ Source27: early-kdump-howto.txt
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
@ -49,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
Requires: dracut >= 049-129
Requires: dracut-network >= 049
Requires: dracut-squash >= 049
Requires: ethtool
BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static 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
@ -65,6 +79,8 @@ BuildRequires: automake autoconf libtool
Obsoletes: diskdumputils netdump kexec-tools-eppic
%endif
ExcludeArch: i686
#START INSERT
#
@ -74,8 +90,7 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic
#
# Patches 101 through 200 are meant for x86_64 kexec-tools enablement
#
Patch101: kexec-tools-2.0.19-x86-Introduce-a-new-option-reuse-video-type.patch
Patch102: kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch
#
# Patches 301 through 400 are meant for ppc64 kexec-tools enablement
#
@ -83,6 +98,7 @@ Patch102: kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Mem
#
# Patches 401 through 500 are meant for s390 kexec-tools enablement
#
#
# Patches 501 through 600 are meant for ARM kexec-tools enablement
#
@ -90,16 +106,17 @@ Patch102: kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Mem
#
# Patches 601 onward are generic patches
#
Patch601: kexec-tools-2.0.16-koji-build-fail-workaround.patch
Patch603: kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch
Patch604: kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch
Patch605: kexec-tools-2.0.18-makedumpfiles-exclude-pages-that-are-logically-offline.patch
Patch606: rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch
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
# Patches 701 onward for makedumpfile
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 /sbin/kexec binary that facilitates a new
kexec-tools provides /usr/sbin/kexec binary that facilitates a new
kernel to boot using the kernel's kexec feature either on a
normal or a panic reboot. This package contains the /sbin/kexec
normal or a panic reboot. This package contains the /usr/sbin/kexec
binary and ancillary utilities that together form the userspace
component of the kernel's kexec feature.
@ -110,13 +127,11 @@ mkdir -p -m755 kcp
tar -z -x -v -f %{SOURCE9}
tar -z -x -v -f %{SOURCE19}
%patch101 -p1
%patch601 -p1
%patch603 -p1
%patch604 -p1
%patch605 -p1
%patch606 -p1
%patch102 -p1
%patch602 -p1
%patch701 -p1
%patch702 -p1
%ifarch ppc
%define archdef ARCH=ppc
@ -133,7 +148,7 @@ autoreconf
--host=powerpc64le-redhat-linux-gnu \
--build=powerpc64le-redhat-linux-gnu \
%endif
--sbindir=/sbin
--sbindir=/usr/sbin
rm -f kexec-tools.spec.in
# setup the docs
cp %{SOURCE10} .
@ -141,17 +156,24 @@ cp %{SOURCE21} .
cp %{SOURCE26} .
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.5 LINKTYPE=dynamic USELZO=on USESNAPPY=on
make -C makedumpfile-1.6.5 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
mkdir -p -m755 $RPM_BUILD_ROOT/sbin
mkdir -p -m755 $RPM_BUILD_ROOT/usr/sbin
mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump
mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump/pre.d
mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump/post.d
mkdir -p -m755 $RPM_BUILD_ROOT%{_localstatedir}/crash
mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/
mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man5/
@ -162,10 +184,11 @@ 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/sbin/kexec
install -m 755 build/sbin/vmcore-dmesg $RPM_BUILD_ROOT/sbin/vmcore-dmesg
install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/usr/sbin/kexec
install -m 755 build/sbin/vmcore-dmesg $RPM_BUILD_ROOT/usr/sbin/vmcore-dmesg
install -m 644 build/man/man8/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/
install -m 644 build/man/man8/vmcore-dmesg.8 $RPM_BUILD_ROOT%{_mandir}/man8/
@ -174,13 +197,15 @@ SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu}
[ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig
install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/sbin/mkdumprd
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd
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
@ -188,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
@ -195,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.5/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile
install -m 644 makedumpfile-1.6.5/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz
install -m 644 makedumpfile-1.6.5/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz
install -m 644 makedumpfile-1.6.5/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample
install -m 755 makedumpfile-1.6.5/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.5/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
@ -226,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
@ -238,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
@ -265,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
@ -275,7 +322,7 @@ fi
/usr/bin/systemd-sysv-convert --save kdump >/dev/null 2>&1 ||:
# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del kdump >/dev/null 2>&1 || :
/usr/sbin/chkconfig --del kdump >/dev/null 2>&1 || :
/bin/systemctl try-restart kdump.service >/dev/null 2>&1 || :
@ -302,10 +349,11 @@ do
done
%files
/sbin/kexec
/sbin/makedumpfile
/sbin/mkdumprd
/sbin/vmcore-dmesg
/usr/sbin/kexec
/usr/sbin/makedumpfile
/usr/sbin/mkdumprd
/usr/sbin/mkfadumprd
/usr/sbin/vmcore-dmesg
%{_bindir}/*
%{_datadir}/kdump
%{_prefix}/lib/kdump
@ -313,13 +361,17 @@ done
%{_sysconfdir}/makedumpfile.conf.sample
%endif
%config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump
%config(noreplace,missingok) %{_sysconfdir}/kdump.conf
%config(noreplace,missingok) %verify(not mtime) %{_sysconfdir}/kdump.conf
%ifnarch s390x
%config %{_udevrulesdir}
%{_udevrulesdir}/../kdump-udev-throttler
%endif
%{dracutlibdir}/modules.d/*
%dir %{_localstatedir}/crash
%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
@ -328,11 +380,13 @@ 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
%doc kexec-kdump-howto.txt
%doc early-kdump-howto.txt
%doc fadump-howto.txt
%doc supported-kdump-targets.txt
%doc kdump-in-cluster-environment.txt
%doc live-image-kdump-howto.txt
@ -342,6 +396,424 @@ done
%endif
%changelog
* 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
* Tue Aug 18 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-33
- sadump, kaslr: fix failure of calculating kaslr_offset due to an sadump format restriction
* Mon Aug 3 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-32
- kdumpctl: exit if either pre.d or post.d is missing
* Wed Jul 22 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-31
- ppc64/kdump: use kexec_file_load when secureboot is enabled
- kdump_pre: make notes more precise
- dracut-kdump.sh: exit shell when machine reboot
- kdump.conf: fix a grammar issue
- kdumpctl: detect modification of scripts by its directory's timestamp
- module-setup.sh: suppress false alarm
- kexec-tools.spec: make the existence of pre.d and post.d mandatory
* Tue Jul 14 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-30
- x86_64: enable the kexec file load by default
- Revert "kdump-lib: switch to the kexec_file_load() syscall on x86_64 by default"
* Wed Jun 24 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-29
- mkdumprd: Improve the error message for umounted dump target
* Wed Jun 24 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-28
- mkdumprd: Fix nfs detection in to_mount
- Always wrap up call to dracut get_persistent_dev function
- man: improve description about /etc/kdump/{pre.d,post.d}interface
* Tue Jun 16 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-27
- kdump-lib: switch to the kexec_file_load() syscall on x86_64 by default
* Mon Jun 15 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-26
- Fix kdump failure when mount target specified by dracut_args
- mkdumprd: Fix dracut error on multiple extra_modules
* Mon Jun 15 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-25
- kdump.conf: Specify /etc/kdump/{pre.d,post.d}interface
- dracut-kdump.sh: Execute the binary and script filesin /etc/kdump/{pre.d,post.d}
- kdumpctl: Check the update of the binary and script files in /etc/kdump/{pre.d,post.d}
- dracut-module-setup.sh: Install files under /etc/kdump/{pre.d,post.d} into kdump initramfs
* Thu Jun 4 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-24
- fadump: update fadump-howto.txt with some more troubleshooting help
* Wed Jun 3 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-23
- fadump-howto.txt: source it in spec file
* Mon Jun 1 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-22
- mkdumprd: Use DUMP_TARGET which printing error message during ssh
* Mon Jun 1 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-21
- Don't inherit swiotlb parameter form 1st kernel by default
- Add a new option 'rd.znet_ifname' in order to use it in udev rules
- kdump.sysconfig: Remove the option 'log_buf_len' from kdump command line
- kdump-error-handler.service: Remove ExecStopPost
- module-setup.sh: Add "rd.neednet" parameter if network is needed
* Thu May 28 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-20
- Update docs for the new noauto dump target support
- kexec-kdump-howto.txt: Add some format to the document
- mkdumprd: generate usable kdump initramfs even target is not mounted
- Use get_mount_info to replace findmnt calls
- kdump-lib.sh: add fstab failback helper for getting mount info
- Allow calling mkdumprd from kdumpctl even if targat not mounted
- Add a is_mounted helper
- Introduce get_kdump_mntpoint_from_target and fix duplicated /
- Doc: Improves the early-kdump-howto.txt document in several points
- Doc: Add --force option to step 2 in early-kdump-howto.txt
- Doc: Fix typo in early-kdump-howto.txt
- Remove adjust_bind_mount_path call
- No longer treat atomic/silverblue specially
- mkdumprd: Simplify handling of user specified target
- mkdumprd: Use get_save_path instead of parsing config
- Remove is_dump_target_configured
- Always use get_save_path to get the 'path' option
- kdump-lib: Don't abuse echo, and clean up
- mkdumprd: Fix dracut args parsing
- mkdumprd: simplify dracut args parsing
* Thu May 21 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-19
- dracut-module-setup.sh: improve get_alias()
- fadump: update fadump-howto.txt with some troubleshooting help
- Append both nofail and x-systemd.before to kdump mount target
- Partially Revert "Don't mount the dump target unless needed"
- Don't unmount the dump target just after saving vmcore
* Mon May 11 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-18
- makedumpfile: Avoid false-positive failure in mem_seciton validation
* Tue Apr 21 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-17
- mkdumprd: Use makedumpfile --check-params option
* Thu Apr 9 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-16
- makedumpfile update to latest
* Wed Apr 1 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-15
- makedumpfile rebase to 1.6.7
* Tue Feb 18 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-14
- kexec-tools/module-setup: Ensure eth devices get IP address for VLAN
* Wed Feb 12 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-13
- Add document to declare FCoE support
* Wed Feb 12 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-12
- powerpc: enable the scripts to capture dump on POWERNV platform
* Tue Feb 4 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-11
- s390: Use get_kaslr_offset_general() for s390x
* Fri Jan 10 2020 Pingfan Liu <piliu@redhat.com> - 2.0.20-10
- arm64: kdump: deal with a lot of resource entries in /proc/iomem
- arm64: kexec: allocate memory space avoiding reserved regions
- kexec: add variant helper functions for handling memory regions
* Thu Dec 12 2019 Pingfan Liu <piliu@redhat.com> - 2.0.20-9
- makedumpfile: assign bitmap1/2 fd for subprocess in non-cyclic mode
* Mon Dec 2 2019 Pingfan Liu <piliu@redhat.com> - 2.0.20-8
- makedumpfile: remove -lebl
* Thu Nov 28 2019 Pingfan Liu <piliu@redhat.com> - 2.0.20-7
- makedumpfile: Fix off-by-one issue in exclude_nodata_pages()
* Wed Nov 27 2019 Pingfan Liu <piliu@redhat.com> - 2.0.20-6
-rhel-8.2.0, origin/rhel-8.2.0) Increase SECTION_MAP_LAST_BIT to 4
- spec: move binaries from /sbin to /usr/sbin
- As /etc/kdump.conf timestamp is updated do not compare it when doing rpm --verify
- kdumpctl: make reload fail proof
* Tue Nov 12 2019 Pingfan Liu <piliu@redhat.com> - 2.0.20-5
- Don't execute final_action if failure_action terminates the system
- module-setup: re-fix 99kdumpbase network dependency
- kdumpctl: bail out immediately if host key verification failed
- kdumpctl: echo msg when waiting for connection
- kdumpctl: distinguish the failed reason of ssh
- kdumpctl: wait a while for network ready if dump target is ssh
- dracut-module-setup: filter out localhost for generic_fence_kdump
- dracut-module-setup: get localhost alias by manual
* Mon Oct 28 2019 Pingfan Liu <piliu@redhat.com> - 2.0.19-12.4
- dracut-module-setup.sh: Don't use squash module for fadump
- Don't mount the dump target unless needed
- dracut-module-setup: fix bond ifcfg processing
- Doc: amend the man page of kdump.conf
* Mon Oct 28 2019 Pingfan Liu <piliu@redhat.com> - 2.0.19-12.3
- Limit the size of vmcore-dmesg.txt to 2G
- makedumpfile: x86_64: Fix incorrect exclusion by -e option with KASLR
- mkdumprd: ensure ssh path exists before check size
* Fri Oct 18 2019 Pingfan Liu <piliu@redhat.com> - 2.0.19-12.2
- rebase to kexec-tools-2.0.20 and makedumpfile-1.6.6
* Fri Aug 9 2019 Pingfan Liu <piliu@redhat.com> - 2.0.19-12
- Don't forward and drop journalctl logs for fadump
* Mon Aug 5 2019 Pingfan Liu <piliu@redhat.com> - 2.0.19-11
- Drop switch root capability for non fadump initramfs
* Mon Aug 5 2019 Pingfan Liu <piliu@redhat.com> - 2.0.19-10
- Forward logs in kdump kernel to console directly
* Fri Jul 19 2019 Pingfan Liu <piliu@redhat.com> - 2.0.19-9
- kexec/arm64: Add support for handling zlib compressed (Image.gz) image
- kexec/kexec-zlib.h: Add 'is_zlib_file()' helper function
- kexec-uImage-arm64.c: Fix return value of uImage_arm64_probe()
- kexec/kexec.c: Add the missing close() for fd used for kexec_file_load()
* Sun Jul 14 2019 Pingfan Liu <piliu@redhat.com> - 2.0.19-8
- kdump.sysconfig/x86_64: Disable HEST by default
* Mon Jun 17 2019 Kairui Song <kasong@redhat.com> - 2.0.19-7
- dracut-kdump-capture.service: Use OnFailureJobMode instead of deprecated OnFailureIsolate