From: Petr Tesarik <ptesarik@suse.cz>
Subject: Regenerate primary initrd if FADUMP is enabled
References: bnc#807260

If fadump is enabled, there is no separate kdump initrd, so the primary
initrd must be rebuilt. However, there is no (easy) way to determine if
fadump should be enabled on the _next_ boot, so FADUMP is now enabled
through a configuration switch in /etc/sysconfig/kdump.

Set KDUMP_FADUMP=yes and run mkdumprd to update the configuration.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 CMakeLists.txt          |   30 +++-
 config.h.in             |    1 
 doc/man/kdump.5.txt.in  |   18 ++
 init/CMakeLists.txt     |   11 +
 init/boot-kdump.sh      |    4 
 init/boot.kdump         |  242 --------------------------------
 init/mkdumprd           |    9 +
 init/rc.kdump.functions |  260 +++++++++++++++++++++++++++++++++++
 kdumptool/define_opt.h  |    3 
 kdumptool/findkernel.cc |    9 +
 process_cond.awk        |   20 ++
 sysconfig.kdump         |  343 ----------------------------------------------
 sysconfig.kdump.in      |  356 ++++++++++++++++++++++++++++++++++++++++++++++++
 13 files changed, 718 insertions(+), 588 deletions(-)

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -141,6 +141,16 @@ ENDIF(NOT LIBSSL_FOUND)
 
 
 #
+# Check for FADUMP
+#
+
+IF(“${CMAKE_SYSTEM_PROCESSOR}” STREQUAL “ppc64”)
+    SET(HAVE_FADUMP TRUE)
+ELSE(“${CMAKE_SYSTEM_PROCESSOR}” STREQUAL “ppc64”)
+    SET(HAVE_FADUMP FALSE)
+ENDIF(“${CMAKE_SYSTEM_PROCESSOR}” STREQUAL “ppc64”)
+
+#
 # Configure file
 #
 
@@ -165,8 +175,26 @@ ENDIF (EXISTS tests)
 #
 # Configuration and Udev
 #
+ADD_CUSTOM_COMMAND(
+    OUTPUT
+        sysconfig.kdump
+    COMMAND
+        HAVE_FADUMP=${HAVE_FADUMP}
+        awk -f ${CMAKE_CURRENT_SOURCE_DIR}/process_cond.awk
+        ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig.kdump.in
+        > ${CMAKE_CURRENT_BINARY_DIR}/sysconfig.kdump
+    DEPENDS
+        sysconfig.kdump.in
+)
+ADD_CUSTOM_TARGET(
+    sysconfig
+    ALL
+    DEPENDS
+        sysconfig.kdump
+)
+
 INSTALL(FILES
-    ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig.kdump
+    ${CMAKE_CURRENT_BINARY_DIR}/sysconfig.kdump
     DESTINATION
         /var/adm/fillup-templates/
 )
--- a/config.h.in
+++ b/config.h.in
@@ -8,3 +8,4 @@
 #define HAVE_LIBSSH2        @LIBSSH2_FOUND@
 #define HAVE_LIBESMTP       @ESMTP_FOUND@
 #define HAVE_LIBSSL         @LIBSSL_FOUND@
+#define HAVE_FADUMP         @HAVE_FADUMP@
--- a/doc/man/kdump.5.txt.in
+++ b/doc/man/kdump.5.txt.in
@@ -185,6 +185,24 @@ See also KDUMP_COMMANDLINE.
 
 Default is "".
 
+ifeval::['@HAVE_FADUMP@'=='TRUE']
+
+KDUMP_FADUMP
+~~~~~~~~~~~~
+
+If this option is set to "yes", kdump will use the FADUMP mechanism
+(firmware-assisted dump). With this option, the secondary kernel is never
+loaded from the primary kernel. Instead, the kdump feature is added to the
+standard initrd. If the primary kernel crashes, the firmware reboots the
+machine in a special environment. The initrd detects this environment on
+boot, saves the dump, and continues with normal startup.
+
+*Note:* FADUMP is only available on powerpc.
+
+Default is "no".
+
+endif::[]
+
 KEXEC_OPTIONS
 ~~~~~~~~~~~~~
 
--- a/init/CMakeLists.txt
+++ b/init/CMakeLists.txt
@@ -54,4 +54,15 @@ INSTALL(
         WORLD_READ WORLD_EXECUTE
 )
 
+INSTALL(
+    FILES
+        ${CMAKE_CURRENT_SOURCE_DIR}/rc.kdump.functions
+    DESTINATION
+        /lib/kdump
+    PERMISSIONS
+        OWNER_READ OWNER_WRITE OWNER_EXECUTE
+        GROUP_READ GROUP_EXECUTE
+        WORLD_READ WORLD_EXECUTE
+)
+
 # vim: set sw=4 ts=4 et:
--- a/init/boot-kdump.sh
+++ b/init/boot-kdump.sh
@@ -26,7 +26,7 @@
 #
 # Returns: 0 (true) if fadump is enabled
 #          1 (false) if fadump is not availabled or disabled
-function use_fadump()
+function fadump_enabled()
 {
     test -f $FADUMP_ENABLED && test "$(cat $FADUMP_ENABLED)" = "1"
 }
@@ -44,7 +44,7 @@ function handle_exit()
         ulimit -c "$backup_ulimit"
     fi
     
-    if use_fadump; then
+    if fadump_enabled; then
         # release memory if possible
         test -f $FADUMP_RELEASE_MEM && echo 1 > $FADUMP_RELEASE_MEM
     elif [ $KDUMP_IMMEDIATE_REBOOT = "yes" \
--- a/init/boot.kdump
+++ b/init/boot.kdump
@@ -25,246 +25,8 @@
 # Description:    This script loads the kdump kernel on startup.
 ### END INIT INFO
 
-. /etc/sysconfig/kdump
 . /etc/rc.status
-
-KEXEC=/sbin/kexec
-BOOTDIR="/boot"
-FADUMP_ENABLED="/sys/kernel/fadump_enabled"
-FADUMP_REGISTERED="/sys/kernel/fadump_registered"
-
-#
-# Checks if fadump is enabled
-#
-# Returns: 0 (true) if fadump is enabled
-#          1 (false) if fadump is not availabled or disabled
-function use_fadump()
-{
-    test -f $FADUMP_ENABLED && test "$(cat $FADUMP_ENABLED)" = "1"
-}
-
-#
-# Checks if currently a kdump kernel is loaded.
-#
-# Returns: 0 (true) if a kdump kernel is loaded,
-#          1 (false) if the kdump kernel is not loaded and
-#          -1 (false) if the feature is not implemented (too old kernel)
-function kdump_kernel_loaded()
-{
-    if [ -f $FADUMP_REGISTERED ]; then
-	if [ "$(cat $FADUMP_REGISTERED)" = "1" ]; then
-	    return 0
-	else
-	    return 1
-	fi
-    fi
-
-    if [ -r /sys/kernel/kexec_crash_loaded ]; then
-        if [ "$(cat /sys/kernel/kexec_crash_loaded)" = "1" ]; then
-            return 0
-        else
-            return 1
-        fi
-    else
-        return -1
-    fi
-}
-
-#
-# Remove an option from the kernel command line
-function remove_from_commandline()
-{
-    local option="$1"
-
-    awk 'BEGIN { ORS="" }
-    {
-        while(length()) {
-            sub(/^[[:space:]]+/,"");
-            pstart=match($0,/("[^"]*"?|[^"[:space:]])+/);
-            plength=RLENGTH;
-            param=substr($0,pstart,plength);
-            raw=param;
-            gsub(/"/,"",raw);
-            if (raw !~ /^('"$option"')(=|$)/)
-                print param " ";
-            $0=substr($0,pstart+plength);
-        }
-        print "\n";
-    }'
-}
-
-#
-# Builds the kdump command line from KDUMP_COMMANDLINE.
-function build_kdump_commandline()
-{
-    local commandline="$KDUMP_COMMANDLINE"
-
-    if [ -z "$commandline" ]; then
-        commandline=$(
-            remove_from_commandline \
-                'crashkernel|splash|mem|BOOT_IMAGE|showopts|zfcp\.allow_lun_scan|hugepages' \
-                < /proc/cmdline)
-        # Use deadline for saving the memory footprint
-        commandline="$commandline elevator=deadline sysrq=yes reset_devices"
-        case `uname -i` in
-        i?86|x86_64|ia64)
-            commandline="$commandline irqpoll maxcpus=${KDUMP_CPUS:-1}"
-            ;;
-	s390*)
-	    commandline="$commandline zfcp.allow_lun_scan=0"
-	    ;;
-        esac
-
-        # Xen does not include the kernel release in VMCOREINFO_XEN
-        # so we have to pass it via the command line
-        if [[ "$(uname -r)" =~ -xen$ ]] ; then
-            kernelrelease=$(uname -r)
-            commandline="$commandline kernelversion=$kernelrelease"
-        fi
-
-	if [ -f /sys/firmware/efi/systab ]
-	then
-		local acpi_addr
-		if grep -q '^ACPI20=' /sys/firmware/efi/systab
-		then
-			acpi_addr=$(awk -F'=' '/^ACPI20=/ {print $2}' /sys/firmware/efi/systab)
-		else
-			acpi_addr=$(awk -F'=' '/^ACPI=/ {print $2}' /sys/firmware/efi/systab)
-		fi
-		commandline="$commandline noefi acpi_rsdp=$acpi_addr"
-	fi
-
-	case `uname -i` in
-	i?86|x86_64)
-            commandline=$(echo "$commandline" |
-                remove_from_commandline 'unknown_nmi_panic')
-            ;;
-	esac
-    fi
-
-    commandline="$commandline $KDUMP_COMMANDLINE_APPEND"
-
-    echo "$commandline"
-}
-
-#
-# Builds the kexec options from KEXEC_OPTIONS
-# Parameters: 1) kernel
-function build_kexec_options()
-{
-    local kdump_kernel=$1
-    local options=$KEXEC_OPTIONS
-
-    # remove `--args-linux' for x86 type kernel files here
-    if [ "$(kdumptool identify_kernel -t "$kdump_kernel")" = "x86" ] ; then
-        options=$(echo $options | sed -e 's/--args-linux//g')
-    fi
-
-    # add --noio on ia64
-    if [ "$(uname -i)" = "ia64" ] ; then
-        options="$options --noio"
-    fi
-
-    echo "$options"
-}
-
-# Load kdump using kexec
-function load_kdump_kexec()
-{
-    if [ $(($KDUMP_VERBOSE & 16)) -gt 0 ] ; then
-        find_kernel_args="-D"
-    fi
-
-    output=$(kdumptool find_kernel $find_kernel_args)
-    if [ $? -ne 0 ] ; then
-        rc_status -s
-        rc_failed 6
-        rc_exit
-    fi
-
-    kdump_kernel=$(echo "$output" | grep ^Kernel | cut -f 2)
-    kdump_initrd=$(echo "$output" | grep ^Initrd | cut -f 2)
-
-    # rebuild the kdump initramfs if necessary, but not at boot
-    if [ "$RUNLEVEL" != "B" ]; then
-        mkdumprd -K "$kdump_kernel" -I "$kdump_initrd" -q
-    fi
-
-    if [ ! -f $kdump_initrd ]; then
-        echo -n ": No kdump initial ramdisk found."
-        echo "Tried to locate ${kdump_initrd}"
-        rc_status -s
-        rc_failed 6
-        rc_exit
-    fi
-
-    local kdump_commandline=$(build_kdump_commandline)
-    local kexec_options=$(build_kexec_options "$kdump_kernel")
-
-    KEXEC_CALL="$KEXEC -p $kdump_kernel --append=\"$kdump_commandline\""
-    KEXEC_CALL="$KEXEC_CALL --initrd=$kdump_initrd $kexec_options"
-
-    result=$(eval "$KEXEC_CALL" 2>&1)
-    rc_check
-
-    # print stderr in any case to show warnings that normally
-    # would be supressed (bnc#374185)
-    echo "$result"
-
-    if rc_status ; then
-        echo 1 > /proc/sys/kernel/panic_on_oops
-    fi
-
-    if [ $(($KDUMP_VERBOSE & 4)) -gt 0 ] ; then
-        echo "Loading kdump kernel: $KEXEC_CALL"
-    fi
-    if [ $(($KDUMP_VERBOSE & 1)) -gt 0 ] ; then
-        if rc_status ; then
-            logger -i -t kdump "Loaded kdump kernel: $KEXEC_CALL, Result: $result"
-        else
-            logger -i -t kdump \
-                "FAILED to load kdump kernel: $KEXEC_CALL, Result: $result"
-        fi
-    fi
-
-}
-
-# Update fadump configuration
-function load_kdump_fadump()
-{
-    # check if the old configuration is still valid
-    boot_opts=$(kdumptool -F /dev/null -C <(kdump-bootloader.pl --get) \
-			  dump_config --usage dump --format kernel --nodefault)
-    curr_opts=$(kdumptool dump_config --usage dump --format kernel --nodefault)
-    if [ "$boot_opts" != "$curr_opts" ]; then
-	kdump-bootloader.pl --update "$curr_opts"
-    fi
-
-    # The kernel fails with EINVAL if registered already
-    # (see bnc#814780)
-    if [ "$(cat $FADUMP_REGISTERED)" != "1" ]; then
-	echo 1 > $FADUMP_REGISTERED
-    fi
-    echo 1 > /proc/sys/kernel/panic_on_oops
-    rc_reset
-}
-
-#
-# Load the kdump kerel specified in /etc/sysconfig/kdump
-function load_kdump()
-{
-    local find_kernel_args=
-    echo "Loading kdump"
-
-    if use_fadump; then
-	load_kdump_fadump
-    else
-	load_kdump_kexec
-    fi
-
-    rc_status -v
-}
-
+. /lib/kdump/rc.kdump.functions
 
 case "$1" in
   start|restart|force-reload)
@@ -278,7 +40,7 @@ case "$1" in
             kdump_kernel_loaded
             if [ $? -ne 1 ] ; then
                 echo -n "Unloading kdump"
-		if use_fadump; then
+		if fadump_enabled; then
 		    # The kernel fails with EINVAL if unregistered already
 		    # (see bnc#814780)
 		    if [ "$(cat $FADUMP_REGISTERED)" != "0" ]; then
--- /dev/null
+++ b/init/rc.kdump.functions
@@ -0,0 +1,260 @@
+#!/bin/sh
+#
+#  Copyright 2005 Red Hat, Inc.
+#  Author:  Jeff Moyer <jmoyer@redhat.com>
+#  Modifications for SUSE from Chris Mason <mason@suse.com>
+#                              Takashi Iwai <tiwai@suse.de>
+#                              Bernhard Walle <bwalle@suse.de>
+#
+# ----------------------------------------------------------------------
+# rc.kdump.functions by Petr Tesarik
+
+KDUMP_CONFIG=/etc/sysconfig/kdump
+KEXEC=/sbin/kexec
+FADUMP_ENABLED="/sys/kernel/fadump_enabled"
+FADUMP_REGISTERED="/sys/kernel/fadump_registered"
+
+#
+# Checks if fadump is enabled
+#
+# Returns: 0 (true) if fadump is enabled
+#          1 (false) if fadump is not availabled or disabled
+function fadump_enabled()
+{
+    test -f $FADUMP_ENABLED && test "$(cat $FADUMP_ENABLED)" = "1"
+}
+
+#
+# Checks if currently a kdump kernel is loaded.
+#
+# Returns: 0 (true) if a kdump kernel is loaded,
+#          1 (false) if the kdump kernel is not loaded and
+#          -1 (false) if the feature is not implemented (too old kernel)
+function kdump_kernel_loaded()
+{
+    if [ -f $FADUMP_REGISTERED ]; then
+	if [ "$(cat $FADUMP_REGISTERED)" = "1" ]; then
+	    return 0
+	else
+	    return 1
+	fi
+    fi
+
+    if [ -r /sys/kernel/kexec_crash_loaded ]; then
+        if [ "$(cat /sys/kernel/kexec_crash_loaded)" = "1" ]; then
+            return 0
+        else
+            return 1
+        fi
+    else
+        return -1
+    fi
+}
+
+#
+# Remove an option from the kernel command line
+function remove_from_commandline()
+{
+    local option="$1"
+
+    awk 'BEGIN { ORS="" }
+    {
+        while(length()) {
+            sub(/^[[:space:]]+/,"");
+            pstart=match($0,/("[^"]*"?|[^"[:space:]])+/);
+            plength=RLENGTH;
+            param=substr($0,pstart,plength);
+            raw=param;
+            gsub(/"/,"",raw);
+            if (raw !~ /^('"$option"')(=|$)/)
+                print param " ";
+            $0=substr($0,pstart+plength);
+        }
+        print "\n";
+    }'
+}
+
+#
+# Builds the kdump command line from KDUMP_COMMANDLINE.
+function build_kdump_commandline()
+{
+    local commandline="$KDUMP_COMMANDLINE"
+
+    if [ -z "$commandline" ]; then
+        commandline=$(
+            remove_from_commandline \
+                'crashkernel|splash|mem|BOOT_IMAGE|showopts|zfcp\.allow_lun_scan|hugepages' \
+                < /proc/cmdline)
+        # Use deadline for saving the memory footprint
+        commandline="$commandline elevator=deadline sysrq=yes reset_devices"
+        case `uname -i` in
+        i?86|x86_64|ia64)
+            commandline="$commandline irqpoll maxcpus=${KDUMP_CPUS:-1}"
+            ;;
+	s390*)
+	    commandline="$commandline zfcp.allow_lun_scan=0"
+	    ;;
+        esac
+
+        # Xen does not include the kernel release in VMCOREINFO_XEN
+        # so we have to pass it via the command line
+        if [[ "$(uname -r)" =~ -xen$ ]] ; then
+            kernelrelease=$(uname -r)
+            commandline="$commandline kernelversion=$kernelrelease"
+        fi
+
+	if [ -f /sys/firmware/efi/systab ]
+	then
+		local acpi_addr
+		if grep -q '^ACPI20=' /sys/firmware/efi/systab
+		then
+			acpi_addr=$(awk -F'=' '/^ACPI20=/ {print $2}' /sys/firmware/efi/systab)
+		else
+			acpi_addr=$(awk -F'=' '/^ACPI=/ {print $2}' /sys/firmware/efi/systab)
+		fi
+		commandline="$commandline noefi acpi_rsdp=$acpi_addr"
+	fi
+
+	case `uname -i` in
+	i?86|x86_64)
+            commandline=$(echo "$commandline" |
+                remove_from_commandline 'unknown_nmi_panic')
+            ;;
+	esac
+    fi
+
+    commandline="$commandline $KDUMP_COMMANDLINE_APPEND"
+
+    echo "$commandline"
+}
+
+#
+# Builds the kexec options from KEXEC_OPTIONS
+# Parameters: 1) kernel
+function build_kexec_options()
+{
+    local kdump_kernel=$1
+    local options=$KEXEC_OPTIONS
+
+    # remove `--args-linux' for x86 type kernel files here
+    if [ "$(kdumptool identify_kernel -t "$kdump_kernel")" = "x86" ] ; then
+        options=$(echo $options | sed -e 's/--args-linux//g')
+    fi
+
+    # add --noio on ia64
+    if [ "$(uname -i)" = "ia64" ] ; then
+        options="$options --noio"
+    fi
+
+    echo "$options"
+}
+
+# Load kdump using kexec
+function load_kdump_kexec()
+{
+    if [ ! -f $kdump_initrd ]; then
+        echo -n ": No kdump initial ramdisk found."
+        echo "Tried to locate ${kdump_initrd}"
+        rc_status -s
+        rc_failed 6
+        rc_exit
+    fi
+
+    local kdump_commandline=$(build_kdump_commandline)
+    local kexec_options=$(build_kexec_options "$kdump_kernel")
+
+    KEXEC_CALL="$KEXEC -p $kdump_kernel --append=\"$kdump_commandline\""
+    KEXEC_CALL="$KEXEC_CALL --initrd=$kdump_initrd $kexec_options"
+
+    result=$(eval "$KEXEC_CALL" 2>&1)
+    rc_check
+
+    # print stderr in any case to show warnings that normally
+    # would be supressed (bnc#374185)
+    echo "$result"
+
+    if rc_status ; then
+        echo 1 > /proc/sys/kernel/panic_on_oops
+    fi
+
+    if [ $(($KDUMP_VERBOSE & 4)) -gt 0 ] ; then
+        echo "Loading kdump kernel: $KEXEC_CALL"
+    fi
+    if [ $(($KDUMP_VERBOSE & 1)) -gt 0 ] ; then
+        if rc_status ; then
+            logger -i -t kdump "Loaded kdump kernel: $KEXEC_CALL, Result: $result"
+        else
+            logger -i -t kdump \
+                "FAILED to load kdump kernel: $KEXEC_CALL, Result: $result"
+        fi
+    fi
+
+}
+
+# Update fadump configuration
+function load_kdump_fadump()
+{
+    if ! fadump_enabled; then
+        echo ": fadump is not enabled in the kernel."
+        rc_status -s
+        rc_failed 6
+        rc_exit
+    fi
+
+    # check if the old configuration is still valid
+    boot_opts=$(kdumptool -F /dev/null -C <(kdump-bootloader.pl --get) \
+			  dump_config --usage dump --format kernel --nodefault)
+    curr_opts=$(kdumptool dump_config --usage dump --format kernel --nodefault)
+    if [ "$boot_opts" != "$curr_opts" ]; then
+	kdump-bootloader.pl --update "$curr_opts"
+    fi
+
+    # The kernel fails with EINVAL if registered already
+    # (see bnc#814780)
+    if [ "$(cat $FADUMP_REGISTERED)" != "1" ]; then
+	echo 1 > $FADUMP_REGISTERED
+    fi
+    echo 1 > /proc/sys/kernel/panic_on_oops
+    rc_reset
+}
+
+#
+# Load the kdump kerel specified in /etc/sysconfig/kdump
+function load_kdump()
+{
+    echo "Loading kdump"
+
+    if [ -f ${KDUMP_CONFIG} ] ; then
+        . ${KDUMP_CONFIG}
+    fi
+
+    local find_kernel_args=
+    if [ $(($KDUMP_VERBOSE & 16)) -gt 0 ] ; then
+        find_kernel_args="-D"
+    fi
+
+    local output=$(kdumptool find_kernel $find_kernel_args)
+    if [ $? -ne 0 ] ; then
+        rc_status -s
+        rc_failed 6
+        rc_exit
+    fi
+
+    kdump_kernel=$(echo "$output" | grep ^Kernel | cut -f 2)
+    kdump_initrd=$(echo "$output" | grep ^Initrd | cut -f 2)
+
+    # rebuild the kdump initramfs if necessary, but not at boot
+    if [ "$RUNLEVEL" != "B" ]; then
+        mkdumprd -K "$kdump_kernel" -I "$kdump_initrd" -q
+    fi
+
+    if [ "$KDUMP_FADUMP" = "yes" ]; then
+	load_kdump_fadump
+    else
+	load_kdump_kexec
+    fi
+
+    rc_status -v
+}
+
+# vim: set ts=4 sw=4 et:
--- a/kdumptool/define_opt.h
+++ b/kdumptool/define_opt.h
@@ -13,6 +13,9 @@ DEFINE_OPT(KDUMP_KERNELVER, String, "",
 DEFINE_OPT(KDUMP_CPUS, Int, 1, KEXEC | DUMP)
 DEFINE_OPT(KDUMP_COMMANDLINE, String, "", KEXEC)
 DEFINE_OPT(KDUMP_COMMANDLINE_APPEND, String, "", KEXEC)
+#if HAVE_FADUMP
+DEFINE_OPT(KDUMP_FADUMP, Bool, false, MKINITRD)
+#endif
 DEFINE_OPT(KEXEC_OPTIONS, String, "", KEXEC)
 DEFINE_OPT(MAKEDUMPFILE_OPTIONS, String, "", DUMP)
 DEFINE_OPT(KDUMP_IMMEDIATE_REBOOT, Bool, true, DUMP)
--- a/kdumptool/findkernel.cc
+++ b/kdumptool/findkernel.cc
@@ -311,7 +311,14 @@ string FindKernel::findInitrd(const stri
         dash = "-";
     }
 
-    if (isKdumpKernel(stripped)) {
+#if HAVE_FADUMP
+    const bool use_fadump =
+        Configuration::config()->getBoolValue(Configuration::KDUMP_FADUMP);
+#else
+    const bool use_fadump = false;
+#endif
+
+    if (isKdumpKernel(stripped) || use_fadump) {
         return FileUtil::pathconcat(dir, "initrd" + dash + stripped);
     } else {
         return FileUtil::pathconcat(dir, "initrd" + dash + stripped + "-kdump");
--- /dev/null
+++ b/process_cond.awk
@@ -0,0 +1,20 @@
+#! /usr/bin/awk -f
+/^@if\>/ {
+    while (match($0, /@(\w+)@/, var))
+	$0 = substr($0, 1, RSTART - 1) \
+	    ENVIRON[var[1]] \
+	    substr($0, RSTART + RLENGTH)
+    stack[sp++] = remove
+    remove = remove || ($2 != $3)
+    skip = 1
+}
+/^@else\>/ {
+    remove = stack[sp-1] || !remove
+    skip = 1
+}
+/^@endif\>/ {
+    remove = stack[--sp]
+    skip = 1
+}
+!remove && !skip { print }
+skip { --skip }
--- a/sysconfig.kdump
+++ /dev/null
@@ -1,343 +0,0 @@
-## Path:        System/Kernel/Kdump
-## Description: Crash Dump Configuration
-
-## Type:	string
-## Default:	""
-## ServiceRestart:	kdump
-#
-# Kernel Version string for the -kdump kernel. Use an empty string to
-# auto-detect a suitable kernel.
-#
-# See also: kdump(5).
-#
-KDUMP_KERNELVER=""
-
-## Type:	integer
-## Default:	1
-## ServiceRestart:	kdump
-#
-# Number of CPUs to be used in the kdump environment. You may want to
-# increase the number if computing power is the bottleneck in your setup.
-# This value is used as the maxcpus parameter of the secondary kernel, so
-# DON'T CHANGE IT unless your system can reliably re-initialize SMP after
-# a kernel crash.
-#
-# WARNING: SETTING THIS NUMBER TO A NUMBER HIGHER THAN 1 IS EXPERIMENTAL!
-# SOME MACHINES ARE KNOWN TO HANG OR REBOOT RANDOMLY DURING INITIALISATION
-# OF THE DUMP KERNEL IF KDUMP_CPUS > 1.
-#
-# See also: kdump(5).
-#
-KDUMP_CPUS=1
-
-## Type:	string
-## Default:	""
-## ServiceRestart:	kdump
-#
-# The kdump commandline is the command line that needs to be passed off to
-# the kdump kernel. If a command line is not specified, the default will be
-# taken from /proc/cmdline and adjusted.
-#
-# WARNING: There are a few options that always should be passed to the kdump
-# kernel. See kdump(5) for details. Don't use that variable, consider using
-# KDUMP_COMMANDLINE_APPEND instead.
-#
-KDUMP_COMMANDLINE=""
-
-## Type:        string
-## Default:     ""
-## ServiceRestart:     kdump
-#
-# Set this variable if you only want to _append_ values to the default
-# command line string. The string gets also appended if KDUMP_COMMANDLINE
-# is set.
-#
-# For network based dumps, you may have to add a "net_delay" parameter
-# here. Consult the man page for details.
-#
-# See also: kdump(5).
-#
-KDUMP_COMMANDLINE_APPEND=""
-
-## Type:	string
-## Default:	""
-## ServiceRestart:	kdump
-#
-# Additional arguments passed to kexec. Normally you don't have to modify
-# the default here.
-#
-# See also: kdump(5).
-#
-KEXEC_OPTIONS=""
-
-## Type:	yesno
-## Default:	yes
-## ServiceRestart:	kdump
-#
-# Immediately reboot after saving the core in the kdump kernel?
-#
-# See also: kdump(5).
-#
-KDUMP_IMMEDIATE_REBOOT="yes"
-
-## Type:	string
-## Default:	""
-## ServiceRestart:	kdump
-#
-# A script or command executed to process and transfer the dump image.
-# It can read the dump image either via /proc/vmcore or /dev/oldmem.
-#
-# WARNING: Setting that option will make most of the other configuration
-# options useless. Don't use that option. It's also not supported.
-#
-# See also: kdump(5).
-#
-KDUMP_TRANSFER=""
-
-## Type:	string
-## Default:	"file:///var/log/dump"
-## ServiceRestart:	kdump
-#
-# Which directory should the dumps be saved in by the default dumper?
-# This can be:
-#
-#   - a local file, for example "file:///var/log/dump" (or, deprecated,
-#     just "/var/log/dump")
-#   - a FTP server, for example "ftp://user:password@host/var/log/dump"
-#   - a SSH server, for example "ssh://user:password@host/var/log/dump"
-#   - a NFS share, for example "nfs://server/export/var/log/dump"
-#   - a CIFS (SMB) share, for example
-#     "cifs://user:password@host/share/var/log/dump"
-#
-# See also: kdump(5) which contains an exact specification for the URL format.
-# Consider using the "yast2 kdump" module if you are unsure.
-#
-KDUMP_SAVEDIR="file:///var/crash"
-
-## Type:	integer
-## Default:	5
-## ServiceRestart:	kdump
-#
-# Specifies how many old dumps are kept.  If the number of dump files
-# exceeds this number, older dumps are removed.
-#
-# You can prevent the automatic removal by setting zero to this.
-# Set KDUMP_KEEP_OLD_DUMPS to "-1" is you want to delete all old
-# dumps before saving the new dump.
-#
-# See also: kdump(5).
-#
-KDUMP_KEEP_OLD_DUMPS=5
-
-## Type:	integer
-## Default:	64
-## ServiceRestart:	kdump
-#
-# Specifies the minimal free disk space (in MB unit) on the dump partition.
-# If the free disk space is less than the sum of this value and memory size,
-# we won't save vmcore file in order to keep the system sane.
-#
-# Setting zero forces to dump without check.
-#
-# See also: kdump(5).
-#
-KDUMP_FREE_DISK_SIZE=64
-
-## Type:        integer
-## Default:     3
-## ServiceRestart:	kdump
-#
-# Determines if kdump uses verbose output. This value is a bitmask:
-#
-# 1: kdump command line is written to system log when executing
-#    /etc/init.d/kdump
-# 2: progress is written to stdout while dumping
-# 4: kdump command line is written so standard output when executing
-#    /etc/init.d/kdump
-# 8: Debugging while saving dump.
-# 16: Debugging when loading (and detecting) the kdump kernel in boot.kdump.
-#
-# See also: kdump(5).
-#
-KDUMP_VERBOSE=3
-
-## Type:        integer
-## Default:     31
-## ServiceRestart:	kdump
-#
-# Determines the dump level. If KDUMP_DUMPLEVEL non-zero 0, then makedumpfile
-# is used to strip pages that may not be necessary for analysing. 0 means
-# no stripping, and 31 is the maximum dump level, i.e. 0 produces the
-# largest dump files and 31 the smallest.
-#
-# See kdump(5) or makedumpfile(8) for a full description what that different
-# dump levels mean.
-#
-KDUMP_DUMPLEVEL=31
-
-## Type:        list(,none,ELF,compressed,lzo)
-## Default:     "compressed"
-## ServiceRestart:	kdump
-#
-# This variable specifies the dump format. Using the "none" option will
-# skip capturing the dump entirely and only save the kernel log buffer.
-#
-# See also: kdump(5).
-KDUMP_DUMPFORMAT="compressed"
-
-## Type:        boolean
-## Default:     true
-## ServiceRestart:	kdump
-#
-# By default, kdumptool(8) copies multiple files with the save_dump action.
-# Set this value to "true" to make kdumptool try to save the next file even
-# if saving the previous file failed, or set it to "false" to let the program
-# immediately abort.
-#
-# See also: kdump(5).
-#
-KDUMP_CONTINUE_ON_ERROR="true"
-
-## Type:        string
-## Default:     ""
-## ServiceRestart:	kdump
-#
-# This is a space-separated list of programs (full path) that are required by
-# KDUMP_TRANSFER, KDUMP_PRESCRIPT or KDUMP_POSTSCRIPT.
-#
-# Dynamic libraries that are required by that programs don't have to be included
-# as they are resolved automatically. However, it's necessary to include other
-# runtime requirements because it's not possible to resolve them automatically.
-#
-# See also: kdump(5).
-#
-KDUMP_REQUIRED_PROGRAMS=""
-
-## Type:        string
-## Default:     ""
-## ServiceRestart:	kdump
-#
-# Program that is executed before taking the dump. You have to include that
-# program in KDUMP_REQUIRED_PROGRAMS.
-#
-# See also: kdump(5).
-#
-KDUMP_PRESCRIPT=""
-
-## Type:        string
-## Default:     ""
-## ServiceRestart:	kdump
-#
-# Program that is executed after taking the dump and before the system is
-# rebooted. You have to include that program in KDUMP_POSTSCRIPT.
-#
-# See also: kdump(5).
-#
-KDUMP_POSTSCRIPT=""
-
-## Type:        yesno
-## Default:     "yes"
-## ServiceRestart:	kdump
-#
-# Not only copy the dump to KDUMP_SAVEDIR but also the installed kernel.
-# If the debugging information is installed, also the debug information will
-# be copied. But only the kernel is copied, not all modules.
-#
-# See also: kdump(5).
-#
-KDUMP_COPY_KERNEL="yes"
-
-## Type:        string(NOSPARSE)
-## Default:     ""
-## ServiceRestart:	kdump
-#
-# Space-separated list of flags to tweak the run-time behaviour of kdumptool.
-# Currently, only one flag is supported: NOSPARSE to disable creation of sparse
-# files.
-#
-# See also: kdump(5).
-#
-KDUMPTOOL_FLAGS=""
-
-## Type:        string
-## Default:     auto
-## ServiceRestart:	kdump
-#
-# Network configuration. Use "auto" for auto-detection in initrd, or a string
-# that contains the network device and the mode (dhcp,static), separated by
-# a colon. Example: "eth0:static" or "eth1:dhcp".
-#
-# For static configuration, you have to add the configuration to
-# KDUMP_COMMANDLINE_APPEND.
-#
-# See also: kdump(5)
-#
-KDUMP_NETCONFIG="auto"
-
-## Type:        string
-## Default:     ""
-## ServiceRestart:	kdump
-#
-# SMTP server used for sending a notification email after a dump has
-# been taken. See also KDUMP_SMTP_USER and KDUMP_SMTP_PASSWORD if you
-# want to use SMTP AUTH.
-#
-# See also: kdump(5)
-#
-KDUMP_SMTP_SERVER=""
-
-## Type:        string
-## Default:     ""
-## ServiceRestart:	kdump
-#
-# Username for SMTP AUTH when KDUMP_SMTP_SERVER is set. This is optional,
-# without username/password, plain SMTP will be used.
-#
-# See also: kdump(5)
-#
-KDUMP_SMTP_USER=""
-
-## Type:        string
-## Default:     ""
-## ServiceRestart:	kdump
-#
-# Password for SMTP AUTH when KDUMP_SMTP_SERVER is set. This is optional,
-# without username/password, plain SMTP will be used.
-#
-# See also: kdump(5)
-#
-KDUMP_SMTP_PASSWORD=""
-
-## Type:        string
-## Default:     ""
-## ServiceRestart:	kdump
-#
-# Mail address to which a notification mail will be sent when a dump has been
-# saved. You have to configure at least KDUMP_SMTP_SERVER to use that feature.
-#
-# See also: kdump(5)
-#
-KDUMP_NOTIFICATION_TO=""
-
-## Type:        string
-## Default:     ""
-## ServiceRestart:	kdump
-#
-# List of space-separated mail addresses to which notification mail will be
-# sent via Cc if a dump has been saved. You have to configure at least
-# KDUMP_SMTP_SERVER to use that feature.
-#
-# See also: kdump(5)
-#
-KDUMP_NOTIFICATION_CC=""
-
-## Type:        string
-## Default:     ""
-## ServiceRestart:	kdump
-#
-# Target host public key, encoded with base64. This is used only for the
-# SFTP transfer protocol. If empty, kdump will run 'ssh-keygen -F' to get
-# the key from known hosts. If set to "*", any host key will be accepted.
-#
-# See also: kdump(5)
-KDUMP_HOST_KEY=""
--- /dev/null
+++ b/sysconfig.kdump.in
@@ -0,0 +1,356 @@
+## Path:        System/Kernel/Kdump
+## Description: Crash Dump Configuration
+
+## Type:	string
+## Default:	""
+## ServiceRestart:	kdump
+#
+# Kernel Version string for the -kdump kernel. Use an empty string to
+# auto-detect a suitable kernel.
+#
+# See also: kdump(5).
+#
+KDUMP_KERNELVER=""
+
+## Type:	integer
+## Default:	1
+## ServiceRestart:	kdump
+#
+# Number of CPUs to be used in the kdump environment. You may want to
+# increase the number if computing power is the bottleneck in your setup.
+# This value is used as the maxcpus parameter of the secondary kernel, so
+# DON'T CHANGE IT unless your system can reliably re-initialize SMP after
+# a kernel crash.
+#
+# WARNING: SETTING THIS NUMBER TO A NUMBER HIGHER THAN 1 IS EXPERIMENTAL!
+# SOME MACHINES ARE KNOWN TO HANG OR REBOOT RANDOMLY DURING INITIALISATION
+# OF THE DUMP KERNEL IF KDUMP_CPUS > 1.
+#
+# See also: kdump(5).
+#
+KDUMP_CPUS=1
+
+## Type:	string
+## Default:	""
+## ServiceRestart:	kdump
+#
+# The kdump commandline is the command line that needs to be passed off to
+# the kdump kernel. If a command line is not specified, the default will be
+# taken from /proc/cmdline and adjusted.
+#
+# WARNING: There are a few options that always should be passed to the kdump
+# kernel. See kdump(5) for details. Don't use that variable, consider using
+# KDUMP_COMMANDLINE_APPEND instead.
+#
+KDUMP_COMMANDLINE=""
+
+## Type:        string
+## Default:     ""
+## ServiceRestart:     kdump
+#
+# Set this variable if you only want to _append_ values to the default
+# command line string. The string gets also appended if KDUMP_COMMANDLINE
+# is set.
+#
+# For network based dumps, you may have to add a "net_delay" parameter
+# here. Consult the man page for details.
+#
+# See also: kdump(5).
+#
+KDUMP_COMMANDLINE_APPEND=""
+
+@if @HAVE_FADUMP@ TRUE
+## Type:        yesno
+## Default:     "no"
+## ServiceRestart:	kdump
+#
+# Set this option to yes if you want to use fadump (firmware-assisted dump).
+# This option is only meaningful on powerpc.
+#
+# See also: kdump(5).
+#
+KDUMP_FADUMP="no"
+
+@endif
+## Type:	string
+## Default:	""
+## ServiceRestart:	kdump
+#
+# Additional arguments passed to kexec. Normally you don't have to modify
+# the default here.
+#
+# See also: kdump(5).
+#
+KEXEC_OPTIONS=""
+
+## Type:	yesno
+## Default:	yes
+## ServiceRestart:	kdump
+#
+# Immediately reboot after saving the core in the kdump kernel?
+#
+# See also: kdump(5).
+#
+KDUMP_IMMEDIATE_REBOOT="yes"
+
+## Type:	string
+## Default:	""
+## ServiceRestart:	kdump
+#
+# A script or command executed to process and transfer the dump image.
+# It can read the dump image either via /proc/vmcore or /dev/oldmem.
+#
+# WARNING: Setting that option will make most of the other configuration
+# options useless. Don't use that option. It's also not supported.
+#
+# See also: kdump(5).
+#
+KDUMP_TRANSFER=""
+
+## Type:	string
+## Default:	"file:///var/log/dump"
+## ServiceRestart:	kdump
+#
+# Which directory should the dumps be saved in by the default dumper?
+# This can be:
+#
+#   - a local file, for example "file:///var/log/dump" (or, deprecated,
+#     just "/var/log/dump")
+#   - a FTP server, for example "ftp://user:password@host/var/log/dump"
+#   - a SSH server, for example "ssh://user:password@host/var/log/dump"
+#   - a NFS share, for example "nfs://server/export/var/log/dump"
+#   - a CIFS (SMB) share, for example
+#     "cifs://user:password@host/share/var/log/dump"
+#
+# See also: kdump(5) which contains an exact specification for the URL format.
+# Consider using the "yast2 kdump" module if you are unsure.
+#
+KDUMP_SAVEDIR="file:///var/crash"
+
+## Type:	integer
+## Default:	5
+## ServiceRestart:	kdump
+#
+# Specifies how many old dumps are kept.  If the number of dump files
+# exceeds this number, older dumps are removed.
+#
+# You can prevent the automatic removal by setting zero to this.
+# Set KDUMP_KEEP_OLD_DUMPS to "-1" is you want to delete all old
+# dumps before saving the new dump.
+#
+# See also: kdump(5).
+#
+KDUMP_KEEP_OLD_DUMPS=5
+
+## Type:	integer
+## Default:	64
+## ServiceRestart:	kdump
+#
+# Specifies the minimal free disk space (in MB unit) on the dump partition.
+# If the free disk space is less than the sum of this value and memory size,
+# we won't save vmcore file in order to keep the system sane.
+#
+# Setting zero forces to dump without check.
+#
+# See also: kdump(5).
+#
+KDUMP_FREE_DISK_SIZE=64
+
+## Type:        integer
+## Default:     3
+## ServiceRestart:	kdump
+#
+# Determines if kdump uses verbose output. This value is a bitmask:
+#
+# 1: kdump command line is written to system log when executing
+#    /etc/init.d/kdump
+# 2: progress is written to stdout while dumping
+# 4: kdump command line is written so standard output when executing
+#    /etc/init.d/kdump
+# 8: Debugging while saving dump.
+# 16: Debugging when loading (and detecting) the kdump kernel in boot.kdump.
+#
+# See also: kdump(5).
+#
+KDUMP_VERBOSE=3
+
+## Type:        integer
+## Default:     31
+## ServiceRestart:	kdump
+#
+# Determines the dump level. If KDUMP_DUMPLEVEL non-zero 0, then makedumpfile
+# is used to strip pages that may not be necessary for analysing. 0 means
+# no stripping, and 31 is the maximum dump level, i.e. 0 produces the
+# largest dump files and 31 the smallest.
+#
+# See kdump(5) or makedumpfile(8) for a full description what that different
+# dump levels mean.
+#
+KDUMP_DUMPLEVEL=31
+
+## Type:        list(,none,ELF,compressed,lzo)
+## Default:     "compressed"
+## ServiceRestart:	kdump
+#
+# This variable specifies the dump format. Using the "none" option will
+# skip capturing the dump entirely and only save the kernel log buffer.
+#
+# See also: kdump(5).
+KDUMP_DUMPFORMAT="compressed"
+
+## Type:        boolean
+## Default:     true
+## ServiceRestart:	kdump
+#
+# By default, kdumptool(8) copies multiple files with the save_dump action.
+# Set this value to "true" to make kdumptool try to save the next file even
+# if saving the previous file failed, or set it to "false" to let the program
+# immediately abort.
+#
+# See also: kdump(5).
+#
+KDUMP_CONTINUE_ON_ERROR="true"
+
+## Type:        string
+## Default:     ""
+## ServiceRestart:	kdump
+#
+# This is a space-separated list of programs (full path) that are required by
+# KDUMP_TRANSFER, KDUMP_PRESCRIPT or KDUMP_POSTSCRIPT.
+#
+# Dynamic libraries that are required by that programs don't have to be included
+# as they are resolved automatically. However, it's necessary to include other
+# runtime requirements because it's not possible to resolve them automatically.
+#
+# See also: kdump(5).
+#
+KDUMP_REQUIRED_PROGRAMS=""
+
+## Type:        string
+## Default:     ""
+## ServiceRestart:	kdump
+#
+# Program that is executed before taking the dump. You have to include that
+# program in KDUMP_REQUIRED_PROGRAMS.
+#
+# See also: kdump(5).
+#
+KDUMP_PRESCRIPT=""
+
+## Type:        string
+## Default:     ""
+## ServiceRestart:	kdump
+#
+# Program that is executed after taking the dump and before the system is
+# rebooted. You have to include that program in KDUMP_POSTSCRIPT.
+#
+# See also: kdump(5).
+#
+KDUMP_POSTSCRIPT=""
+
+## Type:        yesno
+## Default:     "yes"
+## ServiceRestart:	kdump
+#
+# Not only copy the dump to KDUMP_SAVEDIR but also the installed kernel.
+# If the debugging information is installed, also the debug information will
+# be copied. But only the kernel is copied, not all modules.
+#
+# See also: kdump(5).
+#
+KDUMP_COPY_KERNEL="yes"
+
+## Type:        string(NOSPARSE)
+## Default:     ""
+## ServiceRestart:	kdump
+#
+# Space-separated list of flags to tweak the run-time behaviour of kdumptool.
+# Currently, only one flag is supported: NOSPARSE to disable creation of sparse
+# files.
+#
+# See also: kdump(5).
+#
+KDUMPTOOL_FLAGS=""
+
+## Type:        string
+## Default:     auto
+## ServiceRestart:	kdump
+#
+# Network configuration. Use "auto" for auto-detection in initrd, or a string
+# that contains the network device and the mode (dhcp,static), separated by
+# a colon. Example: "eth0:static" or "eth1:dhcp".
+#
+# For static configuration, you have to add the configuration to
+# KDUMP_COMMANDLINE_APPEND.
+#
+# See also: kdump(5)
+#
+KDUMP_NETCONFIG="auto"
+
+## Type:        string
+## Default:     ""
+## ServiceRestart:	kdump
+#
+# SMTP server used for sending a notification email after a dump has
+# been taken. See also KDUMP_SMTP_USER and KDUMP_SMTP_PASSWORD if you
+# want to use SMTP AUTH.
+#
+# See also: kdump(5)
+#
+KDUMP_SMTP_SERVER=""
+
+## Type:        string
+## Default:     ""
+## ServiceRestart:	kdump
+#
+# Username for SMTP AUTH when KDUMP_SMTP_SERVER is set. This is optional,
+# without username/password, plain SMTP will be used.
+#
+# See also: kdump(5)
+#
+KDUMP_SMTP_USER=""
+
+## Type:        string
+## Default:     ""
+## ServiceRestart:	kdump
+#
+# Password for SMTP AUTH when KDUMP_SMTP_SERVER is set. This is optional,
+# without username/password, plain SMTP will be used.
+#
+# See also: kdump(5)
+#
+KDUMP_SMTP_PASSWORD=""
+
+## Type:        string
+## Default:     ""
+## ServiceRestart:	kdump
+#
+# Mail address to which a notification mail will be sent when a dump has been
+# saved. You have to configure at least KDUMP_SMTP_SERVER to use that feature.
+#
+# See also: kdump(5)
+#
+KDUMP_NOTIFICATION_TO=""
+
+## Type:        string
+## Default:     ""
+## ServiceRestart:	kdump
+#
+# List of space-separated mail addresses to which notification mail will be
+# sent via Cc if a dump has been saved. You have to configure at least
+# KDUMP_SMTP_SERVER to use that feature.
+#
+# See also: kdump(5)
+#
+KDUMP_NOTIFICATION_CC=""
+
+## Type:        string
+## Default:     ""
+## ServiceRestart:	kdump
+#
+# Target host public key, encoded with base64. This is used only for the
+# SFTP transfer protocol. If empty, kdump will run 'ssh-keygen -F' to get
+# the key from known hosts. If set to "*", any host key will be accepted.
+#
+# See also: kdump(5)
+KDUMP_HOST_KEY=""
--- a/init/mkdumprd
+++ b/init/mkdumprd
@@ -158,7 +158,14 @@ else
 fi
 
 INITRD_TMP=`mktemp --tmpdir mkdumprd.XXXXXXXXXX` || exit $?
-MKINITRD_ARGS="-B -k $KERNEL -i $INITRD_TMP -f '$FEATURE_LIST'"
+MKINITRD_ARGS="-k $KERNEL -i $INITRD_TMP -f '$FEATURE_LIST'"
+
+#
+# the -B parameter skips bootloader update, which is desirable if the
+# kernel is loaded by kexec, but not if we're using FADUMP
+if [ "$KDUMP_FADUMP" != "yes" ]; then
+    MKINITRD_ARGS="$MKINITRD_ARGS -B"
+fi
 
 #
 # the -s parameter is only available when the bootsplash package and its
