diff --git a/.gitignore b/.gitignore index 029d2b3..aa8d011 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ SOURCES/eppic_030413.tar.gz -SOURCES/kexec-tools-2.0.4.tar.bz2 -SOURCES/kexec-tools-po-20131224.tgz -SOURCES/makedumpfile-1.5.4.tar.gz +SOURCES/kdump-anaconda-addon-003-11-g7f70211.tar.gz +SOURCES/kexec-tools-2.0.7.tar.xz +SOURCES/makedumpfile-1.5.7.tar.gz diff --git a/.kexec-tools.metadata b/.kexec-tools.metadata index 19a95a4..5ea0345 100644 --- a/.kexec-tools.metadata +++ b/.kexec-tools.metadata @@ -1,4 +1,4 @@ dcdb6d2488c8a31ae95563e2113860ae16256c8f SOURCES/eppic_030413.tar.gz -f119507a92446bcda58b108fd7f61e6d9f187358 SOURCES/kexec-tools-2.0.4.tar.bz2 -6da479b880470fd57ecf040e0b1d1ffce21f168b SOURCES/kexec-tools-po-20131224.tgz -077dfb8fbf2f12b5efca385eb1fda55dee2096d5 SOURCES/makedumpfile-1.5.4.tar.gz +41895bf0a59e7359a12d7973a0171337fb69edb0 SOURCES/kdump-anaconda-addon-003-11-g7f70211.tar.gz +56f3c4c829d0078bb705f980e1d9ba22eb9a6246 SOURCES/kexec-tools-2.0.7.tar.xz +16427d952ce7d0426c8b4aecc92f2960cf7926d3 SOURCES/makedumpfile-1.5.7.tar.gz diff --git a/SOURCES/98-kexec.rules b/SOURCES/98-kexec.rules index 8c742dd..e32ee13 100644 --- a/SOURCES/98-kexec.rules +++ b/SOURCES/98-kexec.rules @@ -1,4 +1,4 @@ -SUBSYSTEM=="cpu", ACTION=="online", PROGRAM="/bin/systemctl try-restart kdump.service" -SUBSYSTEM=="cpu", ACTION=="offline", PROGRAM="/bin/systemctl try-restart kdump.service" -SUBSYSTEM=="memory", ACTION=="add", PROGRAM="/bin/systemctl try-restart kdump.service" -SUBSYSTEM=="memory", ACTION=="remove", PROGRAM="/bin/systemctl try-restart kdump.service" +SUBSYSTEM=="cpu", ACTION=="add", PROGRAM="/bin/systemctl try-restart kdump.service" +SUBSYSTEM=="cpu", ACTION=="remove", PROGRAM="/bin/systemctl try-restart kdump.service" +SUBSYSTEM=="memory", ACTION=="online", PROGRAM="/bin/systemctl try-restart kdump.service" +SUBSYSTEM=="memory", ACTION=="offline", PROGRAM="/bin/systemctl try-restart kdump.service" diff --git a/SOURCES/dracut-kdump-capture.service b/SOURCES/dracut-kdump-capture.service new file mode 100644 index 0000000..57139c9 --- /dev/null +++ b/SOURCES/dracut-kdump-capture.service @@ -0,0 +1,30 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Kdump Vmcore Save Service +After=initrd.target initrd-parse-etc.service sysroot.mount +After=dracut-initqueue.service dracut-pre-mount.service dracut-mount.service dracut-pre-pivot.service +Before=initrd-cleanup.service +ConditionPathExists=/etc/initrd-release +OnFailure=emergency.target +OnFailureIsolate=yes + +[Service] +Environment=DRACUT_SYSTEMD=1 +Environment=NEWROOT=/sysroot +Type=oneshot +ExecStart=/bin/kdump.sh +StandardInput=null +StandardOutput=syslog +StandardError=syslog+console +KillMode=process +RemainAfterExit=yes + +# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash +# terminates cleanly. +KillSignal=SIGHUP diff --git a/SOURCES/dracut-kdump-emergency.service b/SOURCES/dracut-kdump-emergency.service new file mode 100644 index 0000000..fb764f2 --- /dev/null +++ b/SOURCES/dracut-kdump-emergency.service @@ -0,0 +1,27 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +# This service will be placed in kdump initramfs and replace both the systemd +# emergency service and dracut emergency shell. IOW, any emergency will be +# kick this service and in turn isolating to kdump error handler. + +[Unit] +Description=Kdump Emergency +DefaultDependencies=no + +[Service] +ExecStart=/usr/bin/systemctl --no-block isolate kdump-error-handler.service +Type=oneshot +StandardInput=tty-force +StandardOutput=inherit +StandardError=inherit +KillMode=process +IgnoreSIGPIPE=no + +# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash +# terminates cleanly. +KillSignal=SIGHUP diff --git a/SOURCES/dracut-kdump-error-handler.service b/SOURCES/dracut-kdump-error-handler.service new file mode 100644 index 0000000..13090be --- /dev/null +++ b/SOURCES/dracut-kdump-error-handler.service @@ -0,0 +1,34 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +# This service will run the real kdump error handler code. Executing the +# default action configured in kdump.conf + +[Unit] +Description=Kdump Error Handler +DefaultDependencies=no +After=systemd-vconsole-setup.service +Wants=systemd-vconsole-setup.service +AllowIsolate=yes + +[Service] +Environment=HOME=/ +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 +StandardError=inherit +KillMode=process +IgnoreSIGPIPE=no + +# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash +# terminates cleanly. +KillSignal=SIGHUP diff --git a/SOURCES/dracut-kdump-error-handler.sh b/SOURCES/dracut-kdump-error-handler.sh new file mode 100755 index 0000000..2f0f1d1 --- /dev/null +++ b/SOURCES/dracut-kdump-error-handler.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +. /lib/kdump-lib-initramfs.sh + +set -o pipefail +export PATH=$PATH:$KDUMP_SCRIPT_DIR + +get_kdump_confs +do_default_action +do_final_action diff --git a/SOURCES/dracut-kdump.sh b/SOURCES/dracut-kdump.sh index d9e65ac..dc948d1 100755 --- a/SOURCES/dracut-kdump.sh +++ b/SOURCES/dracut-kdump.sh @@ -1,31 +1,16 @@ #!/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 +fi + exec &> /dev/console . /lib/dracut-lib.sh -. /lib/kdump-lib.sh - -if [ -f "$initdir/lib/dracut/no-emergency-shell" ]; then - rm -f -- $initdir/lib/dracut/no-emergency-shell -fi +. /lib/kdump-lib-initramfs.sh set -o pipefail -KDUMP_PATH="/var/crash" -CORE_COLLECTOR="" -DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31" -DMESG_COLLECTOR="/sbin/vmcore-dmesg" -DEFAULT_ACTION="reboot -f" -DATEDIR=`date +%Y.%m.%d-%T` -HOST_IP='127.0.0.1' -DUMP_INSTRUCTION="" -SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" -KDUMP_SCRIPT_DIR="/kdumpscripts" -DD_BLKSIZE=512 -FINAL_ACTION="reboot -f" DUMP_RETVAL=0 -conf_file="/etc/kdump.conf" -KDUMP_PRE="" -KDUMP_POST="" -MOUNTS="" export PATH=$PATH:$KDUMP_SCRIPT_DIR @@ -43,27 +28,6 @@ do_dump() return $_ret } -do_umount() -{ - if [ -n "$MOUNTS" ]; then - for mount in $MOUNTS; do - ismounted $mount && umount -R $mount - done - fi -} - -do_final_action() -{ - do_umount - eval $FINAL_ACTION -} - -do_default_action() -{ - wait_for_loginit - eval $DEFAULT_ACTION -} - do_kdump_pre() { if [ -n "$KDUMP_PRE" ]; then @@ -83,39 +47,6 @@ add_dump_code() DUMP_INSTRUCTION=$1 } -# dump_fs -dump_fs() -{ - 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 - fi - MOUNTS="$MOUNTS $_mp" - - # 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/" - - 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/" - - 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 - - echo "kdump: saving vmcore complete" - return 0 -} - dump_raw() { local _raw=$1 @@ -165,21 +96,6 @@ dump_ssh() return 0 } -save_vmcore_dmesg_fs() { - local _dmesg_collector=$1 - local _path=$2 - - echo "kdump: saving vmcore-dmesg.txt" - $_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 - echo "kdump: saving vmcore-dmesg.txt complete" - else - echo "kdump: saving vmcore-dmesg.txt failed" - fi -} - save_vmcore_dmesg_ssh() { local _dmesg_collector=$1 local _path=$2 @@ -198,7 +114,6 @@ save_vmcore_dmesg_ssh() { fi } - get_host_ip() { local _host @@ -218,55 +133,12 @@ get_host_ip() read_kdump_conf() { - if [ ! -f "$conf_file" ]; then - echo "kdump: $conf_file not found" + if [ ! -f "$KDUMP_CONF" ]; then + echo "kdump: $KDUMP_CONF not found" return fi - # first get the necessary variables - while read config_opt config_val; - do - # remove inline comments after the end of a directive. - config_val=$(strip_comments $config_val) - case "$config_opt" in - path) - KDUMP_PATH="$config_val" - ;; - core_collector) - [ -n "$config_val" ] && CORE_COLLECTOR="$config_val" - ;; - sshkey) - if [ -f "$config_val" ]; then - SSH_KEY_LOCATION=$config_val - fi - ;; - kdump_pre) - KDUMP_PRE="$config_val" - ;; - kdump_post) - KDUMP_POST="$config_val" - ;; - default) - case $config_val in - shell) - DEFAULT_ACTION="_emergency_shell kdump" - ;; - reboot) - DEFAULT_ACTION="do_umount; reboot -f" - ;; - halt) - DEFAULT_ACTION="do_umount; halt -f" - ;; - poweroff) - DEFAULT_ACTION="do_umount; poweroff -f" - ;; - dump_to_rootfs) - DEFAULT_ACTION="dump_fs $NEWROOT" - ;; - esac - ;; - esac - done < $conf_file + get_kdump_confs # rescan for add code for dump target while read config_opt config_val; @@ -284,38 +156,23 @@ read_kdump_conf() add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" ;; esac - done < $conf_file + done < $KDUMP_CONF } fence_kdump_notify() { - local nodes - - if [ -f $FENCE_KDUMP_NODES ]; then - if [ -f $FENCE_KDUMP_CONFIG ]; then - . $FENCE_KDUMP_CONFIG - fi - - read nodes < $FENCE_KDUMP_NODES - $FENCE_KDUMP_SEND $FENCE_KDUMP_OPTS $nodes & + if [ -n "$FENCE_KDUMP_NODES" ]; then + $FENCE_KDUMP_SEND $FENCE_KDUMP_ARGS $FENCE_KDUMP_NODES & fi } -fence_kdump_notify read_kdump_conf - -if [ -z "$CORE_COLLECTOR" ];then - CORE_COLLECTOR=$DEFAULT_CORE_COLLECTOR - if is_ssh_dump_target || is_raw_dump_target; then - CORE_COLLECTOR="$CORE_COLLECTOR -F" - fi -fi +fence_kdump_notify get_host_ip if [ $? -ne 0 ]; then echo "kdump: get_host_ip exited with non-zero status!" - do_default_action - do_final_action + exit 1 fi if [ -z "$DUMP_INSTRUCTION" ]; then @@ -337,7 +194,7 @@ if [ $? -ne 0 ]; then fi if [ $DUMP_RETVAL -ne 0 ]; then - do_default_action + exit 1 fi do_final_action diff --git a/SOURCES/dracut-module-setup.sh b/SOURCES/dracut-module-setup.sh index 9538c1e..7c28942 100755 --- a/SOURCES/dracut-module-setup.sh +++ b/SOURCES/dracut-module-setup.sh @@ -20,7 +20,7 @@ depends() { _dep="$_dep drm" fi - if is_fence_kdump; then + if [ is_generic_fence_kdump -o is_pcs_fence_kdump ]; then _dep="$_dep network" fi @@ -79,6 +79,11 @@ kdump_static_ip() { _gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}') echo -n "${_srcaddr}::${_gateway}:${_netmask}::" fi + + /sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev " |\ + while read line; do + echo $line | awk '{printf("rd.route=%s:%s:%s\n", $1, $3, $5)}' + done >> ${initdir}/etc/cmdline.d/45route-static.conf } kdump_get_mac_addr() { @@ -295,6 +300,41 @@ kdump_install_net() { fi } +default_dump_target_install_conf() +{ + local _target _fstype + local _s _t + local _mntpoint + local _path _save_path + + is_user_configured_dump_target && return + + _save_path=$(get_option_value "path") + [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH + + _mntpoint=$(get_mntpoint_from_path $_save_path) + _target=$(get_target_from_path $_save_path) + if [ "$_mntpoint" != "/" ]; then + _fstype=$(get_fs_type_from_target $_target) + + if $(is_fs_type_nfs $_fstype); then + kdump_install_net "$_target" + _fstype="nfs" + else + _target=$(kdump_to_udev_name $_target) + fi + + echo "$_fstype $_target" >> /tmp/$$-kdump.conf + + _path=${_save_path##"$_mntpoint"} + + #erase the old path line, then insert the parsed path + sed -i "/^path/d" /tmp/$$-kdump.conf + echo "path $_path" >> /tmp/$$-kdump.conf + fi + +} + #install kdump.conf and what user specifies in kdump.conf kdump_install_conf() { sed -ne '/^#/!p' /etc/kdump.conf > /tmp/$$-kdump.conf @@ -305,7 +345,7 @@ kdump_install_conf() { config_val=$(strip_comments $config_val) case "$config_opt" in ext[234]|xfs|btrfs|minix|raw) - sed -i -e "s#$config_val#$(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf + sed -i -e "s#^$config_opt[[:space:]]\+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf ;; ssh|nfs) kdump_install_net "$config_val" @@ -319,11 +359,25 @@ kdump_install_conf() { esac done < /etc/kdump.conf - kdump_check_fence_kdump + default_dump_target_install_conf + + kdump_configure_fence_kdump "/tmp/$$-kdump.conf" inst "/tmp/$$-kdump.conf" "/etc/kdump.conf" rm -f /tmp/$$-kdump.conf } +# Default sysctl parameters should suffice for kdump kernel. +# Remove custom configurations sysctl.conf & sysctl.d/* +remove_sysctl_conf() { + + # As custom configurations like vm.min_free_kbytes can lead + # to OOM issues in kdump kernel, avoid them + rm -f "${initdir}/etc/sysctl.conf" + rm -rf "${initdir}/etc/sysctl.d" + rm -rf "${initdir}/run/sysctl.d" + rm -rf "${initdir}/usr/lib/sysctl.d" +} + kdump_iscsi_get_rec_val() { local result @@ -452,13 +506,9 @@ kdump_check_iscsi_targets () { } } - -# setup fence_kdump in cluster -# setup proper network and install needed files -# also preserve '[node list]' for 2nd kernel /etc/fence_kdump_nodes -kdump_check_fence_kdump () { +# retrieves fence_kdump nodes from Pacemaker cluster configuration +get_pcs_fence_kdump_nodes() { local nodes - is_fence_kdump || return 1 # get cluster nodes from cluster cib, get interface and ip address nodelist=`pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -` @@ -470,18 +520,55 @@ kdump_check_fence_kdump () { eval $node nodename=$uname # Skip its own node name - if [ "$nodename" = `hostname` ]; then + if [ "$nodename" = `hostname` -o "$nodename" = `hostname -s` ]; then continue fi nodes="$nodes $nodename" + done + + echo $nodes +} + +# retrieves fence_kdump args from config file +get_pcs_fence_kdump_args() { + if [ -f $FENCE_KDUMP_CONFIG_FILE ]; then + . $FENCE_KDUMP_CONFIG_FILE + echo $FENCE_KDUMP_OPTS + fi +} + +# setup fence_kdump in cluster +# setup proper network and install needed files +kdump_configure_fence_kdump () { + local kdump_cfg_file=$1 + local nodes + local args + + if is_generic_fence_kdump; then + nodes=$(get_option_value "fence_kdump_nodes") + + elif is_pcs_fence_kdump; then + nodes=$(get_pcs_fence_kdump_nodes) + + # set appropriate options in kdump.conf + echo "fence_kdump_nodes $nodes" >> ${kdump_cfg_file} + + args=$(get_pcs_fence_kdump_args) + if [ -n "$args" ]; then + echo "fence_kdump_args $args" >> ${kdump_cfg_file} + fi + + else + # fence_kdump not configured + return 1 + fi - kdump_install_net $nodename + # setup network for each node + for node in ${nodes}; do + kdump_install_net $node done - echo - echo "$nodes" > ${initdir}/$FENCE_KDUMP_NODES dracut_install $FENCE_KDUMP_SEND - dracut_install -o $FENCE_KDUMP_CONFIG } # Install a random seed used to feed /dev/urandom @@ -499,7 +586,7 @@ kdump_install_random_seed() { install() { kdump_install_conf - >"$initdir/lib/dracut/no-emergency-shell" + remove_sysctl_conf if is_ssh_dump_target; then kdump_install_random_seed @@ -514,8 +601,17 @@ install() { inst "/bin/cut" "/bin/cut" inst "/sbin/makedumpfile" "/sbin/makedumpfile" inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg" - inst_hook pre-pivot 9999 "$moddir/kdump.sh" inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" + inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.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" + 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 + cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service" + # Also redirect dracut-emergency to kdump error handler + ln_r "$systemdsystemunitdir/emergency.service" "$systemdsystemunitdir/dracut-emergency.service" # Check for all the devices and if any device is iscsi, bring up iscsi # target. Ideally all this should be pushed into dracut iscsi module diff --git a/SOURCES/firstboot_kdump.py b/SOURCES/firstboot_kdump.py deleted file mode 100755 index a8cd3ba..0000000 --- a/SOURCES/firstboot_kdump.py +++ /dev/null @@ -1,497 +0,0 @@ -# -# firstboot_kdump.py - kdump configuration page for firstboot -# Copyright 2006 Red Hat, Inc. -# Author: Jarod Wilson -# Contributors: -# Neil Horman -# Dave Lehman -# -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -import sys -sys.path.append('/usr/share/system-config-kdump/') - -from gtk import * -import string -import os -import os.path -import time -import gtk -import gobject -import commands -from firstboot.config import * -from firstboot.constants import * -from firstboot.functions import * -from firstboot.module import * -import gettext -_ = lambda x: gettext.ldgettext("kexec-tools", x) -N_ = lambda x: x - -class moduleClass(Module): - def __init__(self): - Module.__init__(self) - self.priority = 100 - self.sidebarTitle = N_("Kdump") - self.title = N_("Kdump") - self.reboot = False - - # runPriority determines the order in which this module runs in firstboot - runPriority = 70 - moduleName = _("Kdump") - windowName = moduleName - reboot = False - - # possible bootloaders we'll need to adjust - # bootloader : (config file, kdump offset) - bootloaders = { "grub" : (["/boot/grub/grub.conf", \ - "/boot/efi/EFI/centos/grub.conf"], [16, 256]),\ - "grub2" : (["/boot/grub2/grub.cfg", \ - "/boot/efi/EFI/fedora/grub.cfg", \ - "/boot/efi/EFI/centos/grub.cfg"], [16, 256]),\ - "zipl" : (["/etc/zipl.conf"], [0]),\ - "yaboot" : (["/boot/etc/yaboot.conf"], [32]) } - bootloader = None - offset = 0 - - # list of architectures without kdump support - unsupportedArches = [ "ppc", "s390", "i386", "i586" ] - - def needsReboot(self): - return self.reboot - - # toggle sensitivity of kdump config bits - def showHideReserve(self, status): - self.labelKdump.set_sensitive(status) - self.kdumpMemspin.set_sensitive(status) - self.totalMem.set_sensitive(status) - self.systemUsableMem.set_sensitive(status) - self.labelTotal.set_sensitive(status) - self.labelSys.set_sensitive(status) - - # toggle sensitivity of kdump config bits - def showHide(self, status): - show_kdumpmem = status - if self.distro == 'rhel': - show_autoreserve = self.buttonAuto.get_active() - if status == True: - if self.buttonAuto.get_active() == True: - show_kdumpmem = False - self.buttonAuto.set_active(show_autoreserve) - self.buttonManual.set_active(not show_autoreserve) - self.labelReserve.set_sensitive(status) - self.buttonAuto.set_sensitive(status) - self.buttonManual.set_sensitive(status) - self.showHideReserve(show_kdumpmem) - self.labelReserved.set_sensitive(status) - self.labelReservedMemsize.set_sensitive(status) - self.kdumpEnabled = status - self.AdvWindow.set_sensitive(status) - - def on_enableKdumpCheck_toggled(self, *args): - showHideStatus = self.enableKdumpCheck.get_active() - self.showHide(showHideStatus) - - def on_auto_toggled(self, *args): - if self.distro == 'rhel': - self.showHideReserve(not self.buttonAuto.get_active()) - - def on_manual_toggled(self, *args): - if self.distro == 'rhel': - self.showHideReserve(self.buttonManual.get_active()) - - def updateAvail(self, widget, spin): - self.reserveMem = eval(string.strip(self.kdumpMemspin.get_text())) - self.remainingMem = self.availMem - self.reserveMem - self.systemUsableMem.set_text("%s" % self.remainingMem) - - def getBootloader(self): - for (name, (conf, offset)) in self.bootloaders.items(): - i = 0 - for c in conf: - if os.access(c, os.W_OK): - self.bootloader = name - self.offset = i - return self.bootloader - i += 1 - - self.offset = None - self.bootloader = None - return None - - def createScreen(self, doDebug = None): - self.doDebug = doDebug - - if doDebug: - print "initializing kdump module" - - # What kernel are we running? - self.runningKernel = os.popen("/bin/uname -r").read().strip() - - # What arch are we running on? - self.arch = os.popen("/bin/uname -m").read().strip() - - # Check for a xen kernel, kdump doesn't work w/xen just yet... - self.xenKernel = self.runningKernel.find("xen") - - # Fedora or RHEL? - releaseFile = '/etc/redhat-release' - lines = open(releaseFile).readlines() - for line in lines: - if line.find("Fedora") != -1: - self.distro = 'fedora' - else: - self.distro = 'rhel' - - # Ascertain how much memory is in the system - memInfo = open("/proc/meminfo").readlines() - self.availMem = 0 - for line in memInfo: - if line.startswith("MemTotal:"): - self.availMem = int(line.split()[1]) / 1024 - break - - # Fix up memory calculations if kdump is already on - cmdLine = open("/proc/cmdline").read() - self.kdumpOffset = 0 - self.origCrashKernel = "" - self.kdumpEnabled = False - chkConfigStatus=commands.getoutput('/bin/systemctl is-enabled kdump.service') - if chkConfigStatus.find("enabled") > -1: - self.kdumpEnabled = True - self.kdumpMemInitial = 0 - - crashString = "" - kexec_crash_size = open("/sys/kernel/kexec_crash_size").read() - self.reservedMem = int(kexec_crash_size)/(1024*1024) - - if cmdLine.find("crashkernel") != -1: - crashString = filter(lambda t: t.startswith("crashkernel="), - cmdLine.split())[0].split("=")[1] - self.origCrashKernel = "crashkernel=%s" % (crashString) - if self.doDebug: - print "crashString is %s" % crashString - if crashString.find("@") != -1: - (self.kdumpMemInitial, self.kdumpOffset) = [int(m[:-1]) for m in crashString.split("@")] - else: - #kdumpMemInitial = -1 means auto reservation - if self.distro == 'rhel' and self.origCrashKernel == 'crashkernel=auto': - self.kdumpMemInitial=-1 - else: - self.kdumpMemInitial=int(crashString[:-1]) - self.kdumpOffset = 0 - if self.kdumpMemInitial != 0: - self.availMem += self.reservedMem - self.kdumpEnabled = True - else: - self.kdumpEnabled = False - if self.origCrashKernel.find("crashkernel=") != -1: - self.kdumpEnabled = True - - self.initialState = self.kdumpEnabled - - # Do some sanity-checking and try to present only sane options. - # - # Defaults - lowerBound = 128 - minUsable = 256 - step = 1 - self.enoughMem = True - if self.arch == 'ia64': - # ia64 usually needs at *least* 256M, page-aligned... :( - lowerBound = 256 - minUsable = 512 - step = 256 - elif self.arch == 'ppc64': - # ppc64 often fails w/128M lately, and we want at least 1G - # of RAM for normal use, due to 64k page size... :\ - lowerBound = 256 - minUsable = 1024 - - upperBound = (self.availMem - minUsable) - (self.availMem % step) - - if upperBound < lowerBound: - self.enoughMem = False - - # Set spinner to lowerBound unless already set on kernel command line - if self.kdumpMemInitial == 0 or self.kdumpMemInitial == -1: - self.kdumpMemInitial = lowerBound - else: - # round down to a multiple of step value - self.kdumpMemInitial = self.kdumpMemInitial - (self.kdumpMemInitial % step) - - # kdump enable/disable checkbox - self.enableKdumpCheck = gtk.CheckButton(_("_Enable kdump?")) - self.enableKdumpCheck.set_alignment(xalign=0, yalign=0) - - # detected total amount of system memory - self.totalMem = gtk.Label(_("%s" % self.availMem)) - self.labelTotal = gtk.Label(_("Total System Memory (MB):")) - self.labelTotal.set_alignment(0.0, 0.5) - self.labelTotal.set_width_chars(32) - - # how much ram to reserve for kdump - self.memAdjustment = gtk.Adjustment(self.kdumpMemInitial, lowerBound, upperBound, step, step, 0) - self.kdumpMemspin = gtk.SpinButton(self.memAdjustment, 0, 0) - self.kdumpMemspin.set_update_policy(gtk.UPDATE_IF_VALID) - self.kdumpMemspin.set_numeric(True) - self.memAdjustment.connect("value_changed", self.updateAvail, self.kdumpMemspin) - self.labelKdump = gtk.Label(_("Memory To Be _Reserved (MB):")) - self.labelKdump.set_use_underline(True) - self.labelKdump.set_mnemonic_widget(self.kdumpMemspin) - self.labelKdump.set_alignment(0.0, 0.5) - - # remaining usable system memory - self.reserveMem = eval(string.strip(self.kdumpMemspin.get_text())) - self.remainingMem = self.availMem - self.reserveMem - self.systemUsableMem = gtk.Label(_("%s" % self.remainingMem)) - self.labelSys = gtk.Label(_("Usable System Memory (MB):")) - self.labelSys.set_alignment(0.0, 0.5) - - self.labelReserved=gtk.Label(_("Memory Currently Reserved (MB):")) - self.labelReservedMemsize=gtk.Label(_("%s" % self.reservedMem)) - self.labelReserved.set_alignment(0.0, 0.5) - - # rhel crashkernel=auto handling - if self.distro == 'rhel': - self.labelReserve = gtk.Label(_("Kdump Memory Reservation:")) - self.buttonAuto = gtk.RadioButton(None, _("_Automatic")) - self.buttonManual = gtk.RadioButton(self.buttonAuto, _("_Manual")) - self.buttonAuto.connect("toggled", self.on_auto_toggled, None) - self.buttonManual.connect("toggled", self.on_manual_toggled, None) - self.buttonAuto.set_use_underline(True) - self.buttonManual.set_use_underline(True) - self.labelReserve.set_alignment(0.0, 0.5) - if self.origCrashKernel == 'crashkernel=auto': - self.buttonAuto.set_active(True) - self.buttonManual.set_active(False) - else: - self.buttonAuto.set_active(False) - self.buttonManual.set_active(True) - self.autoinitial = self.buttonAuto.get_active() - - - # Add an advanced kdump config text widget - inputbuf = open("/etc/kdump.conf", "r") - self.AdvConfig = gtk.TextView() - AdvBuf = gtk.TextBuffer() - AdvBuf.set_text(inputbuf.read()) - inputbuf.close() - - self.AdvConfig.set_buffer(AdvBuf) - self.AdvWindow = gtk.ScrolledWindow() - self.AdvWindow.set_shadow_type(gtk.SHADOW_IN) - self.AdvWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - self.AdvWindow.set_size_request(500, 300) - self.AdvWindow.add(self.AdvConfig) - - self.AdvConfLabel = gtk.Label(_("\nAdvanced kdump configuration")) - self.AdvConfLabel.set_alignment(0.0, 0.5) - - self.vbox = gtk.VBox() - self.vbox.set_size_request(400, 200) - - # title_pix = loadPixbuf("workstation.png") - - internalVBox = gtk.VBox() - internalVBox.set_border_width(10) - internalVBox.set_spacing(10) - - label = gtk.Label(_("Kdump is a kernel crash dumping mechanism. In the event of a " - "system crash, kdump will capture information from your system " - "that can be invaluable in determining the cause of the crash. " - "Note that kdump does require reserving a portion of system " - "memory that will be unavailable for other uses.")) - - label.set_line_wrap(True) - label.set_alignment(0.0, 0.5) - label.set_size_request(500, -1) - internalVBox.pack_start(label, False, True) - - if self.distro == 'rhel': - table = gtk.Table(3, 100) - table.attach(self.enableKdumpCheck, 0, 3, 0, 1, gtk.FILL, gtk.FILL, 5, 5) - table.attach(self.labelReserve, 0, 1, 1, 2, gtk.FILL) - table.attach(self.buttonAuto, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 5, 5) - table.attach(self.buttonManual, 2, 3, 1, 2, gtk.FILL, gtk.FILL, 5, 5) - table.attach(self.labelReserved, 0, 1, 2, 3, gtk.FILL) - table.attach(self.labelReservedMemsize, 2, 3, 2, 3, gtk.SHRINK, gtk.FILL, 5, 5) - table.attach(self.labelKdump, 0, 1, 3, 4, gtk.FILL) - table.attach(self.kdumpMemspin, 2, 3, 3, 4, gtk.SHRINK, gtk.FILL, 5, 5) - table.attach(self.labelTotal, 0, 1, 4, 5, gtk.FILL) - table.attach(self.totalMem, 2, 3, 4, 5, gtk.SHRINK, gtk.FILL, 5, 5) - table.attach(self.labelSys, 0, 1, 5, 6, gtk.FILL) - table.attach(self.systemUsableMem, 2, 3, 5, 6, gtk.SHRINK, gtk.FILL, 5, 5) - table.attach(self.AdvConfLabel, 0, 1, 6, 7, gtk.FILL) - table.attach(self.AdvWindow, 0, 3, 7, 100, gtk.FILL, gtk.FILL, 5, 5) - else: - table = gtk.Table(2, 100) - table.attach(self.enableKdumpCheck, 0, 2, 0, 1, gtk.FILL, gtk.FILL, 5, 5) - table.attach(self.labelTotal, 0, 1, 1, 2, gtk.FILL) - table.attach(self.totalMem, 1, 2, 1, 2, gtk.SHRINK, gtk.FILL, 5, 5) - - table.attach(self.labelKdump, 0, 1, 2, 3, gtk.FILL) - table.attach(self.kdumpMemspin, 1, 2, 2, 3, gtk.SHRINK, gtk.FILL, 5, 5) - - table.attach(self.labelReserved, 0, 1, 3, 4, gtk.FILL) - table.attach(self.labelReservedMemsize, 1, 2, 3, 4, gtk.SHRINK, gtk.FILL, 5, 5) - - table.attach(self.labelSys, 0, 1, 4, 5, gtk.FILL) - table.attach(self.systemUsableMem, 1, 2, 4, 5, gtk.SHRINK, gtk.FILL, 5, 5) - - table.attach(self.AdvConfLabel, 0, 1, 6, 7, gtk.FILL) - table.attach(self.AdvWindow, 0, 2, 7, 100, gtk.FILL, gtk.FILL, 5, 5) - - # disable until user clicks check box, if not already enabled - if self.initialState is False: - self.showHide(False) - else: - self.enableKdumpCheck.set_active(True) - self.showHide(True) - - internalVBox.pack_start(table, True, 15) - - # toggle sensitivity of Mem items - self.enableKdumpCheck.connect("toggled", self.on_enableKdumpCheck_toggled) - - self.vbox.pack_start(internalVBox, False, 15) - - def grabFocus(self): - self.enableKdumpCheck.grab_focus() - - def configChanged(self): - if self.initialState == self.kdumpEnabled and self.initialState == False: - return False - if self.initialState != self.kdumpEnabled \ - or (self.distro == 'rhel' and self.autoinitial != self.buttonAuto.get_active()) \ - or (self.distro == 'rhel' and self.buttonManual.get_active() == True and self.reserveMem != self.kdumpMemInitial) \ - or (self.distro != 'rhel' and self.reserveMem != self.kdumpMemInitial): - return True - return False - - - def apply(self, *args): - if self.kdumpEnabled: - self.reserveMem = self.kdumpMemspin.get_value_as_int() - else: - self.reserveMem = self.kdumpMemInitial - self.remainingMem = self.availMem - self.reserveMem - if self.doDebug: - print "Running kernel %s on %s architecture" % (self.runningKernel, self.arch) - if self.enableKdumpCheck.get_active(): - print "System Mem: %s MB Kdump Mem: %s MB Avail Mem: %s MB" % (totalSysMem, self.reserveMem, self.remainingMem) - else: - print "Kdump will be disabled" - - # Before we do other checks we should save the users config - AdvBuf = self.AdvConfig.get_buffer() - start, end = AdvBuf.get_bounds() - outputbuf = open("/etc/kdump.conf", "rw+") - outputbuf.write(AdvBuf.get_text(start, end)) - outputbuf.close() - - # Regardless of what else happens we need to be sure to disalbe kdump if its disabled here, or - # else it will fail during startup - if (self.enableKdumpCheck.get_active() == False): - os.system("/bin/systemctl disable kdump.service") - - # If the user simply doesn't have enough memory for kdump to be viable/supportable, tell 'em - if self.enoughMem is False and self.kdumpEnabled: - self.showErrorMessage(_("Sorry, your system does not have enough memory for kdump to be viable!")) - self.enableKdumpCheck.set_active(False) - self.showHide(False) - return RESULT_FAILURE - # Alert user that we're not going to turn on kdump if they're running a xen kernel - elif self.xenKernel != -1 and self.kdumpEnabled: - self.showErrorMessage(_("Sorry, Xen kernels do not support kdump at this time!")) - self.enableKdumpCheck.set_active(False) - self.showHide(False) - return RESULT_FAILURE - # If there's no kdump support on this arch, let the user know and don't configure - elif self.arch in self.unsupportedArches: - self.showErrorMessage(_("Sorry, the %s architecture does not support kdump at this time!" % self.arch)) - self.enableKdumpCheck.set_active(False) - self.showHide(False) - return RESULT_FAILURE - - # Don't alert if nothing has changed - if self.configChanged() == True: - dlg = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, - gtk.BUTTONS_YES_NO, - _("Changing Kdump settings requires rebooting the " - "system to reallocate memory accordingly. Would you " - "like to continue with this change and reboot the " - "system after firstboot is complete?")) - dlg.set_position(gtk.WIN_POS_CENTER) - dlg.show_all() - rc = dlg.run() - dlg.destroy() - - if rc != gtk.RESPONSE_YES: - self.reboot = False - return RESULT_SUCCESS - else: - self.reboot = True - - # Find bootloader if it exists, and update accordingly - if self.getBootloader() == None: - self.showErrorMessage(_("Error! No bootloader config file found, aborting configuration!")) - self.enableKdumpCheck.set_active(False) - self.showHide(False) - return RESULT_FAILURE - - # Are we adding or removing the crashkernel param? - if self.kdumpEnabled: - _reserves = "%iM" % (self.reserveMem) - if self.distro == 'rhel': - if self.buttonAuto.get_active() == True: - _reserves = 'auto' - - grubbyCmd = "/sbin/grubby --%s --update-kernel=ALL --args=crashkernel=%s" \ - % (self.bootloader, _reserves) - chkconfigStatus = "enable" - else: - grubbyCmd = "/sbin/grubby --%s --update-kernel=ALL --remove-args=%s" \ - % (self.bootloader, self.origCrashKernel) - chkconfigStatus = "disable" - - if self.doDebug: - print "Using %s bootloader with %iM offset" % (self.bootloader, self.offset) - print "Grubby command would be:\n %s" % grubbyCmd - print "chkconfig status is %s" % chkconfigStatus - else: - os.system(grubbyCmd) - os.system("/bin/systemctl %s kdump.service" % (chkconfigStatus)) - if self.bootloader == 'yaboot': - os.system('/sbin/ybin') - if self.bootloader == 'zipl': - os.system('/sbin/zipl') - else: - self.reboot = False - - - return RESULT_SUCCESS - - def showErrorMessage(self, text): - dlg = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, text) - dlg.set_position(gtk.WIN_POS_CENTER) - dlg.set_modal(True) - rc = dlg.run() - dlg.destroy() - return None - - def initializeUI(self): - pass - diff --git a/SOURCES/kdump-in-cluster-environment.txt b/SOURCES/kdump-in-cluster-environment.txt index c27a5d7..de1eb5e 100644 --- a/SOURCES/kdump-in-cluster-environment.txt +++ b/SOURCES/kdump-in-cluster-environment.txt @@ -34,11 +34,11 @@ recovery service, fence_kdump_send will periodically send messages to all cluster nodes. When the fence_kdump agent receives a valid message from the failed nodes, fencing is complete. -How to configure cluster environment: +How to configure Pacemaker cluster environment: -If we want to use kdump in cluster environment, fence-agents-kdump should be -installed in every nodes in the cluster. You can achieve this via the following -command: +If we want to use kdump in Pacemaker cluster environment, fence-agents-kdump +should be installed in every nodes in the cluster. You can achieve this via +the following command: # yum install -y fence-agents-kdump @@ -61,6 +61,31 @@ Then enable stonith How to configure kdump: -Actually there is nothing special in configuration between normal kdump and -cluster environment kdump. So please refer to Kexec-Kdump-howto file for more -information. +Actually there are two ways how to configure fence_kdump support: + +1) Pacemaker based clusters + If you have successfully configured fence_kdump in Pacemaker, there is + no need to add some special configuration in kdump. So please refer to + Kexec-Kdump-howto file for more information. + +2) Generic clusters + For other types of clusters there are two configuration options in + kdump.conf which enables fence_kdump support: + + fence_kdump_nodes + Contains list of cluster node(s) separated by space to send + fence_kdump notification to (this option is mandatory to enable + fence_kdump) + + fence_kdump_args + Command line arguments for fence_kdump_send (it can contain + all valid arguments except hosts to send notification to) + + These options will most probably be configured by your cluster software, + so please refer to your cluster documentation how to enable fence_kdump + support. + +Please be aware that these two ways cannot be combined and 2) has precedence +over 1). It means that if fence_kdump is configured using fence_kdump_nodes +and fence_kdump_args options in kdump.conf, Pacemaker configuration is not +used even if it exists. diff --git a/SOURCES/kdump-lib-initramfs.sh b/SOURCES/kdump-lib-initramfs.sh new file mode 100755 index 0000000..57b8304 --- /dev/null +++ b/SOURCES/kdump-lib-initramfs.sh @@ -0,0 +1,163 @@ +# These variables and functions are useful in 2nd kernel + +. /lib/kdump-lib.sh + +KDUMP_PATH="/var/crash" +CORE_COLLECTOR="" +DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31" +DMESG_COLLECTOR="/sbin/vmcore-dmesg" +DEFAULT_ACTION="reboot" +DATEDIR=`date +%Y.%m.%d-%T` +HOST_IP='127.0.0.1' +DUMP_INSTRUCTION="" +SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +KDUMP_SCRIPT_DIR="/kdumpscripts" +DD_BLKSIZE=512 +FINAL_ACTION="reboot" +KDUMP_CONF="/etc/kdump.conf" +KDUMP_PRE="" +KDUMP_POST="" +NEWROOT="/sysroot" + +get_kdump_confs() +{ + local config_opt config_val + + while read config_opt config_val; + do + # remove inline comments after the end of a directive. + config_val=$(strip_comments $config_val) + case "$config_opt" in + path) + KDUMP_PATH="$config_val" + ;; + core_collector) + [ -n "$config_val" ] && CORE_COLLECTOR="$config_val" + ;; + sshkey) + if [ -f "$config_val" ]; then + SSH_KEY_LOCATION=$config_val + fi + ;; + kdump_pre) + KDUMP_PRE="$config_val" + ;; + kdump_post) + KDUMP_POST="$config_val" + ;; + fence_kdump_args) + FENCE_KDUMP_ARGS="$config_val" + ;; + fence_kdump_nodes) + FENCE_KDUMP_NODES="$config_val" + ;; + default) + case $config_val in + shell) + DEFAULT_ACTION="kdump_emergency_shell" + ;; + reboot) + DEFAULT_ACTION="reboot" + ;; + halt) + DEFAULT_ACTION="halt" + ;; + poweroff) + DEFAULT_ACTION="poweroff" + ;; + dump_to_rootfs) + DEFAULT_ACTION="dump_to_rootfs" + ;; + esac + ;; + esac + done < $KDUMP_CONF + + if [ -z "$CORE_COLLECTOR" ]; then + CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" + if is_ssh_dump_target || is_raw_dump_target; then + CORE_COLLECTOR="$CORE_COLLECTOR -F" + fi + fi +} + +# dump_fs +dump_fs() +{ + + 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 + 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/" + + 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/" + + 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 + + echo "kdump: saving vmcore complete" +} + +save_vmcore_dmesg_fs() { + local _dmesg_collector=$1 + local _path=$2 + + echo "kdump: saving vmcore-dmesg.txt" + $_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 + + # 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" + else + echo "kdump: saving vmcore-dmesg.txt failed" + fi +} + +dump_to_rootfs() +{ + + echo "Kdump: trying to bring up rootfs device" + systemctl start dracut-initqueue + echo "Kdump: waiting for rootfs mount, will timeout after 90 seconds" + systemctl start sysroot.mount + + dump_fs $NEWROOT +} + +kdump_emergency_shell() +{ + echo "PS1=\"kdump:\\\${PWD}# \"" >/etc/profile + /bin/dracut-emergency + rm -f /etc/profile +} + +do_default_action() +{ + echo "Kdump: Executing default action $DEFAULT_ACTION" + eval $DEFAULT_ACTION +} + +do_final_action() +{ + eval $FINAL_ACTION +} diff --git a/SOURCES/kdump-lib.sh b/SOURCES/kdump-lib.sh index de32650..a20c6e8 100755 --- a/SOURCES/kdump-lib.sh +++ b/SOURCES/kdump-lib.sh @@ -3,9 +3,9 @@ # Kdump common variables and functions # -FENCE_KDUMP_CONFIG="/etc/sysconfig/fence_kdump" +DEFAULT_PATH="/var/crash/" +FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" -FENCE_KDUMP_NODES="/etc/fence_kdump_nodes" is_ssh_dump_target() { @@ -22,13 +22,30 @@ is_raw_dump_target() grep -q "^raw" /etc/kdump.conf } +is_fs_type_nfs() +{ + local _fstype=$1 + [ $_fstype = "nfs" ] || [ $_fstype = "nfs4" ] && return 0 + return 1 +} + +is_fs_dump_target() +{ + egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf +} + +is_user_configured_dump_target() +{ + return $(is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target || is_fs_dump_target) +} + strip_comments() { echo $@ | sed -e 's/\(.*\)#.*/\1/' } -# Check if fence kdump is configured in cluster -is_fence_kdump() +# Check if fence kdump is configured in Pacemaker cluster +is_pcs_fence_kdump() { # no pcs or fence_kdump_send executables installed? type -P pcs > /dev/null || return 1 @@ -38,6 +55,14 @@ is_fence_kdump() (pcs cluster cib | grep -q 'type="fence_kdump"') &> /dev/null || return 1 } +# Check if fence_kdump is configured using kdump options +is_generic_fence_kdump() +{ + [ -x $FENCE_KDUMP_SEND ] || return 1 + + grep -q "^fence_kdump_nodes" /etc/kdump.conf +} + get_user_configured_dump_disk() { local _target @@ -52,26 +77,64 @@ get_user_configured_dump_disk() return } -is_user_configured_dump_target() +get_root_fs_device() { local _target + _target=$(findmnt -k -f -n -o SOURCE /) + [ -n "$_target" ] && echo $_target - if is_ssh_dump_target || is_nfs_dump_target; then - return 0 - fi + return +} - _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}') - [ -n "$_target" ] && return 0 +get_mntpoint_from_path() +{ + echo $(df $1 | tail -1 | awk '{print $NF}') +} - return 1 +get_target_from_path() +{ + echo $(df $1 | tail -1 | awk '{print $1}') } -get_root_fs_device() +get_fs_type_from_target() { - local _target - _target=$(findmnt -k -f -n -o SOURCE /) - [ -n "$_target" ] && echo $_target + echo $(findmnt -k -f -n -r -o FSTYPE $1) +} - return +get_mntpoint_from_target() +{ + echo $(findmnt -k -f -n -r -o TARGET $1) +} + +# get_option_value +# retrieves value of option defined in kdump.conf +get_option_value() { + echo $(strip_comments `grep ^$1 /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 + + [ -n $_target ] && _mnt=$(get_mntpoint_from_target $1) + echo "${_mnt}/$SAVE_PATH" +} + +check_save_path_fs() +{ + local _path=$1 + + if [ ! -d $_path ]; then + perror_exit "Dump path $_path does not exist." + fi } diff --git a/SOURCES/kdump.conf b/SOURCES/kdump.conf index a106462..54b581d 100644 --- a/SOURCES/kdump.conf +++ b/SOURCES/kdump.conf @@ -35,9 +35,18 @@ # such as /dev/vg/. # Otherwise it's suggested to use label or uuid. # -# path - Append path to the filesystem device which you are -# dumping to. Ignored for raw device dumps. -# If unset, will default to /var/crash. +# path - "path" represents the file system path in which +# vmcore will be saved. If a dump target is specified +# in kdump.conf, then "path" is relative to the +# specified dump target. 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. +# Ignored for raw device dumps. If unset, will +# default to /var/crash. # # core_collector # - This allows you to specify the command to copy @@ -123,6 +132,15 @@ # dracut_args # - Pass extra dracut options when rebuilding kdump # initrd. +# +# fence_kdump_args +# - Command line arguments for fence_kdump_send (it can contain +# all valid arguments except hosts to send notification to). +# +# fence_kdump_nodes +# - List of cluster node(s) separated by space to send fence_kdump +# notification to (this option is mandatory to enable fence_kdump). +# #raw /dev/vg/lv_kdump #ext4 /dev/vg/lv_kdump @@ -141,3 +159,5 @@ core_collector makedumpfile -l --message-level 1 -d 31 #default shell #force_rebuild 1 #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 diff --git a/SOURCES/kdump.conf.5 b/SOURCES/kdump.conf.5 index 7eaf9dd..f1c2a2c 100644 --- a/SOURCES/kdump.conf.5 +++ b/SOURCES/kdump.conf.5 @@ -62,7 +62,15 @@ or uuid. It's recommended to use persistent device names such as .B path .RS -Append path to the filesystem device which you are dumping to. +"path" represents the file system path in which vmcore will be saved. +If a dump target is specified in kdump.conf, then "path" is relative to the +specified dump target. +.PP +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. +.PP Ignored for raw device dumps. If unset, will default to /var/crash. .RE @@ -177,6 +185,21 @@ Kdump uses dracut to generate initramfs for second kernel. This option allows a user to pass arguments to dracut directly. .RE + +.B fence_kdump_args +.RS +Command line arguments for fence_kdump_send (it can contain all valid +arguments except hosts to send notification to). +.RE + + +.B fence_kdump_nodes +.RS +List of cluster node(s) separated by space to send fence_kdump notification +to (this option is mandatory to enable fence_kdump). +.RE + + .SH DEPRECATED OPTIONS .B net | diff --git a/SOURCES/kdump.service b/SOURCES/kdump.service index 55b7ca2..24c1386 100644 --- a/SOURCES/kdump.service +++ b/SOURCES/kdump.service @@ -7,6 +7,7 @@ Type=oneshot ExecStart=/usr/bin/kdumpctl start ExecStop=/usr/bin/kdumpctl stop RemainAfterExit=yes +StartLimitInterval=0 [Install] WantedBy=multi-user.target diff --git a/SOURCES/kdump.sysconfig.i386 b/SOURCES/kdump.sysconfig.i386 index 0d26a66..84b2447 100644 --- a/SOURCES/kdump.sysconfig.i386 +++ b/SOURCES/kdump.sysconfig.i386 @@ -26,7 +26,7 @@ KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children KEXEC_ARGS="" #Where to find the boot image -KDUMP_BOOTDIR="/boot" +#KDUMP_BOOTDIR="/boot" #What is the image type used for kdump KDUMP_IMG="vmlinuz" diff --git a/SOURCES/kdump.sysconfig.ppc64 b/SOURCES/kdump.sysconfig.ppc64 index ca7e1d8..5295626 100644 --- a/SOURCES/kdump.sysconfig.ppc64 +++ b/SOURCES/kdump.sysconfig.ppc64 @@ -16,7 +16,7 @@ KDUMP_COMMANDLINE="" # This variable lets us append arguments to the current kdump commandline # As taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 rootflags=nofail" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 rootflags=nofail kvm_cma_resv_ratio=0" # Any additional kexec arguments required. In most situations, this should # be left empty @@ -26,7 +26,7 @@ KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_di KEXEC_ARGS="" #Where to find the boot image -KDUMP_BOOTDIR="/boot" +#KDUMP_BOOTDIR="/boot" #What is the image type used for kdump KDUMP_IMG="vmlinuz" diff --git a/SOURCES/kdump.sysconfig.ppc64le b/SOURCES/kdump.sysconfig.ppc64le new file mode 100644 index 0000000..5295626 --- /dev/null +++ b/SOURCES/kdump.sysconfig.ppc64le @@ -0,0 +1,37 @@ +# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump +# If no version is specified, then the init script will try to find a +# kdump kernel with the same version number as the running kernel. +KDUMP_KERNELVER="" + +# The kdump commandline is the command line that needs to be passed off to +# the kdump kernel. This will likely match the contents of the grub kernel +# line. For example: +# KDUMP_COMMANDLINE="ro root=LABEL=/" +# Dracut depends on proper root= options, so please 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=". +# If a command line is not specified, the default will be taken from +# /proc/cmdline +KDUMP_COMMANDLINE="" + +# This variable lets us append arguments to the current kdump commandline +# As taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 rootflags=nofail kvm_cma_resv_ratio=0" + +# Any additional kexec arguments required. In most situations, this should +# be left empty +# +# Example: +# KEXEC_ARGS="--elf32-core-headers" +KEXEC_ARGS="" + +#Where to find the boot image +#KDUMP_BOOTDIR="/boot" + +#What is the image type used for kdump +KDUMP_IMG="vmlinuz" + +#What is the images extension. Relocatable kernels don't have one +KDUMP_IMG_EXT="" + +#Specify the action after failure diff --git a/SOURCES/kdump.sysconfig.s390x b/SOURCES/kdump.sysconfig.s390x index 848b043..745dd27 100644 --- a/SOURCES/kdump.sysconfig.s390x +++ b/SOURCES/kdump.sysconfig.s390x @@ -29,7 +29,7 @@ MKDUMPRD_ARGS="" KEXEC_ARGS="" #Where to find the boot image -KDUMP_BOOTDIR="/boot" +#KDUMP_BOOTDIR="/boot" #What is the image type used for kdump KDUMP_IMG="vmlinuz" diff --git a/SOURCES/kdump.sysconfig.x86_64 b/SOURCES/kdump.sysconfig.x86_64 index 989c3c7..d9ad9b5 100644 --- a/SOURCES/kdump.sysconfig.x86_64 +++ b/SOURCES/kdump.sysconfig.x86_64 @@ -26,7 +26,7 @@ KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory KEXEC_ARGS="" #Where to find the boot image -KDUMP_BOOTDIR="/boot" +#KDUMP_BOOTDIR="/boot" #What is the image type used for kdump KDUMP_IMG="vmlinuz" diff --git a/SOURCES/kdumpctl b/SOURCES/kdumpctl index 5721f7f..b504734 100755 --- a/SOURCES/kdumpctl +++ b/SOURCES/kdumpctl @@ -9,6 +9,11 @@ MKDUMPRD="/sbin/mkdumprd -f" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" DUMP_TARGET="" +TARGET_INITRD="" +FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" +FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" +#kdump shall be the default dump mode +DEFAULT_DUMP_MODE="kdump" . /lib/kdump/kdump-lib.sh @@ -20,14 +25,34 @@ fi single_instance_lock() { + local rc timeout=5 + exec 9>/var/lock/kdump - flock 9 + + flock -n 9 + rc=$? + + while [ $rc -ne 0 ]; do + echo "Another app is currently holding the kdump lock; waiting for it to exit..." + flock -w $timeout 9 + rc=$? + done +} + +determine_dump_mode() +{ + # Check if firmware-assisted dump is enabled + # if yes, set the dump mode as fadump + if is_fadump_capable; then + echo "Dump mode is fadump" + DEFAULT_DUMP_MODE="fadump" + fi } # remove_cmdline_param [] ... [] # Remove a list of kernel parameters from a given kernel cmdline and print the result. # For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists. -function remove_cmdline_param() +remove_cmdline_param() { local cmdline=$1 shift @@ -45,7 +70,7 @@ function remove_cmdline_param() # This function returns the "initial apicid" of the # boot cpu (cpu 0) if present. # -function get_bootcpu_initial_apicid() +get_bootcpu_initial_apicid() { awk ' \ BEGIN { CPU = "-1"; } \ @@ -58,21 +83,21 @@ function get_bootcpu_initial_apicid() # # This function appends argument "$2=$3" to string ($1) if not already present. # -function append_cmdline() +append_cmdline() { - local cmdline=$1 - local newstr=${cmdline/$2/""} + local cmdline=$1 + local newstr=${cmdline/$2/""} - # unchanged str implies argument wasn't there - if [ "$cmdline" == "$newstr" ]; then - cmdline="${cmdline} ${2}=${3}" - fi + # unchanged str implies argument wasn't there + if [ "$cmdline" == "$newstr" ]; then + cmdline="${cmdline} ${2}=${3}" + fi - echo $cmdline + echo $cmdline } # This function performs a series of edits on the command line -function prepare_cmdline() +prepare_cmdline() { local cmdline; if [ -z "$KDUMP_COMMANDLINE" ]; then @@ -94,7 +119,7 @@ function prepare_cmdline() } -function save_core() +save_core() { coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" @@ -119,17 +144,56 @@ function save_core() fi } -function rebuild_initrd() +rebuild_fadump_initrd() { - $MKDUMPRD $kdump_initrd $kdump_kver + local target_initrd_tmp + + # backup fadump initrd for reference before replacing it + backup_initrd + + # this file tells the initrd is fadump enabled + touch /tmp/fadump.initramfs + target_initrd_tmp="$TARGET_INITRD.tmp" + $MKDUMPRD $target_initrd_tmp --rebuild $TARGET_INITRD --kver $kdump_kver \ + -i /tmp/fadump.initramfs /etc/fadump.initramfs + if [ $? != 0 ]; then + echo "mkdumprd: failed to rebuild initrd with fadump support" >&2 + rm -f /tmp/fadump.initramfs + return 1 + fi + rm -f /tmp/fadump.initramfs + + # updating fadump initrd + mv $target_initrd_tmp $TARGET_INITRD + sync + + return 0 +} + +rebuild_kdump_initrd() +{ + $MKDUMPRD $TARGET_INITRD $kdump_kver if [ $? != 0 ]; then echo "mkdumprd: failed to make kdump initrd" >&2 return 1 fi + + return 0 +} + +rebuild_initrd() +{ + if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + rebuild_fadump_initrd + else + rebuild_kdump_initrd + fi + + return $? } #$1: the files to be checked with IFS=' ' -function check_exist() +check_exist() { for file in $1; do if [ ! -f "$file" ]; then @@ -140,7 +204,7 @@ function check_exist() } #$1: the files to be checked with IFS=' ' -function check_executable() +check_executable() { for file in $1; do if [ ! -x "$file" ]; then @@ -150,7 +214,19 @@ function check_executable() done } -function check_config() +backup_initrd() +{ + local target_initrd_bak + + # Check if backup initrd is already present. + target_initrd_bak="$TARGET_INITRD.bak" + if [ ! -e $target_initrd_bak ];then + echo "Backing up $TARGET_INITRD" + cp $TARGET_INITRD $target_initrd_bak + fi +} + +check_config() { local nr @@ -161,12 +237,12 @@ function check_config() } while read config_opt config_val; do - # remove inline comments after the end of a directive. - config_val=$(strip_comments $config_val) + # remove inline comments after the end of a directive. + config_val=$(strip_comments $config_val) case "$config_opt" in \#* | "") ;; - raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|dracut_args) + raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes) [ -z "$config_val" ] && { echo "Invalid kdump config value for option $config_opt." return 1; @@ -182,32 +258,77 @@ function check_config() ;; esac done < $KDUMP_CONFIG_FILE + + check_fence_kdump_config || return 1 + return 0 } -# check_fence_kdump -# return 0 if fence_kdump is configured and kdump initrd needs to be rebuilt -function check_fence_kdump() +# get_pcs_cluster_modified_files +# return list of modified file for fence_kdump modified in Pacemaker cluster +get_pcs_cluster_modified_files() { local image_time=$1 - local cib_time + local time_stamp + local modified_files - is_fence_kdump || return 1 + is_generic_fence_kdump && return 1 + is_pcs_fence_kdump || return 1 - cib_time=`pcs cluster cib | xmllint --xpath 'string(/cib/@cib-last-written)' - | \ - xargs -0 date +%s --date` + time_stamp=`pcs cluster cib | xmllint --xpath 'string(/cib/@cib-last-written)' - | \ + xargs -0 date +%s --date` - if [ -z $cib_time -o $cib_time -le $image_time ]; then - return 1 + if [ -n $time_stamp -a $time_stamp -gt $image_time ]; then + modified_files="cluster-cib" fi - return 0 + if [ -f $FENCE_KDUMP_CONFIG_FILE ]; then + time_stamp=`stat -c "%Y" $FENCE_KDUMP_CONFIG_FILE` + if [ "$time_stamp" -gt "$image_time" ]; then + modified_files="$modified_files $FENCE_KDUMP_CONFIG_FILE" + fi + fi + + echo $modified_files +} + +check_boot_dir() +{ + local _is_atomic + #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. + [ -n "$KDUMP_BOOTDIR" ] && return + + _is_atomic=$(cat /proc/cmdline | grep "ostree") + if [ -z "$_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) + fi } -function check_rebuild() +setup_target_initrd() +{ + if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + TARGET_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}.img" + if [ ! -s "$TARGET_INITRD" ]; then + echo "Error: No initrd found to rebuild!" + return 1 + fi + else + TARGET_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img" + fi +} + +check_rebuild() { local extra_modules modified_files="" local _force_rebuild force_rebuild="0" + local initramfs_has_fadump + + check_boot_dir if [ -z "$KDUMP_KERNELVER" ]; then kdump_kver=`uname -r` @@ -216,7 +337,10 @@ function check_rebuild() fi kdump_kernel="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}" - kdump_initrd="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img" + setup_target_initrd + if [ $? -ne 0 ]; then + return 1 + fi _force_rebuild=`grep ^force_rebuild $KDUMP_CONFIG_FILE 2>/dev/null` if [ $? -eq 0 ]; then @@ -233,25 +357,21 @@ function check_rebuild() #check to see if dependent files has been modified #since last build of the image file - if [ -f $kdump_initrd ]; then - image_time=`stat -c "%Y" $kdump_initrd 2>/dev/null` + if [ -f $TARGET_INITRD ]; then + image_time=`stat -c "%Y" $TARGET_INITRD 2>/dev/null` else image_time=0 fi - #also rebuild when cluster conf is changed and fence kdump is enabled. - check_fence_kdump $image_time && modified_files="cluster-cib" + #also rebuild when Pacemaker cluster conf is changed and fence kdump is enabled. + modified_files=$(get_pcs_cluster_modified_files $image_time) EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2` CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2` EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-` EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" - files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS" - - if [ -f $FENCE_KDUMP_CONFIG ]; then - files="$files $FENCE_KDUMP_CONFIG" - fi + files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS /etc/fstab" check_exist "$files" && check_executable "$EXTRA_BINS" [ $? -ne 0 ] && return 1 @@ -263,34 +383,41 @@ function check_rebuild() fi done + #check if target initrd has fadump support + if [ "$DEFAULT_DUMP_MODE" = "fadump" ] && [ -f "$TARGET_INITRD" ]; then + initramfs_has_fadump=`lsinitrd -m $TARGET_INITRD | grep ^kdumpbase$ | wc -l` + fi + if [ $image_time -eq 0 ]; then echo -n "No kdump initial ramdisk found."; echo + elif [ $DEFAULT_DUMP_MODE == "fadump" ] && [ "$initramfs_has_fadump" -eq "0" ]; then + echo "$TARGET_INITRD has no fadump support" elif [ "$force_rebuild" != "0" ]; then - echo -n "Force rebuild $kdump_initrd"; echo + echo -n "Force rebuild $TARGET_INITRD"; echo elif [ -n "$modified_files" ]; then - echo "Detected change(s) the following file(s):" + echo "Detected change(s) in the following file(s):" echo -n " "; echo "$modified_files" | sed 's/\s/\n /g' else return 0 fi - echo "Rebuilding $kdump_initrd" + echo "Rebuilding $TARGET_INITRD" rebuild_initrd return $? } # This function check iomem and determines if we have more than # 4GB of ram available. Returns 1 if we do, 0 if we dont -function need_64bit_headers() +need_64bit_headers() { - return `tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); \ - print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'` + return `tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); \ + print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'` } # Load the kdump kerel specified in /etc/sysconfig/kdump # If none is specified, try to load a kdump kernel with the same version # as the currently running kernel. -function load_kdump() +load_kdump() { MEM_RESERVED=$(cat /sys/kernel/kexec_crash_size) if [ $MEM_RESERVED -eq 0 ] @@ -325,9 +452,20 @@ function load_kdump() KDUMP_COMMANDLINE=`prepare_cmdline` + # For secureboot enabled machines, use new kexec file based syscall. + # Old syscall will always fail as it does not have capability to + # to kernel signature verification. + if is_secure_boot_enforced; then + echo "Secure Boot is enabled. Using kexec file based syscall." + KEXEC_ARGS="$KEXEC_ARGS -s" + elif is_secure_mode_enforced; then + echo "securelevel is set to 1 (Secure Mode). Using kexec file based syscall." + KEXEC_ARGS="$KEXEC_ARGS -s" + fi + $KEXEC $KEXEC_ARGS $standard_kexec_args \ --command-line="$KDUMP_COMMANDLINE" \ - --initrd=$kdump_initrd $kdump_kernel 2>/dev/null + --initrd=$TARGET_INITRD $kdump_kernel if [ $? == 0 ]; then echo "kexec: loaded kdump kernel" return 0 @@ -337,11 +475,11 @@ function load_kdump() fi } -function check_ssh_config() +check_ssh_config() { while read config_opt config_val; do - # remove inline comments after the end of a directive. - config_val=$(strip_comments $config_val) + # remove inline comments after the end of a directive. + config_val=$(strip_comments $config_val) case "$config_opt" in sshkey) if [ -f "$config_val" ]; then @@ -370,7 +508,7 @@ function check_ssh_config() return 0 } -function check_ssh_target() +check_ssh_target() { local _ret ssh -q -i $SSH_KEY_LOCATION -o BatchMode=yes $DUMP_TARGET mkdir -p $SAVE_PATH @@ -382,7 +520,7 @@ function check_ssh_target() return 0 } -function propagate_ssh_key() +propagate_ssh_key() { check_ssh_config if [ $? -ne 0 ]; then @@ -405,7 +543,7 @@ function propagate_ssh_key() #now find the target ssh user and server to contact. SSH_USER=`echo $DUMP_TARGET | cut -d\ -f2 | cut -d@ -f1` SSH_SERVER=`echo $DUMP_TARGET | sed -e's/\(.*@\)\(.*$\)/\2/'` - + #now send the found key to the found server ssh-copy-id -i $KEYFILE $SSH_USER@$SSH_SERVER RET=$? @@ -416,10 +554,28 @@ function propagate_ssh_key() echo $errmsg, $KEYFILE failed in transfer to $SSH_SERVER >&2 exit 1 fi - } -function check_current_kdump_status() +is_fadump_capable() +{ + # Check if firmware-assisted dump is enabled + # if no, fallback to kdump check + if [ -f $FADUMP_ENABLED_SYS_NODE ]; then + rc=`cat $FADUMP_ENABLED_SYS_NODE` + [ $rc -eq 1 ] && return 0 + fi + return 1 +} + +check_current_fadump_status() +{ + # Check if firmware-assisted dump has been registered. + rc=`cat $FADUMP_REGISTER_SYS_NODE` + [ $rc -eq 1 ] && return 0 + return 1 +} + +check_current_kdump_status() { rc=`cat /sys/kernel/kexec_crash_loaded` if [ $rc == 1 ]; then @@ -429,7 +585,18 @@ function check_current_kdump_status() fi } -function save_raw() +check_current_status() +{ + if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + check_current_fadump_status + else + check_current_kdump_status + fi + + return $? +} + +save_raw() { local kdump_dir local raw_target @@ -464,7 +631,8 @@ function save_raw() return 0 } -get_save_path() { +get_save_path() +{ local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}') if [ -z "$_save_path" ]; then _save_path="/var/crash" @@ -473,12 +641,13 @@ get_save_path() { echo $_save_path } -is_dump_target_configured() { - local _target +is_dump_target_configured() +{ + local _target - _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw|^ssh|^nfs" /etc/kdump.conf) + _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw|^ssh|^nfs" /etc/kdump.conf) - [ -n "$_target" ] + [ -n "$_target" ] } local_fs_dump_target() @@ -491,7 +660,8 @@ local_fs_dump_target() fi } -path_to_be_relabeled() { +path_to_be_relabeled() +{ local _path _target _mnt="/" _rmnt if is_dump_target_configured; then @@ -545,7 +715,7 @@ selinux_relabel() # more sane way. # # Assume efivars is mounted at /sys/firmware/efi/efivars. -function is_secure_boot_enforced() +is_secure_boot_enforced() { local secure_boot_file setup_mode_file local secure_boot_byte setup_mode_byte @@ -566,7 +736,7 @@ function is_secure_boot_enforced() } # Check if secure mode is being enforced (securelevel =? 1) -function is_secure_mode_enforced() +is_secure_mode_enforced() { local secure_mode_byte @@ -579,23 +749,63 @@ function is_secure_mode_enforced() return 1 } -function check_kdump_feasibility() +check_kdump_feasibility() { - if is_secure_boot_enforced; then - echo "Secure Boot is Enabled. Kdump service can't be started. Disable Secure Boot and retry" - return 1; - elif is_secure_mode_enforced; then - echo "securelevel is set to 1 (Secure Mode). Kdump service can't be started." + if [ ! -e /sys/kernel/kexec_crash_loaded ]; then + echo "Kdump is not supported on this kernel" return 1 fi +} - if [ ! -e /sys/kernel/kexec_crash_loaded ]; then - echo "Kdump is not supported on this kernel" +check_fence_kdump_config() +{ + local hostname=`hostname` + local nodes=$(get_option_value "fence_kdump_nodes") + + for node in $nodes; do + if [ "$node" = "$hostname" ]; then + echo "Option fence_kdump_nodes cannot contain $hostname" + return 1 + fi + done + + return 0 +} + +check_dump_feasibility() +{ + if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + return 0 + fi + + check_kdump_feasibility + return $? +} + +start_fadump() +{ + echo 1 > $FADUMP_REGISTER_SYS_NODE + if ! check_current_fadump_status; then + echo "fadump: failed to register" return 1 fi + + echo "fadump: registered successfully" + return 0 +} + +start_dump() +{ + if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + start_fadump + else + load_kdump + fi + + return $? } -function start() +start() { check_config if [ $? -ne 0 ]; then @@ -612,13 +822,13 @@ function start() return 1 fi - check_kdump_feasibility + check_dump_feasibility if [ $? -ne 0 ]; then echo "Starting kdump: [FAILED]" return 1 fi - check_current_kdump_status + check_current_status if [ $? == 0 ]; then echo "Kdump already running: [WARNING]" return 0 @@ -636,7 +846,8 @@ function start() echo "Starting kdump: [FAILED]" return 1 fi - load_kdump + + start_dump if [ $? != 0 ]; then echo "Starting kdump: [FAILED]" return 1 @@ -645,18 +856,50 @@ function start() echo "Starting kdump: [OK]" } -function stop() +stop_fadump() { - $KEXEC -p -u 2>/dev/null - if [ $? == 0 ]; then - echo "kexec: unloaded kdump kernel" - echo "Stopping kdump: [OK]" - return 0 + echo 0 > $FADUMP_REGISTER_SYS_NODE + if check_current_fadump_status; then + echo "fadump: failed to unregister" + return 1 + fi + + echo "fadump: unregistered successfully" + return 0 +} + +stop_kdump() +{ + if is_secure_boot_enforced; then + $KEXEC -s -p -u else - echo "kexec: failed to unloaded kdump kernel" + $KEXEC -p -u + fi + + if [ $? != 0 ]; then + echo "kexec: failed to unload kdump kernel" + return 1 + fi + + echo "kexec: unloaded kdump kernel" + return 0 +} + +stop() +{ + if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + stop_fadump + else + stop_kdump + fi + + if [ $? != 0 ]; then echo "Stopping kdump: [FAILED]" return 1 fi + + echo "Stopping kdump: [OK]" + return 0 } if [ ! -f "$KDUMP_CONFIG_FILE" ]; then @@ -666,6 +909,9 @@ fi main () { + # Determine if the dump mode is kdump or fadump + determine_dump_mode + case "$1" in start) if [ -s /proc/vmcore ]; then @@ -680,7 +926,7 @@ main () ;; status) EXIT_CODE=0 - check_current_kdump_status + check_current_status case "$?" in 0) echo "Kdump is operational" diff --git a/SOURCES/kexec-kdump-howto.txt b/SOURCES/kexec-kdump-howto.txt index 7ffeab9..05b497f 100644 --- a/SOURCES/kexec-kdump-howto.txt +++ b/SOURCES/kexec-kdump-howto.txt @@ -364,18 +364,56 @@ 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 - -By default, local file system vmcore files are written to /var/crash/%DATE -on the local system, ssh/scp dumps to /var/crash/%HOST-%DATE on the target -system, dedicated file system partition dumps to ./var/crash/%DATE, and -NFS dumps to ./var/crash/%HOST-%DATE, the latter two both relative to -their respective mount points within the kdump initrd (usually /mnt). The -'/var/crash' portion of the path can be overridden using kdump.conf's 'path' -variable, should you wish to write the vmcore out to a different location. For -example, 'path /data/coredumps' would lead to vmcore files being written to -/data/coredumps/%DATE if you were dumping to your local file system. Note -that the path option is ingnored if your kdump configuration results in the -core being saved from the initscripts in the root filesystem. +==== +"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. + +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. + +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. + +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. + +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. Kdump Post-Capture Executable diff --git a/SOURCES/kexec-tools-2.0.3-build-makedumpfile-eppic-shared-object.patch b/SOURCES/kexec-tools-2.0.3-build-makedumpfile-eppic-shared-object.patch deleted file mode 100644 index 15b953e..0000000 --- a/SOURCES/kexec-tools-2.0.3-build-makedumpfile-eppic-shared-object.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- kexec-tools-2.0.3/makedumpfile-1.5.4/Makefile.orig -+++ kexec-tools-2.0.3/makedumpfile-1.5.4/Makefile -@@ -60,7 +60,7 @@ LIBS := -lsnappy $(LIBS) - CFLAGS += -DUSESNAPPY - endif - --all: makedumpfile -+all: makedumpfile eppic_makedumpfile.so - - $(OBJ_PART): $(SRC_PART) - $(CC) $(CFLAGS) -c -o ./$@ ./$(@:.o=.c) -@@ -80,7 +80,7 @@ makedumpfile: $(SRC) $(OBJ_PART) $(OBJ_A - gzip -c ./makedumpfile.conf.5 > ./makedumpfile.conf.5.gz - - eppic_makedumpfile.so: extension_eppic.c -- $(CC) $(CFLAGS) -shared -rdynamic -o $@ extension_eppic.c -fPIC -leppic -ltinfo -+ $(CC) $(CFLAGS) -shared -rdynamic -o $@ extension_eppic.c -I../eppic/libeppic -fPIC ../eppic/libeppic/libeppic.a -ltinfo - - clean: - rm -f $(OBJ) $(OBJ_PART) $(OBJ_ARCH) makedumpfile makedumpfile.8.gz makedumpfile.conf.5.gz diff --git a/SOURCES/kexec-tools-2.0.4-Enumerate-all-sys-devices-system-cpu-cpuN-when-they-.patch b/SOURCES/kexec-tools-2.0.4-Enumerate-all-sys-devices-system-cpu-cpuN-when-they-.patch deleted file mode 100644 index 703ba3e..0000000 --- a/SOURCES/kexec-tools-2.0.4-Enumerate-all-sys-devices-system-cpu-cpuN-when-they-.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 08484c97ecce7df2ded8079c6478a58262007acc Mon Sep 17 00:00:00 2001 -From: Takao Indoh -Date: Thu, 5 Jun 2014 14:10:54 +0900 -Subject: [PATCH 1/2] Enumerate all /sys/devices/system/cpu/cpuN when they are - discontiguous - -There is a case that the number of /sys/devices/system/cpu/cpuN is not -contiguous, for example after cpu hot removing. This patch fixes so that -all /sys/devices/system/cpu/cpuN is handled when they are discontiguous. - -Signed-off-by: Takao Indoh -Reviewed-by: Zhang Yanfei -Acked-by: WANG Chao -Signed-off-by: Simon Horman ---- - kexec/crashdump-elf.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c -index 2baa357..c869347 100644 ---- a/kexec/crashdump-elf.c -+++ b/kexec/crashdump-elf.c -@@ -41,6 +41,7 @@ int FUNC(struct kexec_info *info, - uint64_t vmcoreinfo_addr, vmcoreinfo_len; - int has_vmcoreinfo = 0; - int (*get_note_info)(int cpu, uint64_t *addr, uint64_t *len); -+ long int count_cpu; - - if (xen_present()) - nr_cpus = xen_get_nr_phys_cpus(); -@@ -138,11 +139,13 @@ int FUNC(struct kexec_info *info, - - /* PT_NOTE program headers. One per cpu */ - -- for (i = 0; i < nr_cpus; i++) { -+ count_cpu = nr_cpus; -+ for (i = 0; count_cpu > 0; i++) { - if (get_note_info(i, ¬es_addr, ¬es_len) < 0) { - /* This cpu is not present. Skip it. */ - continue; - } -+ count_cpu--; - - phdr = (PHDR *) bufp; - bufp += sizeof(PHDR); --- -1.9.3 - diff --git a/SOURCES/kexec-tools-2.0.4-Fix-mistaken-check-of-stat-2-return-value.patch b/SOURCES/kexec-tools-2.0.4-Fix-mistaken-check-of-stat-2-return-value.patch deleted file mode 100644 index 2708daa..0000000 --- a/SOURCES/kexec-tools-2.0.4-Fix-mistaken-check-of-stat-2-return-value.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 272ceb535415437041f989278635ac8de729cd6b Mon Sep 17 00:00:00 2001 -From: Takao Indoh -Date: Thu, 5 Jun 2014 14:10:55 +0900 -Subject: [PATCH 2/2] Fix mistaken check of stat(2) return value - -get_crash_notes_per_cpu() should return -1 if return value of stat(2) is -zero (on success). - -Signed-off-by: Takao Indoh -Reviewed-by: Zhang Yanfei -Acked-by: WANG Chao -Signed-off-by: Simon Horman ---- - kexec/crashdump.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/kexec/crashdump.c b/kexec/crashdump.c -index 131e624..15c1105 100644 ---- a/kexec/crashdump.c -+++ b/kexec/crashdump.c -@@ -84,7 +84,7 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len) - if (fopen_errno != ENOENT) - die("Could not open \"%s\": %s\n", crash_notes, - strerror(fopen_errno)); -- if (!stat("/sys/devices", &cpu_stat)) { -+ if (stat("/sys/devices", &cpu_stat)) { - stat_errno = errno; - if (stat_errno == ENOENT) - die("\"/sys/devices\" does not exist. " --- -1.9.3 - diff --git a/SOURCES/kexec-tools-2.0.4-Revert-kexec-include-reserved-e820-sections-in-crash.patch b/SOURCES/kexec-tools-2.0.4-Revert-kexec-include-reserved-e820-sections-in-crash.patch deleted file mode 100644 index a37c3a5..0000000 --- a/SOURCES/kexec-tools-2.0.4-Revert-kexec-include-reserved-e820-sections-in-crash.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 1a4e90ba221684e563bf1baf06f3547cd95e60b0 Mon Sep 17 00:00:00 2001 -Message-Id: <1a4e90ba221684e563bf1baf06f3547cd95e60b0.1380267809.git.bhe@redhat.com> -From: Zhang Yanfei -Date: Sun, 31 Mar 2013 11:12:53 +0800 -Subject: [PATCH] Revert "kexec: include reserved e820 sections in crash - kernel" - -This reverts commit e35aa29fb40b37bf86d980b2e19af5e01c2d2549. -This patch is based on the commit 49320340f705694e387d794f7f19d407ad9baefa - "kexec: lengthen the kernel command line image" -Since the latter commit has been reverted due to its useless, this -patch should be reverted too. - -Besides, This patch also changed a kernel restriction of max segments -from 16 to 70. Though kexec-tools could have more segments, more than 16, -the kexec_load syscall will still fail for the kernel side has a restriction -of 16. - -Cc: Cliff Wickman -Signed-off-by: Zhang Yanfei -Signed-off-by: Simon Horman -Signed-off-by: Baoquan He ---- - kexec/arch/i386/crashdump-x86.c | 31 ++----------------------------- - kexec/kexec-syscall.h | 2 +- - 2 files changed, 3 insertions(+), 30 deletions(-) - -diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c -index 4167e5e..e44fceb 100644 ---- a/kexec/arch/i386/crashdump-x86.c -+++ b/kexec/arch/i386/crashdump-x86.c -@@ -247,8 +247,6 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, - type = RANGE_ACPI; - } else if(memcmp(str,"ACPI Non-volatile Storage\n",26) == 0 ) { - type = RANGE_ACPI_NVS; -- } else if(memcmp(str,"reserved\n", 9) == 0 ) { -- type = RANGE_RESERVED; - } else if (memcmp(str, "GART\n", 5) == 0) { - gart_start = start; - gart_end = end; -@@ -908,27 +906,6 @@ static void get_backup_area(struct kexec_info *info, - info->backup_src_size = BACKUP_SRC_END - BACKUP_SRC_START + 1; - } - --/* Appends memmap=X$Y commandline for reserved memory to command line*/ --static int cmdline_add_memmap_reserved(char *cmdline, unsigned long start, -- unsigned long end) --{ -- int align = 1024; -- unsigned long startk, endk; -- -- if (!(end - start)) -- return 0; -- -- startk = start/1024; -- endk = (end + align - 1)/1024; -- cmdline_add_memmap_internal(cmdline, startk, endk, RANGE_RESERVED); -- --#ifdef DEBUG -- printf("Command line after adding reserved memmap\n"); -- printf("%s\n", cmdline); --#endif -- return 0; --} -- - /* Loads additional segments in case of a panic kernel is being loaded. - * One segment for backup region, another segment for storing elf headers - * for crash memory image. -@@ -1076,15 +1053,11 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, - for (i = 0; i < CRASH_MAX_MEMORY_RANGES; i++) { - unsigned long start, end; - if ( !( mem_range[i].type == RANGE_ACPI -- || mem_range[i].type == RANGE_ACPI_NVS -- || mem_range[i].type == RANGE_RESERVED) ) -+ || mem_range[i].type == RANGE_ACPI_NVS) ) - continue; - start = mem_range[i].start; - end = mem_range[i].end; -- if (mem_range[i].type == RANGE_RESERVED) -- cmdline_add_memmap_reserved(mod_cmdline, start, end); -- else -- cmdline_add_memmap_acpi(mod_cmdline, start, end); -+ cmdline_add_memmap_acpi(mod_cmdline, start, end); - } - return 0; - } -diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h -index f5ee992..b56cb00 100644 ---- a/kexec/kexec-syscall.h -+++ b/kexec/kexec-syscall.h -@@ -78,7 +78,7 @@ static inline long kexec_load(void *entry, unsigned long nr_segments, - #define KEXEC_ARCH_MIPS ( 8 << 16) - #define KEXEC_ARCH_CRIS (76 << 16) - --#define KEXEC_MAX_SEGMENTS 70 -+#define KEXEC_MAX_SEGMENTS 16 - - #ifdef __i386__ - #define KEXEC_ARCH_NATIVE KEXEC_ARCH_386 --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-Revert-kexec-lengthen-the-kernel-command-line-image.patch b/SOURCES/kexec-tools-2.0.4-Revert-kexec-lengthen-the-kernel-command-line-image.patch deleted file mode 100644 index 742d1f0..0000000 --- a/SOURCES/kexec-tools-2.0.4-Revert-kexec-lengthen-the-kernel-command-line-image.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 827491661670e3d7f8edf08cce2ed0f423d710eb Mon Sep 17 00:00:00 2001 -Message-Id: <827491661670e3d7f8edf08cce2ed0f423d710eb.1380270065.git.bhe@redhat.com> -From: Zhang Yanfei -Date: Wed, 27 Mar 2013 20:42:28 +0800 -Subject: [PATCH] Revert: "kexec: lengthen the kernel command line image" - -This reverts commit 49320340f705694e387d794f7f19d407ad9baefa. The change -of COMMAND_LINE_SIZE cannot solve Cliff's problem since the kernel side -has the restriction, so it is useless. Let's recover the original value -defined by kernel side. - -Cc: Cliff Wickman -Signed-off-by: Zhang Yanfei -Signed-off-by: Simon Horman -Signed-off-by: Baoquan He ---- - include/x86/x86-linux.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/include/x86/x86-linux.h b/include/x86/x86-linux.h -index 6681f9e..0949dc2 100644 ---- a/include/x86/x86-linux.h -+++ b/include/x86/x86-linux.h -@@ -197,7 +197,7 @@ struct x86_linux_param_header { - uint8_t _pad8[48]; /* 0xcd0 */ - struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */ - /* 0xeec */ --#define COMMAND_LINE_SIZE (64*1024) -+#define COMMAND_LINE_SIZE 2048 - }; - - struct x86_linux_faked_param_header { --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-kdump-x86-Process-multiple-Crash-kernel-in-proc-iome.patch b/SOURCES/kexec-tools-2.0.4-kdump-x86-Process-multiple-Crash-kernel-in-proc-iome.patch deleted file mode 100644 index 9e2fb41..0000000 --- a/SOURCES/kexec-tools-2.0.4-kdump-x86-Process-multiple-Crash-kernel-in-proc-iome.patch +++ /dev/null @@ -1,230 +0,0 @@ -From e25e6e7593cae350ecaa3fcd6d20c7de87f4c309 Mon Sep 17 00:00:00 2001 -From: Yinghai Lu -Date: Fri, 22 Mar 2013 13:54:06 -0700 -Subject: [PATCH] kdump, x86: Process multiple Crash kernel in /proc/iomem - -Vivek found specical handling crashkernel low in not good. -We should extend kexec-tools to handle multiple Crash kernel instead. - -Extend crash_reserved_mem to array instead and use -kexec_iomem_for_each_line directly. After that we can drop -crashkernel low. - --v2: fix left over calling of parse_iomem_single() found by Vivek. - -Suggested-by: Vivek Goyal -Signed-off-by: Yinghai Lu -Signed-off-by: Simon Horman ---- - kexec/arch/i386/crashdump-x86.c | 107 +++++++++++++++++++++---------------- - kexec/arch/i386/kexec-x86-common.c | 4 +- - kexec/kexec.h | 1 + - 3 files changed, 65 insertions(+), 47 deletions(-) - -diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c -index 9ab648b..4167e5e 100644 ---- a/kexec/arch/i386/crashdump-x86.c -+++ b/kexec/arch/i386/crashdump-x86.c -@@ -188,9 +188,9 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end); - static struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES]; - - /* Memory region reserved for storing panic kernel and other data. */ --static struct memory_range crash_reserved_mem; --/* under 4G parts */ --static struct memory_range crash_reserved_low_mem; -+#define CRASH_RESERVED_MEM_NR 8 -+static struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR]; -+static int crash_reserved_mem_nr; - - /* Reads the appropriate file and retrieves the SYSTEM RAM regions for whom to - * create Elf headers. Keeping it separate from get_memory_ranges() as -@@ -207,7 +207,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, - int kexec_flags, unsigned long lowmem_limit) - { - const char *iomem = proc_iomem(); -- int memory_ranges = 0, gart = 0; -+ int memory_ranges = 0, gart = 0, i; - char line[MAX_LINE]; - FILE *fp; - unsigned long long start, end; -@@ -268,29 +268,28 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, - } - fclose(fp); - if (kexec_flags & KEXEC_PRESERVE_CONTEXT) { -- int i; - for (i = 0; i < memory_ranges; i++) { - if (crash_memory_range[i].end > 0x0009ffff) { -- crash_reserved_mem.start = \ -+ crash_reserved_mem[0].start = \ - crash_memory_range[i].start; - break; - } - } -- if (crash_reserved_mem.start >= mem_max) { -+ if (crash_reserved_mem[0].start >= mem_max) { - fprintf(stderr, "Too small mem_max: 0x%llx.\n", - mem_max); - return -1; - } -- crash_reserved_mem.end = mem_max; -- crash_reserved_mem.type = RANGE_RAM; -+ crash_reserved_mem[0].end = mem_max; -+ crash_reserved_mem[0].type = RANGE_RAM; -+ crash_reserved_mem_nr = 1; - } -- if (exclude_region(&memory_ranges, crash_reserved_mem.start, -- crash_reserved_mem.end) < 0) -- return -1; -- if (crash_reserved_low_mem.start && -- exclude_region(&memory_ranges, crash_reserved_low_mem.start, -- crash_reserved_low_mem.end) < 0) -- return -1; -+ -+ for (i = 0; i < crash_reserved_mem_nr; i++) -+ if (exclude_region(&memory_ranges, crash_reserved_mem[i].start, -+ crash_reserved_mem[i].end) < 0) -+ return -1; -+ - if (gart) { - /* exclude GART region if the system has one */ - if (exclude_region(&memory_ranges, gart_start, gart_end) < 0) -@@ -351,9 +350,10 @@ static int get_crash_memory_ranges_xen(struct memory_range **range, - - qsort(*range, *ranges, sizeof(struct memory_range), compare_ranges); - -- if (exclude_region(ranges, crash_reserved_mem.start, -- crash_reserved_mem.end) < 0) -- goto err; -+ for (i = 0; i < crash_reserved_mem_nr; i++) -+ if (exclude_region(ranges, crash_reserved_mem[i].start, -+ crash_reserved_mem[i].end) < 0) -+ goto err; - - ret = 0; - -@@ -434,9 +434,10 @@ static int get_crash_memory_ranges_xen(struct memory_range **range, - - qsort(*range, *ranges, sizeof(struct memory_range), compare_ranges); - -- if (exclude_region(ranges, crash_reserved_mem.start, -- crash_reserved_mem.end) < 0) -- goto err; -+ for (i = 0; i < crash_reserved_mem_nr; i++) -+ if (exclude_region(ranges, crash_reserved_mem[i].start, -+ crash_reserved_mem[i].end) < 0) -+ goto err; - - ret = 0; - -@@ -1014,15 +1015,10 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, - memmap_p = xmalloc(sz); - memset(memmap_p, 0, sz); - add_memmap(memmap_p, info->backup_src_start, info->backup_src_size); -- sz = crash_reserved_mem.end - crash_reserved_mem.start +1; -- if (add_memmap(memmap_p, crash_reserved_mem.start, sz) < 0) { -- return ENOCRASHKERNEL; -- } -- -- if (crash_reserved_low_mem.start) { -- sz = crash_reserved_low_mem.end - crash_reserved_low_mem.start -- +1; -- add_memmap(memmap_p, crash_reserved_low_mem.start, sz); -+ for (i = 0; i < crash_reserved_mem_nr; i++) { -+ sz = crash_reserved_mem[i].end - crash_reserved_mem[i].start +1; -+ if (add_memmap(memmap_p, crash_reserved_mem[i].start, sz) < 0) -+ return ENOCRASHKERNEL; - } - - /* Create a backup region segment to store backup data*/ -@@ -1093,25 +1089,46 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, - return 0; - } - --int is_crashkernel_mem_reserved(void) -+int get_max_crash_kernel_limit(uint64_t *start, uint64_t *end) - { -- uint64_t start, end; -+ int i, idx = -1; -+ unsigned long sz_max = 0, sz; - -- if (parse_iomem_single("Crash kernel\n", &start, &end) || start == end) -- return 0; -+ if (!crash_reserved_mem_nr) -+ return -1; - -- crash_reserved_mem.start = start; -- crash_reserved_mem.end = end; -- crash_reserved_mem.type = RANGE_RAM; -+ for (i = crash_reserved_mem_nr - 1; i >= 0; i--) { -+ sz = crash_reserved_mem[i].end - crash_reserved_mem[i].start +1; -+ if (sz <= sz_max) -+ continue; -+ sz_max = sz; -+ idx = i; -+ } -+ -+ *start = crash_reserved_mem[idx].start; -+ *end = crash_reserved_mem[idx].end; -+ -+ return 0; -+} - -- /* If there is no Crash low kernel, still can go on */ -- if (parse_iomem_single("Crash kernel low\n", &start, &end) || -- start == end) -+static int crashkernel_mem_callback(void *UNUSED(data), int nr, -+ char *UNUSED(str), -+ unsigned long base, -+ unsigned long length) -+{ -+ if (nr >= CRASH_RESERVED_MEM_NR) - return 1; - -- crash_reserved_low_mem.start = start; -- crash_reserved_low_mem.end = end; -- crash_reserved_low_mem.type = RANGE_RAM; -+ crash_reserved_mem[nr].start = base; -+ crash_reserved_mem[nr].end = base + length - 1; -+ crash_reserved_mem[nr].type = RANGE_RAM; -+ return 0; -+} -+ -+int is_crashkernel_mem_reserved(void) -+{ -+ crash_reserved_mem_nr = kexec_iomem_for_each_line("Crash kernel\n", -+ crashkernel_mem_callback, NULL); - -- return 1; -+ return !!crash_reserved_mem_nr; - } -diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c -index 234823c..ed6c950 100644 ---- a/kexec/arch/i386/kexec-x86-common.c -+++ b/kexec/arch/i386/kexec-x86-common.c -@@ -465,9 +465,9 @@ int get_memory_ranges(struct memory_range **range, int *ranges, - !(kexec_flags & KEXEC_PRESERVE_CONTEXT)) { - uint64_t start, end; - -- ret = parse_iomem_single("Crash kernel\n", &start, &end); -+ ret = get_max_crash_kernel_limit(&start, &end); - if (ret != 0) { -- fprintf(stderr, "parse_iomem_single failed.\n"); -+ fprintf(stderr, "get_max_crash_kernel_limit failed.\n"); - return -1; - } - -diff --git a/kexec/kexec.h b/kexec/kexec.h -index 916a24b..5ded390 100644 ---- a/kexec/kexec.h -+++ b/kexec/kexec.h -@@ -272,6 +272,7 @@ int arch_process_options(int argc, char **argv); - int arch_compat_trampoline(struct kexec_info *info); - void arch_update_purgatory(struct kexec_info *info); - int is_crashkernel_mem_reserved(void); -+int get_max_crash_kernel_limit(uint64_t *start, uint64_t *end); - char *get_command_line(void); - - int kexec_iomem_for_each_line(char *match, --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-kexec-i386-Add-cmdline_add_memmap_internal-to-reduce.patch b/SOURCES/kexec-tools-2.0.4-kexec-i386-Add-cmdline_add_memmap_internal-to-reduce.patch deleted file mode 100644 index c222834..0000000 --- a/SOURCES/kexec-tools-2.0.4-kexec-i386-Add-cmdline_add_memmap_internal-to-reduce.patch +++ /dev/null @@ -1,150 +0,0 @@ -From dc607e4d43308140b4cee6c4503ee71f32b827ad Mon Sep 17 00:00:00 2001 -Message-Id: -From: Zhang Yanfei -Date: Thu, 28 Mar 2013 21:09:59 +0800 -Subject: [PATCH] kexec: i386: Add cmdline_add_memmap_internal() to reduce the - code duplication - -Functions: -- cmdline_add_memmap() -- cmdline_add_memmap_acpi() -- cmdline_add_memmap_reserved() -is kind of similar, So add a new function cmdline_add_memmap_internal() to -hold the common codes, reducing the duplication. - -Signed-off-by: Zhang Yanfei -Signed-off-by: Simon Horman -Signed-off-by: Baoquan He ---- - kexec/arch/i386/crashdump-x86.c | 74 ++++++++++++++++++----------------------- - 1 file changed, 33 insertions(+), 41 deletions(-) - -diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c -index 5462f8b..9ab648b 100644 ---- a/kexec/arch/i386/crashdump-x86.c -+++ b/kexec/arch/i386/crashdump-x86.c -@@ -685,13 +685,40 @@ static void ultoa(unsigned long i, char *str) - } - } - -+static void cmdline_add_memmap_internal(char *cmdline, unsigned long startk, -+ unsigned long endk, int type) -+{ -+ int cmdlen, len; -+ char str_mmap[256], str_tmp[20]; -+ -+ strcpy (str_mmap, " memmap="); -+ ultoa((endk-startk), str_tmp); -+ strcat (str_mmap, str_tmp); -+ -+ if (type == RANGE_RAM) -+ strcat (str_mmap, "K@"); -+ else if (type == RANGE_RESERVED) -+ strcat (str_mmap, "K$"); -+ else if (type == RANGE_ACPI || type == RANGE_ACPI_NVS) -+ strcat (str_mmap, "K#"); -+ -+ ultoa(startk, str_tmp); -+ strcat (str_mmap, str_tmp); -+ strcat (str_mmap, "K"); -+ len = strlen(str_mmap); -+ cmdlen = strlen(cmdline) + len; -+ if (cmdlen > (COMMAND_LINE_SIZE - 1)) -+ die("Command line overflow\n"); -+ strcat(cmdline, str_mmap); -+} -+ - /* Adds the appropriate memmap= options to command line, indicating the - * memory regions the new kernel can use to boot into. */ - static int cmdline_add_memmap(char *cmdline, struct memory_range *memmap_p) - { - int i, cmdlen, len; - unsigned long min_sizek = 100; -- char str_mmap[256], str_tmp[20]; -+ char str_mmap[256]; - - /* Exact map */ - strcpy(str_mmap, " memmap=exactmap"); -@@ -713,18 +740,7 @@ static int cmdline_add_memmap(char *cmdline, struct memory_range *memmap_p) - * up precious command line length. */ - if ((endk - startk) < min_sizek) - continue; -- strcpy (str_mmap, " memmap="); -- ultoa((endk-startk), str_tmp); -- strcat (str_mmap, str_tmp); -- strcat (str_mmap, "K@"); -- ultoa(startk, str_tmp); -- strcat (str_mmap, str_tmp); -- strcat (str_mmap, "K"); -- len = strlen(str_mmap); -- cmdlen = strlen(cmdline) + len; -- if (cmdlen > (COMMAND_LINE_SIZE - 1)) -- die("Command line overflow\n"); -- strcat(cmdline, str_mmap); -+ cmdline_add_memmap_internal(cmdline, startk, endk, RANGE_RAM); - } - - dbgprintf("Command line after adding memmap\n"); -@@ -817,27 +833,15 @@ static enum coretype get_core_type(struct crash_elf_info *elf_info, - static int cmdline_add_memmap_acpi(char *cmdline, unsigned long start, - unsigned long end) - { -- int cmdlen, len, align = 1024; -+ int align = 1024; - unsigned long startk, endk; -- char str_mmap[256], str_tmp[20]; - - if (!(end - start)) - return 0; - - startk = start/1024; - endk = (end + align - 1)/1024; -- strcpy (str_mmap, " memmap="); -- ultoa((endk - startk), str_tmp); -- strcat (str_mmap, str_tmp); -- strcat (str_mmap, "K#"); -- ultoa(startk, str_tmp); -- strcat (str_mmap, str_tmp); -- strcat (str_mmap, "K"); -- len = strlen(str_mmap); -- cmdlen = strlen(cmdline) + len; -- if (cmdlen > (COMMAND_LINE_SIZE - 1)) -- die("Command line overflow\n"); -- strcat(cmdline, str_mmap); -+ cmdline_add_memmap_internal(cmdline, startk, endk, RANGE_ACPI); - - dbgprintf("Command line after adding acpi memmap\n"); - dbgprintf("%s\n", cmdline); -@@ -907,27 +911,15 @@ static void get_backup_area(struct kexec_info *info, - static int cmdline_add_memmap_reserved(char *cmdline, unsigned long start, - unsigned long end) - { -- int cmdlen, len, align = 1024; -+ int align = 1024; - unsigned long startk, endk; -- char str_mmap[256], str_tmp[20]; - - if (!(end - start)) - return 0; - - startk = start/1024; - endk = (end + align - 1)/1024; -- strcpy (str_mmap, " memmap="); -- ultoa((endk - startk), str_tmp); -- strcat (str_mmap, str_tmp); -- strcat (str_mmap, "K$"); -- ultoa(startk, str_tmp); -- strcat (str_mmap, str_tmp); -- strcat (str_mmap, "K"); -- len = strlen(str_mmap); -- cmdlen = strlen(cmdline) + len; -- if (cmdlen > (COMMAND_LINE_SIZE - 1)) -- die("Command line overflow\n"); -- strcat(cmdline, str_mmap); -+ cmdline_add_memmap_internal(cmdline, startk, endk, RANGE_RESERVED); - - #ifdef DEBUG - printf("Command line after adding reserved memmap\n"); --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch deleted file mode 100644 index c834227..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch +++ /dev/null @@ -1,43 +0,0 @@ -From eb708cedde4ed48dde5a918a23b2c3b8235df6c5 Mon Sep 17 00:00:00 2001 -From: Baoquan He -Date: Tue, 2 Jul 2013 11:11:07 +0900 -Subject: [PATCH 2/2] [PATCH 2/2] Add help and man message for '--help'. - -Conventionally '-h' and '--help' are all provided. Currently makedumpfile -lacks help and man message for '--help'. Here add it. - -Signed-off-by: Baoquan He ---- - makedumpfile.8 | 2 +- - print_info.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/makedumpfile-1.5.4/makedumpfile.8 b/makedumpfile-1.5.4/makedumpfile.8 -index adeb811..f50a011 100644 ---- a/makedumpfile-1.5.4/makedumpfile.8 -+++ b/makedumpfile-1.5.4/makedumpfile.8 -@@ -539,7 +539,7 @@ order from left to right. \fIVMCORE\fRs are assembled into a single - Print debugging message. - - .TP --\fB\-h\fR -+\fB\-h (\-\-help)\fR - Show help message and LZO/snappy support status (enabled/disabled). - - .TP -diff --git a/makedumpfile-1.5.4/print_info.c b/makedumpfile-1.5.4/print_info.c -index 06939e0..3527970 100644 ---- a/makedumpfile-1.5.4/print_info.c -+++ b/makedumpfile-1.5.4/print_info.c -@@ -255,7 +255,7 @@ print_usage(void) - MSG(" [-f]:\n"); - MSG(" Overwrite DUMPFILE even if it already exists.\n"); - MSG("\n"); -- MSG(" [-h]:\n"); -+ MSG(" [-h, --help]:\n"); - MSG(" Show help message and LZO/snappy support status (enabled/disabled).\n"); - MSG("\n"); - MSG(" [-v]:\n"); --- -1.8.4.2 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch deleted file mode 100644 index 8a9ee47..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch +++ /dev/null @@ -1,161 +0,0 @@ -From a895dc8f2a17f7dac9d3d63de1cea4720557625d Mon Sep 17 00:00:00 2001 -From: Atsushi Kumagai -Date: Thu, 12 Dec 2013 16:40:12 +0900 -Subject: [PATCH 1/2] [PATCH] Add --non-mmap option to disable mmap() manually. - -When --non-mmap option is specified, makedumpfile doesn't use -mmap() even if /proc/vmcore supports mmap(). - -Signed-off-by: Atsushi Kumagai ---- - makedumpfile.8 | 11 +++++++++++ - makedumpfile.c | 29 +++++++++++++++++++---------- - makedumpfile.h | 9 +++++++++ - print_info.c | 6 ++++++ - 4 files changed, 45 insertions(+), 10 deletions(-) - -diff --git a/makedumpfile-1.5.4/makedumpfile.8 b/makedumpfile-1.5.4/makedumpfile.8 -index f50a011..227b6f7 100644 ---- a/makedumpfile-1.5.4/makedumpfile.8 -+++ b/makedumpfile-1.5.4/makedumpfile.8 -@@ -395,6 +395,17 @@ If you feel the cyclic mode is too slow, please try this mode. - # makedumpfile \-\-non\-cyclic \-d 31 \-x vmlinux /proc/vmcore dumpfile - - .TP -+\fB\-\-non\-mmap\fR -+Never use \fBmmap(2)\fR to read \fIVMCORE\fR even if it supports \fBmmap(2)\fR. -+Generally, reading \fIVMCORE\fR with \fBmmap(2)\fR is faster than without it, -+so ordinary users don't need to specify this option. -+This option is mainly for debugging. -+.br -+.B Example: -+.br -+# makedumpfile \-\-non\-mmap \-d 31 \-x vmlinux /proc/vmcore dumpfile -+ -+.TP - \fB\-\-xen-syms\fR \fIXEN-SYMS\fR - Specify the \fIXEN-SYMS\fR with debug information to analyze the xen's memory usage. - This option extracts the part of xen and domain-0. -diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c -index 600fb5d..b3af28b 100644 ---- a/makedumpfile-1.5.4/makedumpfile.c -+++ b/makedumpfile-1.5.4/makedumpfile.c -@@ -272,7 +272,7 @@ update_mmap_range(off_t offset, int initial) { - static int - is_mapped_with_mmap(off_t offset) { - -- if (info->flag_usemmap -+ if (info->flag_usemmap == MMAP_ENABLE - && offset >= info->mmap_start_offset - && offset < info->mmap_end_offset) - return TRUE; -@@ -320,7 +320,7 @@ read_from_vmcore(off_t offset, void *bufptr, unsigned long size) - { - const off_t failed = (off_t)-1; - -- if (info->flag_usemmap) { -+ if (info->flag_usemmap == MMAP_ENABLE) { - if (!read_with_mmap(offset, bufptr, size)) { - ERRMSG("Can't read the dump memory(%s) with mmap().\n", - info->name_memory); -@@ -3175,14 +3175,14 @@ out: - if (info->dump_level & DL_EXCLUDE_FREE) - setup_page_is_buddy(); - -- if (!initialize_mmap()) { -- /* this kernel does not support mmap of vmcore */ -- DEBUG_MSG("Kernel can't mmap vmcore, using reads.\n"); -- info->flag_usemmap = FALSE; -+ if (info->flag_usemmap == MMAP_TRY && initialize_mmap()) { -+ DEBUG_MSG("mmap() is available on the kernel.\n"); -+ info->flag_usemmap = MMAP_ENABLE; - } else { -- DEBUG_MSG("read %s with mmap()\n", info->name_memory); -- info->flag_usemmap = TRUE; -- } -+ DEBUG_MSG("The kernel doesn't support mmap(),"); -+ DEBUG_MSG("read() will be used instead.\n"); -+ info->flag_usemmap = MMAP_DISABLE; -+ } - - return TRUE; - } -@@ -8947,6 +8947,7 @@ static struct option longopts[] = { - {"non-cyclic", no_argument, NULL, OPT_NON_CYCLIC}, - {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER}, - {"eppic", required_argument, NULL, OPT_EPPIC}, -+ {"non-mmap", no_argument, NULL, OPT_NON_MMAP}, - {0, 0, 0, 0} - }; - -@@ -8972,7 +8973,12 @@ main(int argc, char *argv[]) - * By default, makedumpfile works in constant memory space. - */ - info->flag_cyclic = TRUE; -- -+ -+ /* -+ * By default, makedumpfile try to use mmap(2) to read /proc/vmcore. -+ */ -+ info->flag_usemmap = MMAP_TRY; -+ - info->block_order = DEFAULT_ORDER; - message_level = DEFAULT_MSG_LEVEL; - while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lpRvXx:", longopts, -@@ -9069,6 +9075,9 @@ main(int argc, char *argv[]) - case OPT_NON_CYCLIC: - info->flag_cyclic = FALSE; - break; -+ case OPT_NON_MMAP: -+ info->flag_usemmap = MMAP_DISABLE; -+ break; - case OPT_XEN_VMCOREINFO: - info->flag_read_vmcoreinfo = 1; - info->name_vmcoreinfo = optarg; -diff --git a/makedumpfile-1.5.4/makedumpfile.h b/makedumpfile-1.5.4/makedumpfile.h -index 517e16e..fe88eff 100644 ---- a/makedumpfile-1.5.4/makedumpfile.h -+++ b/makedumpfile-1.5.4/makedumpfile.h -@@ -128,6 +128,14 @@ enum { - MADDR_XEN - }; - -+/* -+ * State of mmap(2) -+ */ -+enum { -+ MMAP_DISABLE, -+ MMAP_TRY, -+ MMAP_ENABLE, -+}; - - static inline int - test_bit(int nr, unsigned long addr) -@@ -1741,6 +1749,7 @@ struct elf_prstatus { - #define OPT_NON_CYCLIC OPT_START+10 - #define OPT_CYCLIC_BUFFER OPT_START+11 - #define OPT_EPPIC OPT_START+12 -+#define OPT_NON_MMAP OPT_START+13 - - /* - * Function Prototype. -diff --git a/makedumpfile-1.5.4/print_info.c b/makedumpfile-1.5.4/print_info.c -index d7a8600..90b6cee 100644 ---- a/makedumpfile-1.5.4/print_info.c -+++ b/makedumpfile-1.5.4/print_info.c -@@ -196,6 +196,12 @@ print_usage(void) - MSG(" same as v1.4.4 or before.\n"); - MSG(" If you feel the cyclic mode is too slow, please try this mode.\n"); - MSG("\n"); -+ MSG(" [--non-mmap]:\n"); -+ MSG(" Never use mmap(2) to read VMCORE even if it supports mmap(2).\n"); -+ MSG(" Generally, reading VMCORE with mmap(2) is faster than without it,\n"); -+ MSG(" so ordinary users don't need to specify this option.\n"); -+ MSG(" This option is mainly for debugging.\n"); -+ MSG("\n"); - MSG(" [--xen-syms XEN-SYMS]:\n"); - MSG(" Specify the XEN-SYMS to analyze Xen's memory usage.\n"); - MSG("\n"); --- -1.8.4.2 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Add-vmap_area_list-definition-for-ppc-ppc64.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Add-vmap_area_list-definition-for-ppc-ppc64.patch deleted file mode 100644 index 8b0a226..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Add-vmap_area_list-definition-for-ppc-ppc64.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 150b58eb299066c65ef7713a93effc35c00be03a Mon Sep 17 00:00:00 2001 -Message-Id: <150b58eb299066c65ef7713a93effc35c00be03a.1374133991.git.bhe@redhat.com> -From: Baoquan He -Date: Mon, 15 Jul 2013 20:37:14 +0800 -Subject: [PATCH] [PATCH] Add vmap_area_list definition for ppc/ppc64. - -vmap_area_list is added to get vmalloc_start for ppc/ppc64, but its -definition is missing, now add them. - -Signed-off-by: Baoquan He ---- - makedumpfile-1.5.4/arch/ppc.c | 2 +- - makedumpfile-1.5.4/arch/ppc64.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/makedumpfile-1.5.4/arch/ppc.c b/makedumpfile-1.5.4/arch/ppc.c -index a9b4812..a3e1a12 100644 ---- a/makedumpfile-1.5.4/arch/ppc.c -+++ b/makedumpfile-1.5.4/arch/ppc.c -@@ -28,7 +28,7 @@ - int - get_machdep_info_ppc(void) - { -- unsigned long vmlist, vmalloc_start; -+ unsigned long vmlist, vmap_area_list, vmalloc_start; - - info->section_size_bits = _SECTION_SIZE_BITS; - info->max_physmem_bits = _MAX_PHYSMEM_BITS; -diff --git a/makedumpfile-1.5.4/arch/ppc64.c b/makedumpfile-1.5.4/arch/ppc64.c -index c229ede..85144f6 100644 ---- a/makedumpfile-1.5.4/arch/ppc64.c -+++ b/makedumpfile-1.5.4/arch/ppc64.c -@@ -49,7 +49,7 @@ set_ppc64_max_physmem_bits(void) - int - get_machdep_info_ppc64(void) - { -- unsigned long vmlist, vmalloc_start; -+ unsigned long vmlist, vmap_area_list, vmalloc_start; - - info->section_size_bits = _SECTION_SIZE_BITS; - if (!set_ppc64_max_physmem_bits()) { --- -1.7.1 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch deleted file mode 100644 index 115e3d8..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch +++ /dev/null @@ -1,244 +0,0 @@ -From bd67c1d5e2633f302b4c0ad50cc830ff7da20b2a Mon Sep 17 00:00:00 2001 -From: Baoquan He -Date: Tue, 2 Jul 2013 11:09:20 +0900 -Subject: [PATCH 1/2] [PATCH 1/2] Assign non-printable value as short options. - -Characters for short options is limited, and now makedumpfile has -considerably many options. As times go on, no enough reasonable -letters can be assigned to each functionality with short options. - -E.g non-cyclic vs Y, cyclic-buffer vs Z, eppic vs S. - -Now assign non-printable value to these kind of short optins, meanwhile -define them as indicative MACRO which can make code more readable. - -Signed-off-by: Baoquan He ---- - makedumpfile.c | 88 +++++++++++++++++++++++++++++----------------------------- - makedumpfile.h | 35 +++++++++++++++++++++++ - 2 files changed, 79 insertions(+), 44 deletions(-) - -diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c -index b42565c..bb72c66 100644 ---- a/makedumpfile-1.5.4/makedumpfile.c -+++ b/makedumpfile-1.5.4/makedumpfile.c -@@ -8555,20 +8555,20 @@ calculate_cyclic_buffer_size(void) { - } - - static struct option longopts[] = { -- {"split", no_argument, NULL, 's'}, -- {"reassemble", no_argument, NULL, 'r'}, -- {"xen-syms", required_argument, NULL, 'y'}, -- {"xen-vmcoreinfo", required_argument, NULL, 'z'}, -- {"xen_phys_start", required_argument, NULL, 'P'}, -- {"message-level", required_argument, NULL, 'm'}, -- {"vtop", required_argument, NULL, 'V'}, -- {"dump-dmesg", no_argument, NULL, 'M'}, -- {"config", required_argument, NULL, 'C'}, -- {"help", no_argument, NULL, 'h'}, -- {"diskset", required_argument, NULL, 'k'}, -- {"non-cyclic", no_argument, NULL, 'Y'}, -- {"cyclic-buffer", required_argument, NULL, 'Z'}, -- {"eppic", required_argument, NULL, 'S'}, -+ {"split", no_argument, NULL, OPT_SPLIT}, -+ {"reassemble", no_argument, NULL, OPT_REASSEMBLE}, -+ {"xen-syms", required_argument, NULL, OPT_XEN_SYMS}, -+ {"xen-vmcoreinfo", required_argument, NULL, OPT_XEN_VMCOREINFO}, -+ {"xen_phys_start", required_argument, NULL, OPT_XEN_PHYS_START}, -+ {"message-level", required_argument, NULL, OPT_MESSAGE_LEVEL}, -+ {"vtop", required_argument, NULL, OPT_VTOP}, -+ {"dump-dmesg", no_argument, NULL, OPT_DUMP_DMESG}, -+ {"config", required_argument, NULL, OPT_CONFIG}, -+ {"help", no_argument, NULL, OPT_HELP}, -+ {"diskset", required_argument, NULL, OPT_DISKSET}, -+ {"non-cyclic", no_argument, NULL, OPT_NON_CYCLIC}, -+ {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER}, -+ {"eppic", required_argument, NULL, OPT_EPPIC}, - {0, 0, 0, 0} - }; - -@@ -8597,29 +8597,29 @@ main(int argc, char *argv[]) - - info->block_order = DEFAULT_ORDER; - message_level = DEFAULT_MSG_LEVEL; -- while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lMpRrsvXx:", longopts, -+ while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lpRvXx:", longopts, - NULL)) != -1) { - switch (opt) { -- case 'b': -+ case OPT_BLOCK_ORDER: - info->block_order = atoi(optarg); - break; -- case 'C': -+ case OPT_CONFIG: - info->name_filterconfig = optarg; - break; -- case 'c': -+ case OPT_COMPRESS_ZLIB: - info->flag_compress = DUMP_DH_COMPRESSED_ZLIB; - break; -- case 'D': -+ case OPT_DEBUG: - flag_debug = TRUE; - break; -- case 'd': -+ case OPT_DUMP_LEVEL: - if (!parse_dump_level(optarg)) - goto out; - break; -- case 'E': -+ case OPT_ELF_DUMPFILE: - info->flag_elf_dumpfile = 1; - break; -- case 'F': -+ case OPT_FLATTEN: - info->flag_flatten = 1; - /* - * All messages are output to STDERR because STDOUT is -@@ -8627,75 +8627,75 @@ main(int argc, char *argv[]) - */ - flag_strerr_message = TRUE; - break; -- case 'f': -+ case OPT_FORCE: - info->flag_force = 1; - break; -- case 'g': -+ case OPT_GENERATE_VMCOREINFO: - info->flag_generate_vmcoreinfo = 1; - info->name_vmcoreinfo = optarg; - break; -- case 'h': -+ case OPT_HELP: - info->flag_show_usage = 1; - break; -- case 'i': -+ case OPT_READ_VMCOREINFO: - info->flag_read_vmcoreinfo = 1; - info->name_vmcoreinfo = optarg; - break; -- case 'k': -+ case OPT_DISKSET: - if (!sadump_add_diskset_info(optarg)) - goto out; - info->flag_sadump_diskset = 1; - break; -- case 'l': -+ case OPT_COMPRESS_LZO: - info->flag_compress = DUMP_DH_COMPRESSED_LZO; - break; -- case 'm': -+ case OPT_MESSAGE_LEVEL: - message_level = atoi(optarg); - break; -- case 'M': -+ case OPT_DUMP_DMESG: - info->flag_dmesg = 1; - break; -- case 'p': -+ case OPT_COMPRESS_SNAPPY: - info->flag_compress = DUMP_DH_COMPRESSED_SNAPPY; - break; -- case 'P': -+ case OPT_XEN_PHYS_START: - info->xen_phys_start = strtoul(optarg, NULL, 0); - break; -- case 'R': -+ case OPT_REARRANGE: - info->flag_rearrange = 1; - break; -- case 's': -+ case OPT_SPLIT: - info->flag_split = 1; - break; -- case 'S': -+ case OPT_EPPIC: - info->name_eppic_config = optarg; - break; -- case 'r': -+ case OPT_REASSEMBLE: - info->flag_reassemble = 1; - break; -- case 'V': -+ case OPT_VTOP: - info->vaddr_for_vtop = strtoul(optarg, NULL, 0); - break; -- case 'v': -+ case OPT_VERSION: - info->flag_show_version = 1; - break; -- case 'X': -+ case OPT_EXCLUDE_XEN_DOM: - info->flag_exclude_xen_dom = 1; - break; -- case 'x': -+ case OPT_VMLINUX: - info->name_vmlinux = optarg; - break; -- case 'y': -+ case OPT_XEN_SYMS: - info->name_xen_syms = optarg; - break; -- case 'Y': -+ case OPT_NON_CYCLIC: - info->flag_cyclic = FALSE; - break; -- case 'z': -+ case OPT_XEN_VMCOREINFO: - info->flag_read_vmcoreinfo = 1; - info->name_vmcoreinfo = optarg; - break; -- case 'Z': -+ case OPT_CYCLIC_BUFFER: - info->bufsize_cyclic = atoi(optarg); - break; - case '?': -diff --git a/makedumpfile-1.5.4/makedumpfile.h b/makedumpfile-1.5.4/makedumpfile.h -index a5826e0..79d4702 100644 ---- a/makedumpfile-1.5.4/makedumpfile.h -+++ b/makedumpfile-1.5.4/makedumpfile.h -@@ -1671,6 +1671,41 @@ struct elf_prstatus { - #endif - - /* -+ * Below are options which getopt_long can recognize. From OPT_START options are -+ * non-printable, just used for implementation. -+ */ -+#define OPT_BLOCK_ORDER 'b' -+#define OPT_COMPRESS_ZLIB 'c' -+#define OPT_DEBUG 'D' -+#define OPT_DUMP_LEVEL 'd' -+#define OPT_ELF_DUMPFILE 'E' -+#define OPT_FLATTEN 'F' -+#define OPT_FORCE 'f' -+#define OPT_GENERATE_VMCOREINFO 'g' -+#define OPT_HELP 'h' -+#define OPT_READ_VMCOREINFO 'i' -+#define OPT_COMPRESS_LZO 'l' -+#define OPT_COMPRESS_SNAPPY 'p' -+#define OPT_REARRANGE 'R' -+#define OPT_VERSION 'v' -+#define OPT_EXCLUDE_XEN_DOM 'X' -+#define OPT_VMLINUX 'x' -+#define OPT_START 256 -+#define OPT_SPLIT OPT_START+0 -+#define OPT_REASSEMBLE OPT_START+1 -+#define OPT_XEN_SYMS OPT_START+2 -+#define OPT_XEN_VMCOREINFO OPT_START+3 -+#define OPT_XEN_PHYS_START OPT_START+4 -+#define OPT_MESSAGE_LEVEL OPT_START+5 -+#define OPT_VTOP OPT_START+6 -+#define OPT_DUMP_DMESG OPT_START+7 -+#define OPT_CONFIG OPT_START+8 -+#define OPT_DISKSET OPT_START+9 -+#define OPT_NON_CYCLIC OPT_START+10 -+#define OPT_CYCLIC_BUFFER OPT_START+11 -+#define OPT_EPPIC OPT_START+12 -+ -+/* - * Function Prototype. - */ - unsigned long long get_num_dumpable_cyclic(void); --- -1.8.4.2 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch deleted file mode 100644 index a4edb75..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 7c770ed052d8452f5d7ce027b23d1b77cf6fbce7 Mon Sep 17 00:00:00 2001 -From: Atsushi Kumagai -Date: Thu, 12 Dec 2013 16:40:31 +0900 -Subject: [PATCH 2/2] [PATCH] Fall back to read() when mmap() fails. - -This is a fall back path for mmap(). -This patch disables mmap() when facing the issues related to mmap(), -and read() will be used to read vmcore instead. - -Signed-off-by: Atsushi Kumagai ---- - makedumpfile.c | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c -index b3af28b..20f107e 100644 ---- a/makedumpfile-1.5.4/makedumpfile.c -+++ b/makedumpfile-1.5.4/makedumpfile.c -@@ -324,7 +324,15 @@ read_from_vmcore(off_t offset, void *bufptr, unsigned long size) - if (!read_with_mmap(offset, bufptr, size)) { - ERRMSG("Can't read the dump memory(%s) with mmap().\n", - info->name_memory); -- return FALSE; -+ -+ ERRMSG("This kernel might have some problems about mmap().\n"); -+ ERRMSG("read() will be used instead of mmap() from now.\n"); -+ -+ /* -+ * Fall back to read(). -+ */ -+ info->flag_usemmap = MMAP_DISABLE; -+ read_from_vmcore(offset, bufptr, size); - } - } else { - if (lseek(info->fd_memory, offset, SEEK_SET) == failed) { --- -1.8.4.2 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Fix-a-segmentation-fault-when-physical-addr.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Fix-a-segmentation-fault-when-physical-addr.patch deleted file mode 100644 index a19d559..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Fix-a-segmentation-fault-when-physical-addr.patch +++ /dev/null @@ -1,96 +0,0 @@ -From abce4d50fc28ff182bd7e0b714e21c0dfec62bd1 Mon Sep 17 00:00:00 2001 -From: Jingbai Ma -Date: Fri, 18 Apr 2014 16:55:02 +0900 -Subject: [PATCH] [PATCH v3] Fix a segmentation fault when physical address - exceeds 8TB boundary. - -This patch intends to fix a segmentation fault when physical address -exceeds 8TB boundary. - -Changelog: -v3: -- Revise some comments according to Daisuke and Petr's feedback. - -v2: -- Add more comments from Daisuke HATAYAMA. - -In function is_on(), if the physical address higher than 8T, pfn (i) will -greater than 2G, it will be a negative value and will cause a segmentation -fault. -is_on(char *bitmap, int i) -{ - return bitmap[i>>3] & (1 << (i & 7)); -} - -Daisuke's detailed analysis: -static inline int -is_dumpable(struct dump_bitmap *bitmap, unsigned long long pfn) -{ - off_t offset; - if (pfn == 0 || bitmap->no_block != pfn/PFN_BUFBITMAP) { - offset = bitmap->offset + BUFSIZE_BITMAP*(pfn/PFN_BUFBITMAP); - lseek(bitmap->fd, offset, SEEK_SET); - read(bitmap->fd, bitmap->buf, BUFSIZE_BITMAP); - if (pfn == 0) - bitmap->no_block = 0; - else - bitmap->no_block = pfn/PFN_BUFBITMAP; - } - return is_on(bitmap->buf, pfn%PFN_BUFBITMAP); -} - -PFN_BUFBTIMAP is constant 32 K. So, it seems that the 4 byte byte -length came here. - -But right shift to signed integer is implementation defined. We should -not use right shift to signed integer. it looks gcc performs -arithmetic shift and this bahaviour is buggy in case of is_on(). - -static inline int -is_dumpable_cyclic(char *bitmap, unsigned long long pfn, struct cycle *cycle) -{ - if (pfn < cycle->start_pfn || cycle->end_pfn <= pfn) - return FALSE; - else - return is_on(bitmap, pfn - cycle->start_pfn); -} - -Simply, (pfn - cycle->start_pfn) could be ((info->max_mapnr - 1) - 0). It's -possible to pass more than 2 Gi by using system with more than 8 TiB -physical memory space. - -So, in function is_on() - -- i must be unsigned in order to make right shift operation - meaningful, and - -- i must have 8 byte for systems with more than 8 TiB physical memory - space. - -Petr's comments: -Why an unsigned long for the variable i is not sufficient? -It would be enough on 64-bit systems, where an unsigned long is just as big as -an unsigned long long (both 64 bits). But on 32-bit systems, an unsigned long -is 32-bit, but physical memory can be larger (e.g. 36 bits with PAE). - -Signed-off-by: Jingbai Ma ---- - makedumpfile.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile.h b/makedumpfile.h -index a5826e0..33ab0cf 100644 ---- a/makedumpfile-1.5.4/makedumpfile.h -+++ b/makedumpfile-1.5.4/makedumpfile.h -@@ -1546,7 +1546,7 @@ int get_xen_info_ia64(void); - #endif /* s390x */ - - static inline int --is_on(char *bitmap, int i) -+is_on(char *bitmap, unsigned long long i) - { - return bitmap[i>>3] & (1 << (i & 7)); - } --- -1.9.3 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Fix-max_mapnr-issue-on-system-has-over-44-b.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Fix-max_mapnr-issue-on-system-has-over-44-b.patch deleted file mode 100644 index fee9cb8..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Fix-max_mapnr-issue-on-system-has-over-44-b.patch +++ /dev/null @@ -1,329 +0,0 @@ -From 8e124174b62376b17ac909bc68622ef07bde6840 Mon Sep 17 00:00:00 2001 -Message-Id: <8e124174b62376b17ac909bc68622ef07bde6840.1382323707.git.bhe@redhat.com> -From: Jingbai Ma -Date: Fri, 18 Oct 2013 18:53:38 +0900 -Subject: [PATCH] [PATCH v4] Fix max_mapnr issue on system has over 44-bit - addressing. - -This patch will fix a bug of makedumpfile doesn't work correctly on system -has over 44-bit addressing in compression dump mode. -This bug was posted here: -http://lists.infradead.org/pipermail/kexec/2013-September/009587.html - -This patch will add 3 new fields in struct kdump_sub_header. -unsigned long long start_pfn_64; /* header_version 6 and later */ -unsigned long long end_pfn_64; /* header_version 6 and later */ -unsigned long long max_mapnr_64; /* header_version 6 and later */ - -And the old "unsigned int max_mapnr" in struct disk_dump_header will -not be used anymore, but still be there for compatibility purpose. - -The max_mapnr_64 only exists in strcut kdump_sub_header, and that only -for compressed kdump format, so for ELF format kdump files (non-compressed), -only the max_mapnr is available, so it still may be truncated for addresses -exceed 44bit (above 16TB). - -This patch will change the header_version to 6. - -The corresponding patch for crash utility can be found here: -http://lists.infradead.org/pipermail/kexec/2013-October/009750.html - -This patch doesn't change sadump_header. - -Changelog: -v4: -- Do not change max_mapnr_64 in kdump_sub_header in memory for old kernel. - -v3: -- Change notes for max_mapnr, start_pfn and end_pfn as obsolete. -- Remove "(32bit)" from debug messages of max_mapnr, start_pfn and end_pfn. -- Set the 32bit start_pfn and end_pfn to UINT_MAX. -- Remove bitmap writting enhancement to another seperate patch. -- Change type of len_bitmap in struct DumpInfo back to unsigned long. - -v2: -- Rename max_mapnr in struct kdump_sub_header to max_mapnr_64. -- Change type of max_mapnr_64 from unsigned long to unsigned long long. - In x86 PAE mode on x86_32 kernel, the address may exceeds 44bit limit. -- Add start_pfn_64, end_pfn_64 for struct kdump_sub_header. -- Only print 64bit start_pfn_64, end_pfn_64 and max_mapnr_64 - debug messages for disk dump header version >= 6. -- Change type of bitmap_len in struct DumpInfo, from unsigned long to - unsigned long long. -- Enhance bitmap writting function in reassemble_kdump_header(). - Prevent bitmap writting failure if the size of bitmap is too large to - fit a sigle write. - -v1: -- http://lists.infradead.org/pipermail/kexec/2013-September/009662.html - -Signed-off-by: Jingbai Ma -Tested-by: Lisa Mitchell ---- - IMPLEMENTATION | 15 ++++++++++--- - diskdump_mod.h | 15 ++++++++++--- - makedumpfile.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++------------ - 3 files changed, 77 insertions(+), 20 deletions(-) - -diff --git a/makedumpfile-1.5.4/IMPLEMENTATION b/makedumpfile-1.5.4/IMPLEMENTATION -index f0f3135..2f4cfd6 100644 ---- a/makedumpfile-1.5.4/IMPLEMENTATION -+++ b/makedumpfile-1.5.4/IMPLEMENTATION -@@ -48,7 +48,9 @@ - header in blocks */ - unsigned int bitmap_blocks; /* Size of Memory bitmap in - block */ -- unsigned int max_mapnr; /* = max_mapnr */ -+ unsigned int max_mapnr; /* = max_mapnr, OBSOLETE! -+ 32bit only, full 64bit -+ in sub header. */ - unsigned int total_ram_blocks;/* Number of blocks should be - written */ - unsigned int device_blocks; /* Number of total blocks in -@@ -69,14 +71,21 @@ - unsigned long phys_base; - int dump_level; /* header_version 1 and later */ - int split; /* header_version 2 and later */ -- unsigned long start_pfn; /* header_version 2 and later */ -- unsigned long end_pfn; /* header_version 2 and later */ -+ unsigned long start_pfn; /* header_version 2 and later, -+ OBSOLETE! 32bit only, full -+ 64bit in start_pfn_64. */ -+ unsigned long end_pfn; /* header_version 2 and later, -+ OBSOLETE! 32bit only, full -+ 64bit in end_pfn_64. */ - off_t offset_vmcoreinfo;/* header_version 3 and later */ - unsigned long size_vmcoreinfo; /* header_version 3 and later */ - off_t offset_note; /* header_version 4 and later */ - unsigned long size_note; /* header_version 4 and later */ - off_t offset_eraseinfo; /* header_version 5 and later */ - unsigned long size_eraseinfo; /* header_version 5 and later */ -+ unsigned long long start_pfn_64; /* header_version 6 and later */ -+ unsigned long long end_pfn_64; /* header_version 6 and later */ -+ unsigned long long max_mapnr_64; /* header_version 6 and later */ - }; - - - 1st-bitmap -diff --git a/makedumpfile-1.5.4/diskdump_mod.h b/makedumpfile-1.5.4/diskdump_mod.h -index 00ab852..dd24eb2 100644 ---- a/makedumpfile-1.5.4/diskdump_mod.h -+++ b/makedumpfile-1.5.4/diskdump_mod.h -@@ -52,7 +52,9 @@ struct disk_dump_header { - header in blocks */ - unsigned int bitmap_blocks; /* Size of Memory bitmap in - block */ -- unsigned int max_mapnr; /* = max_mapnr */ -+ unsigned int max_mapnr; /* = max_mapnr, OBSOLETE! -+ 32bit only, full 64bit -+ in sub header. */ - unsigned int total_ram_blocks;/* Number of blocks should be - written */ - unsigned int device_blocks; /* Number of total blocks in -@@ -71,14 +73,21 @@ struct kdump_sub_header { - unsigned long phys_base; - int dump_level; /* header_version 1 and later */ - int split; /* header_version 2 and later */ -- unsigned long start_pfn; /* header_version 2 and later */ -- unsigned long end_pfn; /* header_version 2 and later */ -+ unsigned long start_pfn; /* header_version 2 and later, -+ OBSOLETE! 32bit only, full -+ 64bit in start_pfn_64. */ -+ unsigned long end_pfn; /* header_version 2 and later, -+ OBSOLETE! 32bit only, full -+ 64bit in end_pfn_64. */ - off_t offset_vmcoreinfo;/* header_version 3 and later */ - unsigned long size_vmcoreinfo; /* header_version 3 and later */ - off_t offset_note; /* header_version 4 and later */ - unsigned long size_note; /* header_version 4 and later */ - off_t offset_eraseinfo; /* header_version 5 and later */ - unsigned long size_eraseinfo; /* header_version 5 and later */ -+ unsigned long long start_pfn_64; /* header_version 6 and later */ -+ unsigned long long end_pfn_64; /* header_version 6 and later */ -+ unsigned long long max_mapnr_64; /* header_version 6 and later */ - }; - - /* page flags */ -diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c -index 9892108..428c53e 100644 ---- a/makedumpfile-1.5.4/makedumpfile.c -+++ b/makedumpfile-1.5.4/makedumpfile.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - struct symbol_table symbol_table; - struct size_table size_table; -@@ -125,7 +126,10 @@ get_max_mapnr(void) - unsigned long long max_paddr; - - if (info->flag_refiltering) { -- info->max_mapnr = info->dh_memory->max_mapnr; -+ if (info->dh_memory->header_version >= 6) -+ info->max_mapnr = info->kh_memory->max_mapnr_64; -+ else -+ info->max_mapnr = info->dh_memory->max_mapnr; - return TRUE; - } - -@@ -802,6 +806,12 @@ get_kdump_compressed_header_info(char *filename) - DEBUG_MSG(" split : %d\n", kh.split); - DEBUG_MSG(" start_pfn : 0x%lx\n", kh.start_pfn); - DEBUG_MSG(" end_pfn : 0x%lx\n", kh.end_pfn); -+ if (dh.header_version >= 6) { -+ /* A dumpfile contains full 64bit values. */ -+ DEBUG_MSG(" start_pfn_64 : 0x%llx\n", kh.start_pfn_64); -+ DEBUG_MSG(" end_pfn_64 : 0x%llx\n", kh.end_pfn_64); -+ DEBUG_MSG(" max_mapnr_64 : 0x%llx\n", kh.max_mapnr_64); -+ } - - info->dh_memory = malloc(sizeof(dh)); - if (info->dh_memory == NULL) { -@@ -2799,14 +2809,16 @@ int - initialize_bitmap_memory(void) - { - struct disk_dump_header *dh; -+ struct kdump_sub_header *kh; - struct dump_bitmap *bmp; - off_t bitmap_offset; -- int bitmap_len, max_sect_len; -+ off_t bitmap_len, max_sect_len; - unsigned long pfn; - int i, j; - long block_size; - - dh = info->dh_memory; -+ kh = info->kh_memory; - block_size = dh->block_size; - - bitmap_offset -@@ -2826,7 +2838,10 @@ initialize_bitmap_memory(void) - bmp->offset = bitmap_offset + bitmap_len / 2; - info->bitmap_memory = bmp; - -- max_sect_len = divideup(dh->max_mapnr, BITMAP_SECT_LEN); -+ if (dh->header_version >= 6) -+ max_sect_len = divideup(kh->max_mapnr_64, BITMAP_SECT_LEN); -+ else -+ max_sect_len = divideup(dh->max_mapnr, BITMAP_SECT_LEN); - info->valid_pages = calloc(sizeof(ulong), max_sect_len); - if (info->valid_pages == NULL) { - ERRMSG("Can't allocate memory for the valid_pages. %s\n", -@@ -4743,7 +4758,7 @@ create_2nd_bitmap(void) - int - prepare_bitmap_buffer(void) - { -- unsigned long tmp; -+ unsigned long long tmp; - - /* - * Create 2 bitmaps (1st-bitmap & 2nd-bitmap) on block_size boundary. -@@ -4775,7 +4790,7 @@ prepare_bitmap_buffer(void) - int - prepare_bitmap_buffer_cyclic(void) - { -- unsigned long tmp; -+ unsigned long long tmp; - - /* - * Create 2 bitmaps (1st-bitmap & 2nd-bitmap) on block_size boundary. -@@ -5190,11 +5205,12 @@ write_kdump_header(void) - * Write common header - */ - strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE)); -- dh->header_version = 5; -+ dh->header_version = 6; - dh->block_size = info->page_size; - dh->sub_hdr_size = sizeof(kh) + size_note; - dh->sub_hdr_size = divideup(dh->sub_hdr_size, dh->block_size); -- dh->max_mapnr = info->max_mapnr; -+ /* dh->max_mapnr may be truncated, full 64bit in kh.max_mapnr_64 */ -+ dh->max_mapnr = MIN(info->max_mapnr, UINT_MAX); - dh->nr_cpus = get_nr_cpus(); - dh->bitmap_blocks = divideup(info->len_bitmap, dh->block_size); - memcpy(&dh->timestamp, &info->timestamp, sizeof(dh->timestamp)); -@@ -5219,12 +5235,22 @@ write_kdump_header(void) - */ - size = sizeof(struct kdump_sub_header); - memset(&kh, 0, size); -+ /* 64bit max_mapnr_64 */ -+ kh.max_mapnr_64 = info->max_mapnr; - kh.phys_base = info->phys_base; - kh.dump_level = info->dump_level; - if (info->flag_split) { - kh.split = 1; -- kh.start_pfn = info->split_start_pfn; -- kh.end_pfn = info->split_end_pfn; -+ /* -+ * start_pfn and end_pfn may be truncated, -+ * only for compatibility purpose -+ */ -+ kh.start_pfn = MIN(info->split_start_pfn, UINT_MAX); -+ kh.end_pfn = MIN(info->split_end_pfn, UINT_MAX); -+ -+ /* 64bit start_pfn_64 and end_pfn_64 */ -+ kh.start_pfn_64 = info->split_start_pfn; -+ kh.end_pfn_64 = info->split_end_pfn; - } - if (has_pt_note()) { - /* -@@ -6470,7 +6496,7 @@ int - write_kdump_bitmap(void) - { - struct cache_data bm; -- long buf_size; -+ long long buf_size; - off_t offset; - - int ret = FALSE; -@@ -7853,10 +7879,8 @@ store_splitting_info(void) - - if (i == 0) { - memcpy(&dh, &tmp_dh, sizeof(tmp_dh)); -- info->max_mapnr = dh.max_mapnr; - if (!set_page_size(dh.block_size)) - return FALSE; -- DEBUG_MSG("max_mapnr : %llx\n", info->max_mapnr); - DEBUG_MSG("page_size : %ld\n", info->page_size); - } - -@@ -7873,11 +7897,24 @@ store_splitting_info(void) - return FALSE; - - if (i == 0) { -+ if (dh.header_version >= 6) -+ info->max_mapnr = kh.max_mapnr_64; -+ else -+ info->max_mapnr = dh.max_mapnr; -+ -+ DEBUG_MSG("max_mapnr : %llx\n", info->max_mapnr); -+ - info->dump_level = kh.dump_level; - DEBUG_MSG("dump_level : %d\n", info->dump_level); - } -- SPLITTING_START_PFN(i) = kh.start_pfn; -- SPLITTING_END_PFN(i) = kh.end_pfn; -+ -+ if (dh.header_version >= 6) { -+ SPLITTING_START_PFN(i) = kh.start_pfn_64; -+ SPLITTING_END_PFN(i) = kh.end_pfn_64; -+ } else { -+ SPLITTING_START_PFN(i) = kh.start_pfn; -+ SPLITTING_END_PFN(i) = kh.end_pfn; -+ } - SPLITTING_OFFSET_EI(i) = kh.offset_eraseinfo; - SPLITTING_SIZE_EI(i) = kh.size_eraseinfo; - } -@@ -8039,6 +8076,8 @@ reassemble_kdump_header(void) - kh.split = 0; - kh.start_pfn = 0; - kh.end_pfn = 0; -+ kh.start_pfn_64 = 0; -+ kh.end_pfn_64 = 0; - - if (lseek(info->fd_dumpfile, info->page_size, SEEK_SET) < 0) { - ERRMSG("Can't seek a file(%s). %s\n", --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Improve-progress-information-for-huge-memor.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Improve-progress-information-for-huge-memor.patch deleted file mode 100644 index 9b15185..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Improve-progress-information-for-huge-memor.patch +++ /dev/null @@ -1,200 +0,0 @@ -From 20ecc0827e7837c52f3903638a59959f8bf17f9e Mon Sep 17 00:00:00 2001 -From: HATAYAMA Daisuke -Date: Tue, 5 Nov 2013 00:29:35 +0900 -Subject: [PATCH] [PATCH v2] Improve progress information for huge memory - system. - -On system with huge memory, percentage in progress information is -updated at very slow interval, because 1 percent on 1 TiB memory is -about 10 GiB, which looks like as if system has freezed. Then, -confused users might get tempted to push a reset button to recover the -system. We want to avoid such situation as much as possible. - -To address the issue, this patch: - -- increases the number of calling print_progress() from once in - (written pages / 100)-pages to once in (written pages / - 10000)-pages, - -- extends precision in progress information by adding 1 digit to its - fractional part, and - -- adds spinner that rotates in the order of /, |, \ and - in next to - the progress indicator in percentage, - -which help users to get aware that system is still active and crash -dump process is still in progress now. - -The spinner code is borrowed from diskdump code. - -The ouput is changed from: - -Copying data : [ 0 %] / -Copying data : [ 8 %] | -Copying data : [ 11 %] \ -Copying data : [ 14 %] - -Copying data : [ 16 %] / -... -Copying data : [ 99 %] / -Copying data : [100 %] | - -to: - -Copying data : [ 0.1 %] / -Copying data : [ 8.9 %] | -Copying data : [ 11.6 %] \ -Copying data : [ 14.3 %] - -Copying data : [ 16.4 %] / -... -Copying data : [ 99.2 %] / -Copying data : [100.0 %] | - -This patch doesn't adopt purely time-based approach that records the -time when print_progress() is called at each invocation and print the -recorded time if it is strictly larger than the previous time value. - -The problem is that calling time() system call amounts to -considertably long time in total on huge memory system. For example, -here is a simple bench that measures total execution time of time() -system call for (1TiB / 4KiB)-times: - -$ ./bench -total: 18.360503 -total: 34.910297 - -the result of which reveals that it amounts to about 20 seconds with -vDSO optimization and about 35 seconds without. - -BTW, on our 12 TiB memory system, we collect about 300 GiB crash dump -in about 40 minutes with dump level 31. On 12TiB, the benchmark result -corresponds to about 4 minutes and 7 minutes respectively, both of which -affects a whole performance. - -==bench.c -static inline double getdtime(void) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - return (double)tv.tv_sec + (double)tv.tv_usec * 1.0e-6; -} - -int main(int argc, char **argv) -{ - unsigned long i; - time_t t; - double t1, t2, total; - const int NR_time = 201; - const unsigned long nr_repeat = (1UL << 40) / 4096; - - total = 0; - for (i = 0; i < nr_repeat; ++i) { - t1 = getdtime(); - time(&t); - t2 = getdtime(); - total += t2 - t1; - } - printf("total: %lf\n", total); - - total = 0; - for (i = 0; i < nr_repeat; ++i) { - t1 = getdtime(); - syscall(NR_time, &t); - t2 = getdtime(); - total += t2 - t1; - } - printf("total: %lf\n", total); - - return 0; -} -== - -Signed-off-by: HATAYAMA Daisuke ---- - makedumpfile.c | 8 ++++---- - print_info.c | 15 +++++++++------ - 2 files changed, 13 insertions(+), 10 deletions(-) - -diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c -index dafe83b..3746cf6 100644 ---- a/makedumpfile-1.5.4/makedumpfile.c -+++ b/makedumpfile-1.5.4/makedumpfile.c -@@ -5573,7 +5573,7 @@ write_elf_pages(struct cache_data *cd_header, struct cache_data *cd_page) - initialize_2nd_bitmap(&bitmap2); - - num_dumpable = get_num_dumpable(); -- per = num_dumpable / 100; -+ per = num_dumpable / 10000; - - off_seg_load = info->offset_load_dumpfile; - cd_page->offset = info->offset_load_dumpfile; -@@ -5858,7 +5858,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page) - return FALSE; - - num_dumpable = info->num_dumpable; -- per = num_dumpable / 100; -+ per = num_dumpable / 10000; - - off_seg_load = info->offset_load_dumpfile; - cd_page->offset = info->offset_load_dumpfile; -@@ -6116,7 +6116,7 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page) - } - - num_dumpable = get_num_dumpable(); -- per = num_dumpable / 100; -+ per = num_dumpable / 10000; - - /* - * Calculate the offset of the page data. -@@ -6317,7 +6317,7 @@ write_kdump_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_pag - goto out; - } - -- per = info->num_dumpable / 100; -+ per = info->num_dumpable / 10000; - - /* - * Set a fileoffset of Physical Address 0x0. -diff --git a/makedumpfile-1.5.4/print_info.c b/makedumpfile-1.5.4/print_info.c -index 3527970..d7a8600 100644 ---- a/makedumpfile-1.5.4/print_info.c -+++ b/makedumpfile-1.5.4/print_info.c -@@ -283,27 +283,30 @@ print_usage(void) - void - print_progress(const char *msg, unsigned long current, unsigned long end) - { -- int progress; -+ float progress; - time_t tm; - static time_t last_time = 0; -+ static unsigned int lapse = 0; -+ static const char *spinner = "/|\\-"; - - if (current < end) { - tm = time(NULL); - if (tm - last_time < 1) - return; - last_time = tm; -- progress = current * 100 / end; -+ progress = (float)current * 100 / end; - } else - progress = 100; - - if (flag_ignore_r_char) { -- PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%]\n", -- msg, progress); -+ PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%5.1f %%] %c\n", -+ msg, progress, spinner[lapse % 4]); - } else { - PROGRESS_MSG("\r"); -- PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%] ", -- msg, progress); -+ PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%5.1f %%] %c", -+ msg, progress, spinner[lapse % 4]); - } -+ lapse++; - } - - void --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-PATCH-Support-newer-kernels.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-PATCH-Support-newer-kernels.patch deleted file mode 100644 index 5e4ff19..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-PATCH-Support-newer-kernels.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 1202589997ad008b18276f504c5c2b8529b41dfe Mon Sep 17 00:00:00 2001 -Message-Id: <1202589997ad008b18276f504c5c2b8529b41dfe.1380186577.git.bhe@redhat.com> -From: Atsushi Kumagai -Date: Fri, 20 Sep 2013 09:34:57 +0900 -Subject: [PATCH] [PATCH] Support newer kernels. - - A new makedumpfile supports newer kernels: - - - 3.10 (x86 FLATMEM) - - 3.10 (x86 SPARSEMEM) - - 3.10 (x86_64 SPARSEMEM) - -Signed-off-by: Atsushi Kumagai -Signed-off-by: Baoquan He ---- - README | 1 + - makedumpfile.h | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -diff --git a/makedumpfile-1.5.4/README b/makedumpfile-1.5.4/README -index b587485..4e838d8 100644 ---- a/makedumpfile-1.5.4/README -+++ b/makedumpfile-1.5.4/README -@@ -97,6 +97,7 @@ - 3.7 | OK | ** | | | | ** | | -- | OK | OK | | | - 3.8 | OK | ** | | | | ** | | -- | OK | OK | | | - 3.9 | OK | ** | | | | ** | | -- | OK | OK | | | -+ 3.10 | OK | ** | | | | ** | | -- | OK | OK | | | - - OK : Support. - -- : Not support. -diff --git a/makedumpfile-1.5.4/makedumpfile.h b/makedumpfile-1.5.4/makedumpfile.h -index a04154e..c504bfb 100644 ---- a/makedumpfile-1.5.4/makedumpfile.h -+++ b/makedumpfile-1.5.4/makedumpfile.h -@@ -426,7 +426,7 @@ do { \ - #define KVER_MIN_SHIFT 16 - #define KERNEL_VERSION(x,y,z) (((x) << KVER_MAJ_SHIFT) | ((y) << KVER_MIN_SHIFT) | (z)) - #define OLDEST_VERSION KERNEL_VERSION(2, 6, 15)/* linux-2.6.15 */ --#define LATEST_VERSION KERNEL_VERSION(3, 9, 6)/* linux-3.9.6 */ -+#define LATEST_VERSION KERNEL_VERSION(3, 10, 7)/* linux-3.10.7 */ - - /* - * vmcoreinfo in /proc/vmcore --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Support-to-filter-dump-for-kernels-that-use.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Support-to-filter-dump-for-kernels-that-use.patch deleted file mode 100644 index 299f1a8..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Support-to-filter-dump-for-kernels-that-use.patch +++ /dev/null @@ -1,429 +0,0 @@ -From bcdba922182def3dac288ca201e77e7738a1e4ab Mon Sep 17 00:00:00 2001 -From: Hari Bathini -Date: Mon, 25 Nov 2013 17:20:55 +0900 -Subject: [PATCH] [PATCH v5] Support to filter dump for kernels that use - CONFIG_SPARSEMEM_VMEMMAP. - -Makedumpfile tool fails to filter dump for kernels that are build with -CONFIG_SPARSEMEM_VMEMMAP set, as it fails to do address translations -for vmemmap regions that are mapped out of zone normal. This patch -provides support in makedumpfile to do vmemmap to physical address -translations when they are mapped outside zone normal. Some kernel -symbols are needed in vmcoreinfo for this changes to be effective. -The kernel patch that adds the necessary symbols to vmcoreinfo has -been posted to linuxppc devel mailing list. This patch is influenced -by vmemmap to physical address translation support code in crash tool. -This patch has been tested successfully at all dump filtering levels -on kernels with CONFIG_SPARSEMEM_VMEMMAP set/unset. Also, tested dump -filtering on already filtered vmcores (re-filtering). - -Changes from v4 to v5: -Trimmed patch description to be compact and readable. - -Changes from v3 to v4: -Rebased to devel branch. - -Signed-off-by: Onkar N Mahajan -Signed-off-by: Hari Bathini ---- - arch/ppc64.c | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- - makedumpfile.c | 39 +++++++++++++ - makedumpfile.h | 37 ++++++++++++ - 3 files changed, 247 insertions(+), 4 deletions(-) - -diff --git a/makedumpfile-1.5.4/arch/ppc64.c b/makedumpfile-1.5.4/arch/ppc64.c -index 85144f6..09c0eb3 100644 ---- a/makedumpfile-1.5.4/arch/ppc64.c -+++ b/makedumpfile-1.5.4/arch/ppc64.c -@@ -24,6 +24,154 @@ - #include "../elf_info.h" - #include "../makedumpfile.h" - -+/* -+ * This function traverses vmemmap list to get the count of vmemmap regions -+ * and populates the regions' info in info->vmemmap_list[] -+ */ -+static int -+get_vmemmap_list_info(ulong head) -+{ -+ int i, cnt; -+ long backing_size, virt_addr_offset, phys_offset, list_offset; -+ ulong curr, next; -+ char *vmemmap_buf = NULL; -+ -+ backing_size = SIZE(vmemmap_backing); -+ virt_addr_offset = OFFSET(vmemmap_backing.virt_addr); -+ phys_offset = OFFSET(vmemmap_backing.phys); -+ list_offset = OFFSET(vmemmap_backing.list); -+ info->vmemmap_list = NULL; -+ -+ /* -+ * Get list count by traversing the vmemmap list -+ */ -+ cnt = 0; -+ curr = head; -+ next = 0; -+ do { -+ if (!readmem(VADDR, (curr + list_offset), &next, -+ sizeof(next))) { -+ ERRMSG("Can't get vmemmap region addresses\n"); -+ goto err; -+ } -+ curr = next; -+ cnt++; -+ } while ((next != 0) && (next != head)); -+ -+ /* -+ * Using temporary buffer to save vmemmap region information -+ */ -+ vmemmap_buf = calloc(1, backing_size); -+ if (vmemmap_buf == NULL) { -+ ERRMSG("Can't allocate memory for vmemmap_buf. %s\n", -+ strerror(errno)); -+ goto err; -+ } -+ -+ info->vmemmap_list = calloc(1, cnt * sizeof(struct ppc64_vmemmap)); -+ if (info->vmemmap_list == NULL) { -+ ERRMSG("Can't allocate memory for vmemmap_list. %s\n", -+ strerror(errno)); -+ goto err; -+ } -+ -+ curr = head; -+ for (i = 0; i < cnt; i++) { -+ if (!readmem(VADDR, curr, vmemmap_buf, backing_size)) { -+ ERRMSG("Can't get vmemmap region info\n"); -+ goto err; -+ } -+ -+ info->vmemmap_list[i].phys = ULONG(vmemmap_buf + phys_offset); -+ info->vmemmap_list[i].virt = ULONG(vmemmap_buf + -+ virt_addr_offset); -+ curr = ULONG(vmemmap_buf + list_offset); -+ -+ if (info->vmemmap_list[i].virt < info->vmemmap_start) -+ info->vmemmap_start = info->vmemmap_list[i].virt; -+ -+ if ((info->vmemmap_list[i].virt + info->vmemmap_psize) > -+ info->vmemmap_end) -+ info->vmemmap_end = (info->vmemmap_list[i].virt + -+ info->vmemmap_psize); -+ } -+ -+ free(vmemmap_buf); -+ return cnt; -+err: -+ free(vmemmap_buf); -+ free(info->vmemmap_list); -+ return 0; -+} -+ -+/* -+ * Verify that the kernel has made the vmemmap list available, -+ * and if so, stash the relevant data required to make vtop -+ * translations. -+ */ -+static int -+ppc64_vmemmap_init(void) -+{ -+ int psize, shift; -+ ulong head; -+ -+ if ((SYMBOL(vmemmap_list) == NOT_FOUND_SYMBOL) -+ || (SYMBOL(mmu_psize_defs) == NOT_FOUND_SYMBOL) -+ || (SYMBOL(mmu_vmemmap_psize) == NOT_FOUND_SYMBOL) -+ || (SIZE(vmemmap_backing) == NOT_FOUND_STRUCTURE) -+ || (SIZE(mmu_psize_def) == NOT_FOUND_STRUCTURE) -+ || (OFFSET(mmu_psize_def.shift) == NOT_FOUND_STRUCTURE) -+ || (OFFSET(vmemmap_backing.phys) == NOT_FOUND_STRUCTURE) -+ || (OFFSET(vmemmap_backing.virt_addr) == NOT_FOUND_STRUCTURE) -+ || (OFFSET(vmemmap_backing.list) == NOT_FOUND_STRUCTURE)) -+ return FALSE; -+ -+ if (!readmem(VADDR, SYMBOL(mmu_vmemmap_psize), &psize, sizeof(int))) -+ return FALSE; -+ -+ if (!readmem(VADDR, SYMBOL(mmu_psize_defs) + -+ (SIZE(mmu_psize_def) * psize) + -+ OFFSET(mmu_psize_def.shift), &shift, sizeof(int))) -+ return FALSE; -+ info->vmemmap_psize = 1 << shift; -+ -+ if (!readmem(VADDR, SYMBOL(vmemmap_list), &head, sizeof(unsigned long))) -+ return FALSE; -+ -+ /* -+ * Get vmemmap list count and populate vmemmap regions info -+ */ -+ info->vmemmap_cnt = get_vmemmap_list_info(head); -+ if (info->vmemmap_cnt == 0) -+ return FALSE; -+ -+ info->flag_vmemmap = TRUE; -+ return TRUE; -+} -+ -+/* -+ * If the vmemmap address translation information is stored in the kernel, -+ * make the translation. -+ */ -+static unsigned long long -+ppc64_vmemmap_to_phys(unsigned long vaddr) -+{ -+ int i; -+ ulong offset; -+ unsigned long long paddr = NOT_PADDR; -+ -+ for (i = 0; i < info->vmemmap_cnt; i++) { -+ if ((vaddr >= info->vmemmap_list[i].virt) && (vaddr < -+ (info->vmemmap_list[i].virt + info->vmemmap_psize))) { -+ offset = vaddr - info->vmemmap_list[i].virt; -+ paddr = info->vmemmap_list[i].phys + offset; -+ break; -+ } -+ } -+ -+ return paddr; -+} -+ - int - set_ppc64_max_physmem_bits(void) - { -@@ -103,6 +251,16 @@ get_machdep_info_ppc64(void) - info->vmalloc_start = vmalloc_start; - DEBUG_MSG("vmalloc_start: %lx\n", vmalloc_start); - -+ if (SYMBOL(vmemmap_list) != NOT_FOUND_SYMBOL) { -+ info->vmemmap_start = VMEMMAP_REGION_ID << REGION_SHIFT; -+ info->vmemmap_end = info->vmemmap_start; -+ if (ppc64_vmemmap_init() == FALSE) { -+ ERRMSG("Can't get vmemmap list info.\n"); -+ return FALSE; -+ } -+ DEBUG_MSG("vmemmap_start: %lx\n", info->vmemmap_start); -+ } -+ - return TRUE; - } - -@@ -121,14 +279,23 @@ vaddr_to_paddr_ppc64(unsigned long vaddr) - if (paddr != NOT_PADDR) - return paddr; - -- if ((SYMBOL(vmlist) == NOT_FOUND_SYMBOL) -- || (OFFSET(vm_struct.addr) == NOT_FOUND_STRUCTURE)) { -- ERRMSG("Can't get necessary information for vmalloc translation.\n"); -- return NOT_PADDR; -+ if ((SYMBOL(vmap_area_list) == NOT_FOUND_SYMBOL) -+ || (OFFSET(vmap_area.va_start) == NOT_FOUND_STRUCTURE) -+ || (OFFSET(vmap_area.list) == NOT_FOUND_STRUCTURE)) { -+ if ((SYMBOL(vmlist) == NOT_FOUND_SYMBOL) -+ || (OFFSET(vm_struct.addr) == NOT_FOUND_STRUCTURE)) { -+ ERRMSG("Can't get info for vmalloc translation.\n"); -+ return NOT_PADDR; -+ } - } - if (!is_vmalloc_addr_ppc64(vaddr)) - return (vaddr - info->kernel_start); - -+ if ((info->flag_vmemmap) -+ && (vaddr >= info->vmemmap_start)) { -+ return ppc64_vmemmap_to_phys(vaddr); -+ } -+ - /* - * TODO: Support vmalloc translation. - */ -diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c -index 3746cf6..0c68f32 100644 ---- a/makedumpfile-1.5.4/makedumpfile.c -+++ b/makedumpfile-1.5.4/makedumpfile.c -@@ -1107,6 +1107,10 @@ get_symbol_info(void) - SYMBOL_ARRAY_LENGTH_INIT(node_remap_start_pfn, - "node_remap_start_pfn"); - -+ SYMBOL_INIT(vmemmap_list, "vmemmap_list"); -+ SYMBOL_INIT(mmu_psize_defs, "mmu_psize_defs"); -+ SYMBOL_INIT(mmu_vmemmap_psize, "mmu_vmemmap_psize"); -+ - return TRUE; - } - -@@ -1417,6 +1421,20 @@ get_structure_info(void) - OFFSET_INIT(printk_log.text_len, "log", "text_len"); - } - -+ /* -+ * Get offsets of the vmemmap_backing's members. -+ */ -+ SIZE_INIT(vmemmap_backing, "vmemmap_backing"); -+ OFFSET_INIT(vmemmap_backing.phys, "vmemmap_backing", "phys"); -+ OFFSET_INIT(vmemmap_backing.virt_addr, "vmemmap_backing", "virt_addr"); -+ OFFSET_INIT(vmemmap_backing.list, "vmemmap_backing", "list"); -+ -+ /* -+ * Get offsets of the mmu_psize_def's members. -+ */ -+ SIZE_INIT(mmu_psize_def, "mmu_psize_def"); -+ OFFSET_INIT(mmu_psize_def.shift, "mmu_psize_def", "shift"); -+ - return TRUE; - } - -@@ -1603,6 +1621,9 @@ write_vmcoreinfo_data(void) - WRITE_SYMBOL("node_remap_start_vaddr", node_remap_start_vaddr); - WRITE_SYMBOL("node_remap_end_vaddr", node_remap_end_vaddr); - WRITE_SYMBOL("node_remap_start_pfn", node_remap_start_pfn); -+ WRITE_SYMBOL("vmemmap_list", vmemmap_list); -+ WRITE_SYMBOL("mmu_psize_defs", mmu_psize_defs); -+ WRITE_SYMBOL("mmu_vmemmap_psize", mmu_vmemmap_psize); - - /* - * write the structure size of 1st kernel -@@ -1620,6 +1641,8 @@ write_vmcoreinfo_data(void) - WRITE_STRUCTURE_SIZE("printk_log", printk_log); - else - WRITE_STRUCTURE_SIZE("log", printk_log); -+ WRITE_STRUCTURE_SIZE("vmemmap_backing", vmemmap_backing); -+ WRITE_STRUCTURE_SIZE("mmu_psize_def", mmu_psize_def); - - /* - * write the member offset of 1st kernel -@@ -1664,6 +1687,11 @@ write_vmcoreinfo_data(void) - WRITE_MEMBER_OFFSET("log.len", printk_log.len); - WRITE_MEMBER_OFFSET("log.text_len", printk_log.text_len); - } -+ WRITE_MEMBER_OFFSET("vmemmap_backing.phys", vmemmap_backing.phys); -+ WRITE_MEMBER_OFFSET("vmemmap_backing.virt_addr", -+ vmemmap_backing.virt_addr); -+ WRITE_MEMBER_OFFSET("vmemmap_backing.list", vmemmap_backing.list); -+ WRITE_MEMBER_OFFSET("mmu_psize_def.shift", mmu_psize_def.shift); - - if (SYMBOL(node_data) != NOT_FOUND_SYMBOL) - WRITE_ARRAY_LENGTH("node_data", node_data); -@@ -1932,6 +1960,9 @@ read_vmcoreinfo(void) - READ_SYMBOL("node_remap_start_vaddr", node_remap_start_vaddr); - READ_SYMBOL("node_remap_end_vaddr", node_remap_end_vaddr); - READ_SYMBOL("node_remap_start_pfn", node_remap_start_pfn); -+ READ_SYMBOL("vmemmap_list", vmemmap_list); -+ READ_SYMBOL("mmu_psize_defs", mmu_psize_defs); -+ READ_SYMBOL("mmu_vmemmap_psize", mmu_vmemmap_psize); - - READ_STRUCTURE_SIZE("page", page); - READ_STRUCTURE_SIZE("mem_section", mem_section); -@@ -1942,6 +1973,9 @@ read_vmcoreinfo(void) - READ_STRUCTURE_SIZE("node_memblk_s", node_memblk_s); - READ_STRUCTURE_SIZE("nodemask_t", nodemask_t); - READ_STRUCTURE_SIZE("pageflags", pageflags); -+ READ_STRUCTURE_SIZE("vmemmap_backing", vmemmap_backing); -+ READ_STRUCTURE_SIZE("mmu_psize_def", mmu_psize_def); -+ - - READ_MEMBER_OFFSET("page.flags", page.flags); - READ_MEMBER_OFFSET("page._count", page._count); -@@ -1972,6 +2006,11 @@ read_vmcoreinfo(void) - READ_MEMBER_OFFSET("vm_struct.addr", vm_struct.addr); - READ_MEMBER_OFFSET("vmap_area.va_start", vmap_area.va_start); - READ_MEMBER_OFFSET("vmap_area.list", vmap_area.list); -+ READ_MEMBER_OFFSET("vmemmap_backing.phys", vmemmap_backing.phys); -+ READ_MEMBER_OFFSET("vmemmap_backing.virt_addr", -+ vmemmap_backing.virt_addr); -+ READ_MEMBER_OFFSET("vmemmap_backing.list", vmemmap_backing.list); -+ READ_MEMBER_OFFSET("mmu_psize_def.shift", mmu_psize_def.shift); - - READ_STRUCTURE_SIZE("printk_log", printk_log); - if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { -diff --git a/makedumpfile-1.5.4/makedumpfile.h b/makedumpfile-1.5.4/makedumpfile.h -index 3a7e61a..517e16e 100644 ---- a/makedumpfile-1.5.4/makedumpfile.h -+++ b/makedumpfile-1.5.4/makedumpfile.h -@@ -576,6 +576,8 @@ do { \ - #define _SECTION_SIZE_BITS (24) - #define _MAX_PHYSMEM_BITS_ORIG (44) - #define _MAX_PHYSMEM_BITS_3_7 (46) -+#define REGION_SHIFT (60UL) -+#define VMEMMAP_REGION_ID (0xfUL) - #endif - - #ifdef __powerpc32__ -@@ -862,6 +864,11 @@ struct splitting_info { - unsigned long size_eraseinfo; - } splitting_info_t; - -+struct ppc64_vmemmap { -+ unsigned long phys; -+ unsigned long virt; -+}; -+ - struct DumpInfo { - int32_t kernel_version; /* version of first kernel*/ - struct timeval timestamp; -@@ -895,6 +902,7 @@ struct DumpInfo { - int flag_dmesg; /* dump the dmesg log out of the vmcore file */ - int flag_use_printk_log; /* did we read printk_log symbol name? */ - int flag_nospace; /* the flag of "No space on device" error */ -+ int flag_vmemmap; /* kernel supports vmemmap address space */ - unsigned long vaddr_for_vtop; /* virtual address for debugging */ - long page_size; /* size of page */ - long page_shift; -@@ -909,6 +917,9 @@ struct DumpInfo { - unsigned long vmalloc_end; - unsigned long vmemmap_start; - unsigned long vmemmap_end; -+ int vmemmap_psize; -+ int vmemmap_cnt; -+ struct ppc64_vmemmap *vmemmap_list; - - /* - * Filter config file containing filter commands to filter out kernel -@@ -1166,6 +1177,13 @@ struct symbol_table { - unsigned long long __per_cpu_load; - unsigned long long cpu_online_mask; - unsigned long long kexec_crash_image; -+ -+ /* -+ * vmemmap symbols on ppc64 arch -+ */ -+ unsigned long long vmemmap_list; -+ unsigned long long mmu_vmemmap_psize; -+ unsigned long long mmu_psize_defs; - }; - - struct size_table { -@@ -1201,6 +1219,12 @@ struct size_table { - long kexec_segment; - long elf64_hdr; - -+ /* -+ * vmemmap symbols on ppc64 arch -+ */ -+ long vmemmap_backing; -+ long mmu_psize_def; -+ - long pageflags; - }; - -@@ -1344,6 +1368,19 @@ struct offset_table { - long text_len; - } printk_log; - -+ /* -+ * vmemmap symbols on ppc64 arch -+ */ -+ struct mmu_psize_def { -+ long shift; -+ } mmu_psize_def; -+ -+ struct vmemmap_backing { -+ long phys; -+ long virt_addr; -+ long list; -+ } vmemmap_backing; -+ - }; - - /* --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch deleted file mode 100644 index 084e7d5..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch +++ /dev/null @@ -1,197 +0,0 @@ -From a01b663749c4b221ecd03285fa24a4b31e742004 Mon Sep 17 00:00:00 2001 -From: Lubomir Rintel -Date: Fri, 20 Sep 2013 15:56:49 +0900 -Subject: [PATCH] [PATCH v2] dump-dmesg: Understand >= v3.11-rc4 dmesg. - -Symbol name changed with the following commit: -62e32ac printk: rename struct log to struct printk_log - -Changes for v2: - * Only back values for symbol names we did actually read; - either "log" or "printk_log" - -Signed-off-by: Lubomir Rintel ---- - makedumpfile.c | 69 +++++++++++++++++++++++++++++++++++++++++++--------------- - makedumpfile.h | 7 +++--- - 2 files changed, 55 insertions(+), 21 deletions(-) - -diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c -index e01ff50..7bbdcc2 100644 ---- a/makedumpfile-1.5.4/makedumpfile.c -+++ b/makedumpfile-1.5.4/makedumpfile.c -@@ -1389,10 +1389,23 @@ get_structure_info(void) - OFFSET_INIT(elf64_phdr.p_paddr, "elf64_phdr", "p_paddr"); - OFFSET_INIT(elf64_phdr.p_memsz, "elf64_phdr", "p_memsz"); - -- SIZE_INIT(log, "log"); -- OFFSET_INIT(log.ts_nsec, "log", "ts_nsec"); -- OFFSET_INIT(log.len, "log", "len"); -- OFFSET_INIT(log.text_len, "log", "text_len"); -+ SIZE_INIT(printk_log, "printk_log"); -+ if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { -+ /* -+ * In kernel 3.11-rc4 the log structure name was renamed -+ * to "printk_log". -+ */ -+ info->flag_use_printk_log = TRUE; -+ OFFSET_INIT(printk_log.ts_nsec, "printk_log", "ts_nsec"); -+ OFFSET_INIT(printk_log.len, "printk_log", "len"); -+ OFFSET_INIT(printk_log.text_len, "printk_log", "text_len"); -+ } else { -+ info->flag_use_printk_log = FALSE; -+ SIZE_INIT(printk_log, "log"); -+ OFFSET_INIT(printk_log.ts_nsec, "log", "ts_nsec"); -+ OFFSET_INIT(printk_log.len, "log", "len"); -+ OFFSET_INIT(printk_log.text_len, "log", "text_len"); -+ } - - return TRUE; - } -@@ -1593,7 +1606,10 @@ write_vmcoreinfo_data(void) - WRITE_STRUCTURE_SIZE("node_memblk_s", node_memblk_s); - WRITE_STRUCTURE_SIZE("nodemask_t", nodemask_t); - WRITE_STRUCTURE_SIZE("pageflags", pageflags); -- WRITE_STRUCTURE_SIZE("log", log); -+ if (info->flag_use_printk_log) -+ WRITE_STRUCTURE_SIZE("printk_log", printk_log); -+ else -+ WRITE_STRUCTURE_SIZE("log", printk_log); - - /* - * write the member offset of 1st kernel -@@ -1628,9 +1644,16 @@ write_vmcoreinfo_data(void) - WRITE_MEMBER_OFFSET("vm_struct.addr", vm_struct.addr); - WRITE_MEMBER_OFFSET("vmap_area.va_start", vmap_area.va_start); - WRITE_MEMBER_OFFSET("vmap_area.list", vmap_area.list); -- WRITE_MEMBER_OFFSET("log.ts_nsec", log.ts_nsec); -- WRITE_MEMBER_OFFSET("log.len", log.len); -- WRITE_MEMBER_OFFSET("log.text_len", log.text_len); -+ if (info->flag_use_printk_log) { -+ WRITE_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec); -+ WRITE_MEMBER_OFFSET("printk_log.len", printk_log.len); -+ WRITE_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len); -+ } else { -+ /* Compatibility with pre-3.11-rc4 */ -+ WRITE_MEMBER_OFFSET("log.ts_nsec", printk_log.ts_nsec); -+ WRITE_MEMBER_OFFSET("log.len", printk_log.len); -+ WRITE_MEMBER_OFFSET("log.text_len", printk_log.text_len); -+ } - - if (SYMBOL(node_data) != NOT_FOUND_SYMBOL) - WRITE_ARRAY_LENGTH("node_data", node_data); -@@ -1909,7 +1932,6 @@ read_vmcoreinfo(void) - READ_STRUCTURE_SIZE("node_memblk_s", node_memblk_s); - READ_STRUCTURE_SIZE("nodemask_t", nodemask_t); - READ_STRUCTURE_SIZE("pageflags", pageflags); -- READ_STRUCTURE_SIZE("log", log); - - READ_MEMBER_OFFSET("page.flags", page.flags); - READ_MEMBER_OFFSET("page._count", page._count); -@@ -1940,9 +1962,20 @@ read_vmcoreinfo(void) - READ_MEMBER_OFFSET("vm_struct.addr", vm_struct.addr); - READ_MEMBER_OFFSET("vmap_area.va_start", vmap_area.va_start); - READ_MEMBER_OFFSET("vmap_area.list", vmap_area.list); -- READ_MEMBER_OFFSET("log.ts_nsec", log.ts_nsec); -- READ_MEMBER_OFFSET("log.len", log.len); -- READ_MEMBER_OFFSET("log.text_len", log.text_len); -+ -+ READ_STRUCTURE_SIZE("printk_log", printk_log); -+ if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { -+ info->flag_use_printk_log = TRUE; -+ READ_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec); -+ READ_MEMBER_OFFSET("printk_log.len", printk_log.len); -+ READ_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len); -+ } else { -+ info->flag_use_printk_log = FALSE; -+ READ_STRUCTURE_SIZE("log", printk_log); -+ READ_MEMBER_OFFSET("log.ts_nsec", printk_log.ts_nsec); -+ READ_MEMBER_OFFSET("log.len", printk_log.len); -+ READ_MEMBER_OFFSET("log.text_len", printk_log.text_len); -+ } - - READ_ARRAY_LENGTH("node_data", node_data); - READ_ARRAY_LENGTH("pgdat_list", pgdat_list); -@@ -3710,13 +3743,13 @@ dump_log_entry(char *logptr, int fp) - ulonglong nanos; - ulong rem; - -- text_len = USHORT(logptr + OFFSET(log.text_len)); -- ts_nsec = ULONGLONG(logptr + OFFSET(log.ts_nsec)); -+ text_len = USHORT(logptr + OFFSET(printk_log.text_len)); -+ ts_nsec = ULONGLONG(logptr + OFFSET(printk_log.ts_nsec)); - - nanos = (ulonglong)ts_nsec / (ulonglong)1000000000; - rem = (ulonglong)ts_nsec % (ulonglong)1000000000; - -- msg = logptr + SIZE(log); -+ msg = logptr + SIZE(printk_log); - - sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000); - -@@ -3754,7 +3787,7 @@ log_from_idx(unsigned int idx, char *logbuf) - * the buffer. - */ - -- msglen = USHORT(logptr + OFFSET(log.len)); -+ msglen = USHORT(logptr + OFFSET(printk_log.len)); - if (!msglen) - logptr = logbuf; - -@@ -3775,9 +3808,9 @@ log_next(unsigned int idx, char *logbuf) - * return the one after that. - */ - -- msglen = USHORT(logptr + OFFSET(log.len)); -+ msglen = USHORT(logptr + OFFSET(printk_log.len)); - if (!msglen) { -- msglen = USHORT(logbuf + OFFSET(log.len)); -+ msglen = USHORT(logbuf + OFFSET(printk_log.len)); - return msglen; - } - -diff --git a/makedumpfile-1.5.4/makedumpfile.h b/makedumpfile-1.5.4/makedumpfile.h -index c504bfb..3a7e61a 100644 ---- a/makedumpfile-1.5.4/makedumpfile.h -+++ b/makedumpfile-1.5.4/makedumpfile.h -@@ -893,6 +893,7 @@ struct DumpInfo { - int flag_force; /* overwrite existing stuff */ - int flag_exclude_xen_dom;/* exclude Domain-U from xen-kdump */ - int flag_dmesg; /* dump the dmesg log out of the vmcore file */ -+ int flag_use_printk_log; /* did we read printk_log symbol name? */ - int flag_nospace; /* the flag of "No space on device" error */ - unsigned long vaddr_for_vtop; /* virtual address for debugging */ - long page_size; /* size of page */ -@@ -1176,6 +1177,7 @@ struct size_table { - long list_head; - long node_memblk_s; - long nodemask_t; -+ long printk_log; - - /* - * for Xen extraction -@@ -1198,7 +1200,6 @@ struct size_table { - long cpumask_t; - long kexec_segment; - long elf64_hdr; -- long log; - - long pageflags; - }; -@@ -1337,11 +1338,11 @@ struct offset_table { - long p_memsz; - } elf64_phdr; - -- struct log_s { -+ struct printk_log_s { - long ts_nsec; - long len; - long text_len; -- } log; -+ } printk_log; - - }; - --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Update-pfn_cyclic-when-the-cyclic-buffer-size-.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Update-pfn_cyclic-when-the-cyclic-buffer-size-.patch deleted file mode 100644 index 87b9256..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Update-pfn_cyclic-when-the-cyclic-buffer-size-.patch +++ /dev/null @@ -1,33 +0,0 @@ -From a785fa7dd7a7bd7dcbb017d0bea8848243b0924f Mon Sep 17 00:00:00 2001 -Message-Id: -From: Atsushi Kumagai -Date: Thu, 12 Sep 2013 08:31:28 +0900 -Subject: [PATCH 1/2] [PATCH] Update pfn_cyclic when the cyclic buffer size is - corrected. - -When the clearing bit operation for excluding free pages can overrun -the cyclic buffer, the buffer size is changed with -check_cyclic_buffer_overrun(). -Then pfn_cyclic should be recalculated. - -Reviewed-by: HATAYAMA Daisuke -Signed-off-by: Atsushi Kumagai ---- - makedumpfile.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c -index 09c0d4a..164b3f1 100644 ---- a/makedumpfile-1.5.4/makedumpfile.c -+++ b/makedumpfile-1.5.4/makedumpfile.c -@@ -4091,6 +4091,7 @@ check_cyclic_buffer_overrun(void) - - bufsize = info->bufsize_cyclic; - info->bufsize_cyclic = round(bufsize, max_block_size); -+ info->pfn_cyclic = info->bufsize_cyclic * BITPERBYTE; - - MSG("cyclic buffer size has been changed: %lu => %lu\n", - bufsize, info->bufsize_cyclic); --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-required-bit.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-required-bit.patch deleted file mode 100644 index 177e853..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-required-bit.patch +++ /dev/null @@ -1,44 +0,0 @@ -From f8c8218856effc43ea01cd9394761cfb8aeaa8df Mon Sep 17 00:00:00 2001 -Message-Id: -In-Reply-To: -References: -From: HATAYAMA Daisuke -Date: Thu, 12 Sep 2013 13:19:00 +0900 -Subject: [PATCH 2/2] [PATCH] Use divideup() to calculate maximum required - bitmap size. - -Currently, check_cyclic_buffer_overrun() wrongly calculates maximum -bitmap size required to represent maximum block size managed by buddy -allocator with roundup(). Then, max_block_size is BITPERBYTE-time -larger than its correct size. As a result, although the bug never -affect free-page filtering since roundup(max_order_nr_pages, -BITPERBYTE) is a multiple of divideup(max_order_nr_pages, BITPERBYTE), -the following sanity check, (max_block_size > info->bufsize_cyclic), -and recalculation of info->bufsize_cyclic becomes BITPERBYTE-time -conservative and inefficient. - -Signed-off-by: HATAYAMA Daisuke ---- - makedumpfile.c | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c -index 164b3f1..1718f88 100644 ---- a/makedumpfile-1.5.4/makedumpfile.c -+++ b/makedumpfile-1.5.4/makedumpfile.c -@@ -4078,10 +4078,9 @@ check_cyclic_buffer_overrun(void) - { - int max_order = ARRAY_LENGTH(zone.free_area); - int max_order_nr_pages = 1 << (max_order - 1); -- unsigned long max_block_size = roundup(max_order_nr_pages, BITPERBYTE); -+ unsigned long max_block_size = divideup(max_order_nr_pages, BITPERBYTE); - -- if (info->bufsize_cyclic % -- roundup(max_order_nr_pages, BITPERBYTE)) { -+ if (info->bufsize_cyclic % max_block_size) { - unsigned long bufsize; - - if (max_block_size > info->bufsize_cyclic) { --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch deleted file mode 100644 index 8f0fbeb..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 92563d7a7a5175ef78c4a94ee269b1b455331b4c Mon Sep 17 00:00:00 2001 -From: HATAYAMA Daisuke -Date: Tue, 17 Sep 2013 15:29:33 +0900 -Subject: [PATCH] [PATCH 1/2] cache: Allocate buffers at initialization to - detect malloc() failure. - -malloc() is used in cache_alloc() but there's no check for it. If I -added check in cache_alloc() directly, cache_alloc() needs to return -one more error status and code gets somewhat complicated. Instead, I -move malloc() in initial() to detect allocation failure at -initialization. By this change, 8 buffers are allocated at the same -time, no longer incrementally. However, 8 buffers are almost always -used throughout execution. There's essential differnece from the -incremental one. - -Signed-off-by: HATAYAMA Daisuke ---- - cache.c | 29 ++++++++++++++++++++++------- - cache.h | 1 + - makedumpfile.c | 3 +++ - 3 files changed, 26 insertions(+), 7 deletions(-) - -diff --git a/makedumpfile-1.5.4/cache.c b/makedumpfile-1.5.4/cache.c -index 3bea089..dad8d80 100644 ---- a/makedumpfile-1.5.4/cache.c -+++ b/makedumpfile-1.5.4/cache.c -@@ -18,6 +18,7 @@ - - #include "makedumpfile.h" - #include "cache.h" -+#include "print_info.h" - - struct cache_entry { - unsigned long long paddr; -@@ -36,6 +37,25 @@ static int avail = CACHE_SIZE; - - static struct cache used, pending; - -+int -+cache_init(void) -+{ -+ void *bufptr; -+ int i; -+ -+ for (i = 0; i < CACHE_SIZE; ++i) { -+ bufptr = malloc(info->page_size); -+ if (bufptr == NULL) { -+ ERRMSG("Can't allocate memory for cache. %s\n", -+ strerror(errno)); -+ return FALSE; -+ } -+ pool[i].bufptr = bufptr; -+ } -+ -+ return TRUE; -+} -+ - static void - add_entry(struct cache *cache, struct cache_entry *entry) - { -@@ -83,13 +103,8 @@ cache_alloc(unsigned long long paddr) - { - struct cache_entry *entry = NULL; - -- if (avail) { -- void *bufptr = malloc(info->page_size); -- if (bufptr) { -- entry = &pool[--avail]; -- entry->bufptr = bufptr; -- } -- } -+ if (avail) -+ entry = &pool[--avail]; - - if (!entry) { - if (used.tail) { -diff --git a/makedumpfile-1.5.4/cache.h b/makedumpfile-1.5.4/cache.h -index f37d883..4730e12 100644 ---- a/makedumpfile-1.5.4/cache.h -+++ b/makedumpfile-1.5.4/cache.h -@@ -19,6 +19,7 @@ - #ifndef _CACHE_H - #define _CACHE_H - -+int cache_init(void); - void *cache_search(unsigned long long paddr); - void *cache_alloc(unsigned long long paddr); - void cache_add(unsigned long long paddr); -diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c -index 1718f88..e01ff50 100644 ---- a/makedumpfile-1.5.4/makedumpfile.c -+++ b/makedumpfile-1.5.4/makedumpfile.c -@@ -3017,6 +3017,9 @@ out: - DEBUG_MSG("Buffer size for the cyclic mode: %ld\n", info->bufsize_cyclic); - } - -+ if (!cache_init()) -+ return FALSE; -+ - if (debug_info) { - if (info->flag_sadump) - (void) sadump_virt_phys_base(); --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch b/SOURCES/kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch deleted file mode 100644 index 1438b0f..0000000 --- a/SOURCES/kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch +++ /dev/null @@ -1,120 +0,0 @@ -From e23dc0a1aa5fa7a4429f72ff1c2fe87a87291065 Mon Sep 17 00:00:00 2001 -From: HATAYAMA Daisuke -Date: Tue, 17 Sep 2013 15:29:38 +0900 -Subject: [PATCH] [PATCH 2/2] cache: Reuse entry in pending list. - -Currently, sadump_virt_phys_base() fails to calculate phys_base as -below: - -$ /pub/repos/makedumpfile/makedumpfile -f -p -d 31 -x /pub3/vmcores/comparevmcore_data/vmlinux-2.6.18-363.el5 /pub3/vmcores/comparevmcore_data/vmcore-2.6.18-363.el5-sadump /pub3/vmcores/comparevmcore_data/vmcore-pd31 -Switched running mode from cyclic to non-cyclic, -because the cyclic mode doesn't support sadump format. -readmem: type_addr: 1, addr:296020, size:13 -readmem: type_addr: 1, addr:ffffffffff296020, size:13 -readmem: type_addr: 1, addr:ffffffffff396020, size:13 -readmem: type_addr: 1, addr:ffffffffff496020, size:13 -readmem: type_addr: 1, addr:ffffffffff596020, size:13 -readmem: type_addr: 1, addr:ffffffffff696020, size:13 -readmem: type_addr: 1, addr:ffffffffff796020, size:13 -readmem: type_addr: 1, addr:ffffffffff896020, size:13 -readmem: type_addr: 1, addr:ffffffffff996020, size:13 -readmem: type_addr: 1, addr:ffffffffffa96020, size:13 -readmem: type_addr: 1, addr:ffffffffffb96020, size:13 -readmem: type_addr: 1, addr:ffffffffffc96020, size:13 -readmem: type_addr: 1, addr:ffffffffffd96020, size:13 -readmem: type_addr: 1, addr:ffffffffffe96020, size:13 -readmem: type_addr: 1, addr:fffffffffff96020, size:13 -readmem: type_addr: 1, addr:96020, size:13 -readmem: type_addr: 1, addr:196020, size:13 -readmem: type_addr: 1, addr:296020, size:13 -readmem: type_addr: 1, addr:396020, size:13 -readmem: type_addr: 1, addr:496020, size:13 -readmem: type_addr: 1, addr:596020, size:13 -readmem: type_addr: 1, addr:696020, size:13 -readmem: type_addr: 1, addr:796020, size:13 -readmem: type_addr: 1, addr:896020, size:13 -readmem: type_addr: 1, addr:996020, size:13 -readmem: type_addr: 1, addr:a96020, size:13 -readmem: type_addr: 1, addr:b96020, size:13 -readmem: type_addr: 1, addr:c96020, size:13 -readmem: type_addr: 1, addr:d96020, size:13 -readmem: type_addr: 1, addr:e96020, size:13 -readmem: type_addr: 1, addr:f96020, size:13 -readmem: type_addr: 1, addr:1096020, size:13 -readmem: type_addr: 1, addr:1196020, size:13 -readmem: type_addr: 1, addr:1296020, size:13 -readmem: type_addr: 0, addr:ffffffff8045e260, size:32 -cpu_online_mask_init: Can't read cpu_online_mask memory. - -makedumpfile Failed. - -By git bisect, I found this bug is caused by the following commit: - -commit 0aff0e5174d0708bf1bfb039ab863e1fea8a1029 -Author: Petr Tesarik -Date: Wed Oct 31 16:12:47 2012 +0900 - - [PATCH] keep dumpfile pages in a cache. - -Then, I found this bug happens in the following senario. - -If one of the readpage_xxx() methods fails reading 8 pages in a row, 8 -entries in pool are fully contained in pending list. Then, -cache_alloc() returns NULL and this continues forever in the -execution. In other words, there's assumption in cache_alloc() that if -pool is fully used, they are fully in used list, not in pending list -at all. However, the buggy path here breaks the assumption. This patch -changes cache_alloc() so that it first tries to reuse enty in pending -list if exists. - -In fact, I found this bug in ad-hoc phys_base calculation performed in -sadump_virt_phys_base(). However, I fixed cache side since this bug -can occur in general on every vmcore format. Crash dump can contain -broken data in any part of vmcore and so requested physical address to -read can be broken likewise. - -Signed-off-by: HATAYAMA Daisuke ---- - cache.c | 25 +++++++++++++------------ - 1 file changed, 13 insertions(+), 12 deletions(-) - -diff --git a/makedumpfile-1.5.4/cache.c b/makedumpfile-1.5.4/cache.c -index dad8d80..0dd957c 100644 ---- a/makedumpfile-1.5.4/cache.c -+++ b/makedumpfile-1.5.4/cache.c -@@ -103,19 +103,20 @@ cache_alloc(unsigned long long paddr) - { - struct cache_entry *entry = NULL; - -- if (avail) -+ if (avail) { - entry = &pool[--avail]; -- -- if (!entry) { -- if (used.tail) { -- entry = used.tail; -- remove_entry(&used, entry); -- } else -- return NULL; -- } -- -- entry->paddr = paddr; -- add_entry(&pending, entry); -+ entry->paddr = paddr; -+ add_entry(&pending, entry); -+ } else if (pending.tail) { -+ entry = pending.tail; -+ entry->paddr = paddr; -+ } else if (used.tail) { -+ entry = used.tail; -+ remove_entry(&used, entry); -+ entry->paddr = paddr; -+ add_entry(&pending, entry); -+ } else -+ return NULL; - - return entry->bufptr; - } --- -1.8.3.1 - diff --git a/SOURCES/kexec-tools-2.0.4-vmcore-dmesg-stack-smashing-happend-in-extreme-case.patch b/SOURCES/kexec-tools-2.0.4-vmcore-dmesg-stack-smashing-happend-in-extreme-case.patch deleted file mode 100644 index 044cb61..0000000 --- a/SOURCES/kexec-tools-2.0.4-vmcore-dmesg-stack-smashing-happend-in-extreme-case.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 401e037e5e9527134c594b8923342a69ff38b7cb Mon Sep 17 00:00:00 2001 -From: Arthur Zou -Date: Wed, 12 Mar 2014 13:05:18 +0800 -Subject: [PATCH] vmcore-dmesg stack smashing happend in extreme case - -Description -in dump_dmesg_structured() the out_buf size is 4096, and if the -length is less than 4080( 4096-16 ) it won't really write out. -Normally, after writing one or four chars to the out_buf, it will -check the length of out_buf. But in extreme cases, 19 chars was -written to the out_buf before checking the length. This may cause -the stack corruption. If the length was 4079 (won't realy write out), -and then write 19 chars to it. the out_buf will overflow. - -Solution -Change 16 to 64 thus can make sure that always have 64bytes before -moving to next records. why using 64 is that a long long int can take -20 bytes. so the length of timestamp can be 44 ('[','.',']',' ') in -extreme case. - -Signed-off-by: Arthur Zou -Acked-by: Vivek Goyal -Signed-off-by: Simon Horman ---- - vmcore-dmesg/vmcore-dmesg.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c -index 0345660..e15cd91 100644 ---- a/vmcore-dmesg/vmcore-dmesg.c -+++ b/vmcore-dmesg/vmcore-dmesg.c -@@ -674,7 +674,7 @@ static void dump_dmesg_structured(int fd) - else - out_buf[len++] = c; - -- if (len >= OUT_BUF_SIZE - 16) { -+ if (len >= OUT_BUF_SIZE - 64) { - write_to_stdout(out_buf, len); - len = 0; - } --- -1.8.4.2 - diff --git a/SOURCES/kexec-tools-2.0.4-vmcore-dmesg-struct_val_u64-not-casting-u64-to-u32.patch b/SOURCES/kexec-tools-2.0.4-vmcore-dmesg-struct_val_u64-not-casting-u64-to-u32.patch deleted file mode 100644 index e2e43ff..0000000 --- a/SOURCES/kexec-tools-2.0.4-vmcore-dmesg-struct_val_u64-not-casting-u64-to-u32.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 158d7638f1669a8d34def55ab81f10993e68e76a Mon Sep 17 00:00:00 2001 -From: WANG Chao -Date: Tue, 7 Jan 2014 01:37:34 +0800 -Subject: [PATCH] vmcore-dmesg: struct_val_u64() not casting u64 to u32 - -It seems gcc doesn't check return type from inline function. -struct_val_u64() should return u64 otherwise upper 32bit is lost. - -Signed-off-by: WANG Chao -Acked-by: Vivek Goyal -Signed-off-by: Simon Horman ---- - vmcore-dmesg/vmcore-dmesg.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c -index 0f477c0..df14c89 100644 ---- a/vmcore-dmesg/vmcore-dmesg.c -+++ b/vmcore-dmesg/vmcore-dmesg.c -@@ -529,7 +529,7 @@ static inline uint32_t struct_val_u32(char *ptr, unsigned int offset) - return(file32_to_cpu(*(uint32_t *)(ptr + offset))); - } - --static inline uint32_t struct_val_u64(char *ptr, unsigned int offset) -+static inline uint64_t struct_val_u64(char *ptr, unsigned int offset) - { - return(file64_to_cpu(*(uint64_t *)(ptr + offset))); - } --- -1.8.4.2 - diff --git a/SOURCES/kexec-tools-2.0.7-Provide-an-option-to-use-new-kexec-system-call.patch b/SOURCES/kexec-tools-2.0.7-Provide-an-option-to-use-new-kexec-system-call.patch new file mode 100644 index 0000000..7a2b61e --- /dev/null +++ b/SOURCES/kexec-tools-2.0.7-Provide-an-option-to-use-new-kexec-system-call.patch @@ -0,0 +1,443 @@ +From 046d1755d2bd723a11a180c265e61a884990712e Mon Sep 17 00:00:00 2001 +From: Vivek Goyal +Date: Mon, 18 Aug 2014 11:22:32 -0400 +Subject: [PATCH] kexec: Provide an option to use new kexec system call + +Hi, + +This is v2 of the patch. Since v1, I moved syscall implemented check littler +earlier in the function as per the feedback. + +Now a new kexec syscall (kexec_file_load()) has been merged in upstream +kernel. This system call takes file descriptors of kernel and initramfs +as input (as opposed to list of segments to be loaded). This new system +call allows for signature verification of the kernel being loaded. + +One use of signature verification of kernel is secureboot systems where +we want to allow kexec into a kernel only if it is validly signed by +a key system trusts. + +This patch provides and option --kexec-file-syscall (-s), to force use of +new system call for kexec. Default is to continue to use old syscall. + +Currently only bzImage64 on x86_64 can be loaded using this system call. +As kernel adds support for more arches and for more image types, kexec-tools +can be modified accordingly. + +Signed-off-by: Vivek Goyal +Acked-by: Baoquan He +Signed-off-by: Simon Horman +--- + kexec/arch/x86_64/kexec-bzImage64.c | 86 +++++++++++++++++++++++ + kexec/kexec-syscall.h | 32 +++++++++ + kexec/kexec.c | 132 +++++++++++++++++++++++++++++++++++- + kexec/kexec.h | 11 ++- + 4 files changed, 257 insertions(+), 4 deletions(-) + +diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c +index 1983bcf..8edb3e4 100644 +--- a/kexec/arch/x86_64/kexec-bzImage64.c ++++ b/kexec/arch/x86_64/kexec-bzImage64.c +@@ -235,6 +235,89 @@ static int do_bzImage64_load(struct kexec_info *info, + return 0; + } + ++/* This assumes file is being loaded using file based kexec syscall */ ++int bzImage64_load_file(int argc, char **argv, struct kexec_info *info) ++{ ++ int ret = 0; ++ char *command_line = NULL, *tmp_cmdline = NULL; ++ const char *ramdisk = NULL, *append = NULL; ++ int entry_16bit = 0, entry_32bit = 0; ++ int opt; ++ int command_line_len; ++ ++ /* See options.h -- add any more there, too. */ ++ static const struct option options[] = { ++ KEXEC_ARCH_OPTIONS ++ { "command-line", 1, 0, OPT_APPEND }, ++ { "append", 1, 0, OPT_APPEND }, ++ { "reuse-cmdline", 0, 0, OPT_REUSE_CMDLINE }, ++ { "initrd", 1, 0, OPT_RAMDISK }, ++ { "ramdisk", 1, 0, OPT_RAMDISK }, ++ { "real-mode", 0, 0, OPT_REAL_MODE }, ++ { "entry-32bit", 0, 0, OPT_ENTRY_32BIT }, ++ { 0, 0, 0, 0 }, ++ }; ++ static const char short_options[] = KEXEC_ARCH_OPT_STR "d"; ++ ++ while ((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) { ++ switch (opt) { ++ default: ++ /* Ignore core options */ ++ if (opt < OPT_ARCH_MAX) ++ break; ++ case OPT_APPEND: ++ append = optarg; ++ break; ++ case OPT_REUSE_CMDLINE: ++ tmp_cmdline = get_command_line(); ++ break; ++ case OPT_RAMDISK: ++ ramdisk = optarg; ++ break; ++ case OPT_REAL_MODE: ++ entry_16bit = 1; ++ break; ++ case OPT_ENTRY_32BIT: ++ entry_32bit = 1; ++ break; ++ } ++ } ++ command_line = concat_cmdline(tmp_cmdline, append); ++ if (tmp_cmdline) ++ free(tmp_cmdline); ++ command_line_len = 0; ++ if (command_line) { ++ command_line_len = strlen(command_line) + 1; ++ } else { ++ command_line = strdup("\0"); ++ command_line_len = 1; ++ } ++ ++ if (entry_16bit || entry_32bit) { ++ fprintf(stderr, "Kexec2 syscall does not support 16bit" ++ " or 32bit entry yet\n"); ++ ret = -1; ++ goto out; ++ } ++ ++ if (ramdisk) { ++ info->initrd_fd = open(ramdisk, O_RDONLY); ++ if (info->initrd_fd == -1) { ++ fprintf(stderr, "Could not open initrd file %s:%s\n", ++ ramdisk, strerror(errno)); ++ ret = -1; ++ goto out; ++ } ++ } ++ ++ info->command_line = command_line; ++ info->command_line_len = command_line_len; ++ return ret; ++out: ++ free(command_line); ++ return ret; ++} ++ + int bzImage64_load(int argc, char **argv, const char *buf, off_t len, + struct kexec_info *info) + { +@@ -247,6 +330,9 @@ int bzImage64_load(int argc, char **argv, const char *buf, off_t len, + int opt; + int result; + ++ if (info->file_mode) ++ return bzImage64_load_file(argc, argv, info); ++ + /* See options.h -- add any more there, too. */ + static const struct option options[] = { + KEXEC_ARCH_OPTIONS +diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h +index 6238044..ce2e20b 100644 +--- a/kexec/kexec-syscall.h ++++ b/kexec/kexec-syscall.h +@@ -53,6 +53,19 @@ + #endif + #endif /*ifndef __NR_kexec_load*/ + ++#ifndef __NR_kexec_file_load ++ ++#ifdef __x86_64__ ++#define __NR_kexec_file_load 320 ++#endif ++ ++#ifndef __NR_kexec_file_load ++/* system call not available for the arch */ ++#define __NR_kexec_file_load 0xffffffff /* system call not available */ ++#endif ++ ++#endif /*ifndef __NR_kexec_file_load*/ ++ + struct kexec_segment; + + static inline long kexec_load(void *entry, unsigned long nr_segments, +@@ -61,10 +74,29 @@ static inline long kexec_load(void *entry, unsigned long nr_segments, + return (long) syscall(__NR_kexec_load, entry, nr_segments, segments, flags); + } + ++static inline int is_kexec_file_load_implemented(void) { ++ if (__NR_kexec_file_load != 0xffffffff) ++ return 1; ++ return 0; ++} ++ ++static inline long kexec_file_load(int kernel_fd, int initrd_fd, ++ unsigned long cmdline_len, const char *cmdline_ptr, ++ unsigned long flags) ++{ ++ return (long) syscall(__NR_kexec_file_load, kernel_fd, initrd_fd, ++ cmdline_len, cmdline_ptr, flags); ++} ++ + #define KEXEC_ON_CRASH 0x00000001 + #define KEXEC_PRESERVE_CONTEXT 0x00000002 + #define KEXEC_ARCH_MASK 0xffff0000 + ++/* Flags for kexec file based system call */ ++#define KEXEC_FILE_UNLOAD 0x00000001 ++#define KEXEC_FILE_ON_CRASH 0x00000002 ++#define KEXEC_FILE_NO_INITRAMFS 0x00000004 ++ + /* These values match the ELF architecture values. + * Unless there is a good reason that should continue to be the case. + */ +diff --git a/kexec/kexec.c b/kexec/kexec.c +index 133e622..7e7b604 100644 +--- a/kexec/kexec.c ++++ b/kexec/kexec.c +@@ -51,6 +51,8 @@ + unsigned long long mem_min = 0; + unsigned long long mem_max = ULONG_MAX; + static unsigned long kexec_flags = 0; ++/* Flags for kexec file (fd) based syscall */ ++static unsigned long kexec_file_flags = 0; + int kexec_debug = 0; + + void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr) +@@ -787,6 +789,19 @@ static int my_load(const char *type, int fileind, int argc, char **argv, + return result; + } + ++static int kexec_file_unload(unsigned long kexec_file_flags) ++{ ++ int ret = 0; ++ ++ ret = kexec_file_load(-1, -1, 0, NULL, kexec_file_flags); ++ if (ret != 0) { ++ /* The unload failed, print some debugging information */ ++ fprintf(stderr, "kexec_file_load(unload) failed\n: %s\n", ++ strerror(errno)); ++ } ++ return ret; ++} ++ + static int k_unload (unsigned long kexec_flags) + { + int result; +@@ -925,6 +940,7 @@ void usage(void) + " (0 means it's not jump back or\n" + " preserve context)\n" + " to original kernel.\n" ++ " -s, --kexec-file-syscall Use file based syscall for kexec operation\n" + " -d, --debug Enable debugging to help spot a failure.\n" + "\n" + "Supported kernel file types and options: \n"); +@@ -1072,6 +1088,82 @@ char *concat_cmdline(const char *base, const char *append) + return cmdline; + } + ++/* New file based kexec system call related code */ ++static int do_kexec_file_load(int fileind, int argc, char **argv, ++ unsigned long flags) { ++ ++ char *kernel; ++ int kernel_fd, i; ++ struct kexec_info info; ++ int ret = 0; ++ char *kernel_buf; ++ off_t kernel_size; ++ ++ memset(&info, 0, sizeof(info)); ++ info.segment = NULL; ++ info.nr_segments = 0; ++ info.entry = NULL; ++ info.backup_start = 0; ++ info.kexec_flags = flags; ++ ++ info.file_mode = 1; ++ info.initrd_fd = -1; ++ ++ if (!is_kexec_file_load_implemented()) { ++ fprintf(stderr, "syscall kexec_file_load not available.\n"); ++ return -1; ++ } ++ ++ if (argc - fileind <= 0) { ++ fprintf(stderr, "No kernel specified\n"); ++ usage(); ++ return -1; ++ } ++ ++ kernel = argv[fileind]; ++ ++ kernel_fd = open(kernel, O_RDONLY); ++ if (kernel_fd == -1) { ++ fprintf(stderr, "Failed to open file %s:%s\n", kernel, ++ strerror(errno)); ++ return -1; ++ } ++ ++ /* slurp in the input kernel */ ++ kernel_buf = slurp_decompress_file(kernel, &kernel_size); ++ ++ for (i = 0; i < file_types; i++) { ++ if (file_type[i].probe(kernel_buf, kernel_size) >= 0) ++ break; ++ } ++ ++ if (i == file_types) { ++ fprintf(stderr, "Cannot determine the file type " "of %s\n", ++ kernel); ++ return -1; ++ } ++ ++ ret = file_type[i].load(argc, argv, kernel_buf, kernel_size, &info); ++ if (ret < 0) { ++ fprintf(stderr, "Cannot load %s\n", kernel); ++ return ret; ++ } ++ ++ /* ++ * If there is no initramfs, set KEXEC_FILE_NO_INITRAMFS flag so that ++ * kernel does not return error with negative initrd_fd. ++ */ ++ if (info.initrd_fd == -1) ++ info.kexec_flags |= KEXEC_FILE_NO_INITRAMFS; ++ ++ ret = kexec_file_load(kernel_fd, info.initrd_fd, info.command_line_len, ++ info.command_line, info.kexec_flags); ++ if (ret != 0) ++ fprintf(stderr, "kexec_file_load failed: %s\n", ++ strerror(errno)); ++ return ret; ++} ++ + + int main(int argc, char *argv[]) + { +@@ -1083,6 +1175,7 @@ int main(int argc, char *argv[]) + int do_ifdown = 0; + int do_unload = 0; + int do_reuse_initrd = 0; ++ int do_kexec_file_syscall = 0; + void *entry = 0; + char *type = 0; + char *endptr; +@@ -1095,6 +1188,23 @@ int main(int argc, char *argv[]) + }; + static const char short_options[] = KEXEC_ALL_OPT_STR; + ++ /* ++ * First check if --use-kexec-file-syscall is set. That changes lot of ++ * things ++ */ ++ while ((opt = getopt_long(argc, argv, short_options, ++ options, 0)) != -1) { ++ switch(opt) { ++ case OPT_KEXEC_FILE_SYSCALL: ++ do_kexec_file_syscall = 1; ++ break; ++ } ++ } ++ ++ /* Reset getopt for the next pass. */ ++ opterr = 1; ++ optind = 1; ++ + while ((opt = getopt_long(argc, argv, short_options, + options, 0)) != -1) { + switch(opt) { +@@ -1127,6 +1237,8 @@ int main(int argc, char *argv[]) + do_shutdown = 0; + do_sync = 0; + do_unload = 1; ++ if (do_kexec_file_syscall) ++ kexec_file_flags |= KEXEC_FILE_UNLOAD; + break; + case OPT_EXEC: + do_load = 0; +@@ -1169,7 +1281,10 @@ int main(int argc, char *argv[]) + do_exec = 0; + do_shutdown = 0; + do_sync = 0; +- kexec_flags = KEXEC_ON_CRASH; ++ if (do_kexec_file_syscall) ++ kexec_file_flags |= KEXEC_FILE_ON_CRASH; ++ else ++ kexec_flags = KEXEC_ON_CRASH; + break; + case OPT_MEM_MIN: + mem_min = strtoul(optarg, &endptr, 0); +@@ -1194,6 +1309,9 @@ int main(int argc, char *argv[]) + case OPT_REUSE_INITRD: + do_reuse_initrd = 1; + break; ++ case OPT_KEXEC_FILE_SYSCALL: ++ /* We already parsed it. Nothing to do. */ ++ break; + default: + break; + } +@@ -1238,10 +1356,18 @@ int main(int argc, char *argv[]) + } + + if (do_unload) { +- result = k_unload(kexec_flags); ++ if (do_kexec_file_syscall) ++ result = kexec_file_unload(kexec_file_flags); ++ else ++ result = k_unload(kexec_flags); + } + if (do_load && (result == 0)) { +- result = my_load(type, fileind, argc, argv, kexec_flags, entry); ++ if (do_kexec_file_syscall) ++ result = do_kexec_file_load(fileind, argc, argv, ++ kexec_file_flags); ++ else ++ result = my_load(type, fileind, argc, argv, ++ kexec_flags, entry); + } + /* Don't shutdown unless there is something to reboot to! */ + if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) { +diff --git a/kexec/kexec.h b/kexec/kexec.h +index 2fad7dc..4be2b2f 100644 +--- a/kexec/kexec.h ++++ b/kexec/kexec.h +@@ -156,6 +156,13 @@ struct kexec_info { + unsigned long kexec_flags; + unsigned long backup_src_start; + unsigned long backup_src_size; ++ /* Set to 1 if we are using kexec file syscall */ ++ unsigned long file_mode :1; ++ ++ /* Filled by kernel image processing code */ ++ int initrd_fd; ++ char *command_line; ++ int command_line_len; + }; + + struct arch_map_entry { +@@ -207,6 +214,7 @@ extern int file_types; + #define OPT_UNLOAD 'u' + #define OPT_TYPE 't' + #define OPT_PANIC 'p' ++#define OPT_KEXEC_FILE_SYSCALL 's' + #define OPT_MEM_MIN 256 + #define OPT_MEM_MAX 257 + #define OPT_REUSE_INITRD 258 +@@ -230,9 +238,10 @@ extern int file_types; + { "mem-min", 1, 0, OPT_MEM_MIN }, \ + { "mem-max", 1, 0, OPT_MEM_MAX }, \ + { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ ++ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ + { "debug", 0, 0, OPT_DEBUG }, \ + +-#define KEXEC_OPT_STR "h?vdfxluet:p" ++#define KEXEC_OPT_STR "h?vdfxluet:ps" + + extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr); + extern void die(const char *fmt, ...) +-- +1.9.0 + diff --git a/SOURCES/kexec-tools-2.0.7-kexec-ppc64-disabling-exception-handling-when-buildi.patch b/SOURCES/kexec-tools-2.0.7-kexec-ppc64-disabling-exception-handling-when-buildi.patch new file mode 100644 index 0000000..4c92242 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.7-kexec-ppc64-disabling-exception-handling-when-buildi.patch @@ -0,0 +1,37 @@ +From 335bad77fb0750f3961aa8df47c83a522d212b08 Mon Sep 17 00:00:00 2001 +From: Laurent Dufour +Date: Tue, 22 Jul 2014 18:22:28 +0200 +Subject: [PATCH] kexec/ppc64: disabling exception handling when building the + purgatory + +Some Linux distributions would like to turn on the GCC exception handling +by default. As this option introduces symbols in the built code that are +defined in a separate shared library, this is not a good idea to have such +an option activated when building the purgatory. + +This patch forces the exception handling to be turned off when building the +purgatory on ppc64 BE and LE. + +Signed-off-by: Laurent Dufour +Signed-off-by: Simon Horman +--- + purgatory/arch/ppc64/Makefile | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/purgatory/arch/ppc64/Makefile b/purgatory/arch/ppc64/Makefile +index 712e2b1..6c58fa2 100644 +--- a/purgatory/arch/ppc64/Makefile ++++ b/purgatory/arch/ppc64/Makefile +@@ -9,7 +9,8 @@ ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/console-ppc64.c + ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/crashdump_backup.c + ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/misc.S + +-ppc64_PURGATORY_EXTRA_CFLAGS += -m64 -msoft-float -fno-stack-protector ++ppc64_PURGATORY_EXTRA_CFLAGS += -m64 -msoft-float -fno-stack-protector \ ++ -fno-exceptions + ppc64_PURGATORY_EXTRA_ASFLAGS += -m64 + ifeq ($(SUBARCH),BE) + ppc64_PURGATORY_EXTRA_LDFLAGS += -melf64ppc +-- +1.9.3 + diff --git a/SOURCES/kexec-tools-2.0.7-kexec-ppc64-move-to-device-tree-version-17.patch b/SOURCES/kexec-tools-2.0.7-kexec-ppc64-move-to-device-tree-version-17.patch new file mode 100644 index 0000000..c7a4bb4 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.7-kexec-ppc64-move-to-device-tree-version-17.patch @@ -0,0 +1,42 @@ +From 2ca220389d212249cc842d49084c95e524fb299b Mon Sep 17 00:00:00 2001 +From: Laurent Dufour +Date: Mon, 16 Jun 2014 14:42:43 +0200 +Subject: [PATCH] kexec/ppc64: move to device tree version 17 + +Kernel commit e6a6928c3ea1d0195ed75a091e345696b916c09b changed the way the +device tree is processed in the kernel. Now version 2 is no more supported. + +This patch move the version of the device tree generated in ppc64 +environment from 2 to 17, allowing to kexec kernel 3.16. + +In addition, automates the define of NEED_STRUCTURE_BLOCK_EXTRA_PAD which +should not be set for DT version 16 and above. + +Signed-off-by: Laurent Dufour +Signed-off-by: Simon Horman +--- + kexec/arch/ppc64/kexec-ppc64.h | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/kexec/arch/ppc64/kexec-ppc64.h b/kexec/arch/ppc64/kexec-ppc64.h +index 9a0aecf..89ee942 100644 +--- a/kexec/arch/ppc64/kexec-ppc64.h ++++ b/kexec/arch/ppc64/kexec-ppc64.h +@@ -6,9 +6,11 @@ + #define CORE_TYPE_ELF32 1 + #define CORE_TYPE_ELF64 2 + +-#define BOOT_BLOCK_VERSION 2 +-#define BOOT_BLOCK_LAST_COMP_VERSION 2 +-#define NEED_STRUCTURE_BLOCK_EXTRA_PAD ++#define BOOT_BLOCK_VERSION 17 ++#define BOOT_BLOCK_LAST_COMP_VERSION 17 ++#if (BOOT_BLOCK_VERSION < 16) ++# define NEED_STRUCTURE_BLOCK_EXTRA_PAD ++#endif + #define HAVE_DYNAMIC_MEMORY + #define NEED_RESERVE_DTB + +-- +1.9.3 + diff --git a/SOURCES/kexec-tools-2.0.7-ppc64-kdump-Fix-ELF-header-endianess.patch b/SOURCES/kexec-tools-2.0.7-ppc64-kdump-Fix-ELF-header-endianess.patch new file mode 100644 index 0000000..eb6bbd7 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.7-ppc64-kdump-Fix-ELF-header-endianess.patch @@ -0,0 +1,36 @@ +From 45b33eb2e70cd44f41abf1058a92659cb4315011 Mon Sep 17 00:00:00 2001 +From: Laurent Dufour +Date: Fri, 25 Jul 2014 17:07:49 +0200 +Subject: [PATCH] ppc64/kdump: Fix ELF header endianess + +The ELF header created among the loading of the kdump kernel should be +flagged using the current endianess and not always as big endian. + +Without this patch the data exposed in /proc/vmcore are not readable when +running in LE mode. + +Signed-off-by: Laurent Dufour +Signed-off-by: Simon Horman +--- + kexec/arch/ppc64/crashdump-ppc64.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c +index 00a0e63..6214b83 100644 +--- a/kexec/arch/ppc64/crashdump-ppc64.c ++++ b/kexec/arch/ppc64/crashdump-ppc64.c +@@ -38,7 +38,11 @@ + static struct crash_elf_info elf_info64 = + { + class: ELFCLASS64, ++#if BYTE_ORDER == LITTLE_ENDIAN ++ data: ELFDATA2LSB, ++#else + data: ELFDATA2MSB, ++#endif + machine: EM_PPC64, + page_offset: PAGE_OFFSET, + lowmem_limit: MAXMEM, +-- +1.9.3 + diff --git a/SOURCES/mkdumprd b/SOURCES/mkdumprd index 2801eaa..0480060 100644 --- a/SOURCES/mkdumprd +++ b/SOURCES/mkdumprd @@ -12,9 +12,9 @@ export IN_KDUMP=1 conf_file="/etc/kdump.conf" SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) -[ -z "$SAVE_PATH" ] && SAVE_PATH="/var/crash" +[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH extra_modules="" -dracut_args=("--hostonly" "--hostonly-cmdline" "-o" "plymouth dash") +dracut_args=("--hostonly" "--hostonly-cmdline" "-o" "plymouth dash resume") OVERRIDE_RESETTABLE=0 perror_exit() { @@ -97,19 +97,42 @@ target_is_root() { # caller should ensure $1 is valid and mounted in 1st kernel to_mount() { - local _dev=$1 _s _t _o _mntopts _pdev - - _s=$(findmnt -k -f -n -r -o SOURCE $_dev) - _t=$(findmnt -k -f -n -r -o TARGET,FSTYPE $_dev) - _o=$(findmnt -k -f -n -r -o OPTIONS $_dev) - _o=${_o/#ro/rw} #mount fs target as rw in 2nd kernel - # "nofail" mount could be run later than kdump.sh. So we don't pass nofail - # for short term. - #_o="${_o},nofail" #with nofail set, systemd won't block for mount failure - _mntopts="$_t $_o" + local _dev=$1 _source _target _fstype _options _mntopts _pdev + + _source=$(findmnt -k -f -n -r -o SOURCE $_dev) + _target=$(findmnt -k -f -n -r -o 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. + + if [ "$_target" = "/" ];then + _target="/sysroot" + else + _target="/kdumproot/$_target" + fi + + _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev) + _options=$(findmnt --fstab -f -n -r -o OPTIONS $_dev) + [ -z "$_options" ] && _options=$(findmnt -k -f -n -r -o OPTIONS $_dev) + _options=${_options/#ro/rw} #mount fs target as rw in 2nd kernel + # "x-initrd.mount" mount failure will trigger isolate emergency service + # W/o this, systemd won't isolate, thus we won't get to emergency. + # This is not applicable to remote fs mount, because if we use + # "x-initrd.mount", remote mount will become required by + # "initrd-root-fs.target", instead of "remote-fs.target". That's how it is + # handled within systemd internal. We need remote mount to be required + # "remote-fs.target", because we need to bring up network before any remote + # mount and "remote-fs.target" can be a checkpoint of that. + # If remote mount fails, dracut-initqueue will still start and once + # dracut-initqueue finishes, kdump service will start. Because remote mount + # failed, kdump service will fail and it will lead to kdump error handler. + if ! is_nfs_dump_target; then + _options="$_options,x-initrd.mount" + fi + _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name - if [ -b "$_s" ]; then - _pdev="$(get_persistent_dev $_s)" + if [ -b "$_source" ]; then + _pdev="$(get_persistent_dev $_source)" if [ $? -ne 0 ]; then return 1 fi @@ -175,37 +198,6 @@ mkdir_save_path_ssh() return 0 } - -#mkdir if save path does not exist on dump target filesystem -#$1=dump target -#caller should ensure $1 is mounted -mkdir_save_path_fs() { - local _mnt=$(to_mount_point $1) - local _remount="no" - local _ret - - [ ! -d ${_mnt}/$SAVE_PATH ] && { - if is_readonly_mount $1; then - echo "Mounting $1 as read-write for creating dump directory.." - mount -o remount,rw $1 || { - perror_exit "Mounting $1 as read-write failed." - } - _remount="yes" - fi - mkdir -p ${_mnt}/$SAVE_PATH - _ret=$? - [ "$_remount" = "yes" ] && { - echo "Remounting $1 as read-only." - mount -o remount,ro $1 || { - perror_exit "Remounting $1 as read-only failed." - } - } - [ $_ret -ne 0 ] && { - perror_exit "Creating ${_mnt}/$SAVE_PATH failed." - } - } -} - #Function: get_fs_size #$1=dump target get_fs_size() { @@ -358,24 +350,29 @@ get_block_dump_target() [ -b "$_target" ] && echo $(to_dev_name $_target) } -# If no dump disk is specified make sure /var/crash is not mounted on a -# separate disk. -check_block_dump_target() +#handle the case user does not specify the dump target explicitly +handle_default_dump_target() { local _target local _mntpoint + local _fstype is_user_configured_dump_target && return - _target=$(get_root_fs_device) - if [ -b "$_target" ]; then - mkdir -p $SAVE_PATH - _mntpoint=`df $SAVE_PATH | tail -1 | awk '{print $NF}'` - if [ "$_mntpoint" != "/" ]; then - perror "No dump target specified. Default dump target is rootfs block device." - perror "But dump path $SAVE_PATH is not backed by rootfs block device. " - perror_exit "Either explicitly specify a dump target or specify a dump path backed by rootfs block device" + check_save_path_fs $SAVE_PATH + + _mntpoint=$(get_mntpoint_from_path $SAVE_PATH) + _target=$(get_target_from_path $SAVE_PATH) + if [ "$_mntpoint" != "/" ]; then + SAVE_PATH=${SAVE_PATH##"$_mntpoint"} + _fstype=$(get_fs_type_from_target $_target) + + if $(is_fs_type_nfs $_fstype); then + add_dracut_module "nfs" fi + + add_mount "$_target" + check_size fs $_target fi } @@ -502,8 +499,6 @@ check_crypt() return 1 } -check_block_dump_target - if ! check_resettable; then exit 1 fi @@ -540,7 +535,7 @@ do add_dracut_module "nfs" fi add_mount "$config_val" - mkdir_save_path_fs $config_val + check_save_path_fs $(make_absolute_save_path $config_val) check_size fs $config_val ;; raw) @@ -581,6 +576,8 @@ do esac done < $conf_file +handle_default_dump_target + if [ -n "$extra_modules" ] then add_dracut_arg "--add-drivers" "$extra_modules" diff --git a/SOURCES/rhcrashkernel-param b/SOURCES/rhcrashkernel-param deleted file mode 100644 index a823e4b..0000000 --- a/SOURCES/rhcrashkernel-param +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -if grep -q Fedora /etc/redhat-release; then - echo -n -else - echo crashkernel=auto -fi diff --git a/SPECS/kexec-tools.spec b/SPECS/kexec-tools.spec index a33a4f9..da70498 100644 --- a/SPECS/kexec-tools.spec +++ b/SPECS/kexec-tools.spec @@ -1,10 +1,10 @@ Name: kexec-tools -Version: 2.0.4 -Release: 32%{?dist}.5 +Version: 2.0.7 +Release: 19%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component. -Source0: http://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.bz2 +Source0: http://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz Source1: kdumpctl Source2: kdump.sysconfig Source3: kdump.sysconfig.x86_64 @@ -13,21 +13,21 @@ Source5: kdump.sysconfig.ppc64 Source6: kdump.sysconfig.ia64 Source7: mkdumprd Source8: kdump.conf -Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.5.4/makedumpfile-1.5.4.tar.gz +Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.5.7/makedumpfile-1.5.7.tar.gz Source10: kexec-kdump-howto.txt -Source11: firstboot_kdump.py Source12: mkdumprd.8 -Source13: kexec-tools-po-20131224.tgz Source14: 98-kexec.rules Source15: kdump.conf.5 Source16: kdump.service -Source17: rhcrashkernel-param Source18: kdump.sysconfig.s390x Source19: eppic_030413.tar.gz Source20: kdump-lib.sh Source21: kdump-in-cluster-environment.txt Source22: supported-kdump-targets.txt Source23: kdump-dep-generator.sh +Source24: kdump-lib-initramfs.sh +Source25: kdump-anaconda-addon-003-11-g7f70211.tar.gz +Source26: kdump.sysconfig.ppc64le ####################################### # These are sources for mkdumpramfs @@ -36,6 +36,10 @@ Source23: kdump-dep-generator.sh Source100: dracut-kdump.sh Source101: dracut-module-setup.sh Source102: dracut-monitor_dd_progress +Source103: dracut-kdump-error-handler.sh +Source104: dracut-kdump-emergency.service +Source105: dracut-kdump-error-handler.service +Source106: dracut-kdump-capture.service Requires(post): systemd-units Requires(preun): systemd-units @@ -46,24 +50,23 @@ Requires: dracut-network, ethtool BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-units -%ifarch %{ix86} x86_64 ppc64 ia64 ppc s390x +%ifarch %{ix86} x86_64 ppc64 ia64 ppc s390x ppc64le Obsoletes: diskdumputils netdump %endif +ExcludeArch: aarch64 + #START INSERT # # Patches 0 through 100 are meant for x86 kexec-tools enablement # -Patch001: kexec-tools-2.0.4-Revert-kexec-lengthen-the-kernel-command-line-image.patch -Patch002: kexec-tools-2.0.4-kexec-i386-Add-cmdline_add_memmap_internal-to-reduce.patch -Patch003: kexec-tools-2.0.4-Revert-kexec-include-reserved-e820-sections-in-crash.patch # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # -Patch101: kexec-tools-2.0.4-kdump-x86-Process-multiple-Crash-kernel-in-proc-iome.patch +Patch101: kexec-tools-2.0.7-Provide-an-option-to-use-new-kexec-system-call.patch # # Patches 201 through 300 are meant for ia64 kexec-tools enablement @@ -72,8 +75,9 @@ Patch101: kexec-tools-2.0.4-kdump-x86-Process-multiple-Crash-kernel-in-proc-iome # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement # -Patch301: kexec-tools-2.0.4-makedumpfile-Add-vmap_area_list-definition-for-ppc-ppc64.patch -Patch302: kexec-tools-2.0.4-makedumpfile-Support-to-filter-dump-for-kernels-that-use.patch +Patch301: kexec-tools-2.0.7-kexec-ppc64-disabling-exception-handling-when-buildi.patch +Patch302: kexec-tools-2.0.7-kexec-ppc64-move-to-device-tree-version-17.patch +Patch303: kexec-tools-2.0.7-ppc64-kdump-Fix-ELF-header-endianess.patch # # Patches 401 through 500 are meant for s390 kexec-tools enablement @@ -86,24 +90,10 @@ Patch302: kexec-tools-2.0.4-makedumpfile-Support-to-filter-dump-for-kernels-that # Patches 601 onward are generic patches # Patch601: kexec-tools-2.0.3-disable-kexec-test.patch -Patch604: kexec-tools-2.0.3-build-makedumpfile-eppic-shared-object.patch -Patch605: kexec-tools-2.0.4-makedumpfile-PATCH-Support-newer-kernels.patch -Patch606: kexec-tools-2.0.4-makedumpfile-Fix-max_mapnr-issue-on-system-has-over-44-b.patch -Patch607: kexec-tools-2.0.4-makedumpfile-Update-pfn_cyclic-when-the-cyclic-buffer-size-.patch -Patch608: kexec-tools-2.0.4-makedumpfile-Use-divideup-to-calculate-maximum-required-bit.patch -Patch609: kexec-tools-2.0.4-makedumpfile-cache-Allocate-buffers-at-initialization-t.patch -Patch610: kexec-tools-2.0.4-makedumpfile-cache-Reuse-entry-in-pending-list.patch -Patch612: kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch -Patch613: kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch -Patch614: kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch -Patch615: kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch -Patch616: kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch -Patch617: kexec-tools-2.0.4-vmcore-dmesg-struct_val_u64-not-casting-u64-to-u32.patch -Patch618: kexec-tools-2.0.4-makedumpfile-Improve-progress-information-for-huge-memor.patch -Patch619: kexec-tools-2.0.4-vmcore-dmesg-stack-smashing-happend-in-extreme-case.patch -Patch620: kexec-tools-2.0.4-Enumerate-all-sys-devices-system-cpu-cpuN-when-they-.patch -Patch621: kexec-tools-2.0.4-Fix-mistaken-check-of-stat-2-return-value.patch -Patch622: kexec-tools-2.0.4-makedumpfile-Fix-a-segmentation-fault-when-physical-addr.patch + +# +# Patch 701 through 800 are meant for kdump anaconda addon +# %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -112,9 +102,9 @@ normal or a panic reboot. This package contains the /sbin/kexec binary and ancillary utilities that together form the userspace component of the kernel's kexec feature. -%ifarch %{ix86} x86_64 ia64 ppc64 s390x +%ifarch %{ix86} x86_64 ia64 ppc64 s390x ppc64le %package eppic -Requires: %{name} = %{version} +Requires: %{name} = %{version}-%{release} Summary: Additional eppic_makedumpfile.so shared object Group: Applications/System @@ -124,41 +114,27 @@ The eppic_makedumpfile.so shared object is loaded by the or confidential kernel data from a dumpfile. %endif +%package anaconda-addon +Summary: Kdump configration anaconda addon +Requires: anaconda >= 19.31.85 +%description anaconda-addon +Kdump anaconda addon + %prep %setup -q mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} +tar -z -x -v -f %{SOURCE25} %patch101 -p1 -%patch301 -p1 %patch601 -p1 -%patch604 -p1 -%patch605 -p1 -%patch606 -p1 -%patch607 -p1 -%patch608 -p1 -%patch609 -p1 -%patch610 -p1 -%patch001 -p1 -%patch002 -p1 -%patch003 -p1 -%patch612 -p1 +%patch301 -p1 %patch302 -p1 -%patch613 -p1 -%patch614 -p1 -%patch615 -p1 -%patch616 -p1 -%patch617 -p1 -%patch618 -p1 -%patch619 -p1 -%patch620 -p1 -%patch621 -p1 -%patch622 -p1 - -tar -z -x -v -f %{SOURCE13} +%patch303 -p1 + %ifarch ppc %define archdef ARCH=ppc @@ -179,6 +155,10 @@ export CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2" --host=powerpc64-redhat-linux-gnu \ --build=powerpc64-redhat-linux-gnu \ %endif +%ifarch ppc64le + --host=powerpc64le-redhat-linux-gnu \ + --build=powerpc64le-redhat-linux-gnu \ +%endif --sbindir=/sbin rm -f kexec-tools.spec.in # setup the docs @@ -187,11 +167,12 @@ cp %{SOURCE21} . cp %{SOURCE22} . make -%ifarch %{ix86} x86_64 ia64 ppc64 s390x +%ifarch %{ix86} x86_64 ia64 ppc64 s390x ppc64le make -C eppic/libeppic -make -C makedumpfile-1.5.4 LINKTYPE=dynamic USELZO=on USESNAPPY=on +make -C makedumpfile-1.5.7 LINKTYPE=dynamic USELZO=on USESNAPPY=on +make -C makedumpfile-1.5.7 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so %endif -make -C kexec-tools-po +make -C kdump-anaconda-addon/po %install make install DESTDIR=$RPM_BUILD_ROOT @@ -201,7 +182,7 @@ mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/ mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man5/ mkdir -p -m755 $RPM_BUILD_ROOT%{_docdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_datadir}/kdump -mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d +mkdir -p -m755 $RPM_BUILD_ROOT%{_udevrulesdir} mkdir -p $RPM_BUILD_ROOT%{_unitdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_bindir} mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir} @@ -216,29 +197,29 @@ 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 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 -install -m 755 %{SOURCE11} $RPM_BUILD_ROOT%{_datadir}/kdump/firstboot_kdump.py install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh +install -m 755 %{SOURCE24} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh %ifnarch s390x # For s390x the ELF header is created in the kdump kernel and therefore kexec # udev rules are not required -install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d/98-kexec.rules +install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules %endif 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 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh -mkdir -p $RPM_BUILD_ROOT/usr/sbin -install -m 755 %{SOURCE17} $RPM_BUILD_ROOT/usr/sbin/rhcrashkernel-param - -%ifarch %{ix86} x86_64 ia64 ppc64 s390x -install -m 755 makedumpfile-1.5.4/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile -install -m 644 makedumpfile-1.5.4/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz -install -m 644 makedumpfile-1.5.4/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz -install -m 644 makedumpfile-1.5.4/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample -install -m 755 makedumpfile-1.5.4/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so + +%ifarch %{ix86} x86_64 ia64 ppc64 s390x ppc64le +install -m 755 makedumpfile-1.5.7/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile +install -m 644 makedumpfile-1.5.7/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz +install -m 644 makedumpfile-1.5.7/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz +install -m 644 makedumpfile-1.5.7/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample +install -m 755 makedumpfile-1.5.7/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.5.7/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ %endif -make -C kexec-tools-po install DESTDIR=$RPM_BUILD_ROOT -%find_lang %{name} +make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT +%find_lang kdump-anaconda-addon %define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') @@ -247,7 +228,10 @@ mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpba cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} - +cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}} +cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} +cp %{SOURCE105} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE105}} +cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} @@ -303,25 +287,10 @@ fi /bin/systemctl try-restart kdump.service >/dev/null 2>&1 || : -%triggerin -- firstboot -# we enable kdump everywhere except for paravirtualized xen domains; check here -if [ -f /proc/xen/capabilities ]; then - if [ -z `grep control_d /proc/xen/capabilities` ]; then - exit 0 - fi -fi -if [ ! -e %{_datadir}/firstboot/modules/firstboot_kdump.py ] -then - ln -s %{_datadir}/kdump/firstboot_kdump.py %{_datadir}/firstboot/modules/firstboot_kdump.py -fi - %triggerin -- kernel-kdump touch %{_sysconfdir}/kdump.conf -%triggerun -- firstboot -rm -f %{_datadir}/firstboot/modules/firstboot_kdump.py - %triggerpostun -- kernel kernel-xen kernel-debug kernel-PAE kernel-kdump # List out the initrds here, strip out version nubmers # and search for corresponding kernel installs, if a kernel @@ -347,19 +316,18 @@ do fi done -%files -f %{name}.lang +%files /sbin/* -/usr/sbin/* %{_bindir}/* %{_datadir}/kdump %{_prefix}/lib/kdump -%ifarch %{ix86} x86_64 ia64 ppc64 s390x +%ifarch %{ix86} x86_64 ia64 ppc64 s390x ppc64le %{_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 %{_sysconfdir}/udev/rules.d/* +%config %{_udevrulesdir} %endif %{dracutlibdir}/modules.d/* %dir %{_localstatedir}/crash @@ -374,30 +342,99 @@ done %doc kdump-in-cluster-environment.txt %doc supported-kdump-targets.txt -%ifarch %{ix86} x86_64 ia64 ppc64 s390x +%ifarch %{ix86} x86_64 ia64 ppc64 s390x ppc64le %files eppic %{_libdir}/eppic_makedumpfile.so +/usr/share/makedumpfile/eppic_scripts/ %endif +%files anaconda-addon -f kdump-anaconda-addon.lang +%{_datadir}/anaconda/addons/com_redhat_kdump +%doc + %changelog -* Thu Oct 23 2014 Johnny Hughes - 2.0.4-32.5 -- modify SOURCE firstboot_kdump.py to include centos in EFI +* Fri Feb 6 2015 Dave Young - 2.0.7-19 +- Fix to 2.0.7-18, forgot to update SOURCE25 addon tarball. -* Wed Oct 08 2014 WANG Chao - 2.0.4-32.5 -- Fix an issue on iscsi boot environment +* Fri Feb 6 2015 Dave Young - 2.0.7-18 +- update addon translations, delete untranslated po files. + +* Fri Jan 30 2015 Baoquan He - 2.0.7-17 +- Just fix a typo in kexec-tools.spec + +* Fri Jan 30 2015 Baoquan He - 2.0.7-16 +- kdumpctl: adjust the boot dir if kernel is put in sub dir of /boot -* Mon Sep 15 2014 WANG Chao - 2.0.4-32.4 -- Fix a segmentation fault when physical address exceeds 8TB boundary. +* Tue Jan 13 2015 WANG Chao - 2.0.7-15 +- mount fail if its mount poing doesn't exist in /sysroot +- rebuild initrd dependency during kdump restart +- fix a dump path issue -* Thu Aug 07 2014 WANG Chao - 2.0.4-32.3 -- Fix an issue that can't bring up the correct network device +* Thu Dec 18 2014 WANG Chao - 2.0.7-14 +- fix core_collector issue for ssh/raw dump +- remove sysctl.conf for kdump kernel +- exclude aarch64 build +- fix path directive issue +- remove panic_on_warn kernel parameter -* Fri Jul 04 2014 WANG Chao - 2.0.4-32.2 -- kexec hotplug/remove fix -- handle IPADDR option in ifcfg-* +* Wed Nov 12 2014 WANG Chao - 2.0.7-13 +- Update kdump-anaconda-addon -* Fri May 09 2014 WANG Chao - 2.0.4-32.1 -- remove "nofail" from mount options +* Tue Nov 04 2014 WANG Chao - 2.0.7-12 +- Fix ppc64le installation issue + +* Tue Oct 28 2014 WANG Chao - 2.0.7-11 +- fadump fix +- kdump-anaconda-addon fix + +* Mon Sep 29 2014 WANG Chao - 2.0.7-10 +- Rebase makedumpfile-1.5.7 +- Fix an issue on iscsi boot environment +- Disable kvm CMA reservation in kdump kernel + +* Tue Sep 23 2014 WANG Chao - 2.0.7-9 +- Enable ppc64le arch. +- add sample eppic scripts to kexec-tools-eppic package +- Restart kdump service on cpu ADD/REMOVE events + +* Fri Sep 12 2014 WANG Chao - 2.0.7-8 +- use kexec_file_load() syscall when SecureBoot enabled. +- update kdump-anaconda-addon + +* Fri Aug 29 2014 WANG Chao - 2.0.7-7 +- add kexec-tools-anaconda-addon subpackage +- use absolute path for executable in systemd service. + +* Mon Aug 25 2014 WANG Chao - 2.0.7-6 +- install udev rules to /usr/lib/ +- allow short hostname in cluster configuration + +* Wed Aug 06 2014 WANG Chao - 2.0.7-5 +- rework of kdump error handling +- ppc: add fadump support +- add static route support +- systemd will take care of shutdown and unmount filesystems +- fix an issue that can't bring up correct network device + +* Wed Aug 06 2014 WANG Chao - 2.0.7-4 +- ppc64: kexec load fails due to elf symbol relocation failure. +- display a message while waiting for kdump lock + +* Tue Jul 22 2014 WANG Chao - 2.0.7-3 +- Backport several latest bits from Fedora +- Fix makedumpfile OOM issue + +* Fri Jul 04 2014 WANG Chao - 2.0.7-2 +- do not verify mtime of kdump.conf + +* Tue Jul 01 2014 WANG Chao - 2.0.7-1 +- Rebase kexec-tools-2.0.7 +- Rebase makedumpfile-1.5.6 + +* Tue Jun 10 2014 WANG Chao - 2.0.4-33 +- support fence_kdump for generic cluster +- handle static ip fix +- stop passing "nofail" mount option to 2nd kernel * Wed Apr 30 2014 Madper Xie - 2.0.4-32 - spec: fix wrong source id