[PATCH 00/11] crashkernel=auto: support fadump, reserve extra SWIOTLB memory and remove crashkernel.default
by Coiby Xu
The crashkernel=auto implementation in kernel space has been rejected
upstream [1]. The current user space implementation [2] [3] ships a
crashkernel.default but hasn't supported the swiotlb memory requirement,
custom crashkernel value from user and fadump.
The crashkernel.default implementation seems to be overly
complex,
- the default crashkernel value rarely changes. This is no need to ship
the same crashkernel.default default for every kernel package of a
architecture;
- when deciding the value of crashkernel for a new kernel, the
crashkernel.default of existing kernel is took into consideration
We can simply let the kexec-tools maintain the default crashkernel
values and provide an API for kdump-anacon-addon to query it. And for
a newly installed kernel, we can simply call "kdumpctl reset-crashkernel
KERNELPATH" to set its crashkernel value.
For the unfulfilled requirements,
- crashkernel is introduced to /etc/kdump.conf for the user can set
custom crashkernel value to tell kexec-tools to manage crashkernel
value automatically.
- "kdumpctl reset-crashkernel" has been written for the above
purpose.
- "kdumpctl fadump on/off" is added for supporting fadump.
[1] https://lore.kernel.org/linux-mm/20210507010432.IN24PudKT%25akpm@linux-fo...
[2] https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1171
[3] https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.o...
Coiby Xu (11):
update default crashkernel value
factor out kdump_get_arch_recommend_crashkernel
provide get_default_crashkernel for kdump_anaconda_addon
introduce crashkernel option to kdump.conf
add a helper function to write a config value to kdump.conf
add a helper function to read kernel cmdline parameter from grubby
--info
rewrite reset_crashkernel to provide more features for the user and to
be called by kernel installation hook
allow to add extra memory to crashkernel string
Reserve extra memory when SME or SEV is active
provide kdumpctl fadump on/off
use "kdumpctl reset-crashkernel KERNELIMAGE" in kernel installation
hook
92-crashkernel.install | 135 +----------------------------
kdump-lib-initramfs.sh | 9 ++
kdump-lib.sh | 95 +++++++++++++++------
kdump.conf | 6 ++
kdump.conf.5 | 7 ++
kdumpctl | 188 ++++++++++++++++++++++++++++++++++++-----
kdumpctl.8 | 16 ++--
7 files changed, 271 insertions(+), 185 deletions(-)
--
2.31.1
11 months, 3 weeks
[PATCH] mkdumprd: allow spaces after 'path' config phrase when network dump
by Kazuhito Hagio
Without this patch, when there are two or more spaces after 'path'
configuration phrase with ssh or nfs setting, SAVE_PATH is set to
'/var/crash' in mkdumprd, and in most cases kdump service fails to
start.
ssh kdump(a)192.168.122.1
path /kdump
^^
This behavior would be too sensitive and different from the other
configurations. With this patch, mkdumprd allows such spaces.
Signed-off-by: Kazuhito Hagio <k-hagio(a)ab.jp.nec.com>
---
mkdumprd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd
index a6f7fe8..aa0abfd 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -13,7 +13,7 @@ export IN_KDUMP=1
conf_file="/etc/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
-SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2)
+SAVE_PATH=$(awk '/^path/ {print $2}' $conf_file)
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
# strip the duplicated "/"
SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
--
2.18.0
1 year
[PATCH 00/15] kdumpctl: various fixes and cleanups
by Philipp Rudo
Hi,
while looking into transforming mkdumprd and mkfadumprd into library functions
I noticed various nits in kdumpctl. This series addresses them.
The series is made up of two parts:
Patches 1-8 are small independent cleanups and fixes.
Patches 9-15 tries to reduce the number of file accesses to /etc/kdump.conf. It
achieves this by only parsing kdump.conf once in check_config and storing the
parsed values in an array. Later accesses can then simply use the value stored
in the array instead of calling kdump_get_conf_val.
Thanks
Philipp
Philipp Rudo (15):
kdump-capture.service: switch to journal for stdout
kdumpctl: source dependencies before defining globals
kdump-lib: fix typo in variable name
kdumpctl: remove unnecessary uses of $?
kdump-lib-initramfs: merge definitions for default ssh key
kdumpctl: fix comment in check_and_wait_network_ready
kdumpctl: forbid aliases from ssh config
kdumpctl: simplify propagate_ssh_key
kdumpctl: merge check_ssh_config into check_config
kdumpctl: reduce file operations on kdump.conf
kdumpctl: drop SAVE_PATH variable
kdumpctl: drop SSH_KEY_LOCATION variable
kdumpctl: drop DUMP_TARGET variable
kdumpctl: remove kdump_get_conf_val in save_raw
kdumpctl: simplify local_fs_dump_target
dracut-kdump-capture.service | 4 +-
dracut-kdump.sh | 2 +-
kdump-lib-initramfs.sh | 1 +
kdump-lib.sh | 14 +-
kdumpctl | 258 ++++++++++++++++-------------------
mkdumprd | 2 +-
6 files changed, 128 insertions(+), 153 deletions(-)
--
2.34.1
1 year, 2 months
[RFC 0/8] unit tests with ShellSpec
by Coiby Xu
Potential benefits brought by unit tests
=======================================
- catch as many bugs as possible and catch them as early as possible
- improve the code quality and make the code robust
- Keep API stable
- prevent regressions from change during the development and in the future
(it's quite annoying to solve one problem only to find another cropping up)
- make it easy for code review because of concrete test cases
Why ShellSpec
=============
ShellSpec [1] is chosen for the following benefits,
- rich features: to name a few
- mocking
- Parameterized tests
- code coverage
- good documentation and examples
For the full comparison between shellspec and other frameworks, please
refer to [2].
How to run the tests
====================
After installing shellspec and optionally kcov
$ curl -fsSL https://git.io/shellspec | sh
$ sudo dnf install kcov
1. go to the root of this repo
2. create a file with _spec as suffix in the spec folder, e.g. spec/kdumpctl_spec.sh
3. run shellspec
shellspec --kcov --kcov-options "--include-pattern=kdumpctl,kdump-lib.sh,kdump-lib-initramfs.sh,kdump-logger.sh"
Running: /bin/sh [bash 5.1.0(1)-release]
................................................................
Finished in 11.15 seconds (user 6.97 seconds, sys 9.54 seconds)
64 examples, 0 failures
Code covered: 16.08%, Executed lines: 224, Instrumented lines: 1393
[1] https://github.com/shellspec/shellspec
[2] https://github.com/dodie/testing-in-bash#detailed-comparision
Coiby Xu (8):
unit tests: prepare for kdumpctl and kdump-lib.sh to be unit-tested
unit tests: add tests for get_grub_kernel_boot_parameter
unit tests: add tests for get_dump_mode_by_fadump_val
unit tests: add tests for kdumpctl read_proc_environ_var and
_is_osbuild
unit tests: add tests for
_{add,remove,read}_kernel_arg_in_grub_etc_default in kdumpctl
unit tests: add tests for "kdumpctl reset-crashkernel"
unit tests: add tests for kdump_get_conf_val in kdump-lib-initramfs.sh
unit tests: add check_config with with the default kdump.conf
.shellspec | 0
kdump-lib.sh | 7 +-
kdumpctl | 24 +-
spec/kdump-lib-initramfs_spec.sh | 41 ++++
spec/kdumpctl_general_spec.sh | 175 ++++++++++++++
spec/kdumpctl_reset_crashkernel_spec.sh | 216 ++++++++++++++++++
spec/support/bin/@grubby | 3 +
...846f63134c7295458cf36300ba5b-0-rescue.conf | 8 +
...58cf36300ba5b-5.14.14-200.fc34.x86_64.conf | 8 +
...458cf36300ba5b-5.15.6-100.fc34.x86_64.conf | 8 +
spec/support/grub_env | 3 +
11 files changed, 484 insertions(+), 9 deletions(-)
create mode 100644 .shellspec
create mode 100644 spec/kdump-lib-initramfs_spec.sh
create mode 100644 spec/kdumpctl_general_spec.sh
create mode 100644 spec/kdumpctl_reset_crashkernel_spec.sh
create mode 100755 spec/support/bin/@grubby
create mode 100644 spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-0-rescue.conf
create mode 100644 spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.14.14-200.fc34.x86_64.conf
create mode 100644 spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.15.6-100.fc34.x86_64.conf
create mode 100644 spec/support/grub_env
--
2.34.1
1 year, 3 months
[PATCH] kdumpctl: sync the $TARGET_INITRD after rebuild
by Lichen Liu
There is a system-wide sync call at the end of mkdumprd, move it to
kdumpctl after rebuild initrd and add another one for mkfadumprd.
Sync only the $TARGET_INITRD to avoid a system-wide sync taking too
long on a system with high disk activity.
Signed-off-by: Lichen Liu <lichliu(a)redhat.com>
---
kdumpctl | 2 ++
mkdumprd | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index 9fd76ac..fa83c05 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -79,6 +79,7 @@ rebuild_fadump_initrd()
return 1
fi
+ sync -f "$TARGET_INITRD"
return 0
}
@@ -100,6 +101,7 @@ rebuild_kdump_initrd()
dwarn "Tips: If early kdump is enabled, also require rebuilding the system initramfs to make the changes take effect for early kdump."
fi
+ sync -f "$TARGET_INITRD"
return 0
}
diff --git a/mkdumprd b/mkdumprd
index 593ec77..d5f8945 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -460,5 +460,4 @@ fi
dracut "${dracut_args[@]}" "$@"
_rc=$?
-sync
exit $_rc
--
2.27.0
1 year, 3 months
[PATCH v4 1/2] address the case where there are multiple values for the same kernel arg
by Coiby Xu
When updating the kernel command line in /etc/default/grub, grubby only
replaces a given entry if it is the last entry on the command line.
In all other cases it appends a new entry to it. This behavior makes it
quite likely that there are multiple entries of the same parameter on
the command line, e.g.
GRUB_CMDLINE_LINUX="crashkernel=110M crashkernel=220M fadump=on crashkernel=330M".
In such an situation _update_kernel_cmdline_in_grub_etc_default only
updates/removes the last entry. Which is usually not what you
want as the kernel (for crashkernel) takes the last entry it can find.
Thus make sure the case with multiple entries of the same parameter is
handled properly by removing all occurrences of given parameter first.
Note
1. sed command group and conditional control has been used to get rid of
grep.
2. Fully supporting kernel cmdline as documented in
Documentation/admin-guide/kernel-parameters.rst is complex and in
foreseeable future a full implementation is not needed. So simply
document the unsupported cases instead.
Reported-by: Philipp Rudo <prudo(a)redhat.com>
Suggested-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kdumpctl | 54 ++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 40 insertions(+), 14 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 9fd76ac..978aee1 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1399,25 +1399,49 @@ _get_all_kernels_from_grubby()
}
GRUB_ETC_DEFAULT="/etc/default/grub"
-# modify the kernel command line parameter in default grub conf
+# Update a kernel parameter in default grub conf
+#
+# If a value is specified, it will be inserted in the end. Otherwise it
+# would remove given kernel parameter.
+#
+# Note this function doesn't address the following cases,
+# 1. The kernel ignores everything on the command line after a '--'. So
+# simply adding the new entry to the end will fail if the cmdline
+# contains a --.
+# 2. If the value for a parameter contains spaces it can be quoted using
+# double quotes, for example param="value with spaces". This will
+# break the [^[:space:]\"] regex for the value.
+# 3. Dashes and underscores in the parameter name are equivalent. So
+# some_parameter and some-parameter are identical.
+# 4. Some parameters, e.g. efivar_ssdt, can be given multiple times.
+# 5. Some kernel parameters, e.g. quiet, doesn't have value
#
# $1: the name of the kernel command line parameter
-# $2: new value. If empty, the parameter would be removed
-_update_kernel_cmdline_in_grub_etc_default()
+# $2: new value. If empty, given parameter would be removed
+_update_kernel_arg_in_grub_etc_default()
{
- local _para=$1 _val=$2 _para_val _regex
+ local _para=$1 _val=$2 _para_val
if [[ -n $_val ]]; then
_para_val="$_para=$_val"
fi
- _regex='^(GRUB_CMDLINE_LINUX=.*)([[:space:]"])'"$_para"'=[^[:space:]"]*(.*)$'
- if grep -q -E "$_regex" "$GRUB_ETC_DEFAULT"; then
- sed -i -E 's/'"$_regex"'/\1\2'"$_para_val"'\3/' "$GRUB_ETC_DEFAULT"
- elif [[ -n $_para_val ]]; then
- # If the kernel parameter doesn't exist, put it in the first
- sed -i -E 's/^(GRUB_CMDLINE_LINUX=")/\1'"$_para_val"' /' "$GRUB_ETC_DEFAULT"
- fi
+ # Update the command line /etc/default/grub, i.e.
+ # on the line that starts with 'GRUB_CMDLINE_LINUX=',
+ # 1) remove $para=$val if the it's the first arg
+ # 2) remove all occurences of $para=$val
+ # 3) insert $_para_val to end
+ # 4) remove duplicate spaces left over by 1) or 2) or 3)
+ # 5) remove space at the beginning of the string left over by 1) or 2) or 3)
+ # 6) remove space at the end of the string left over by 1) or 2) or 3)
+ sed -i -E "/^GRUB_CMDLINE_LINUX=/ {
+ s/\"${_para}=[^[:space:]\"]*/\"/g;
+ s/[[:space:]]+${_para}=[^[:space:]\"]*/ /g;
+ s/\"$/ ${_para_val}\"/
+ s/[[:space:]]+/ /g;
+ s/(\")[[:space:]]+/\1/g;
+ s/[[:space:]]+(\")/\1/g;
+ }" "$GRUB_ETC_DEFAULT"
}
reset_crashkernel()
@@ -1496,10 +1520,12 @@ reset_crashkernel()
# - set the dump mode as kdump for non-ppc64le cases
# - retrieved the default crashkernel value for given dump mode
if [[ $_grubby_kernel_path == ALL && -n $_dump_mode ]]; then
- _update_kernel_cmdline_in_grub_etc_default crashkernel "$_crashkernel"
+ _update_kernel_arg_in_grub_etc_default crashkernel "$_crashkernel"
# remove the fadump if fadump is disabled
- [[ $_fadump_val == off ]] && _fadump_val=""
- _update_kernel_cmdline_in_grub_etc_default fadump "$_fadump_val"
+ if [[ $_fadump_val == off ]]; then
+ _fadump_val=""
+ fi
+ _update_kernel_arg_in_grub_etc_default fadump "$_fadump_val"
fi
# If kernel-path not specified, either
--
2.34.1
1 year, 3 months
[PATCH] kdumpctl: Redirect the stdout of restorecon to /dev/null
by Lichen Liu
kdumpctl will restore files default SELinux security contexts via restorecon
command, but the files in /tmp don't have a default label, restorecon will
complain like below:
"Warning no default label for /tmp/mkfadumprd.XXXXXX/fadump.img"
Redirect the stdout to /dev/null for ignoring the harmless warning.
Signed-off-by: Lichen Liu <lichliu(a)redhat.com>
---
kdumpctl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index 9fd76ac..3928bda 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -906,7 +906,7 @@ selinux_relabel()
while IFS= read -r -d '' _i; do
_attr=$(getfattr -m "security.selinux" "$_i" 2> /dev/null)
if [[ -z $_attr ]]; then
- restorecon "$_i"
+ restorecon "$_i" > /dev/null
fi
done < <(find "$_path" -print0)
}
--
2.27.0
1 year, 3 months
[PATCH v3 1/2] address the case where there are multiple values for the same kernel arg
by Coiby Xu
When updating kernel arg in /etc/default/grub, grubby will replace the
given arg with new value if the arg is the last one. If given arg isn't
the last one, it would insert it in the end. So it's quite likely there are
multiple values for the same kernel arg. e.g
GRUB_CMDLINE_LINUX="crashkernel=110M crashkernel=220M fadump=on crashkernel=330M".
So all values should be removed when removing a kernel arg from
/etc/default/grub.
Now _update_kernel_cmdline_in_grub_etc_default is split into
{_add,_remove}_kernel_arg_in_grub_etc_default to address this case.
Note
1. to be consist with grubby, _add_kernel_arg_in_grub_etc_default will
always make sure the new value appears in the end
2. sed command group and conditional control hasn't bee used to get rid of
grep.
3. Fully supporting kernel cmdline as documented in
Documentation/admin-guide/kernel-parameters.rst is complex and in
foreseeable future a full implementation is not needed. So simply
document the unsupported cases instead.
Reported-by: Philipp Rudo <prudo(a)redhat.com>
Suggested-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kdumpctl | 85 ++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 70 insertions(+), 15 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 9fd76ac..d9edc4b 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1399,25 +1399,77 @@ _get_all_kernels_from_grubby()
}
GRUB_ETC_DEFAULT="/etc/default/grub"
-# modify the kernel command line parameter in default grub conf
+# Add a kernel arguement in default grub conf
+#
+# As is the same with grubby, this function would replace the given parameter
+# with new value if given parameter appears in the end. Otherwise, it insert
+# the entry in the end.
+#
+# Note as similar to grubby, this function doesn't address the following cases
+# either,
+# 1. The kernel ignores everything on the command line after a '--'. So
+# simply adding the the new entry to the end will fail if the cmdline
+# contains a --.
+# 2. If the value for a parameter contains spaces it can be quoted using
+# double quotes, for example param="value with spaces". This will
+# break the [^[:space:]\"] regex for the value.
+# 3. Dashes and underscores in the parameter name are equivalent. So
+# some_parameter and some-parameter are identical.
+# 4. multiple variables have the same name but with different values
+# e.g. efivar_ssdt
+#
+# Besides, this function doesn't support adding a kernel parameter
+# that doesn't have a value
#
# $1: the name of the kernel command line parameter
# $2: new value. If empty, the parameter would be removed
-_update_kernel_cmdline_in_grub_etc_default()
+_add_kernel_arg_in_grub_etc_default()
{
- local _para=$1 _val=$2 _para_val _regex
+ local _para=$1 _val=$2 _para_val
- if [[ -n $_val ]]; then
- _para_val="$_para=$_val"
+ if [[ -z $_val ]]; then
+ derror "value not specified for $_para"
+ return 1
fi
- _regex='^(GRUB_CMDLINE_LINUX=.*)([[:space:]"])'"$_para"'=[^[:space:]"]*(.*)$'
- if grep -q -E "$_regex" "$GRUB_ETC_DEFAULT"; then
- sed -i -E 's/'"$_regex"'/\1\2'"$_para_val"'\3/' "$GRUB_ETC_DEFAULT"
- elif [[ -n $_para_val ]]; then
- # If the kernel parameter doesn't exist, put it in the first
- sed -i -E 's/^(GRUB_CMDLINE_LINUX=")/\1'"$_para_val"' /' "$GRUB_ETC_DEFAULT"
- fi
+ _para_val="$_para=$_val"
+ # Update the command line /etc/default/grub, i.e.
+ # on the line that starts with 'GRUB_CMDLINE_LINUX=',
+ # 1) if given parameter appear in the end, replace it with new entry
+ # 2) otherwise, insert the entry in the end
+ sed -i -E "/^GRUB_CMDLINE_LINUX=/ {
+ s/([[:space:]\"])${_para}=[^[:space:]\"]*[[:space:]]*\"$/\1${_para_val}\"/;
+ # t: jump to a label only if a s/// command has succeeded.
+ # Since there is no label, it would jump to the end i.e.
+ # skip the last command if the parameter already exists
+ t;
+ s/\"$/ ${_para_val}\"/
+ }" "$GRUB_ETC_DEFAULT"
+}
+
+# Remove a kernel argument from default grub conf
+#
+# Note removing a kernel parameter that doesn't have a value isn't supported
+# e.g. quiet.
+#
+# $1: the name of the kernel parameter
+_remove_kernel_arg_in_grub_etc_default()
+{
+ local _para=$1
+
+ # On the line that starts with 'GRUB_CMDLINE_LINUX=' do
+ # 1) remove $para=$val if the it's the first arg
+ # 2) remove all occurences of $para=$val
+ # 3) remove duplicate spaces left over by 1) or 2)
+ # 4) remove space at the beginning of the string left over by 1) or 2)
+ # 5) remove space at the end of the string left over by 1) or 2)
+ sed -i -E "/^GRUB_CMDLINE_LINUX=/ {
+ s/\"${_para}=[^[:space:]\"]*/\"/g;
+ s/[[:space:]]+${_para}=[^[:space:]\"]*/ /g;
+ s/[[:space:]]+/ /g;
+ s/(\")[[:space:]]+/\1/g;
+ s/[[:space:]]+(\")/\1/g;
+ }" "$GRUB_ETC_DEFAULT"
}
reset_crashkernel()
@@ -1496,10 +1548,13 @@ reset_crashkernel()
# - set the dump mode as kdump for non-ppc64le cases
# - retrieved the default crashkernel value for given dump mode
if [[ $_grubby_kernel_path == ALL && -n $_dump_mode ]]; then
- _update_kernel_cmdline_in_grub_etc_default crashkernel "$_crashkernel"
+ _add_kernel_arg_in_grub_etc_default crashkernel "$_crashkernel"
# remove the fadump if fadump is disabled
- [[ $_fadump_val == off ]] && _fadump_val=""
- _update_kernel_cmdline_in_grub_etc_default fadump "$_fadump_val"
+ if [[ $_fadump_val == off ]]; then
+ _remove_kernel_arg_in_grub_etc_default fadump
+ else
+ _add_kernel_arg_in_grub_etc_default fadump "$_fadump_val"
+ fi
fi
# If kernel-path not specified, either
--
2.34.1
1 year, 3 months
[PATCH 1/3] update kernel crashkernel in posttrans RPM scriptlet when updating kexec-tools
by Coiby Xu
When doing in-place upgrading using leapp on x86_64, kdumpcl can't
acquire instance lock when running in %post RPM scriplet on x86_64,
localhost upgrade[1306]: /bin/kdumpctl: line 49: /var/lock/kdump: No such file or directory
localhost upgrade[1306]: kdump: Create file lock failed
and running "touch /var/lock/dkump" also fails with
"No such file or directory". Thus kdumpctl can't be run in %post
scriptlet. But kdumpctl can be run in %posttrans RPM scriplet.
Besides, it's better to update crashkernel after the kernel has been
updated. So let's update kernel crashkernel in the %posttrans
scriptlet which will be run in the end of a transaction i.e. after
the kernel has been updated.
Note for %posttrans scriptlet, "$1 == 1" means both installing a new
package and upgrading a package.
Reported-by: Jie Li <jieli(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kexec-tools.spec | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/kexec-tools.spec b/kexec-tools.spec
index ac134da..6b7ef14 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -305,19 +305,6 @@ then
mv /etc/sysconfig/kdump.new /etc/sysconfig/kdump
fi
-# try to reset kernel crashkernel value to new default value when upgrading
-# the package
-if ! grep -qs "ostree" /proc/cmdline && [ $1 == 2 ]; then
- kdumpctl reset-crashkernel-after-update
- rm /tmp/old_default_crashkernel 2>/dev/null
-%ifarch ppc64 ppc64le
- rm /tmp/old_default_crashkernel_fadump 2>/dev/null
-%endif
- # dnf would complain about the exit code not being 0. To keep it happy,
- # always return 0
- :
-fi
-
%postun
%systemd_postun_with_restart kdump.service
@@ -350,6 +337,21 @@ do
fi
done
+%posttrans
+# try to reset kernel crashkernel value to new default value when upgrading
+# the package
+if ! grep -qs "ostree" /proc/cmdline && [ $1 == 1 ]; then
+ kdumpctl reset-crashkernel-after-update
+ rm /tmp/old_default_crashkernel 2>/dev/null
+%ifarch ppc64 ppc64le
+ rm /tmp/old_default_crashkernel_fadump 2>/dev/null
+%endif
+ # dnf would complain about the exit code not being 0. To keep it happy,
+ # always return 0
+ :
+fi
+
+
%files
/usr/sbin/kexec
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
--
2.34.1
1 year, 3 months
[PATCH] makedumpfile: sadump, kaslr: fix failure of calculating kaslr_offset
by Tao Liu
Resolves: bz2055498
Upstream: github.com/makedumpfile/makedumpfile.git
commit 59b1726fbcc251155140c8a1972384498fee4daf
Author: HATAYAMA Daisuke <d.hatayama(a)fujitsu.com>
Date: Tue Jan 25 12:55:15 2022 +0000
[PATCH] sadump, kaslr: fix failure of calculating kaslr_offset
On kernels v5.8 or later, makedumpfile fails for memory dumps in the
sadump-related formats as follows:
# makedumpfile -f -l -d 31 -x ./vmlinux /dev/sdd4 /root/vmcore-ld31
__vtop4_x86_64: Can't get a valid pud_pte.
...110 lines of the same message...
__vtop4_x86_64: Can't get a valid pud_pte.
calc_kaslr_offset: failed to calculate kaslr_offset and phys_base; default to 0
readmem: type_addr: 1, addr:ffffffff85411858, size:8
__vtop4_x86_64: Can't get pgd (page_dir:ffffffff85411858).
readmem: Can't convert a virtual address(ffffffff059be980) to physical address.
readmem: type_addr: 0, addr:ffffffff059be980, size:1024
cpu_online_mask_init: Can't read cpu_online_mask memory.
makedumpfile Failed.
This is caused by the kernel commit 9d06c4027f21 ("x86/entry: Convert
Divide Error to IDTENTRY") that renamed divide_error to
asm_exc_divide_error, breaking logic for calculating kaslr offset.
Fix this by adding initialization of asm_exc_divide_error.
Signed-off-by: HATAYAMA Daisuke <d.hatayama(a)fujitsu.com>
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
...lr-fix-failure-of-calculating-kaslr_.patch | 49 +++++++++++++++++++
kexec-tools.spec | 2 +
2 files changed, 51 insertions(+)
create mode 100644 kexec-tools-2.0.23-makedumpfile-sadump-kaslr-fix-failure-of-calculating-kaslr_.patch
diff --git a/kexec-tools-2.0.23-makedumpfile-sadump-kaslr-fix-failure-of-calculating-kaslr_.patch b/kexec-tools-2.0.23-makedumpfile-sadump-kaslr-fix-failure-of-calculating-kaslr_.patch
new file mode 100644
index 0000000..e7a47b5
--- /dev/null
+++ b/kexec-tools-2.0.23-makedumpfile-sadump-kaslr-fix-failure-of-calculating-kaslr_.patch
@@ -0,0 +1,49 @@
+From 59b1726fbcc251155140c8a1972384498fee4daf Mon Sep 17 00:00:00 2001
+From: HATAYAMA Daisuke <d.hatayama(a)fujitsu.com>
+Date: Tue, 25 Jan 2022 12:55:15 +0000
+Subject: [PATCH] [PATCH] sadump, kaslr: fix failure of calculating
+ kaslr_offset
+
+On kernels v5.8 or later, makedumpfile fails for memory dumps in the
+sadump-related formats as follows:
+
+ # makedumpfile -f -l -d 31 -x ./vmlinux /dev/sdd4 /root/vmcore-ld31
+ __vtop4_x86_64: Can't get a valid pud_pte.
+ ...110 lines of the same message...
+ __vtop4_x86_64: Can't get a valid pud_pte.
+ calc_kaslr_offset: failed to calculate kaslr_offset and phys_base; default to 0
+ readmem: type_addr: 1, addr:ffffffff85411858, size:8
+ __vtop4_x86_64: Can't get pgd (page_dir:ffffffff85411858).
+ readmem: Can't convert a virtual address(ffffffff059be980) to physical address.
+ readmem: type_addr: 0, addr:ffffffff059be980, size:1024
+ cpu_online_mask_init: Can't read cpu_online_mask memory.
+
+ makedumpfile Failed.
+
+This is caused by the kernel commit 9d06c4027f21 ("x86/entry: Convert
+Divide Error to IDTENTRY") that renamed divide_error to
+asm_exc_divide_error, breaking logic for calculating kaslr offset.
+
+Fix this by adding initialization of asm_exc_divide_error.
+
+Signed-off-by: HATAYAMA Daisuke <d.hatayama(a)fujitsu.com>
+---
+ makedumpfile.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/makedumpfile-1.7.0/makedumpfile.c b/makedumpfile-1.7.0/makedumpfile.c
+index a51bdaf..7ed9756 100644
+--- a/makedumpfile-1.7.0/makedumpfile.c
++++ b/makedumpfile-1.7.0/makedumpfile.c
+@@ -1667,6 +1667,8 @@ get_symbol_info(void)
+ SYMBOL_INIT(cur_cpu_spec, "cur_cpu_spec");
+
+ SYMBOL_INIT(divide_error, "divide_error");
++ if (SYMBOL(divide_error) == NOT_FOUND_SYMBOL)
++ SYMBOL_INIT(divide_error, "asm_exc_divide_error");
+ SYMBOL_INIT(idt_table, "idt_table");
+ SYMBOL_INIT(saved_command_line, "saved_command_line");
+ SYMBOL_INIT(pti_init, "pti_init");
+--
+2.33.1
+
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 6b7ef14..182662e 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -112,6 +112,7 @@ Patch401: ./kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machi
#
# Patches 601 onward are generic patches
#
+Patch601: ./kexec-tools-2.0.23-makedumpfile-sadump-kaslr-fix-failure-of-calculating-kaslr_.patch
%description
kexec-tools provides /sbin/kexec binary that facilitates a new
@@ -128,6 +129,7 @@ tar -z -x -v -f %{SOURCE9}
tar -z -x -v -f %{SOURCE19}
%patch401 -p1
+%patch601 -p1
%ifarch ppc
%define archdef ARCH=ppc
--
2.33.1
1 year, 3 months