From 7a865b3cad45f82e3d02a58f2ee18fce1fc356c5 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Apr 28 2020 09:39:54 +0000 Subject: import kexec-tools-2.0.20-14.el8 --- diff --git a/.gitignore b/.gitignore index 297060f..abb4bc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ SOURCES/eppic_050615.tar.gz -SOURCES/kexec-tools-2.0.19.tar.xz -SOURCES/makedumpfile-1.6.5.tar.gz +SOURCES/kexec-tools-2.0.20.tar.xz +SOURCES/makedumpfile-1.6.6.tar.gz diff --git a/.kexec-tools.metadata b/.kexec-tools.metadata index b43204b..11cef96 100644 --- a/.kexec-tools.metadata +++ b/.kexec-tools.metadata @@ -1,3 +1,3 @@ a096c8e0892b559f40b01916aae240652f75b68a SOURCES/eppic_050615.tar.gz -5d080337da7a1603e542fc3db1f08cf8685eda02 SOURCES/kexec-tools-2.0.19.tar.xz -700f2ff13f75d97a0df2303ff9f580cdddadf7b0 SOURCES/makedumpfile-1.6.5.tar.gz +5d9acd2e741d356d4a48fe4f2d63f66ba431051d SOURCES/kexec-tools-2.0.20.tar.xz +68f5276d82091b54452f754aa41e2e8746f47814 SOURCES/makedumpfile-1.6.6.tar.gz diff --git a/SOURCES/dracut-kdump.sh b/SOURCES/dracut-kdump.sh index 2ae1c7c..cb22254 100755 --- a/SOURCES/dracut-kdump.sh +++ b/SOURCES/dracut-kdump.sh @@ -1,8 +1,8 @@ #!/bin/sh # continue here only if we have to save dump. -if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ]; then - exit 0 +if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then + exit 0 fi exec &> /dev/console @@ -81,6 +81,7 @@ dump_ssh() ssh -q $_opt $_host mkdir -p $_dir || return 1 save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" $_host + save_opalcore_ssh ${_dir} "${_opt}" $_host echo "kdump: saving vmcore" @@ -96,6 +97,32 @@ dump_ssh() return 0 } +save_opalcore_ssh() { + local _path=$1 + local _opts="$2" + local _location=$3 + + if [ ! -f $OPALCORE ]; then + # Check if we are on an old kernel that uses a different path + if [ -f /sys/firmware/opal/core ]; then + OPALCORE="/sys/firmware/opal/core" + else + return 0 + fi + fi + + echo "kdump: saving opalcore" + scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete + if [ $? -ne 0 ]; then + echo "kdump: saving opalcore failed" + return 1 + fi + + ssh $_opts $_location mv $_path/opalcore-incomplete $_path/opalcore + echo "kdump: saving opalcore complete" + return 0 +} + save_vmcore_dmesg_ssh() { local _dmesg_collector=$1 local _path=$2 diff --git a/SOURCES/dracut-module-setup.sh b/SOURCES/dracut-module-setup.sh index f492096..e7a2e63 100755 --- a/SOURCES/dracut-module-setup.sh +++ b/SOURCES/dracut-module-setup.sh @@ -40,7 +40,7 @@ depends() { _dep="$_dep drm" fi - if is_generic_fence_kdump -o is_pcs_fence_kdump; then + if is_generic_fence_kdump || is_pcs_fence_kdump; then _dep="$_dep network" fi @@ -225,7 +225,7 @@ kdump_setup_bond() { source_ifcfg_file $_netdev - bondoptions="$(echo :$BONDING_OPTS | sed 's/\s\+/,/')" + bondoptions=":$(echo $BONDING_OPTS | xargs echo | tr " " ",")" echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf } @@ -268,10 +268,10 @@ kdump_setup_vlan() { exit 1 elif kdump_is_bond "$_phydev"; then kdump_setup_bond "$_phydev" - echo " vlan=$_netdev:$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf + echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf else _kdumpdev="$(kdump_setup_ifname $_phydev)" - echo " vlan=$_netdev:$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf + echo " vlan=$(kdump_setup_ifname $_netdev):$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf fi } @@ -650,6 +650,40 @@ kdump_check_iscsi_targets () { } } +# hostname -a is deprecated, do it by ourself +get_alias() { + local ips + local entries + local alias_set + + ips=$(hostname -I) + for ip in $ips + do + entries=$(grep $ip /etc/hosts | awk '{ $1=$2=""; print $0 }') + if [ $? -eq 0 ]; then + alias_set="$alias_set $entries" + fi + done + + echo $alias_set +} + +is_localhost() { + local hostnames=$(hostname -A) + local shortnames=$(hostname -A -s) + local aliasname=$(get_alias) + local nodename=$1 + + hostnames="$hostnames $shortnames $aliasname" + + for name in ${hostnames}; do + if [ "$name" == "$nodename" ]; then + return 0 + fi + done + return 1 +} + # retrieves fence_kdump nodes from Pacemaker cluster configuration get_pcs_fence_kdump_nodes() { local nodes @@ -681,6 +715,21 @@ get_pcs_fence_kdump_args() { fi } +get_generic_fence_kdump_nodes() { + local filtered + local nodes + + nodes=$(get_option_value "fence_kdump_nodes") + for node in ${nodes}; do + # Skip its own node name + if is_localhost $node; then + continue + fi + filtered="$filtered $node" + done + echo $filtered +} + # setup fence_kdump in cluster # setup proper network and install needed files kdump_configure_fence_kdump () { @@ -689,7 +738,7 @@ kdump_configure_fence_kdump () { local args if is_generic_fence_kdump; then - nodes=$(get_option_value "fence_kdump_nodes") + nodes=$(get_generic_fence_kdump_nodes) elif is_pcs_fence_kdump; then nodes=$(get_pcs_fence_kdump_nodes) diff --git a/SOURCES/kdump-lib-initramfs.sh b/SOURCES/kdump-lib-initramfs.sh index c7f9522..a1ee9cd 100755 --- a/SOURCES/kdump-lib-initramfs.sh +++ b/SOURCES/kdump-lib-initramfs.sh @@ -18,6 +18,7 @@ KDUMP_CONF="/etc/kdump.conf" KDUMP_PRE="" KDUMP_POST="" NEWROOT="/sysroot" +OPALCORE="/sys/firmware/opal/mpipl/core" get_kdump_confs() { @@ -132,6 +133,7 @@ dump_fs() mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1 save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" + save_opalcore_fs "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" echo "kdump: saving vmcore" $CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete || return 1 @@ -168,6 +170,30 @@ save_vmcore_dmesg_fs() { fi } +save_opalcore_fs() { + local _path=$1 + + if [ ! -f $OPALCORE ]; then + # Check if we are on an old kernel that uses a different path + if [ -f /sys/firmware/opal/core ]; then + OPALCORE="/sys/firmware/opal/core" + else + return 0 + fi + fi + + echo "kdump: saving opalcore" + cp $OPALCORE ${_path}/opalcore + if [ $? -ne 0 ]; then + echo "kdump: saving opalcore failed" + return 1 + fi + + sync + echo "kdump: saving opalcore complete" + return 0 +} + dump_to_rootfs() { diff --git a/SOURCES/kdump.conf.5 b/SOURCES/kdump.conf.5 index fda3770..adfc372 100644 --- a/SOURCES/kdump.conf.5 +++ b/SOURCES/kdump.conf.5 @@ -275,7 +275,7 @@ retaining blacklist option creates more confusing behavior. It has been deprecated. .PP Instead, use rd.driver.blacklist option on second kernel to blacklist -a certain module. One can edit /etc/sysconfig/kdump.conf and edit +a certain module. One can edit /etc/sysconfig/kdump and edit KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer to dracut.cmdline man page for more details on module blacklist option. .RE diff --git a/SOURCES/kdumpctl b/SOURCES/kdumpctl index c6c1736..89030dd 100755 --- a/SOURCES/kdumpctl +++ b/SOURCES/kdumpctl @@ -242,6 +242,9 @@ check_config() echo "Invalid kdump config value for option $config_opt." return 1; } + if [ -d "/proc/device-tree/ibm,opal/dump" ] && [ "$config_opt" == "raw" ]; then + echo "WARNING: Won't capture opalcore when 'raw' dump target is used." + fi ;; net|options|link_delay|disk_timeout|debug_mem_level|blacklist) echo "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." @@ -727,13 +730,60 @@ check_ssh_config() return 0 } +# ipv6 host address may takes a long time to be ready. +# Instead of checking against ipv6 address, we just check the network reachable +# by the return val of 'ssh' +check_and_wait_network_ready() +{ + local start_time=$(date +%s) + local warn_once=1 + local cur + local diff + local retval + local errmsg + + while true; do + errmsg=$(ssh -i $SSH_KEY_LOCATION -o BatchMode=yes $DUMP_TARGET mkdir -p $SAVE_PATH 2>&1) + retval=$? + + # ssh exits with the exit status of the remote command or with 255 if an error occurred + if [ $retval -eq 0 ]; then + return 0 + elif [ $retval -ne 255 ]; then + echo "Could not create $DUMP_TARGET:$SAVE_PATH, you should check the privilege on server side" >&2 + return 1 + fi + + # if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa + echo $errmsg | grep -q "Permission denied\|No such file or directory\|Host key verification failed" + if [ $? -eq 0 ]; then + echo "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" >&2 + return 1 + fi + + if [ $warn_once -eq 1 ]; then + echo "Network dump target is not usable, waiting for it to be ready" + warn_once=0 + fi + echo -n . + + cur=$(date +%s) + let "diff = $cur - $start_time" + # 60s time out + if [ $diff -gt 180 ]; then + break; + fi + sleep 1 + done + + echo "Could not create $DUMP_TARGET:$SAVE_PATH, ipaddr is not ready yet. You should check network connection" >&2 + return 1 +} + check_ssh_target() { - local _ret - ssh -q -i $SSH_KEY_LOCATION -o BatchMode=yes $DUMP_TARGET mkdir -p $SAVE_PATH - _ret=$? - if [ $_ret -ne 0 ]; then - echo "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" >&2 + check_and_wait_network_ready + if [ $? -ne 0 ]; then return 1 fi return 0 @@ -1061,8 +1111,7 @@ reload() { check_current_status if [ $? -ne 0 ]; then - echo "Kdump is not running: [WARNING]" - return 0 + echo "Kdump was not running: [WARNING]" fi if [ $DEFAULT_DUMP_MODE == "fadump" ]; then diff --git a/SOURCES/kexec-tools-2.0.16-koji-build-fail-workaround.patch b/SOURCES/kexec-tools-2.0.16-koji-build-fail-workaround.patch deleted file mode 100644 index c406063..0000000 --- a/SOURCES/kexec-tools-2.0.16-koji-build-fail-workaround.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/purgatory/Makefile b/purgatory/Makefile -index 49ce80a..97b7a03 100644 ---- a/purgatory/Makefile -+++ b/purgatory/Makefile -@@ -67,7 +67,7 @@ $(PURGATORY): $(PURGATORY_OBJS) - $(MKDIR) -p $(@D) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@.sym $^ - # $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB) -- $(STRIP) --strip-debug -o $@ $@.sym -+ $(STRIP) --strip-debug --no-merge-notes -o $@ $@.sym - - echo:: - @echo "PURGATORY_SRCS $(PURGATORY_SRCS)" diff --git a/SOURCES/kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch b/SOURCES/kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch deleted file mode 100644 index 0eee6ea..0000000 --- a/SOURCES/kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch +++ /dev/null @@ -1,51 +0,0 @@ -From ce720608d5933e62f77f2c2f216859cf4f06adf8 Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Wed, 13 Feb 2019 00:03:51 +0800 -Subject: [PATCH] Fix eppic issue with hardening flags - -This is stash of two commits: - -commit f98cf5fe07f390554696755f0a5843f6bb9c4716 -Author: ryncsn -Date: Tue Mar 19 13:39:25 2019 +0800 - - Tell gcc not to omit frame pointer - - After commit 0209874, it's now possible to enable optimization above O0. - But eppic might call __builtin_return_address(1). With O1, - -fomit-frame-pointer is enabled gcc may omit frame pointer. - __builtin_return_address(1) relies on callee preserves RBP as the stack - base, which is untrue if optimization is usded. In this case it may return - wrong value or crash. - - In case of any potential failure, use -fno-omit-frame-pointer globally. - - Signed-off-by: Kairui Song - -commit 0209874f4b46b8af5a2d42662ba6775cf5a1dc44 -Author: Kairui Song -Date: Wed Feb 13 00:03:51 2019 +0800 - - Drop O0 CFLAGS override in Makefile - -Signed-off-by: Kairui Song ---- - libeppic/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libeppic/Makefile b/libeppic/Makefile -index bcf2edf..8b97c87 100644 ---- a/eppic/libeppic/Makefile -+++ b/eppic/libeppic/Makefile -@@ -24,7 +24,7 @@ LDIRT = lex.eppic.c lex.eppicpp.c eppic.tab.c eppic.tab.h eppicpp.tab.c \ - LIBDIR = /usr/lib - TARGETS = libeppic.a - --CFLAGS += -O0 -g -fPIC -+CFLAGS += -g -fno-omit-frame-pointer -fPIC - ifeq ($(TARGET), PPC64) - CFLAGS += -m64 - endif --- -2.20.1 - diff --git a/SOURCES/kexec-tools-2.0.18-makedumpfiles-exclude-pages-that-are-logically-offline.patch b/SOURCES/kexec-tools-2.0.18-makedumpfiles-exclude-pages-that-are-logically-offline.patch deleted file mode 100644 index 9825ef4..0000000 --- a/SOURCES/kexec-tools-2.0.18-makedumpfiles-exclude-pages-that-are-logically-offline.patch +++ /dev/null @@ -1,149 +0,0 @@ -From 0f9ee000904ffd1e171ba1f000a83e5ce3717e45 Mon Sep 17 00:00:00 2001 -From: David Hildenbrand -Date: Thu, 22 Nov 2018 11:09:38 +0100 -Subject: [PATCH] [PATCH] exclude pages that are logically offline - -Linux marks pages that are logically offline via a page flag (map count). -Such pages e.g. include pages infated as part of a balloon driver or -pages that were not actually onlined when onlining the whole section. - -While the hypervisor usually allows to read such inflated memory, we -basically read and dump data that is completely irrelevant. Also, this -might result in quite some overhead in the hypervisor. In addition, -we saw some problems under Hyper-V, whereby we can crash the kernel by -dumping, when reading memory of a partially onlined memory segment -(for memory added by the Hyper-V balloon driver). - -Therefore, don't read and dump pages that are marked as being logically -offline. - -Signed-off-by: David Hildenbrand -Signed-off-by: Pingfan Liu ---- - makedumpfile.c | 34 ++++++++++++++++++++++++++++++---- - makedumpfile.h | 1 + - 2 files changed, 31 insertions(+), 4 deletions(-) - -diff --git a/makedumpfile.c b/makedumpfile.c -index 8923538..a5f2ea9 100644 ---- a/makedumpfile-1.6.5/makedumpfile.c -+++ b/makedumpfile-1.6.5/makedumpfile.c -@@ -88,6 +88,7 @@ mdf_pfn_t pfn_cache_private; - mdf_pfn_t pfn_user; - mdf_pfn_t pfn_free; - mdf_pfn_t pfn_hwpoison; -+mdf_pfn_t pfn_offline; - - mdf_pfn_t num_dumped; - -@@ -250,6 +251,21 @@ isHugetlb(unsigned long dtor) - } - - static int -+isOffline(unsigned long flags, unsigned int _mapcount) -+{ -+ if (NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE) == NOT_FOUND_NUMBER) -+ return FALSE; -+ -+ if (flags & (1UL << NUMBER(PG_slab))) -+ return FALSE; -+ -+ if (_mapcount == (int)NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE)) -+ return TRUE; -+ -+ return FALSE; -+} -+ -+static int - is_cache_page(unsigned long flags) - { - if (isLRU(flags)) -@@ -2287,6 +2303,8 @@ write_vmcoreinfo_data(void) - WRITE_NUMBER("PG_hwpoison", PG_hwpoison); - - WRITE_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE); -+ WRITE_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", -+ PAGE_OFFLINE_MAPCOUNT_VALUE); - WRITE_NUMBER("phys_base", phys_base); - - WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR); -@@ -2687,6 +2705,7 @@ read_vmcoreinfo(void) - READ_SRCFILE("pud_t", pud_t); - - READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE); -+ READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE); - READ_NUMBER("phys_base", phys_base); - #ifdef __aarch64__ - READ_NUMBER("VA_BITS", VA_BITS); -@@ -6042,6 +6061,12 @@ __exclude_unnecessary_pages(unsigned long mem_map, - pfn_counter = &pfn_hwpoison; - } - /* -+ * Exclude pages that are logically offline. -+ */ -+ else if (isOffline(flags, _mapcount)) { -+ pfn_counter = &pfn_offline; -+ } -+ /* - * Unexcludable page - */ - else -@@ -7522,7 +7547,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page) - */ - if (info->flag_cyclic) { - pfn_zero = pfn_cache = pfn_cache_private = 0; -- pfn_user = pfn_free = pfn_hwpoison = 0; -+ pfn_user = pfn_free = pfn_hwpoison = pfn_offline = 0; - pfn_memhole = info->max_mapnr; - } - -@@ -8804,7 +8829,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d - * Reset counter for debug message. - */ - pfn_zero = pfn_cache = pfn_cache_private = 0; -- pfn_user = pfn_free = pfn_hwpoison = 0; -+ pfn_user = pfn_free = pfn_hwpoison = pfn_offline = 0; - pfn_memhole = info->max_mapnr; - - /* -@@ -9749,7 +9774,7 @@ print_report(void) - pfn_original = info->max_mapnr - pfn_memhole; - - pfn_excluded = pfn_zero + pfn_cache + pfn_cache_private -- + pfn_user + pfn_free + pfn_hwpoison; -+ + pfn_user + pfn_free + pfn_hwpoison + pfn_offline; - shrinking = (pfn_original - pfn_excluded) * 100; - shrinking = shrinking / pfn_original; - -@@ -9763,6 +9788,7 @@ print_report(void) - REPORT_MSG(" User process data pages : 0x%016llx\n", pfn_user); - REPORT_MSG(" Free pages : 0x%016llx\n", pfn_free); - REPORT_MSG(" Hwpoison pages : 0x%016llx\n", pfn_hwpoison); -+ REPORT_MSG(" Offline pages : 0x%016llx\n", pfn_offline); - REPORT_MSG(" Remaining pages : 0x%016llx\n", - pfn_original - pfn_excluded); - REPORT_MSG(" (The number of pages is reduced to %lld%%.)\n", -@@ -9790,7 +9816,7 @@ print_mem_usage(void) - pfn_original = info->max_mapnr - pfn_memhole; - - pfn_excluded = pfn_zero + pfn_cache + pfn_cache_private -- + pfn_user + pfn_free + pfn_hwpoison; -+ + pfn_user + pfn_free + pfn_hwpoison + pfn_offline; - shrinking = (pfn_original - pfn_excluded) * 100; - shrinking = shrinking / pfn_original; - total_size = info->page_size * pfn_original; -diff --git a/makedumpfile.h b/makedumpfile.h -index 73813ed..04c903f 100644 ---- a/makedumpfile-1.6.5/makedumpfile.h -+++ b/makedumpfile-1.6.5/makedumpfile.h -@@ -1927,6 +1927,7 @@ struct number_table { - long PG_hwpoison; - - long PAGE_BUDDY_MAPCOUNT_VALUE; -+ long PAGE_OFFLINE_MAPCOUNT_VALUE; - long SECTION_SIZE_BITS; - long MAX_PHYSMEM_BITS; - long HUGETLB_PAGE_DTOR; --- -2.7.4 - diff --git a/SOURCES/kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch b/SOURCES/kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch deleted file mode 100644 index e4052fa..0000000 --- a/SOURCES/kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 2f007b48c581a81d7e95678b6bcb77cfbe177135 Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Tue, 29 Jan 2019 11:14:15 +0800 -Subject: [PATCH] [PATCH v2] honor the CFLAGS from environment variables - -This makes it possible to pass in extra cflags, for example, hardening -flags could be passed in with environment variable when building a -hardened package. - -Also introduce a CFLAGS_BASE to hold common CFLAGS, which simplify the -CFLAGS definition. - -Suggested-by: Kazuhito Hagio -Signed-off-by: Kairui Song ---- - Makefile | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/Makefile b/Makefile -index ea3c47d..bd681d2 100644 ---- a/makedumpfile-1.6.5/Makefile -+++ b/makedumpfile-1.6.5/Makefile -@@ -8,11 +8,10 @@ ifeq ($(strip $CC),) - CC = gcc - endif - --CFLAGS = -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ -- -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \ -- -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"' --CFLAGS_ARCH = -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ -- -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -+CFLAGS_BASE := $(CFLAGS) -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ -+ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -+CFLAGS := $(CFLAGS_BASE) -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"' -+CFLAGS_ARCH := $(CFLAGS_BASE) - # LDFLAGS = -L/usr/local/lib -I/usr/local/include - - HOST_ARCH := $(shell uname -m) --- -2.20.1 - diff --git a/SOURCES/kexec-tools-2.0.19-kexec-arm64-Add-support-for-handling-zlib-compressed.patch b/SOURCES/kexec-tools-2.0.19-kexec-arm64-Add-support-for-handling-zlib-compressed.patch deleted file mode 100644 index bdbf067..0000000 --- a/SOURCES/kexec-tools-2.0.19-kexec-arm64-Add-support-for-handling-zlib-compressed.patch +++ /dev/null @@ -1,385 +0,0 @@ -From f4c1caaa97a2e019ccc00ab63e390c60d1c9454c Mon Sep 17 00:00:00 2001 -From: Bhupesh Sharma -Date: Mon, 15 Jul 2019 11:32:56 +0530 -Subject: [PATCH 4/5] kexec/arm64: Add support for handling zlib compressed - (Image.gz) image - -Currently the kexec_file_load() support for arm64 doesn't allow -handling zlib compressed (i.e. Image.gz) image. - -Since most distributions use 'make zinstall' rule inside -'arch/arm64/boot/Makefile' to install the arm64 -Image.gz compressed file inside the boot destination directory (for e.g. -/boot), currently we cannot use kexec_file_load() to load vmlinuz (or -Image.gz): - - # file /boot/vmlinuz - /boot/vmlinuz: gzip compressed data, was "Image", <..snip..>, max - compression, from Unix, original size 21945120 - - Now, since via kexec_file_load() we pass the 'fd' of Image.gz - (compressed file) via the following command line ... - - # kexec -s -l /boot/vmlinuz-`uname -r` --initrd=/boot/initramfs-`uname - -r`.img --reuse-cmdline - -... kernel returns -EINVAL error value, as it is not able to locate -the magic number =0x644d5241, which is expected in the 64-byte header -of the decompressed kernel image. - -We can fix this in user-space kexec-tools, which handles an -'Image.gz' being passed via kexec_file_load(), using an approach -as follows: - -a). Copy the contents of Image.gz to a temporary file. -b). Decompress (gunzip-decompress) the contents inside the - temporary file. -c). Pass the 'fd' of the temporary file to the kernel space. So - basically the kernel space still gets a decompressed kernel - image to load via kexec-tools - -I tested this patch for the following three use-cases: - -1. Uncompressed Image file: - #kexec -s -l Image --initrd=/boot/initramfs-`uname -r`.img --reuse-cmdline - -2. Signed Image file: - #kexec -s -l Image.signed --initrd=/boot/initramfs-`uname -r`.img --reuse-cmdline - -3. zlib compressed Image.gz file: - #kexec -s -l /boot/vmlinuz-`uname -r` --initrd=/boot/initramfs-`uname -r`.img --reuse-cmdline - -Signed-off-by: Bhupesh Sharma -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/Makefile | 3 +- - kexec/arch/arm64/kexec-arm64.c | 1 + - kexec/arch/arm64/kexec-arm64.h | 7 ++ - kexec/arch/arm64/kexec-image-arm64.c | 4 +- - kexec/arch/arm64/kexec-zImage-arm64.c | 226 ++++++++++++++++++++++++++++++++++ - kexec/kexec.c | 12 ++ - 6 files changed, 250 insertions(+), 3 deletions(-) - create mode 100644 kexec/arch/arm64/kexec-zImage-arm64.c - -diff --git a/kexec/arch/arm64/Makefile b/kexec/arch/arm64/Makefile -index 9d9111caa8ed..d27c8ee1b5e7 100644 ---- a/kexec/arch/arm64/Makefile -+++ b/kexec/arch/arm64/Makefile -@@ -15,7 +15,8 @@ arm64_KEXEC_SRCS += \ - kexec/arch/arm64/kexec-arm64.c \ - kexec/arch/arm64/kexec-elf-arm64.c \ - kexec/arch/arm64/kexec-uImage-arm64.c \ -- kexec/arch/arm64/kexec-image-arm64.c -+ kexec/arch/arm64/kexec-image-arm64.c \ -+ kexec/arch/arm64/kexec-zImage-arm64.c - - arm64_UIMAGE = kexec/kexec-uImage.c - -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index 2992bce8139f..eb3a3a37307c 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -71,6 +71,7 @@ struct file_type file_type[] = { - {"vmlinux", elf_arm64_probe, elf_arm64_load, elf_arm64_usage}, - {"Image", image_arm64_probe, image_arm64_load, image_arm64_usage}, - {"uImage", uImage_arm64_probe, uImage_arm64_load, uImage_arm64_usage}, -+ {"zImage", zImage_arm64_probe, zImage_arm64_load, zImage_arm64_usage}, - }; - - int file_types = sizeof(file_type) / sizeof(file_type[0]); -diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h -index cc3419f4c10f..628de79b7f70 100644 ---- a/kexec/arch/arm64/kexec-arm64.h -+++ b/kexec/arch/arm64/kexec-arm64.h -@@ -38,11 +38,18 @@ int image_arm64_probe(const char *kernel_buf, off_t kernel_size); - int image_arm64_load(int argc, char **argv, const char *kernel_buf, - off_t kernel_size, struct kexec_info *info); - void image_arm64_usage(void); -+ - int uImage_arm64_probe(const char *buf, off_t len); - int uImage_arm64_load(int argc, char **argv, const char *buf, off_t len, - struct kexec_info *info); - void uImage_arm64_usage(void); - -+int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size); -+int zImage_arm64_load(int argc, char **argv, const char *kernel_buf, -+ off_t kernel_size, struct kexec_info *info); -+void zImage_arm64_usage(void); -+ -+ - off_t initrd_base; - off_t initrd_size; - -diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c -index 685a99352e39..aa8f2e22d72b 100644 ---- a/kexec/arch/arm64/kexec-image-arm64.c -+++ b/kexec/arch/arm64/kexec-image-arm64.c -@@ -114,6 +114,6 @@ exit: - void image_arm64_usage(void) - { - printf( --" An ARM64 binary image, compressed or not, big or little endian.\n" --" Typically an Image, Image.gz or Image.lzma file.\n\n"); -+" An ARM64 binary image, uncompressed, big or little endian.\n" -+" Typically an Image file.\n\n"); - } -diff --git a/kexec/arch/arm64/kexec-zImage-arm64.c b/kexec/arch/arm64/kexec-zImage-arm64.c -new file mode 100644 -index 000000000000..6ee82ff6c79e ---- /dev/null -+++ b/kexec/arch/arm64/kexec-zImage-arm64.c -@@ -0,0 +1,226 @@ -+/* -+ * ARM64 kexec zImage (Image.gz) support. -+ * -+ * Several distros use 'make zinstall' rule inside -+ * 'arch/arm64/boot/Makefile' to install the arm64 -+ * Image.gz compressed file inside the boot destination -+ * directory (for e.g. /boot). -+ * -+ * Currently we cannot use kexec_file_load() to load vmlinuz -+ * (or Image.gz). -+ * -+ * To support Image.gz, we should: -+ * a). Copy the contents of Image.gz to a temporary file. -+ * b). Decompress (gunzip-decompress) the contents inside the -+ * temporary file. -+ * c). Pass the 'fd' of the temporary file to the kernel space. -+ * -+ * So basically the kernel space still gets a decompressed -+ * kernel image to load via kexec-tools. -+ */ -+ -+#define _GNU_SOURCE -+ -+#include -+#include -+#include -+#include -+#include "crashdump-arm64.h" -+#include "image-header.h" -+#include "kexec.h" -+#include "kexec-arm64.h" -+#include "kexec-syscall.h" -+#include "kexec-zlib.h" -+#include "arch/options.h" -+ -+#define FILENAME_IMAGE "/tmp/ImageXXXXXX" -+ -+/* Returns: -+ * -1 : in case of error/invalid format (not a valid Image.gz format. -+ * fd : File descriptor of the temp file containing the decompressed -+ * Image. -+ */ -+int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size) -+{ -+ int ret = -1; -+ int fd = 0; -+ int kernel_fd = 0; -+ char *fname = NULL; -+ char *kernel_uncompressed_buf = NULL; -+ const struct arm64_image_header *h; -+ -+ if (!is_zlib_file(kernel_buf, &kernel_size)) { -+ dbgprintf("%s: Not an zImage file (Image.gz).\n", __func__); -+ return -1; -+ } -+ -+ if (!(fname = strdup(FILENAME_IMAGE))) { -+ dbgprintf("%s: Can't duplicate strings %s\n", __func__, -+ fname); -+ return -1; -+ } -+ -+ if ((fd = mkstemp(fname)) < 0) { -+ dbgprintf("%s: Can't open file %s\n", __func__, -+ fname); -+ ret = -1; -+ goto fail_mkstemp; -+ } -+ -+ kernel_uncompressed_buf = -+ (char *) calloc(kernel_size, sizeof(off_t)); -+ if (!kernel_uncompressed_buf) { -+ dbgprintf("%s: Can't calloc %ld bytes\n", -+ __func__, kernel_size); -+ ret= -ENOMEM; -+ goto fail_calloc; -+ } -+ -+ /* slurp in the input kernel */ -+ dbgprintf("%s: ", __func__); -+ kernel_uncompressed_buf = slurp_decompress_file(kernel_buf, -+ &kernel_size); -+ -+ /* check for correct header magic */ -+ if (kernel_size < sizeof(struct arm64_image_header)) { -+ dbgprintf("%s: No arm64 image header.\n", __func__); -+ ret = -1; -+ goto fail_bad_header; -+ } -+ -+ h = (const struct arm64_image_header *)(kernel_uncompressed_buf); -+ -+ if (!arm64_header_check_magic(h)) { -+ dbgprintf("%s: Bad arm64 image header.\n", __func__); -+ ret = -1; -+ goto fail_bad_header; -+ } -+ -+ if (write(fd, kernel_uncompressed_buf, -+ kernel_size) != kernel_size) { -+ dbgprintf("%s: Can't write the uncompressed file %s\n", -+ __func__, fname); -+ ret = -1; -+ goto fail_bad_header; -+ } -+ -+ close(fd); -+ -+ /* Open the tmp file again, this time in O_RDONLY mode, as -+ * opening the file in O_RDWR and calling kexec_file_load() -+ * causes the kernel to return -ETXTBSY -+ */ -+ kernel_fd = open(fname, O_RDONLY); -+ if (kernel_fd == -1) { -+ dbgprintf("%s: Failed to open file %s\n", -+ __func__, fname); -+ ret = -1; -+ goto fail_bad_header; -+ } -+ -+ unlink(fname); -+ -+ free(kernel_uncompressed_buf); -+ free(fname); -+ -+ return kernel_fd; -+ -+fail_bad_header: -+ free(kernel_uncompressed_buf); -+ -+fail_calloc: -+ if (fd >= 0) -+ close(fd); -+ -+ unlink(fname); -+ -+fail_mkstemp: -+ free(fname); -+ -+ return ret; -+} -+ -+int zImage_arm64_load(int argc, char **argv, const char *kernel_buf, -+ off_t kernel_size, struct kexec_info *info) -+{ -+ const struct arm64_image_header *header; -+ unsigned long kernel_segment; -+ int result; -+ -+ if (info->file_mode) { -+ if (arm64_opts.initrd) { -+ info->initrd_fd = open(arm64_opts.initrd, O_RDONLY); -+ if (info->initrd_fd == -1) { -+ fprintf(stderr, -+ "Could not open initrd file %s:%s\n", -+ arm64_opts.initrd, strerror(errno)); -+ result = EFAILED; -+ goto exit; -+ } -+ } -+ -+ if (arm64_opts.command_line) { -+ info->command_line = (char *)arm64_opts.command_line; -+ info->command_line_len = -+ strlen(arm64_opts.command_line) + 1; -+ } -+ -+ return 0; -+ } -+ -+ header = (const struct arm64_image_header *)(kernel_buf); -+ -+ if (arm64_process_image_header(header)) -+ return EFAILED; -+ -+ kernel_segment = arm64_locate_kernel_segment(info); -+ -+ if (kernel_segment == ULONG_MAX) { -+ dbgprintf("%s: Kernel segment is not allocated\n", __func__); -+ result = EFAILED; -+ goto exit; -+ } -+ -+ dbgprintf("%s: kernel_segment: %016lx\n", __func__, kernel_segment); -+ dbgprintf("%s: text_offset: %016lx\n", __func__, -+ arm64_mem.text_offset); -+ dbgprintf("%s: image_size: %016lx\n", __func__, -+ arm64_mem.image_size); -+ dbgprintf("%s: phys_offset: %016lx\n", __func__, -+ arm64_mem.phys_offset); -+ dbgprintf("%s: vp_offset: %016lx\n", __func__, -+ arm64_mem.vp_offset); -+ dbgprintf("%s: PE format: %s\n", __func__, -+ (arm64_header_check_pe_sig(header) ? "yes" : "no")); -+ -+ /* create and initialize elf core header segment */ -+ if (info->kexec_flags & KEXEC_ON_CRASH) { -+ result = load_crashdump_segments(info); -+ if (result) { -+ dbgprintf("%s: Creating eflcorehdr failed.\n", -+ __func__); -+ goto exit; -+ } -+ } -+ -+ /* load the kernel */ -+ add_segment_phys_virt(info, kernel_buf, kernel_size, -+ kernel_segment + arm64_mem.text_offset, -+ arm64_mem.image_size, 0); -+ -+ /* load additional data */ -+ result = arm64_load_other_segments(info, kernel_segment -+ + arm64_mem.text_offset); -+ -+exit: -+ if (result) -+ fprintf(stderr, "kexec: load failed.\n"); -+ return result; -+} -+ -+void zImage_arm64_usage(void) -+{ -+ printf( -+" An ARM64 zImage, compressed, big or little endian.\n" -+" Typically an Image.gz or Image.lzma file.\n\n"); -+} -diff --git a/kexec/kexec.c b/kexec/kexec.c -index 8ca3b457cac8..bc6ab3dbd10b 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -1206,8 +1206,20 @@ static int do_kexec_file_load(int fileind, int argc, char **argv, - kernel_buf = slurp_decompress_file(kernel, &kernel_size); - - for (i = 0; i < file_types; i++) { -+#ifdef __aarch64__ -+ /* handle Image.gz like cases */ -+ if (is_zlib_file(kernel, &kernel_size)) { -+ if ((ret = file_type[i].probe(kernel, kernel_size)) >= 0) { -+ kernel_fd = ret; -+ break; -+ } -+ } else -+ if (file_type[i].probe(kernel_buf, kernel_size) >= 0) -+ break; -+#else - if (file_type[i].probe(kernel_buf, kernel_size) >= 0) - break; -+#endif - } - - if (i == file_types) { --- -2.7.4 - diff --git a/SOURCES/kexec-tools-2.0.19-kexec-kexec-zlib.h-Add-is_zlib_file-helper-function.patch b/SOURCES/kexec-tools-2.0.19-kexec-kexec-zlib.h-Add-is_zlib_file-helper-function.patch deleted file mode 100644 index 786f90c..0000000 --- a/SOURCES/kexec-tools-2.0.19-kexec-kexec-zlib.h-Add-is_zlib_file-helper-function.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 0e709571bfe7e3b8160044970e2084194f9a963b Mon Sep 17 00:00:00 2001 -From: Bhupesh Sharma -Date: Mon, 15 Jul 2019 11:32:55 +0530 -Subject: [PATCH 3/5] kexec/kexec-zlib.h: Add 'is_zlib_file()' helper function - -This patch adds 'is_zlib_file()' helper function which can be -used to quickly determine with the passed kernel image is a zlib -compressed kernel image. - -This is specifically useful for arm64 zImage (or Image.gz) support, -which is introduced by later patches in this patchset. - -Signed-off-by: Bhupesh Sharma -Signed-off-by: Simon Horman ---- - kexec/kexec-zlib.h | 1 + - kexec/zlib.c | 38 ++++++++++++++++++++++++++++++++++++++ - 2 files changed, 39 insertions(+) - -diff --git a/kexec/kexec-zlib.h b/kexec/kexec-zlib.h -index 43c107bf4a72..16300f294759 100644 ---- a/kexec/kexec-zlib.h -+++ b/kexec/kexec-zlib.h -@@ -6,5 +6,6 @@ - - #include "config.h" - -+int is_zlib_file(const char *filename, off_t *r_size); - char *zlib_decompress_file(const char *filename, off_t *r_size); - #endif /* __KEXEC_ZLIB_H */ -diff --git a/kexec/zlib.c b/kexec/zlib.c -index 95b608059d41..9bc340d85001 100644 ---- a/kexec/zlib.c -+++ b/kexec/zlib.c -@@ -23,6 +23,38 @@ static void _gzerror(gzFile fp, int *errnum, const char **errmsg) - } - } - -+int is_zlib_file(const char *filename, off_t *r_size) -+{ -+ gzFile fp; -+ int errnum; -+ int is_zlib_file = 0; /* default: It's not in gzip format */ -+ const char *msg; -+ ssize_t result; -+ -+ if (!filename) -+ goto out; -+ -+ fp = gzopen(filename, "rb"); -+ if (fp == 0) { -+ _gzerror(fp, &errnum, &msg); -+ dbgprintf("Cannot open `%s': %s\n", filename, msg); -+ goto out; -+ } -+ -+ if (!gzdirect(fp)) -+ /* It's in gzip format */ -+ is_zlib_file = 1; -+ -+ result = gzclose(fp); -+ if (result != Z_OK) { -+ _gzerror(fp, &errnum, &msg); -+ dbgprintf(" Close of %s failed: %s\n", filename, msg); -+ } -+ -+out: -+ return is_zlib_file; -+} -+ - char *zlib_decompress_file(const char *filename, off_t *r_size) - { - gzFile fp; -@@ -84,6 +116,12 @@ fail: - return buf; - } - #else -+ -+int is_zlib_file(const char *filename, off_t *r_size) -+{ -+ return 0; -+} -+ - char *zlib_decompress_file(const char *UNUSED(filename), off_t *UNUSED(r_size)) - { - return NULL; --- -2.7.4 - diff --git a/SOURCES/kexec-tools-2.0.19-kexec-kexec.c-Add-the-missing-close-for-fd-used-for-.patch b/SOURCES/kexec-tools-2.0.19-kexec-kexec.c-Add-the-missing-close-for-fd-used-for-.patch deleted file mode 100644 index 4bc6ca7..0000000 --- a/SOURCES/kexec-tools-2.0.19-kexec-kexec.c-Add-the-missing-close-for-fd-used-for-.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 019d8258f15c2a716786880c3cbd0f327a4dfc09 Mon Sep 17 00:00:00 2001 -From: Bhupesh Sharma -Date: Mon, 15 Jul 2019 11:32:53 +0530 -Subject: [PATCH 1/5] kexec/kexec.c: Add the missing close() for fd used for - kexec_file_load() - -In kexec/kexec.c, we open() the kernel Image file and pass this file -descriptor to the kexec_file_load() system call, but never call a -corresponding close(). - -Fix the same via this patch. - -Signed-off-by: Bhupesh Sharma -Signed-off-by: Simon Horman ---- - kexec/kexec.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/kexec/kexec.c b/kexec/kexec.c -index 32ae56c8f1c3..8ca3b457cac8 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -1234,6 +1234,8 @@ static int do_kexec_file_load(int fileind, int argc, char **argv, - if (ret != 0) - fprintf(stderr, "kexec_file_load failed: %s\n", - strerror(errno)); -+ -+ close(kernel_fd); - return ret; - } - --- -2.7.4 - diff --git a/SOURCES/kexec-tools-2.0.19-kexec-uImage-arm64.c-Fix-return-value-of-uImage_arm6.patch b/SOURCES/kexec-tools-2.0.19-kexec-uImage-arm64.c-Fix-return-value-of-uImage_arm6.patch deleted file mode 100644 index 644a117..0000000 --- a/SOURCES/kexec-tools-2.0.19-kexec-uImage-arm64.c-Fix-return-value-of-uImage_arm6.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 6ef59c03bf2c42f6577c708b58598868e8e8fb0b Mon Sep 17 00:00:00 2001 -From: Bhupesh Sharma -Date: Mon, 15 Jul 2019 11:32:54 +0530 -Subject: [PATCH 2/5] kexec-uImage-arm64.c: Fix return value of - uImage_arm64_probe() - -Commit bf06cf2095e1 ("kexec/uImage: probe to identify a corrupted image"), -defined the 'uImage_probe_kernel()' function return values and -correspondingly ;uImage_arm64_probe()' returns the same (0 -> If the -image is valid 'type' image, -1 -> If the image is corrupted and -1 -> If the image is not a uImage). - -This causes issues because, in later patches we introduce zImage -support for arm64, and since it is probed after uImage, the return -values from 'uImage_arm64_probe()' needs to be fixed to make sure -that kexec will not return with an invalid error code. - -Now, 'uImage_arm64_probe()' returns the following values instead: - 0 - valid uImage. - -1 - uImage is corrupted. - 1 - image is not a uImage. - -Signed-off-by: Bhupesh Sharma -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/kexec-uImage-arm64.c | 13 ++++++++++++- - 1 file changed, 12 insertions(+), 1 deletion(-) - -diff --git a/kexec/arch/arm64/kexec-uImage-arm64.c b/kexec/arch/arm64/kexec-uImage-arm64.c -index 126ea9c2555b..c4669131b667 100644 ---- a/kexec/arch/arm64/kexec-uImage-arm64.c -+++ b/kexec/arch/arm64/kexec-uImage-arm64.c -@@ -11,7 +11,18 @@ - - int uImage_arm64_probe(const char *buf, off_t len) - { -- return uImage_probe_kernel(buf, len, IH_ARCH_ARM64); -+ int ret; -+ -+ ret = uImage_probe_kernel(buf, len, IH_ARCH_ARM64); -+ -+ /* 0 - valid uImage. -+ * -1 - uImage is corrupted. -+ * 1 - image is not a uImage. -+ */ -+ if (!ret) -+ return 0; -+ else -+ return -1; - } - - int uImage_arm64_load(int argc, char **argv, const char *buf, off_t len, --- -2.7.4 - diff --git a/SOURCES/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch b/SOURCES/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch deleted file mode 100644 index 662fd27..0000000 --- a/SOURCES/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch +++ /dev/null @@ -1,198 +0,0 @@ -From d222b01e516bba73ef9fefee4146734a5f260fa1 Mon Sep 17 00:00:00 2001 -From: Lianbo Jiang -Date: Wed, 30 Jan 2019 10:48:53 +0800 -Subject: [PATCH] [PATCH] x86_64: Add support for AMD Secure Memory Encryption - -On AMD machine with Secure Memory Encryption (SME) feature, if SME is -enabled, page tables contain a specific attribute bit (C-bit) in their -entries to indicate whether a page is encrypted or unencrypted. - -So get NUMBER(sme_mask) from vmcoreinfo, which stores the value of -the C-bit position, and drop it to obtain the true physical address. - -Signed-off-by: Lianbo Jiang ---- - arch/x86_64.c | 30 +++++++++++++++++++----------- - makedumpfile.c | 4 ++++ - makedumpfile.h | 1 + - 3 files changed, 24 insertions(+), 11 deletions(-) - -diff --git a/arch/x86_64.c b/arch/x86_64.c -index 9db1f8139f28..46e93366f0be 100644 ---- a/makedumpfile-1.6.5/arch/x86_64.c -+++ b/makedumpfile-1.6.5/arch/x86_64.c -@@ -297,6 +297,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - unsigned long page_dir, pgd, pud_paddr, pud_pte, pmd_paddr, pmd_pte; - unsigned long pte_paddr, pte; - unsigned long p4d_paddr, p4d_pte; -+ unsigned long entry_mask = ENTRY_MASK; - - /* - * Get PGD. -@@ -308,6 +309,9 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - return NOT_PADDR; - } - -+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) -+ entry_mask &= ~(NUMBER(sme_mask)); -+ - if (check_5level_paging()) { - page_dir += pgd5_index(vaddr) * sizeof(unsigned long); - if (!readmem(PADDR, page_dir, &pgd, sizeof pgd)) { -@@ -324,7 +328,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - /* - * Get P4D. - */ -- p4d_paddr = pgd & ENTRY_MASK; -+ p4d_paddr = pgd & entry_mask; - p4d_paddr += p4d_index(vaddr) * sizeof(unsigned long); - if (!readmem(PADDR, p4d_paddr, &p4d_pte, sizeof p4d_pte)) { - ERRMSG("Can't get p4d_pte (p4d_paddr:%lx).\n", p4d_paddr); -@@ -337,7 +341,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - ERRMSG("Can't get a valid p4d_pte.\n"); - return NOT_PADDR; - } -- pud_paddr = p4d_pte & ENTRY_MASK; -+ pud_paddr = p4d_pte & entry_mask; - }else { - page_dir += pgd_index(vaddr) * sizeof(unsigned long); - if (!readmem(PADDR, page_dir, &pgd, sizeof pgd)) { -@@ -351,7 +355,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - ERRMSG("Can't get a valid pgd.\n"); - return NOT_PADDR; - } -- pud_paddr = pgd & ENTRY_MASK; -+ pud_paddr = pgd & entry_mask; - } - - /* -@@ -370,13 +374,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - return NOT_PADDR; - } - if (pud_pte & _PAGE_PSE) /* 1GB pages */ -- return (pud_pte & ENTRY_MASK & PUD_MASK) + -+ return (pud_pte & entry_mask & PUD_MASK) + - (vaddr & ~PUD_MASK); - - /* - * Get PMD. - */ -- pmd_paddr = pud_pte & ENTRY_MASK; -+ pmd_paddr = pud_pte & entry_mask; - pmd_paddr += pmd_index(vaddr) * sizeof(unsigned long); - if (!readmem(PADDR, pmd_paddr, &pmd_pte, sizeof pmd_pte)) { - ERRMSG("Can't get pmd_pte (pmd_paddr:%lx).\n", pmd_paddr); -@@ -390,13 +394,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - return NOT_PADDR; - } - if (pmd_pte & _PAGE_PSE) /* 2MB pages */ -- return (pmd_pte & ENTRY_MASK & PMD_MASK) + -+ return (pmd_pte & entry_mask & PMD_MASK) + - (vaddr & ~PMD_MASK); - - /* - * Get PTE. - */ -- pte_paddr = pmd_pte & ENTRY_MASK; -+ pte_paddr = pmd_pte & entry_mask; - pte_paddr += pte_index(vaddr) * sizeof(unsigned long); - if (!readmem(PADDR, pte_paddr, &pte, sizeof pte)) { - ERRMSG("Can't get pte (pte_paddr:%lx).\n", pte_paddr); -@@ -409,7 +413,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - ERRMSG("Can't get a valid pte.\n"); - return NOT_PADDR; - } -- return (pte & ENTRY_MASK) + PAGEOFFSET(vaddr); -+ return (pte & entry_mask) + PAGEOFFSET(vaddr); - } - - unsigned long long -@@ -642,6 +646,7 @@ find_vmemmap_x86_64() - unsigned long pmd, tpfn; - unsigned long pvaddr = 0; - unsigned long data_addr = 0, last_data_addr = 0, start_data_addr = 0; -+ unsigned long pmask = PMASK; - /* - * data_addr is the paddr of the page holding the page structs. - * We keep lists of contiguous pages and the pfn's that their -@@ -662,6 +667,9 @@ find_vmemmap_x86_64() - return FAILED; - } - -+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) -+ pmask &= ~(NUMBER(sme_mask)); -+ - pagestructsize = size_table.page; - hugepagesize = PTRS_PER_PMD * info->page_size; - vaddr_base = info->vmemmap_start; -@@ -692,7 +700,7 @@ find_vmemmap_x86_64() - } - - /* mask the pgd entry for the address of the pud page */ -- pud_addr &= PMASK; -+ pud_addr &= pmask; - if (pud_addr == 0) - continue; - /* read the entire pud page */ -@@ -705,7 +713,7 @@ find_vmemmap_x86_64() - /* pudp points to an entry in the pud page */ - for (pudp = (unsigned long *)pud_page, pudindex = 0; - pudindex < PTRS_PER_PUD; pudindex++, pudp++) { -- pmd_addr = *pudp & PMASK; -+ pmd_addr = *pudp & pmask; - /* read the entire pmd page */ - if (pmd_addr == 0) - continue; -@@ -747,7 +755,7 @@ find_vmemmap_x86_64() - * - we discontiguous page is a string of valids - */ - if (pmd) { -- data_addr = (pmd & PMASK); -+ data_addr = (pmd & pmask); - if (start_range) { - /* first-time kludge */ - start_data_addr = data_addr; -diff --git a/makedumpfile.c b/makedumpfile.c -index 7dfe70fb8792..590f759c84f1 100644 ---- a/makedumpfile-1.6.5/makedumpfile.c -+++ b/makedumpfile-1.6.5/makedumpfile.c -@@ -993,6 +993,8 @@ next_page: - read_size = MIN(info->page_size - PAGEOFFSET(paddr), size); - - pgaddr = PAGEBASE(paddr); -+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) -+ pgaddr = pgaddr & ~(NUMBER(sme_mask)); - pgbuf = cache_search(pgaddr, read_size); - if (!pgbuf) { - ++cache_miss; -@@ -2292,6 +2294,7 @@ write_vmcoreinfo_data(void) - WRITE_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES); - WRITE_NUMBER("N_ONLINE", N_ONLINE); - WRITE_NUMBER("pgtable_l5_enabled", pgtable_l5_enabled); -+ WRITE_NUMBER("sme_mask", sme_mask); - - WRITE_NUMBER("PG_lru", PG_lru); - WRITE_NUMBER("PG_private", PG_private); -@@ -2695,6 +2698,7 @@ read_vmcoreinfo(void) - READ_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES); - READ_NUMBER("N_ONLINE", N_ONLINE); - READ_NUMBER("pgtable_l5_enabled", pgtable_l5_enabled); -+ READ_NUMBER("sme_mask", sme_mask); - - READ_NUMBER("PG_lru", PG_lru); - READ_NUMBER("PG_private", PG_private); -diff --git a/makedumpfile.h b/makedumpfile.h -index 2e73beca48c5..5ad38e9ae40c 100644 ---- a/makedumpfile-1.6.5/makedumpfile.h -+++ b/makedumpfile-1.6.5/makedumpfile.h -@@ -1913,6 +1913,7 @@ struct number_table { - long NR_FREE_PAGES; - long N_ONLINE; - long pgtable_l5_enabled; -+ long sme_mask; - - /* - * Page flags --- -2.17.1 - diff --git a/SOURCES/kexec-tools-2.0.19-x86-Introduce-a-new-option-reuse-video-type.patch b/SOURCES/kexec-tools-2.0.19-x86-Introduce-a-new-option-reuse-video-type.patch deleted file mode 100644 index 90481a1..0000000 --- a/SOURCES/kexec-tools-2.0.19-x86-Introduce-a-new-option-reuse-video-type.patch +++ /dev/null @@ -1,129 +0,0 @@ -From fb5a8792e6e4ee7de7ae3e06d193ea5beaaececc Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Tue, 5 Mar 2019 19:34:33 +0800 -Subject: [PATCH] x86: Introduce a new option --reuse-video-type - -After commit 060eee58 "x86: use old screen_info if needed", kexec-tools -will force use old screen_info and vga type if failed to determine -current vga type. But it is not always a good idea. - -Currently kernel hanging is inspected on some hyper-v VMs after this -commit, because hyperv_fb will mimic EFI (or VESA) VGA on first boot -up, but after the real driver is loaded, it will switch to new mode -and no longer compatible with EFI/VESA VGA. Keep setting -orig_video_isVGA to EFI/VESA VGA flag will get wrong driver loaded and -try to manipulate the framebuffer in a wrong way. - -We can't ensure this won't happen on other framebuffer drivers, But -it's a helpful feature if the framebuffer drivers just work. So this -patch introduce a --reuse-video-type options to let user decide if the -old screen_info hould be used unconditional or not. - -Signed-off-by: Kairui Song -Reviewed-by: Dave Young -Signed-off-by: Simon Horman ---- - kexec/arch/i386/include/arch/options.h | 2 ++ - kexec/arch/i386/kexec-x86.h | 1 + - kexec/arch/i386/x86-linux-setup.c | 8 ++++++-- - kexec/arch/x86_64/kexec-x86_64.c | 5 +++++ - 4 files changed, 14 insertions(+), 2 deletions(-) - -diff --git a/kexec/arch/i386/include/arch/options.h b/kexec/arch/i386/include/arch/options.h -index c113a83..0e57951 100644 ---- a/kexec/arch/i386/include/arch/options.h -+++ b/kexec/arch/i386/include/arch/options.h -@@ -32,6 +32,7 @@ - #define OPT_ENTRY_32BIT (OPT_ARCH_MAX+10) - #define OPT_PASS_MEMMAP_CMDLINE (OPT_ARCH_MAX+11) - #define OPT_NOEFI (OPT_ARCH_MAX+12) -+#define OPT_REUSE_VIDEO_TYPE (OPT_ARCH_MAX+13) - - /* Options relevant to the architecture (excluding loader-specific ones): */ - #define KEXEC_ARCH_OPTIONS \ -@@ -45,6 +46,7 @@ - { "elf64-core-headers", 0, 0, OPT_ELF64_CORE }, \ - { "pass-memmap-cmdline", 0, 0, OPT_PASS_MEMMAP_CMDLINE }, \ - { "noefi", 0, 0, OPT_NOEFI}, \ -+ { "reuse-video-type", 0, 0, OPT_REUSE_VIDEO_TYPE }, \ - - #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR "" - -diff --git a/kexec/arch/i386/kexec-x86.h b/kexec/arch/i386/kexec-x86.h -index 51855f8..c2bcd37 100644 ---- a/kexec/arch/i386/kexec-x86.h -+++ b/kexec/arch/i386/kexec-x86.h -@@ -52,6 +52,7 @@ struct arch_options_t { - enum coretype core_header_type; - uint8_t pass_memmap_cmdline; - uint8_t noefi; -+ uint8_t reuse_video_type; - }; - - int multiboot_x86_probe(const char *buf, off_t len); -diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c -index 1bd408b..8fad115 100644 ---- a/kexec/arch/i386/x86-linux-setup.c -+++ b/kexec/arch/i386/x86-linux-setup.c -@@ -144,7 +144,7 @@ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode) - } else if (0 == strcmp(fix.id, "EFI VGA")) { - /* VIDEO_TYPE_EFI */ - real_mode->orig_video_isVGA = 0x70; -- } else { -+ } else if (arch_options.reuse_video_type) { - int err; - off_t offset = offsetof(typeof(*real_mode), orig_video_isVGA); - -@@ -152,6 +152,10 @@ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode) - err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1); - if (err) - goto out; -+ } else { -+ real_mode->orig_video_isVGA = 0; -+ close(fd); -+ return 0; - } - close(fd); - -@@ -844,7 +848,7 @@ void setup_linux_system_parameters(struct kexec_info *info, - setup_subarch(real_mode); - if (bzImage_support_efi_boot && !arch_options.noefi) - setup_efi_info(info, real_mode); -- -+ - /* Default screen size */ - real_mode->orig_x = 0; - real_mode->orig_y = 0; -diff --git a/kexec/arch/x86_64/kexec-x86_64.c b/kexec/arch/x86_64/kexec-x86_64.c -index 041b007..ccdc980 100644 ---- a/kexec/arch/x86_64/kexec-x86_64.c -+++ b/kexec/arch/x86_64/kexec-x86_64.c -@@ -55,6 +55,7 @@ void arch_usage(void) - " --console-serial Enable the serial console\n" - " --pass-memmap-cmdline Pass memory map via command line in kexec on panic case\n" - " --noefi Disable efi support\n" -+ " --reuse-video-type Reuse old boot time video type blindly\n" - ); - } - -@@ -67,6 +68,7 @@ struct arch_options_t arch_options = { - .core_header_type = CORE_TYPE_ELF64, - .pass_memmap_cmdline = 0, - .noefi = 0, -+ .reuse_video_type = 0, - }; - - int arch_process_options(int argc, char **argv) -@@ -136,6 +138,9 @@ int arch_process_options(int argc, char **argv) - case OPT_NOEFI: - arch_options.noefi = 1; - break; -+ case OPT_REUSE_VIDEO_TYPE: -+ arch_options.reuse_video_type = 1; -+ break; - } - } - /* Reset getopt for the next pass; called in other source modules */ --- -2.20.1 - diff --git a/SOURCES/kexec-tools-2.0.20-Cleanup-move-it-back-from-util_lib-elf_info.c.patch b/SOURCES/kexec-tools-2.0.20-Cleanup-move-it-back-from-util_lib-elf_info.c.patch new file mode 100644 index 0000000..b8759ee --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-Cleanup-move-it-back-from-util_lib-elf_info.c.patch @@ -0,0 +1,181 @@ +From a7c4cb8e998571cb3dd62e907935a1e052b15d6c Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Fri, 23 Aug 2019 20:05:38 +0800 +Subject: [PATCH 3/5] Cleanup: move it back from util_lib/elf_info.c + +Some code related to vmcore-dmesg.c is put into the util_lib, which +is not very reasonable, so lets move it back and tidy up those code. + +In addition, that will also help to limit the size of vmcore-dmesg.txt +in vmcore-dmesg.c instead of elf_info.c. + +Signed-off-by: Lianbo Jiang +Signed-off-by: Simon Horman +--- + util_lib/elf_info.c | 48 +++++++++---------------------------- + util_lib/include/elf_info.h | 2 +- + vmcore-dmesg/vmcore-dmesg.c | 30 ++++++++++++++++++++++- + 3 files changed, 41 insertions(+), 39 deletions(-) + +diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c +index 5d0efaafab53..2bce5cb1713c 100644 +--- a/util_lib/elf_info.c ++++ b/util_lib/elf_info.c +@@ -531,19 +531,7 @@ static int32_t read_file_s32(int fd, uint64_t addr) + return read_file_u32(fd, addr); + } + +-static void write_to_stdout(char *buf, unsigned int nr) +-{ +- ssize_t ret; +- +- ret = write(STDOUT_FILENO, buf, nr); +- if (ret != nr) { +- fprintf(stderr, "Failed to write out the dmesg log buffer!:" +- " %s\n", strerror(errno)); +- exit(54); +- } +-} +- +-static void dump_dmesg_legacy(int fd) ++static void dump_dmesg_legacy(int fd, void (*handler)(char*, unsigned int)) + { + uint64_t log_buf, log_buf_offset; + unsigned log_end, logged_chars, log_end_wrapped; +@@ -604,7 +592,8 @@ static void dump_dmesg_legacy(int fd) + */ + logged_chars = log_end < log_buf_len ? log_end : log_buf_len; + +- write_to_stdout(buf + (log_buf_len - logged_chars), logged_chars); ++ if (handler) ++ handler(buf + (log_buf_len - logged_chars), logged_chars); + } + + static inline uint16_t struct_val_u16(char *ptr, unsigned int offset) +@@ -623,7 +612,7 @@ static inline uint64_t struct_val_u64(char *ptr, unsigned int offset) + } + + /* Read headers of log records and dump accordingly */ +-static void dump_dmesg_structured(int fd) ++static void dump_dmesg_structured(int fd, void (*handler)(char*, unsigned int)) + { + #define OUT_BUF_SIZE 4096 + uint64_t log_buf, log_buf_offset, ts_nsec; +@@ -733,7 +722,8 @@ static void dump_dmesg_structured(int fd) + out_buf[len++] = c; + + if (len >= OUT_BUF_SIZE - 64) { +- write_to_stdout(out_buf, len); ++ if (handler) ++ handler(out_buf, len); + len = 0; + } + } +@@ -752,16 +742,16 @@ static void dump_dmesg_structured(int fd) + current_idx += loglen; + } + free(buf); +- if (len) +- write_to_stdout(out_buf, len); ++ if (len && handler) ++ handler(out_buf, len); + } + +-static void dump_dmesg(int fd) ++void dump_dmesg(int fd, void (*handler)(char*, unsigned int)) + { + if (log_first_idx_vaddr) +- dump_dmesg_structured(fd); ++ dump_dmesg_structured(fd, handler); + else +- dump_dmesg_legacy(fd); ++ dump_dmesg_legacy(fd, handler); + } + + int read_elf(int fd) +@@ -808,22 +798,6 @@ int read_elf(int fd) + return 0; + } + +-int read_elf_vmcore(int fd) +-{ +- int ret; +- +- ret = read_elf(fd); +- if (ret > 0) { +- fprintf(stderr, "Unable to read ELF information" +- " from vmcore\n"); +- return ret; +- } +- +- dump_dmesg(fd); +- +- return 0; +-} +- + int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off) + { + int ret; +diff --git a/util_lib/include/elf_info.h b/util_lib/include/elf_info.h +index c328a1b0ecf2..4bc9279ba603 100644 +--- a/util_lib/include/elf_info.h ++++ b/util_lib/include/elf_info.h +@@ -30,6 +30,6 @@ int get_pt_load(int idx, + unsigned long long *virt_end); + int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off); + int read_elf(int fd); +-int read_elf_vmcore(int fd); ++void dump_dmesg(int fd, void (*handler)(char*, unsigned int)); + + #endif /* ELF_INFO_H */ +diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c +index bebc348a657e..fe7df8ec372c 100644 +--- a/vmcore-dmesg/vmcore-dmesg.c ++++ b/vmcore-dmesg/vmcore-dmesg.c +@@ -5,6 +5,34 @@ typedef Elf32_Nhdr Elf_Nhdr; + + extern const char *fname; + ++static void write_to_stdout(char *buf, unsigned int nr) ++{ ++ ssize_t ret; ++ ++ ret = write(STDOUT_FILENO, buf, nr); ++ if (ret != nr) { ++ fprintf(stderr, "Failed to write out the dmesg log buffer!:" ++ " %s\n", strerror(errno)); ++ exit(54); ++ } ++} ++ ++static int read_vmcore_dmesg(int fd, void (*handler)(char*, unsigned int)) ++{ ++ int ret; ++ ++ ret = read_elf(fd); ++ if (ret > 0) { ++ fprintf(stderr, "Unable to read ELF information" ++ " from vmcore\n"); ++ return ret; ++ } ++ ++ dump_dmesg(fd, handler); ++ ++ return 0; ++} ++ + int main(int argc, char **argv) + { + ssize_t ret; +@@ -23,7 +51,7 @@ int main(int argc, char **argv) + return 2; + } + +- ret = read_elf_vmcore(fd); ++ ret = read_vmcore_dmesg(fd, write_to_stdout); + + close(fd); + +-- +2.17.1 + diff --git a/SOURCES/kexec-tools-2.0.20-Cleanup-remove-the-read_elf_kcore.patch b/SOURCES/kexec-tools-2.0.20-Cleanup-remove-the-read_elf_kcore.patch new file mode 100644 index 0000000..f47b8f6 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-Cleanup-remove-the-read_elf_kcore.patch @@ -0,0 +1,84 @@ +From 545c811050a375f79e0fa0e107cb35b9ae3a1599 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Fri, 23 Aug 2019 20:05:36 +0800 +Subject: [PATCH 1/5] Cleanup: remove the read_elf_kcore() + +Here, no need to wrap the read_elf() again, lets invoke it directly. +So remove the read_elf_kcore() and clean up redundant code. + +Signed-off-by: Lianbo Jiang +Signed-off-by: Simon Horman +--- + kexec/arch/arm64/kexec-arm64.c | 2 +- + util_lib/elf_info.c | 15 ++------------- + util_lib/include/elf_info.h | 2 +- + 3 files changed, 4 insertions(+), 15 deletions(-) + +diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c +index eb3a3a37307c..6ad3b0a134b3 100644 +--- a/kexec/arch/arm64/kexec-arm64.c ++++ b/kexec/arch/arm64/kexec-arm64.c +@@ -889,7 +889,7 @@ int get_phys_base_from_pt_load(unsigned long *phys_offset) + return EFAILED; + } + +- read_elf_kcore(fd); ++ read_elf(fd); + + for (i = 0; get_pt_load(i, + &phys_start, NULL, &virt_start, NULL); +diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c +index 90a3b21662e7..d9397ecd8626 100644 +--- a/util_lib/elf_info.c ++++ b/util_lib/elf_info.c +@@ -764,7 +764,7 @@ static void dump_dmesg(int fd) + dump_dmesg_legacy(fd); + } + +-static int read_elf(int fd) ++int read_elf(int fd) + { + int ret; + +@@ -824,24 +824,13 @@ int read_elf_vmcore(int fd) + return 0; + } + +-int read_elf_kcore(int fd) +-{ +- int ret; +- +- ret = read_elf(fd); +- if (ret != 0) +- return ret; +- +- return 0; +-} +- + int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off) + { + int ret; + + *phys_off = UINT64_MAX; + +- ret = read_elf_kcore(fd); ++ ret = read_elf(fd); + if (!ret) { + /* If we have a valid 'PHYS_OFFSET' by now, + * return it to the caller now. +diff --git a/util_lib/include/elf_info.h b/util_lib/include/elf_info.h +index 1a4debd2d4ba..c328a1b0ecf2 100644 +--- a/util_lib/include/elf_info.h ++++ b/util_lib/include/elf_info.h +@@ -29,7 +29,7 @@ int get_pt_load(int idx, + unsigned long long *virt_start, + unsigned long long *virt_end); + int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off); +-int read_elf_kcore(int fd); ++int read_elf(int fd); + int read_elf_vmcore(int fd); + + #endif /* ELF_INFO_H */ +-- +2.17.1 + diff --git a/SOURCES/kexec-tools-2.0.20-Fix-an-error-definition-about-the-variable-fname.patch b/SOURCES/kexec-tools-2.0.20-Fix-an-error-definition-about-the-variable-fname.patch new file mode 100644 index 0000000..d68b211 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-Fix-an-error-definition-about-the-variable-fname.patch @@ -0,0 +1,47 @@ +From 14ad054e7baa788a6629385ffe5e0f1996b7de02 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Fri, 23 Aug 2019 20:05:37 +0800 +Subject: [PATCH 2/5] Fix an error definition about the variable 'fname' + +The variable 'fname' is mistakenly defined two twice, the first definition +is in the vmcore-dmesg.c, and the second definition is in the elf_info.c. +That is confused and incorrect although it's a static type, because the +value of variable 'fname' is not assigned(set) in elf_info.c. Anyway, its +value will be always 'null' when printing an error information. + +Signed-off-by: Lianbo Jiang +Signed-off-by: Simon Horman +--- + util_lib/elf_info.c | 2 +- + vmcore-dmesg/vmcore-dmesg.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c +index d9397ecd8626..5d0efaafab53 100644 +--- a/util_lib/elf_info.c ++++ b/util_lib/elf_info.c +@@ -20,7 +20,7 @@ + /* The 32bit and 64bit note headers make it clear we don't care */ + typedef Elf32_Nhdr Elf_Nhdr; + +-static const char *fname; ++const char *fname; + static Elf64_Ehdr ehdr; + static Elf64_Phdr *phdr; + static int num_pt_loads; +diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c +index 7a386b380291..bebc348a657e 100644 +--- a/vmcore-dmesg/vmcore-dmesg.c ++++ b/vmcore-dmesg/vmcore-dmesg.c +@@ -3,7 +3,7 @@ + /* The 32bit and 64bit note headers make it clear we don't care */ + typedef Elf32_Nhdr Elf_Nhdr; + +-static const char *fname; ++extern const char *fname; + + int main(int argc, char **argv) + { +-- +2.17.1 + diff --git a/SOURCES/kexec-tools-2.0.20-Limit-the-size-of-vmcore-dmesg.txt-to-2G.patch b/SOURCES/kexec-tools-2.0.20-Limit-the-size-of-vmcore-dmesg.txt-to-2G.patch new file mode 100644 index 0000000..0146da0 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-Limit-the-size-of-vmcore-dmesg.txt-to-2G.patch @@ -0,0 +1,55 @@ +From fa3f0ed47f3e6dbee485722d13713ad495571b7e Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Fri, 23 Aug 2019 20:05:39 +0800 +Subject: [PATCH 4/5] Limit the size of vmcore-dmesg.txt to 2G + +With some corrupted vmcore files, the vmcore-dmesg.txt file may grow +forever till the kdump disk becomes full, and also probably causes +the disk error messages as follow: +... +sd 0:0:0:0: [sda] tag#6 FAILED Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK +sd 0:0:0:0: [sda] tag#6 CDB: Read(10) 28 00 08 06 4c 98 00 00 08 00 +blk_update_request: I/O error, dev sda, sector 134630552 +sd 0:0:0:0: [sda] tag#7 FAILED Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK +sd 0:0:0:0: [sda] tag#7 CDB: Read(10) 28 00 08 06 4c 98 00 00 08 00 +blk_update_request: I/O error, dev sda, sector 134630552 +... + +If vmcore-dmesg.txt occupies the whole disk, the vmcore can not be +saved, this is also a problem. + +Lets limit the size of vmcore-dmesg.txt to avoid such problems. + +Signed-off-by: Lianbo Jiang +Signed-off-by: Simon Horman +--- + vmcore-dmesg/vmcore-dmesg.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c +index fe7df8ec372c..81c2a58c9d86 100644 +--- a/vmcore-dmesg/vmcore-dmesg.c ++++ b/vmcore-dmesg/vmcore-dmesg.c +@@ -5,9 +5,19 @@ typedef Elf32_Nhdr Elf_Nhdr; + + extern const char *fname; + ++/* stole this macro from kernel printk.c */ ++#define LOG_BUF_LEN_MAX (uint32_t)(1 << 31) ++ + static void write_to_stdout(char *buf, unsigned int nr) + { + ssize_t ret; ++ static uint32_t n_bytes = 0; ++ ++ n_bytes += nr; ++ if (n_bytes > LOG_BUF_LEN_MAX) { ++ fprintf(stderr, "The vmcore-dmesg.txt over 2G in size is not supported.\n"); ++ exit(53); ++ } + + ret = write(STDOUT_FILENO, buf, nr); + if (ret != nr) { +-- +2.17.1 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Fix-off-by-one-issue-in-exclude_nodata_pages.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Fix-off-by-one-issue-in-exclude_nodata_pages.patch new file mode 100644 index 0000000..454b3a3 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-Fix-off-by-one-issue-in-exclude_nodata_pages.patch @@ -0,0 +1,42 @@ +From 56511628fa6714b189509b2842eadce0842bfeb5 Mon Sep 17 00:00:00 2001 +From: Mikhail Zaslonko +Date: Mon, 4 Nov 2019 14:05:15 +0100 +Subject: [PATCH] [PATCH] Fix off-by-one issue in exclude_nodata_pages() + +When building a dump bitmap (2nd bitmap) for the ELF dump, the last pfn +of the cycle is always ignored in exclude_nodata_pages() function due to +off-by-one error on cycle boundary check. Thus, the respective bit of +the bitmap is never cleared. + +That can lead to the error when such a pfn should not be dumpable (e.g. +the last pfn of the ELF-load of zero filesize). Based on the bit in the +bitmap the page is treated as dumpable in write_elf_pages_cyclic() function +and the follow on error is triggered in write_elf_load_segment() function +due to the failing sanity check of paddr_to_offset2(): + + $ makedumpfile -E dump.elf dump.elf.E + Checking for memory holes : [100.0 %] | + write_elf_load_segment: Can't convert physaddr(7ffff000) to an offset. + makedumpfile Failed. + +Signed-off-by: Mikhail Zaslonko +--- + makedumpfile.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c +index de0973f9e763..4a000112ba59 100644 +--- a/makedumpfile-1.6.6/makedumpfile.c ++++ b/makedumpfile-1.6.6/makedumpfile.c +@@ -4740,7 +4740,7 @@ exclude_nodata_pages(struct cycle *cycle) + if (pfn < cycle->start_pfn) + pfn = cycle->start_pfn; + if (pfn_end >= cycle->end_pfn) +- pfn_end = cycle->end_pfn - 1; ++ pfn_end = cycle->end_pfn; + while (pfn < pfn_end) { + clear_bit_on_2nd_bitmap(pfn, cycle); + ++pfn; +-- +2.17.1 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Generalize-get_kaslr_offset_arm64-for-other-ar.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Generalize-get_kaslr_offset_arm64-for-other-ar.patch new file mode 100644 index 0000000..3fc9d83 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-Generalize-get_kaslr_offset_arm64-for-other-ar.patch @@ -0,0 +1,219 @@ +From c6992684b51ba9604d50016f36c9139bf54ae03b Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Tue, 17 Dec 2019 11:12:50 -0500 +Subject: [PATCH 1/3] [PATCH] Generalize get_kaslr_offset_arm64() for other + architectures + +Generalize the get_kaslr_offset_arm64() and rename it to +get_kaslr_offset_general() for use by other architectures +supporting KASLR. + +Also, modify the confusing comment in the function and its +x86_64 version. + +Signed-off-by: Kazuhito Hagio +--- + arch/arm64.c | 61 -------------------------------------------------- + arch/x86_64.c | 8 +++---- + makedumpfile.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ + makedumpfile.h | 4 ++-- + 4 files changed, 66 insertions(+), 67 deletions(-) + +diff --git a/makedumpfile-1.6.6/arch/arm64.c b/makedumpfile-1.6.6/arch/arm64.c +index 3516b340adfd..43164ccc32d4 100644 +--- a/makedumpfile-1.6.6/arch/arm64.c ++++ b/makedumpfile-1.6.6/arch/arm64.c +@@ -205,67 +205,6 @@ get_phys_base_arm64(void) + return FALSE; + } + +-unsigned long +-get_kaslr_offset_arm64(unsigned long vaddr) +-{ +- unsigned int i; +- char buf[BUFSIZE_FGETS], *endp; +- static unsigned long _text = NOT_FOUND_SYMBOL; +- static unsigned long _end = NOT_FOUND_SYMBOL; +- +- if (!info->kaslr_offset && info->file_vmcoreinfo) { +- if (fseek(info->file_vmcoreinfo, 0, SEEK_SET) < 0) { +- ERRMSG("Can't seek the vmcoreinfo file(%s). %s\n", +- info->name_vmcoreinfo, strerror(errno)); +- return FALSE; +- } +- +- while (fgets(buf, BUFSIZE_FGETS, info->file_vmcoreinfo)) { +- i = strlen(buf); +- if (!i) +- break; +- if (buf[i - 1] == '\n') +- buf[i - 1] = '\0'; +- if (strncmp(buf, STR_KERNELOFFSET, +- strlen(STR_KERNELOFFSET)) == 0) { +- info->kaslr_offset = +- strtoul(buf+strlen(STR_KERNELOFFSET),&endp,16); +- DEBUG_MSG("info->kaslr_offset: %lx\n", info->kaslr_offset); +- } +- } +- } +- if (!info->kaslr_offset) +- return 0; +- +- if (_text == NOT_FOUND_SYMBOL) { +- /* +- * Currently, the return value of this function is used in +- * resolve_config_entry() only, and in that case, we must +- * have a vmlinux. +- */ +- if (info->name_vmlinux) { +- _text = get_symbol_addr("_text"); +- _end = get_symbol_addr("_end"); +- } +- DEBUG_MSG("_text: %lx, _end: %lx\n", _text, _end); +- if (_text == NOT_FOUND_SYMBOL || _end == NOT_FOUND_SYMBOL) { +- ERRMSG("Cannot determine _text and _end address\n"); +- return FALSE; +- } +- } +- +- if (_text <= vaddr && vaddr <= _end) { +- DEBUG_MSG("info->kaslr_offset: %lx\n", info->kaslr_offset); +- return info->kaslr_offset; +- } else { +- /* +- * TODO: we need to check if it is vmalloc/vmmemmap/module +- * address, we will have different offset +- */ +- return 0; +- } +-} +- + ulong + get_stext_symbol(void) + { +diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c +index 876644f932be..7a2c05c36809 100644 +--- a/makedumpfile-1.6.6/arch/x86_64.c ++++ b/makedumpfile-1.6.6/arch/x86_64.c +@@ -77,14 +77,14 @@ get_kaslr_offset_x86_64(unsigned long vaddr) + else + kernel_image_size = KERNEL_IMAGE_SIZE_KASLR_ORIG; + ++ /* ++ * Returns the kaslr offset only if the vaddr needs it to be added, ++ * i.e. only kernel text address for now. Otherwise returns 0. ++ */ + if (vaddr >= __START_KERNEL_map && + vaddr < __START_KERNEL_map + kernel_image_size) + return info->kaslr_offset; + else +- /* +- * TODO: we need to check if it is vmalloc/vmmemmap/module +- * address, we will have different offset +- */ + return 0; + } + +diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c +index 7586d7c001d4..332b804cd756 100644 +--- a/makedumpfile-1.6.6/makedumpfile.c ++++ b/makedumpfile-1.6.6/makedumpfile.c +@@ -3945,6 +3945,66 @@ free_for_parallel() + } + } + ++unsigned long ++get_kaslr_offset_general(unsigned long vaddr) ++{ ++ unsigned int i; ++ char buf[BUFSIZE_FGETS], *endp; ++ static unsigned long _text = NOT_FOUND_SYMBOL; ++ static unsigned long _end = NOT_FOUND_SYMBOL; ++ ++ if (!info->kaslr_offset && info->file_vmcoreinfo) { ++ if (fseek(info->file_vmcoreinfo, 0, SEEK_SET) < 0) { ++ ERRMSG("Can't seek the vmcoreinfo file(%s). %s\n", ++ info->name_vmcoreinfo, strerror(errno)); ++ return FALSE; ++ } ++ ++ while (fgets(buf, BUFSIZE_FGETS, info->file_vmcoreinfo)) { ++ i = strlen(buf); ++ if (!i) ++ break; ++ if (buf[i - 1] == '\n') ++ buf[i - 1] = '\0'; ++ if (strncmp(buf, STR_KERNELOFFSET, ++ strlen(STR_KERNELOFFSET)) == 0) { ++ info->kaslr_offset = strtoul(buf + ++ strlen(STR_KERNELOFFSET), &endp, 16); ++ DEBUG_MSG("info->kaslr_offset: %lx\n", ++ info->kaslr_offset); ++ } ++ } ++ } ++ if (!info->kaslr_offset) ++ return 0; ++ ++ if (_text == NOT_FOUND_SYMBOL) { ++ /* ++ * Currently, the return value of this function is used in ++ * resolve_config_entry() only, and in that case, we must ++ * have a vmlinux. ++ */ ++ if (info->name_vmlinux) { ++ _text = get_symbol_addr("_text"); ++ _end = get_symbol_addr("_end"); ++ } ++ DEBUG_MSG("_text: %lx, _end: %lx\n", _text, _end); ++ if (_text == NOT_FOUND_SYMBOL || _end == NOT_FOUND_SYMBOL) { ++ ERRMSG("Cannot determine _text and _end address\n"); ++ return FALSE; ++ } ++ } ++ ++ /* ++ * Returns the kaslr offset only if the vaddr needs it to be added, ++ * i.e. only kernel text address for now. Otherwise returns 0. ++ */ ++ if (_text <= vaddr && vaddr <= _end) ++ return info->kaslr_offset; ++ else ++ return 0; ++} ++ + int + find_kaslr_offsets() + { +diff --git a/makedumpfile-1.6.6/makedumpfile.h b/makedumpfile-1.6.6/makedumpfile.h +index ac11e906b5b7..067fa483aa01 100644 +--- a/makedumpfile-1.6.6/makedumpfile.h ++++ b/makedumpfile-1.6.6/makedumpfile.h +@@ -964,6 +964,7 @@ typedef unsigned long pgd_t; + static inline int stub_true() { return TRUE; } + static inline int stub_true_ul(unsigned long x) { return TRUE; } + static inline int stub_false() { return FALSE; } ++unsigned long get_kaslr_offset_general(unsigned long vaddr); + #define paddr_to_vaddr_general(X) ((X) + PAGE_OFFSET) + + #ifdef __aarch64__ +@@ -973,7 +974,6 @@ unsigned long long vaddr_to_paddr_arm64(unsigned long vaddr); + int get_versiondep_info_arm64(void); + int get_xen_basic_info_arm64(void); + int get_xen_info_arm64(void); +-unsigned long get_kaslr_offset_arm64(unsigned long vaddr); + #define paddr_to_vaddr_arm64(X) (((X) - info->phys_base) | PAGE_OFFSET) + + #define find_vmemmap() stub_false() +@@ -982,7 +982,7 @@ unsigned long get_kaslr_offset_arm64(unsigned long vaddr); + #define get_phys_base() get_phys_base_arm64() + #define get_machdep_info() get_machdep_info_arm64() + #define get_versiondep_info() get_versiondep_info_arm64() +-#define get_kaslr_offset(X) get_kaslr_offset_arm64(X) ++#define get_kaslr_offset(X) get_kaslr_offset_general(X) + #define get_xen_basic_info_arch(X) get_xen_basic_info_arm64(X) + #define get_xen_info_arch(X) get_xen_info_arm64(X) + #define is_phys_addr(X) stub_true_ul(X) +-- +2.17.1 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch new file mode 100644 index 0000000..b9c5eff --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch @@ -0,0 +1,38 @@ +From 7bdb468c2c99dd780c9a5321f93c79cbfdce2527 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Tue, 23 Jul 2019 12:24:47 -0400 +Subject: [PATCH] [PATCH] Increase SECTION_MAP_LAST_BIT to 4 + +kernel commit 326e1b8f83a4 ("mm/sparsemem: introduce a SECTION_IS_EARLY +flag") added the flag to mem_section->section_mem_map value, and it caused +makedumpfile an error like the following: + + readmem: Can't convert a virtual address(fffffc97d1000000) to physical address. + readmem: type_addr: 0, addr:fffffc97d1000000, size:32768 + __exclude_unnecessary_pages: Can't read the buffer of struct page. + create_2nd_bitmap: Can't exclude unnecessary pages. + +To fix this, SECTION_MAP_LAST_BIT needs to be updated. The bit has not +been used until the addition, so we can just increase the value. + +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.6/makedumpfile.h b/makedumpfile-1.6.6/makedumpfile.h +index 24b2f69f400c..df745b9f53e5 100644 +--- a/makedumpfile-1.6.6/makedumpfile.h ++++ b/makedumpfile-1.6.6/makedumpfile.h +@@ -195,7 +195,7 @@ isAnon(unsigned long mapping) + * 2. it has been verified that (1UL<<2) was never set, so it is + * safe to mask that bit off even in old kernels. + */ +-#define SECTION_MAP_LAST_BIT (1UL<<3) ++#define SECTION_MAP_LAST_BIT (1UL<<4) + #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) + #define NR_SECTION_ROOTS() divideup(num_section, SECTIONS_PER_ROOT()) + #define SECTION_NR_TO_PFN(sec) ((sec) << PFN_SECTION_SHIFT()) +-- +2.17.2 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Pass-0-to-get_kaslr_offset-in-find_kaslr_offse.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Pass-0-to-get_kaslr_offset-in-find_kaslr_offse.patch new file mode 100644 index 0000000..3db1f56 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-Pass-0-to-get_kaslr_offset-in-find_kaslr_offse.patch @@ -0,0 +1,65 @@ +From 60cf280ebfe8b6468bfd1dd592a117e719c56ccf Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Fri, 3 Jan 2020 11:27:41 -0500 +Subject: [PATCH 2/3] [PATCH] Pass 0 to get_kaslr_offset() in + find_kaslr_offsets() + +Currently SYMBOL(_stext) is passed to get_kaslr_offset() in +find_kaslr_offsets(), but it is always zero, because it has not +been set yet at the time. + +On the other hand, the vaddr argument of get_kaslr_offset() is +only used to decide whether to return a KASLR offset or not, but +the return value is not used in find_kaslr_offsets(). + +Therefore, passing SYMBOL(_stext) is meaningless and confusing, +so let's pass it 0 explicitly to avoid confusion. + +Reported-by: Lianbo Jiang +Signed-off-by: Kazuhito Hagio +--- + arch/x86_64.c | 2 +- + makedumpfile.c | 6 ++++-- + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c +index 7a2c05c36809..b5e295452964 100644 +--- a/makedumpfile-1.6.6/arch/x86_64.c ++++ b/makedumpfile-1.6.6/arch/x86_64.c +@@ -69,7 +69,7 @@ get_kaslr_offset_x86_64(unsigned long vaddr) + strtoul(buf+strlen(STR_KERNELOFFSET),&endp,16); + } + } +- if (!info->kaslr_offset) ++ if (!info->kaslr_offset || !vaddr) + return 0; + + if (NUMBER(KERNEL_IMAGE_SIZE) != NOT_FOUND_NUMBER) +diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c +index 332b804cd756..e290fbdb4f9f 100644 +--- a/makedumpfile-1.6.6/makedumpfile.c ++++ b/makedumpfile-1.6.6/makedumpfile.c +@@ -3975,7 +3975,7 @@ get_kaslr_offset_general(unsigned long vaddr) + } + } + } +- if (!info->kaslr_offset) ++ if (!info->kaslr_offset || !vaddr) + return 0; + + if (_text == NOT_FOUND_SYMBOL) { +@@ -4032,8 +4032,10 @@ find_kaslr_offsets() + * function might need to read from vmcoreinfo, therefore we have + * called this function between open_vmcoreinfo() and + * close_vmcoreinfo() ++ * And the argument is not needed, because we don't use the return ++ * value here. So pass it 0 explicitly. + */ +- get_kaslr_offset(SYMBOL(_stext)); ++ get_kaslr_offset(0); + + close_vmcoreinfo(); + +-- +2.17.1 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-arm64-fix-get_kaslr_offset_arm64-to-return-kas.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-arm64-fix-get_kaslr_offset_arm64-to-return-kas.patch new file mode 100644 index 0000000..368996e --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-arm64-fix-get_kaslr_offset_arm64-to-return-kas.patch @@ -0,0 +1,85 @@ +From 76f9cc0f3de2f4727a1f838ce9f10d848b92e1a4 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Tue, 4 Jun 2019 15:00:15 -0400 +Subject: [PATCH] [PATCH] arm64: fix get_kaslr_offset_arm64() to return + kaslr_offset correctly + +Currently, the get_kaslr_offset_arm64() function has the following +condition to return info->kaslr_offset, but kernel text mapping is +placed in another range on arm64 by default, so it returns 0 for +kernel text addresses. + + if (vaddr >= __START_KERNEL_map && + vaddr < __START_KERNEL_map + info->kaslr_offset) + +Consequently, kernel text symbols in erase config are resolved wrongly +with KASLR enabled vmcore, and makedumpfile erases unintended data. + +Since the return value of get_kaslr_offset_arm64() is used in +resolve_config_entry() only, and in that case, we must have a vmlinux, +so get the addresses of _text and _end from vmlinux and use them. + +Signed-off-by: Kazuhito Hagio +--- + arch/arm64.c | 24 ++++++++++++++++++++++-- + makedumpfile.h | 1 - + 2 files changed, 22 insertions(+), 3 deletions(-) + +diff --git a/makedumpfile-1.6.6/arch/arm64.c b/makedumpfile-1.6.6/arch/arm64.c +index 053519359cbc..3516b340adfd 100644 +--- a/makedumpfile-1.6.6/arch/arm64.c ++++ b/makedumpfile-1.6.6/arch/arm64.c +@@ -210,6 +210,8 @@ get_kaslr_offset_arm64(unsigned long vaddr) + { + unsigned int i; + char buf[BUFSIZE_FGETS], *endp; ++ static unsigned long _text = NOT_FOUND_SYMBOL; ++ static unsigned long _end = NOT_FOUND_SYMBOL; + + if (!info->kaslr_offset && info->file_vmcoreinfo) { + if (fseek(info->file_vmcoreinfo, 0, SEEK_SET) < 0) { +@@ -232,9 +234,27 @@ get_kaslr_offset_arm64(unsigned long vaddr) + } + } + } ++ if (!info->kaslr_offset) ++ return 0; ++ ++ if (_text == NOT_FOUND_SYMBOL) { ++ /* ++ * Currently, the return value of this function is used in ++ * resolve_config_entry() only, and in that case, we must ++ * have a vmlinux. ++ */ ++ if (info->name_vmlinux) { ++ _text = get_symbol_addr("_text"); ++ _end = get_symbol_addr("_end"); ++ } ++ DEBUG_MSG("_text: %lx, _end: %lx\n", _text, _end); ++ if (_text == NOT_FOUND_SYMBOL || _end == NOT_FOUND_SYMBOL) { ++ ERRMSG("Cannot determine _text and _end address\n"); ++ return FALSE; ++ } ++ } + +- if (vaddr >= __START_KERNEL_map && +- vaddr < __START_KERNEL_map + info->kaslr_offset) { ++ if (_text <= vaddr && vaddr <= _end) { + DEBUG_MSG("info->kaslr_offset: %lx\n", info->kaslr_offset); + return info->kaslr_offset; + } else { +diff --git a/makedumpfile-1.6.6/makedumpfile.h b/makedumpfile-1.6.6/makedumpfile.h +index df745b9f53e5..ac11e906b5b7 100644 +--- a/makedumpfile-1.6.6/makedumpfile.h ++++ b/makedumpfile-1.6.6/makedumpfile.h +@@ -542,7 +542,6 @@ do { \ + #ifdef __aarch64__ + unsigned long get_kvbase_arm64(void); + #define KVBASE get_kvbase_arm64() +-#define __START_KERNEL_map (0xffffffff80000000UL) + + #endif /* aarch64 */ + +-- +2.17.1 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-assign-bitmap1-2-fd-for-subprocess-in-non-cycl.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-assign-bitmap1-2-fd-for-subprocess-in-non-cycl.patch new file mode 100644 index 0000000..7f347cc --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-assign-bitmap1-2-fd-for-subprocess-in-non-cycl.patch @@ -0,0 +1,44 @@ +From 5519b3eba68544dc484d85e9540d440d93f8c924 Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Tue, 3 Dec 2019 15:37:07 +0800 +Subject: [PATCH] [PATCH] assign bitmap1/2 fd for subprocess in non-cyclic mode + +In non-cyclic mode with the --split option, each subprocess inherits +bitmap1/2->fd from parent. Then they lseek()/read() on the same fd, +which means that they interfere with each other. + +This breaks the purpose of SPLITTING_FD_BITMAP(i) for each subprocess. +Without this patch, makedumpfile can fail with error like the following +in refiltering, or can break the dumpfile silently by excluding pages +wrongly. + + readpage_kdump_compressed: pfn(2fc1000) is excluded from vmcore. + readmem: type_addr: 1, addr:2fc1000000, size:4096 + read_pfn: Can't get the page data. + +Fix it by assigning a subprocess dedicated fd to bitmap1/2->fd. + +Signed-off-by: Pingfan Liu +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c +index 43107d9..7586d7c 100644 +--- a/makedumpfile-1.6.6/makedumpfile.c ++++ b/makedumpfile-1.6.6/makedumpfile.c +@@ -10091,6 +10091,10 @@ writeout_multiple_dumpfiles(void) + info->split_start_pfn = SPLITTING_START_PFN(i); + info->split_end_pfn = SPLITTING_END_PFN(i); + ++ if (!info->flag_cyclic) { ++ info->bitmap1->fd = info->fd_bitmap; ++ info->bitmap2->fd = info->fd_bitmap; ++ } + if (!reopen_dump_memory()) + exit(1); + if ((status = writeout_dumpfile()) == FALSE) +-- +2.7.5 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-s390-Use-get_kaslr_offset_general-for-s390x.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-s390-Use-get_kaslr_offset_general-for-s390x.patch new file mode 100644 index 0000000..6958ee9 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-s390-Use-get_kaslr_offset_general-for-s390x.patch @@ -0,0 +1,30 @@ +From 577854dd62a6b22aa2c0dce59f0541ac1c0c7ab5 Mon Sep 17 00:00:00 2001 +From: Mikhail Zaslonko +Date: Tue, 7 Jan 2020 13:38:14 +0100 +Subject: [PATCH 3/3] [PATCH] s390: Use get_kaslr_offset_general() for s390x + +Since kernel v5.2 KASLR is supported on s390. Use recently introduced +get_kaslr_offset_general() for s390x in order to derive kaslr offset +from vmcoreinfo when -x makedumpfile option specified. + +Signed-off-by: Mikhail Zaslonko +--- + makedumpfile.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.6/makedumpfile.h b/makedumpfile-1.6.6/makedumpfile.h +index 067fa483aa01..e6c815da6775 100644 +--- a/makedumpfile-1.6.6/makedumpfile.h ++++ b/makedumpfile-1.6.6/makedumpfile.h +@@ -1075,7 +1075,7 @@ int is_iomem_phys_addr_s390x(unsigned long addr); + #define get_phys_base() stub_true() + #define get_machdep_info() get_machdep_info_s390x() + #define get_versiondep_info() stub_true() +-#define get_kaslr_offset(X) stub_false() ++#define get_kaslr_offset(X) get_kaslr_offset_general(X) + #define vaddr_to_paddr(X) vaddr_to_paddr_s390x(X) + #define paddr_to_vaddr(X) paddr_to_vaddr_general(X) + #define is_phys_addr(X) is_iomem_phys_addr_s390x(X) +-- +2.17.1 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option-wit.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option-wit.patch new file mode 100644 index 0000000..343c83d --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option-wit.patch @@ -0,0 +1,41 @@ +From aa5ab4cf6c7335392094577380d2eaee8a0a8d52 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Thu, 29 Aug 2019 12:26:34 -0400 +Subject: [PATCH] x86_64: Fix incorrect exclusion by -e option with KASLR + +The -e option uses info->vmemmap_start for creating a table to determine +the positions of page structures that should be excluded, but it is a +hardcoded value even with KASLR-enabled vmcore. As a result, the option +excludes incorrect pages from it. + +To fix this, get the vmemmap start address from info->mem_map_data. + +Signed-off-by: Kazuhito Hagio +--- + arch/x86_64.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c +index 3c0fdc5e72fb..4eeaf4925f43 100644 +--- a/makedumpfile-1.6.6/arch/x86_64.c ++++ b/makedumpfile-1.6.6/arch/x86_64.c +@@ -679,6 +679,16 @@ find_vmemmap_x86_64() + if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) + pmask &= ~(NUMBER(sme_mask)); + ++ /* ++ * vmemmap region can be randomized by KASLR. ++ * (currently we don't utilize info->vmemmap_end on x86_64.) ++ */ ++ if (info->mem_map_data && ++ info->mem_map_data[0].mem_map != NOT_MEMMAP_ADDR) ++ info->vmemmap_start = info->mem_map_data[0].mem_map; ++ ++ DEBUG_MSG("vmemmap_start: %16lx\n", info->vmemmap_start); ++ + pagestructsize = size_table.page; + hugepagesize = PTRS_PER_PMD * info->page_size; + vaddr_base = info->vmemmap_start; +-- +2.18.1 + diff --git a/SOURCES/kexec-tools-2.0.20-vmcore-dmesg-vmcore-dmesg.c-Fix-shifting-error-repor.patch b/SOURCES/kexec-tools-2.0.20-vmcore-dmesg-vmcore-dmesg.c-Fix-shifting-error-repor.patch new file mode 100644 index 0000000..e43b45a --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-vmcore-dmesg-vmcore-dmesg.c-Fix-shifting-error-repor.patch @@ -0,0 +1,38 @@ +From a46c686f615a86933134c0924c3391ba598a02b8 Mon Sep 17 00:00:00 2001 +From: Bhupesh Sharma +Date: Tue, 10 Sep 2019 15:51:49 +0530 +Subject: [PATCH 5/5] vmcore-dmesg/vmcore-dmesg.c: Fix shifting error reported + by cppcheck + +Running 'cppcheck' static code analyzer (see cppcheck(1)) + on 'vmcore-dmesg/vmcore-dmesg.c' shows the following +shifting error: + +$ cppcheck --enable=all vmcore-dmesg/vmcore-dmesg.c +Checking vmcore-dmesg/vmcore-dmesg.c ... +[vmcore-dmesg/vmcore-dmesg.c:17]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour + +Fix the same via this patch. + +Signed-off-by: Bhupesh Sharma +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 81c2a58c9d86..122e53672e01 100644 +--- a/vmcore-dmesg/vmcore-dmesg.c ++++ b/vmcore-dmesg/vmcore-dmesg.c +@@ -6,7 +6,7 @@ typedef Elf32_Nhdr Elf_Nhdr; + extern const char *fname; + + /* stole this macro from kernel printk.c */ +-#define LOG_BUF_LEN_MAX (uint32_t)(1 << 31) ++#define LOG_BUF_LEN_MAX (uint32_t)(1U << 31) + + static void write_to_stdout(char *buf, unsigned int nr) + { +-- +2.17.1 + diff --git a/SOURCES/mkdumprd b/SOURCES/mkdumprd index 3ea683c..cd1b592 100644 --- a/SOURCES/mkdumprd +++ b/SOURCES/mkdumprd @@ -426,10 +426,10 @@ do ssh) if strstr "$config_val" "@"; then - check_size ssh $config_val mkdir_save_path_ssh $config_val + check_size ssh $config_val add_dracut_module "ssh-client" - add_dracut_sshkey "$SSH_KEY_LOCATION" + add_dracut_sshkey "$SSH_KEY_LOCATION" else perror_exit "Bad ssh dump target $config_val" fi diff --git a/SOURCES/rhelonly-kexec-tools-2.0.16-koji-build-fail-workaround.patch b/SOURCES/rhelonly-kexec-tools-2.0.16-koji-build-fail-workaround.patch new file mode 100644 index 0000000..c406063 --- /dev/null +++ b/SOURCES/rhelonly-kexec-tools-2.0.16-koji-build-fail-workaround.patch @@ -0,0 +1,13 @@ +diff --git a/purgatory/Makefile b/purgatory/Makefile +index 49ce80a..97b7a03 100644 +--- a/purgatory/Makefile ++++ b/purgatory/Makefile +@@ -67,7 +67,7 @@ $(PURGATORY): $(PURGATORY_OBJS) + $(MKDIR) -p $(@D) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@.sym $^ + # $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB) +- $(STRIP) --strip-debug -o $@ $@.sym ++ $(STRIP) --strip-debug --no-merge-notes -o $@ $@.sym + + echo:: + @echo "PURGATORY_SRCS $(PURGATORY_SRCS)" diff --git a/SOURCES/rhelonly-kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch b/SOURCES/rhelonly-kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch new file mode 100644 index 0000000..0eee6ea --- /dev/null +++ b/SOURCES/rhelonly-kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch @@ -0,0 +1,51 @@ +From ce720608d5933e62f77f2c2f216859cf4f06adf8 Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Wed, 13 Feb 2019 00:03:51 +0800 +Subject: [PATCH] Fix eppic issue with hardening flags + +This is stash of two commits: + +commit f98cf5fe07f390554696755f0a5843f6bb9c4716 +Author: ryncsn +Date: Tue Mar 19 13:39:25 2019 +0800 + + Tell gcc not to omit frame pointer + + After commit 0209874, it's now possible to enable optimization above O0. + But eppic might call __builtin_return_address(1). With O1, + -fomit-frame-pointer is enabled gcc may omit frame pointer. + __builtin_return_address(1) relies on callee preserves RBP as the stack + base, which is untrue if optimization is usded. In this case it may return + wrong value or crash. + + In case of any potential failure, use -fno-omit-frame-pointer globally. + + Signed-off-by: Kairui Song + +commit 0209874f4b46b8af5a2d42662ba6775cf5a1dc44 +Author: Kairui Song +Date: Wed Feb 13 00:03:51 2019 +0800 + + Drop O0 CFLAGS override in Makefile + +Signed-off-by: Kairui Song +--- + libeppic/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libeppic/Makefile b/libeppic/Makefile +index bcf2edf..8b97c87 100644 +--- a/eppic/libeppic/Makefile ++++ b/eppic/libeppic/Makefile +@@ -24,7 +24,7 @@ LDIRT = lex.eppic.c lex.eppicpp.c eppic.tab.c eppic.tab.h eppicpp.tab.c \ + LIBDIR = /usr/lib + TARGETS = libeppic.a + +-CFLAGS += -O0 -g -fPIC ++CFLAGS += -g -fno-omit-frame-pointer -fPIC + ifeq ($(TARGET), PPC64) + CFLAGS += -m64 + endif +-- +2.20.1 + diff --git a/SOURCES/rhelonly-kexec-tools-2.0.20-makedumpfile-remove-lebl.patch b/SOURCES/rhelonly-kexec-tools-2.0.20-makedumpfile-remove-lebl.patch new file mode 100644 index 0000000..ca63d82 --- /dev/null +++ b/SOURCES/rhelonly-kexec-tools-2.0.20-makedumpfile-remove-lebl.patch @@ -0,0 +1,26 @@ +From 3beef142bc003d9cf2e957c6a21e51d661f9b13e Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Thu, 28 Nov 2019 21:23:00 +0800 +Subject: [PATCH] makedumpfile: remove -lebl + +Signed-off-by: Pingfan Liu +--- + makedumpfile-1.6.6/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.6/Makefile b/makedumpfile-1.6.6/Makefile +index 1fdb628..df21b93 100644 +--- a/makedumpfile-1.6.6/Makefile ++++ b/makedumpfile-1.6.6/Makefile +@@ -50,7 +50,7 @@ OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) + SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c + OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) + +-LIBS = -ldw -lbz2 -lebl -ldl -lelf -lz ++LIBS = -ldw -lbz2 -ldl -lelf -lz + ifneq ($(LINKTYPE), dynamic) + LIBS := -static $(LIBS) + endif +-- +2.20.1 + diff --git a/SOURCES/rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch b/SOURCES/rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch index 014de57..dad84d1 100644 --- a/SOURCES/rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch +++ b/SOURCES/rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch @@ -1,4 +1,3 @@ -From 54d6ee9d9d4ee807de32ad490040cbb9a3055a09 Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Wed, 6 Feb 2019 12:31:29 +0530 Subject: [PATCH] makedumpfile/arm64: Add support for ARMv8.2-LVA (52-bit @@ -36,16 +35,17 @@ version D.a http://lists.infradead.org/pipermail/kexec/2019-February/022411.html Signed-off-by: Bhupesh Sharma + --- arch/arm64.c | 109 ++++++++++++++++++++++++++++++++++++++++++--------------- makedumpfile.c | 2 ++ makedumpfile.h | 1 + 3 files changed, 83 insertions(+), 29 deletions(-) -diff --git a/makedumpfile-1.6.5/arch/arm64.c b/makedumpfile-1.6.5/arch/arm64.c -index 053519359cbc..5fcf59d36fed 100644 ---- a/makedumpfile-1.6.5/arch/arm64.c -+++ b/makedumpfile-1.6.5/arch/arm64.c +diff --git a/makedumpfile-1.6.6/arch/arm64.c b/makedumpfile-1.6.6/arch/arm64.c +index 0535193..5fcf59d 100644 +--- a/makedumpfile-1.6.6/arch/arm64.c ++++ b/makedumpfile-1.6.6/arch/arm64.c @@ -41,6 +41,7 @@ typedef struct { static int pgtable_level; @@ -198,11 +198,11 @@ index 053519359cbc..5fcf59d36fed 100644 return TRUE; } -diff --git a/makedumpfile-1.6.5/makedumpfile.c b/makedumpfile-1.6.5/makedumpfile.c -index 590f759c84f1..b9085247375e 100644 ---- a/makedumpfile-1.6.5/makedumpfile.c -+++ b/makedumpfile-1.6.5/makedumpfile.c -@@ -2312,6 +2312,7 @@ write_vmcoreinfo_data(void) +diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c +index d76a435..c8906b5 100644 +--- a/makedumpfile-1.6.6/makedumpfile.c ++++ b/makedumpfile-1.6.6/makedumpfile.c +@@ -2313,6 +2313,7 @@ write_vmcoreinfo_data(void) WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR); #ifdef __aarch64__ @@ -210,26 +210,26 @@ index 590f759c84f1..b9085247375e 100644 WRITE_NUMBER("VA_BITS", VA_BITS); WRITE_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET); WRITE_NUMBER_UNSIGNED("kimage_voffset", kimage_voffset); -@@ -2717,6 +2718,7 @@ read_vmcoreinfo(void) - READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE); +@@ -2719,6 +2720,7 @@ read_vmcoreinfo(void) READ_NUMBER("phys_base", phys_base); + READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE); #ifdef __aarch64__ + READ_NUMBER("MAX_USER_VA_BITS", MAX_USER_VA_BITS); READ_NUMBER("VA_BITS", VA_BITS); READ_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET); READ_NUMBER_UNSIGNED("kimage_voffset", kimage_voffset); -diff --git a/makedumpfile-1.6.5/makedumpfile.h b/makedumpfile-1.6.5/makedumpfile.h -index 5ad38e9ae40c..311ac05a28ab 100644 ---- a/makedumpfile-1.6.5/makedumpfile.h -+++ b/makedumpfile-1.6.5/makedumpfile.h -@@ -1935,6 +1935,7 @@ struct number_table { - long HUGETLB_PAGE_DTOR; +diff --git a/makedumpfile-1.6.6/makedumpfile.h b/makedumpfile-1.6.6/makedumpfile.h +index 24b2f69..cccb52a 100644 +--- a/makedumpfile-1.6.6/makedumpfile.h ++++ b/makedumpfile-1.6.6/makedumpfile.h +@@ -1937,6 +1937,7 @@ struct number_table { long phys_base; + long KERNEL_IMAGE_SIZE; #ifdef __aarch64__ + long MAX_USER_VA_BITS; long VA_BITS; unsigned long PHYS_OFFSET; unsigned long kimage_voffset; -- -2.7.4 +2.7.5 diff --git a/SOURCES/supported-kdump-targets.txt b/SOURCES/supported-kdump-targets.txt index 64b7f59..f540f59 100644 --- a/SOURCES/supported-kdump-targets.txt +++ b/SOURCES/supported-kdump-targets.txt @@ -42,6 +42,9 @@ storage: hardware RAID (cciss, hpsa, megaraid_sas, mpt2sas, aacraid) SCSI/SATA disks iSCSI HBA (all offload) + hardware FCoE (qla2xxx, lpfc) + software FCoE (bnx2fc) (Extra configuration required, + please read "Note on FCoE" section below) network: Hardware using kernel modules: (tg3, igb, ixgbe, sfc, e1000e, bna, @@ -104,6 +107,21 @@ hypervisor: Hyper-V 2012 +Note on FCoE +===================== +If you are trying to dump to a software FCoE target, you may encounter OOM +issue, because some software FCoE requires more memory to work. In such case, +you may need to increase the kdump reserved memory size in "crashkernel=" +kernel parameter. + +By default, RHEL systems have "crashkernel=auto" in kernel boot arguments. +The auto reserved memory size is designed to balance the coverage of use cases +and an acceptable memory overhead, so not every use case could fit in, software +FCoE is one of the case. + +For hardware FCoE, kdump should work naturally as firmware will do the +initialization job. The capture kernel and kdump tools will run just fine. + Useful Links ============ [1] RHEL6: Enabling kdump for full-virt (HVM) Xen DomU diff --git a/SPECS/kexec-tools.spec b/SPECS/kexec-tools.spec index 0375061..cfeae25 100644 --- a/SPECS/kexec-tools.spec +++ b/SPECS/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools -Version: 2.0.19 -Release: 12%{?dist}.2 +Version: 2.0.20 +Release: 14%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -13,7 +13,7 @@ Source4: kdump.sysconfig.i386 Source5: kdump.sysconfig.ppc64 Source7: mkdumprd Source8: kdump.conf -Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.5/makedumpfile-1.6.5.tar.gz +Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.6/makedumpfile-1.6.6.tar.gz Source10: kexec-kdump-howto.txt Source12: mkdumprd.8 Source13: 98-kexec.rules @@ -57,7 +57,7 @@ Requires: dracut >= 049-24 Requires: dracut-network >= 049 Requires: dracut-squash >= 049 Requires: ethtool -BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel +BuildRequires: zlib-devel zlib zlib-static elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-units BuildRequires: automake autoconf libtool @@ -65,6 +65,8 @@ BuildRequires: automake autoconf libtool Obsoletes: diskdumputils netdump kexec-tools-eppic %endif +ExcludeArch: i686 + #START INSERT # @@ -74,8 +76,7 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # -Patch101: kexec-tools-2.0.19-x86-Introduce-a-new-option-reuse-video-type.patch -Patch102: kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch + # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement # @@ -86,27 +87,35 @@ Patch102: kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Mem # # Patches 501 through 600 are meant for ARM kexec-tools enablement # -Patch501: kexec-tools-2.0.19-kexec-kexec.c-Add-the-missing-close-for-fd-used-for-.patch -Patch502: kexec-tools-2.0.19-kexec-uImage-arm64.c-Fix-return-value-of-uImage_arm6.patch -Patch503: kexec-tools-2.0.19-kexec-kexec-zlib.h-Add-is_zlib_file-helper-function.patch -Patch504: kexec-tools-2.0.19-kexec-arm64-Add-support-for-handling-zlib-compressed.patch # # Patches 601 onward are generic patches # -Patch601: kexec-tools-2.0.16-koji-build-fail-workaround.patch -Patch603: kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch -Patch604: kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch -Patch605: kexec-tools-2.0.18-makedumpfiles-exclude-pages-that-are-logically-offline.patch -Patch606: rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch -Patch607: kexec-tools-2.0.20-kexec-add-variant-helper-functions-for-handling-memo.patch -Patch608: kexec-tools-2.0.20-arm64-kexec-allocate-memory-space-avoiding-reserved-.patch -Patch609: kexec-tools-2.0.20-arm64-kdump-deal-with-a-lot-of-resource-entries-in-p.patch +Patch601: rhelonly-kexec-tools-2.0.16-koji-build-fail-workaround.patch +Patch602: rhelonly-kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch +Patch603: rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch +Patch604: kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option-wit.patch +Patch605: kexec-tools-2.0.20-Cleanup-remove-the-read_elf_kcore.patch +Patch606: kexec-tools-2.0.20-Fix-an-error-definition-about-the-variable-fname.patch +Patch607: kexec-tools-2.0.20-Cleanup-move-it-back-from-util_lib-elf_info.c.patch +Patch608: kexec-tools-2.0.20-Limit-the-size-of-vmcore-dmesg.txt-to-2G.patch +Patch609: kexec-tools-2.0.20-vmcore-dmesg-vmcore-dmesg.c-Fix-shifting-error-repor.patch +Patch610: kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch +Patch611: kexec-tools-2.0.20-makedumpfile-Fix-off-by-one-issue-in-exclude_nodata_pages.patch +Patch612: rhelonly-kexec-tools-2.0.20-makedumpfile-remove-lebl.patch +Patch613: kexec-tools-2.0.20-makedumpfile-assign-bitmap1-2-fd-for-subprocess-in-non-cycl.patch +Patch614: kexec-tools-2.0.20-kexec-add-variant-helper-functions-for-handling-memo.patch +Patch615: kexec-tools-2.0.20-arm64-kexec-allocate-memory-space-avoiding-reserved-.patch +Patch616: kexec-tools-2.0.20-arm64-kdump-deal-with-a-lot-of-resource-entries-in-p.patch +Patch617: kexec-tools-2.0.20-makedumpfile-arm64-fix-get_kaslr_offset_arm64-to-return-kas.patch +Patch618: kexec-tools-2.0.20-makedumpfile-Generalize-get_kaslr_offset_arm64-for-other-ar.patch +Patch619: kexec-tools-2.0.20-makedumpfile-Pass-0-to-get_kaslr_offset-in-find_kaslr_offse.patch +Patch620: kexec-tools-2.0.20-makedumpfile-s390-Use-get_kaslr_offset_general-for-s390x.patch %description -kexec-tools provides /sbin/kexec binary that facilitates a new +kexec-tools provides /usr/sbin/kexec binary that facilitates a new kernel to boot using the kernel's kexec feature either on a -normal or a panic reboot. This package contains the /sbin/kexec +normal or a panic reboot. This package contains the /usr/sbin/kexec binary and ancillary utilities that together form the userspace component of the kernel's kexec feature. @@ -117,20 +126,26 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch101 -p1 -%patch501 -p1 -%patch502 -p1 -%patch503 -p1 -%patch504 -p1 %patch601 -p1 +%patch602 -p1 %patch603 -p1 %patch604 -p1 %patch605 -p1 %patch606 -p1 -%patch102 -p1 %patch607 -p1 %patch608 -p1 %patch609 -p1 +%patch610 -p1 +%patch611 -p1 +%patch612 -p1 +%patch613 -p1 +%patch614 -p1 +%patch615 -p1 +%patch616 -p1 +%patch617 -p1 +%patch618 -p1 +%patch619 -p1 +%patch620 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -147,7 +162,7 @@ autoreconf --host=powerpc64le-redhat-linux-gnu \ --build=powerpc64le-redhat-linux-gnu \ %endif - --sbindir=/sbin + --sbindir=/usr/sbin rm -f kexec-tools.spec.in # setup the docs cp %{SOURCE10} . @@ -157,14 +172,14 @@ cp %{SOURCE27} . cp %{SOURCE28} . make -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 %{arm} +%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic/libeppic -make -C makedumpfile-1.6.5 LINKTYPE=dynamic USELZO=on USESNAPPY=on -make -C makedumpfile-1.6.5 LDFLAGS="$LDFLAGS -I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so +make -C makedumpfile-1.6.6 LINKTYPE=dynamic USELZO=on USESNAPPY=on +make -C makedumpfile-1.6.6 LDFLAGS="$LDFLAGS -I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so %endif %install -mkdir -p -m755 $RPM_BUILD_ROOT/sbin +mkdir -p -m755 $RPM_BUILD_ROOT/usr/sbin mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig mkdir -p -m755 $RPM_BUILD_ROOT%{_localstatedir}/crash mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/ @@ -178,8 +193,8 @@ mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_prefix}/lib/kdump install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl -install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/sbin/kexec -install -m 755 build/sbin/vmcore-dmesg $RPM_BUILD_ROOT/sbin/vmcore-dmesg +install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/usr/sbin/kexec +install -m 755 build/sbin/vmcore-dmesg $RPM_BUILD_ROOT/usr/sbin/vmcore-dmesg install -m 644 build/man/man8/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/ install -m 644 build/man/man8/vmcore-dmesg.8 $RPM_BUILD_ROOT%{_mandir}/man8/ @@ -188,7 +203,7 @@ SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu} [ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump -install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/sbin/mkdumprd +install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/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 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 @@ -210,14 +225,14 @@ install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 %{arm} -install -m 755 makedumpfile-1.6.5/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile -install -m 644 makedumpfile-1.6.5/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz -install -m 644 makedumpfile-1.6.5/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz -install -m 644 makedumpfile-1.6.5/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample -install -m 755 makedumpfile-1.6.5/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so +%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 +install -m 755 makedumpfile-1.6.6/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile +install -m 644 makedumpfile-1.6.6/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz +install -m 644 makedumpfile-1.6.6/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz +install -m 644 makedumpfile-1.6.6/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample +install -m 755 makedumpfile-1.6.6/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ -install -m 644 makedumpfile-1.6.5/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ +install -m 644 makedumpfile-1.6.6/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ %endif %define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') @@ -289,7 +304,7 @@ fi /usr/bin/systemd-sysv-convert --save kdump >/dev/null 2>&1 ||: # Run these because the SysV package being removed won't do them -/sbin/chkconfig --del kdump >/dev/null 2>&1 || : +/usr/sbin/chkconfig --del kdump >/dev/null 2>&1 || : /bin/systemctl try-restart kdump.service >/dev/null 2>&1 || : @@ -316,18 +331,18 @@ do done %files -/sbin/kexec -/sbin/makedumpfile -/sbin/mkdumprd -/sbin/vmcore-dmesg +/usr/sbin/kexec +/usr/sbin/makedumpfile +/usr/sbin/mkdumprd +/usr/sbin/vmcore-dmesg %{_bindir}/* %{_datadir}/kdump %{_prefix}/lib/kdump -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 %{arm} +%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 %{_sysconfdir}/makedumpfile.conf.sample %endif %config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump -%config(noreplace,missingok) %{_sysconfdir}/kdump.conf +%config(noreplace,missingok) %verify(not mtime) %{_sysconfdir}/kdump.conf %ifnarch s390x %config %{_udevrulesdir} %{_udevrulesdir}/../kdump-udev-throttler @@ -350,21 +365,67 @@ done %doc supported-kdump-targets.txt %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 %{arm} +%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 %{_libdir}/eppic_makedumpfile.so /usr/share/makedumpfile/ %endif %changelog -* Fri Jan 10 2020 Pingfan Liu - 2.0.19-12.2 +* Tue Feb 18 2020 Pingfan Liu - 2.0.20-14 +- kexec-tools/module-setup: Ensure eth devices get IP address for VLAN + +* Wed Feb 12 2020 Pingfan Liu - 2.0.20-13 +- Add document to declare FCoE support + +* Wed Feb 12 2020 Pingfan Liu - 2.0.20-12 +- powerpc: enable the scripts to capture dump on POWERNV platform + +* Tue Feb 4 2020 Pingfan Liu - 2.0.20-11 +- s390: Use get_kaslr_offset_general() for s390x + +* Fri Jan 10 2020 Pingfan Liu - 2.0.20-10 - arm64: kdump: deal with a lot of resource entries in /proc/iomem - arm64: kexec: allocate memory space avoiding reserved regions - kexec: add variant helper functions for handling memory regions -* Thu Nov 14 2019 Pingfan Liu - 2.0.19-12.1 +* Thu Dec 12 2019 Pingfan Liu - 2.0.20-9 +- makedumpfile: assign bitmap1/2 fd for subprocess in non-cyclic mode + +* Mon Dec 2 2019 Pingfan Liu - 2.0.20-8 +- makedumpfile: remove -lebl + +* Thu Nov 28 2019 Pingfan Liu - 2.0.20-7 +- makedumpfile: Fix off-by-one issue in exclude_nodata_pages() + +* Wed Nov 27 2019 Pingfan Liu - 2.0.20-6 +-rhel-8.2.0, origin/rhel-8.2.0) Increase SECTION_MAP_LAST_BIT to 4 +- spec: move binaries from /sbin to /usr/sbin +- As /etc/kdump.conf timestamp is updated do not compare it when doing rpm --verify +- kdumpctl: make reload fail proof + +* Tue Nov 12 2019 Pingfan Liu - 2.0.20-5 - Don't execute final_action if failure_action terminates the system +- module-setup: re-fix 99kdumpbase network dependency +- kdumpctl: bail out immediately if host key verification failed +- kdumpctl: echo msg when waiting for connection +- kdumpctl: distinguish the failed reason of ssh +- kdumpctl: wait a while for network ready if dump target is ssh +- dracut-module-setup: filter out localhost for generic_fence_kdump +- dracut-module-setup: get localhost alias by manual + +* Mon Oct 28 2019 Pingfan Liu - 2.0.19-12.4 - dracut-module-setup.sh: Don't use squash module for fadump - Don't mount the dump target unless needed +- dracut-module-setup: fix bond ifcfg processing +- Doc: amend the man page of kdump.conf + +* Mon Oct 28 2019 Pingfan Liu - 2.0.19-12.3 +- Limit the size of vmcore-dmesg.txt to 2G +- makedumpfile: x86_64: Fix incorrect exclusion by -e option with KASLR +- mkdumprd: ensure ssh path exists before check size + +* Fri Oct 18 2019 Pingfan Liu - 2.0.19-12.2 +- rebase to kexec-tools-2.0.20 and makedumpfile-1.6.6 * Fri Aug 9 2019 Pingfan Liu - 2.0.19-12 - Don't forward and drop journalctl logs for fadump