[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] dracut-module-setup.sh: Don't use squash module for fadump
by Kairui Song
Squash module is used to save memory. For fadump this is not neccessary
and may slow down the build time, and make it more fragile.
fadump initramfs is used for normal boot as well, although squash module
is capable of being used for generic normal boot, but there are cases
where is doesn't work well. So disable it and make fadump more robust.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
dracut-module-setup.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 2998c72..5222040 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -30,7 +30,7 @@ depends() {
done
}
- if is_squash_available; then
+ if is_squash_available && ! is_fadump_capable; then
_dep="$_dep squash"
else
dwarning "Required modules to build a squashed kdump image is missing!"
--
2.21.0
3 years, 10 months
[PATCH] Forward logs in kdump kernel to console directly
by Kairui Song
Don't use any log storage and forward to console directly, this make
console output more useful, and also save more memory. On a fresh
installed Fedora 30 it saved ~5M of memory, and the amount of log being
printed to console is still acceptable.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
dracut-module-setup.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 5222040..27b9f02 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -822,4 +822,11 @@ install() {
echo "[Manager]" > ${initdir}/etc/systemd/system.conf.d/kdump.conf
echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf
fi
+
+ # Forward logs to console directly, this avoids unneccessary memory
+ # consumption and make console output more useful
+ mkdir -p ${initdir}/etc/systemd/journald.conf.d
+ echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf
+ echo "Storage=none" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
+ echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
}
--
2.21.0
3 years, 10 months
[PATCH] kexec/x86: Always try to fill acpi_rsdp_addr in boot params
by Kairui Song
This patch sync the behavior of user space kexec and kexec_file_load,
they will both fill the boot_params.acpi_rsdp_addr with a valid RSDP
value, to make sure second kernel can always get the RSDP consistently.
This will make it effortless to boot newer version of kernel (5.0+)
without specifying acpi_rsdp= cmdline on EFI system even with EFI
service disabled. Should not change any behavior with older kernels.
Backport the following commits from upstream:
commit 40805e393b2fc84551a6705e1890e995e3ee8320
Author: Kairui Song <kasong(a)redhat.com>
crashdump/x86: Use new introduce helper for getting RSDP
commit b071fc084bdafd4674cd776581cab2bf2b44a004
Author: Kairui Song <kasong(a)redhat.com>
x86: Always try to fill acpi_rsdp_addr in boot params
commit cedeee0a30075030632a18e419419371ddf3fca3
Author: Kairui Song <kasong(a)redhat.com>
x86: Introduce helpers for getting RSDP address
commit 402351390f31b2db0768eef4ced375d00bff9e17
Author: Kairui Song <kasong(a)redhat.com>
x86: Update boot parameters defination
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
...o-fill-acpi_rsdp_addr-in-boot-params.patch | 272 ++++++++++++++++++
kexec-tools.spec | 4 +-
2 files changed, 275 insertions(+), 1 deletion(-)
create mode 100644 kexec-tools-2.0.19-always-try-to-fill-acpi_rsdp_addr-in-boot-params.patch
diff --git a/kexec-tools-2.0.19-always-try-to-fill-acpi_rsdp_addr-in-boot-params.patch b/kexec-tools-2.0.19-always-try-to-fill-acpi_rsdp_addr-in-boot-params.patch
new file mode 100644
index 0000000..c9f6459
--- /dev/null
+++ b/kexec-tools-2.0.19-always-try-to-fill-acpi_rsdp_addr-in-boot-params.patch
@@ -0,0 +1,272 @@
+From f9bfb3d112ee4ba7566bc07d744cb356e4383254 Mon Sep 17 00:00:00 2001
+From: Kairui Song <kasong(a)redhat.com>
+Date: Fri, 24 May 2019 14:23:18 +0800
+Subject: [PATCH] x86: Always try to fill acpi_rsdp_addr in boot params
+
+This is squash of following commits:
+
+commit 40805e393b2fc84551a6705e1890e995e3ee8320
+Author: Kairui Song <kasong(a)redhat.com>
+Date: Fri May 24 14:23:21 2019 +0800
+
+ crashdump/x86: Use new introduce helper for getting RSDP
+
+ Use the new introduce helper for getting RSDP, this ensures RSDP is
+ always accessible and avoid code duplication.
+
+ Signed-off-by: Kairui Song <kasong(a)redhat.com>
+ Signed-off-by: Simon Horman <horms(a)verge.net.au>
+
+commit b071fc084bdafd4674cd776581cab2bf2b44a004
+Author: Kairui Song <kasong(a)redhat.com>
+Date: Fri May 24 14:23:20 2019 +0800
+
+ x86: Always try to fill acpi_rsdp_addr in boot params
+
+ Since kernel commit e6e094e053af75 ("x86/acpi, x86/boot: Take RSDP address
+ from boot params if available"), kernel accept an acpi_rsdp_addr param in
+ boot_params. So fill in this parameter unconditionally, ensure second
+ kernel always get the right RSDP address consistently, and boot well on
+ EFI system even with EFI service disabled. User no longer need to change
+ the kernel cmdline to workaround the missing RSDP issue.
+
+ For older version of kernels (Before 5.0), there won't be any change of
+ behavior.
+
+ Signed-off-by: Kairui Song <kasong(a)redhat.com>
+ Signed-off-by: Simon Horman <horms(a)verge.net.au>
+
+commit cedeee0a30075030632a18e419419371ddf3fca3
+Author: Kairui Song <kasong(a)redhat.com>
+Date: Fri May 24 14:23:19 2019 +0800
+
+ x86: Introduce helpers for getting RSDP address
+
+ On x86 RSDP is fundamental for booting the machine. When second kernel
+ is incapable of parsing the RSDP address (eg. kexec next kernel on an EFI
+ system with EFI service disabled), kexec should prepare the RSDP address
+ for second kernel.
+
+ Introduce helpers for getting RSDP from multiple sources, including boot
+ params and EFI firmware.
+
+ For legacy BIOS interface, there is no better way to find the RSDP address
+ rather than scanning the memory region and search for it, and this will
+ always be done by the kernel as a fallback, so this is no need to try to
+ get the RSDP address for that case.
+
+ Signed-off-by: Kairui Song <kasong(a)redhat.com>
+ Signed-off-by: Simon Horman <horms(a)verge.net.au>
+
+commit 402351390f31b2db0768eef4ced375d00bff9e17
+Author: Kairui Song <kasong(a)redhat.com>
+Date: Fri May 24 14:23:18 2019 +0800
+
+ x86: Update boot parameters defination
+
+ Since kernel commit e6e094e053af75 ("x86/acpi, x86/boot: Take RSDP address
+ from boot params if available"), kernel accept a acpi_rsdp_addr param in
+ boot_params. Sync the x86_linux_param_header to support this param.
+
+ Signed-off-by: Kairui Song <kasong(a)redhat.com>
+ Signed-off-by: Simon Horman <horms(a)verge.net.au>
+---
+ include/x86/x86-linux.h | 6 +++--
+ kexec/arch/i386/crashdump-x86.c | 34 +++++++----------------
+ kexec/arch/i386/kexec-x86-common.c | 43 ++++++++++++++++++++++++++++++
+ kexec/arch/i386/kexec-x86.h | 1 +
+ kexec/arch/i386/x86-linux-setup.c | 6 +++--
+ kexec/arch/i386/x86-linux-setup.h | 1 +
+ 6 files changed, 62 insertions(+), 29 deletions(-)
+
+diff --git a/include/x86/x86-linux.h b/include/x86/x86-linux.h
+index 352ea02..9646102 100644
+--- a/include/x86/x86-linux.h
++++ b/include/x86/x86-linux.h
+@@ -45,7 +45,6 @@ struct apm_bios_info {
+ uint16_t cseg_len; /* 0x4e */
+ uint16_t cseg_16_len; /* 0x50 */
+ uint16_t dseg_len; /* 0x52 */
+- uint8_t reserved[44]; /* 0x54 */
+ };
+
+ /*
+@@ -113,12 +112,15 @@ struct x86_linux_param_header {
+ uint8_t reserved4[2]; /* 0x3e -- 0x3f reserved for future expansion */
+
+ struct apm_bios_info apm_bios_info; /* 0x40 */
++ uint8_t reserved4_1[28]; /* 0x54 */
++ uint64_t acpi_rsdp_addr; /* 0x70 */
++ uint8_t reserved4_2[8]; /* 0x78 */
+ struct drive_info_struct drive_info; /* 0x80 */
+ struct sys_desc_table sys_desc_table; /* 0xa0 */
+ uint32_t ext_ramdisk_image; /* 0xc0 */
+ uint32_t ext_ramdisk_size; /* 0xc4 */
+ uint32_t ext_cmd_line_ptr; /* 0xc8 */
+- uint8_t reserved4_1[0x1c0 - 0xcc]; /* 0xe4 */
++ uint8_t reserved4_3[0x1c0 - 0xcc]; /* 0xe4 */
+ uint8_t efi_info[32]; /* 0x1c0 */
+ uint32_t alt_mem_k; /* 0x1e0 */
+ uint8_t reserved5[4]; /* 0x1e4 */
+diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
+index 140f45b..a2aea31 100644
+--- a/kexec/arch/i386/crashdump-x86.c
++++ b/kexec/arch/i386/crashdump-x86.c
+@@ -787,35 +787,19 @@ static int sysfs_efi_runtime_map_exist(void)
+ /* Appends 'acpi_rsdp=' commandline for efi boot crash dump */
+ static void cmdline_add_efi(char *cmdline)
+ {
+- FILE *fp;
+- int cmdlen, len;
+- char line[MAX_LINE], *s;
+- const char *acpis = " acpi_rsdp=";
++ uint64_t acpi_rsdp;
++ char acpi_rsdp_buf[MAX_LINE];
+
+- fp = fopen("/sys/firmware/efi/systab", "r");
+- if (!fp)
+- return;
++ acpi_rsdp = get_acpi_rsdp();
+
+- while(fgets(line, sizeof(line), fp) != 0) {
+- /* ACPI20= always goes before ACPI= */
+- if ((strstr(line, "ACPI20=")) || (strstr(line, "ACPI="))) {
+- line[strlen(line) - 1] = '\0';
+- s = strchr(line, '=');
+- s += 1;
+- len = strlen(s) + strlen(acpis);
+- cmdlen = strlen(cmdline) + len;
+- if (cmdlen > (COMMAND_LINE_SIZE - 1))
+- die("Command line overflow\n");
+- strcat(cmdline, acpis);
+- strcat(cmdline, s);
+- dbgprintf("Command line after adding efi\n");
+- dbgprintf("%s\n", cmdline);
++ if (!acpi_rsdp)
++ return;
+
+- break;
+- }
+- }
++ sprintf(acpi_rsdp_buf, " acpi_rsdp=0x%lx", acpi_rsdp);
++ if (strlen(cmdline) + strlen(acpi_rsdp_buf) > (COMMAND_LINE_SIZE - 1))
++ die("Command line overflow\n");
+
+- fclose(fp);
++ strcat(cmdline, acpi_rsdp_buf);
+ }
+
+ static void get_backup_area(struct kexec_info *info,
+diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
+index de99758..5c55ec8 100644
+--- a/kexec/arch/i386/kexec-x86-common.c
++++ b/kexec/arch/i386/kexec-x86-common.c
+@@ -39,6 +39,7 @@
+ #include "../../firmware_memmap.h"
+ #include "../../crashdump.h"
+ #include "kexec-x86.h"
++#include "x86-linux-setup.h"
+ #include "../../kexec-xen.h"
+
+ /* Used below but not present in (older?) xenctrl.h */
+@@ -392,4 +393,46 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
+ return ret;
+ }
+
++static uint64_t bootparam_get_acpi_rsdp(void) {
++ uint64_t acpi_rsdp = 0;
++ off_t offset = offsetof(struct x86_linux_param_header, acpi_rsdp_addr);
+
++ if (get_bootparam(&acpi_rsdp, offset, sizeof(acpi_rsdp)))
++ return 0;
++
++ return acpi_rsdp;
++}
++
++static uint64_t efi_get_acpi_rsdp(void) {
++ FILE *fp;
++ char line[MAX_LINE], *s;
++ uint64_t acpi_rsdp = 0;
++
++ fp = fopen("/sys/firmware/efi/systab", "r");
++ if (!fp)
++ return acpi_rsdp;
++
++ while(fgets(line, sizeof(line), fp) != 0) {
++ /* ACPI20= always goes before ACPI= */
++ if ((strstr(line, "ACPI20=")) || (strstr(line, "ACPI="))) {
++ s = strchr(line, '=') + 1;
++ sscanf(s, "0x%lx", &acpi_rsdp);
++ break;
++ }
++ }
++ fclose(fp);
++
++ return acpi_rsdp;
++}
++
++uint64_t get_acpi_rsdp(void)
++{
++ uint64_t acpi_rsdp = 0;
++
++ acpi_rsdp = bootparam_get_acpi_rsdp();
++
++ if (!acpi_rsdp)
++ acpi_rsdp = efi_get_acpi_rsdp();
++
++ return acpi_rsdp;
++}
+diff --git a/kexec/arch/i386/kexec-x86.h b/kexec/arch/i386/kexec-x86.h
+index c2bcd37..1b58c3b 100644
+--- a/kexec/arch/i386/kexec-x86.h
++++ b/kexec/arch/i386/kexec-x86.h
+@@ -86,4 +86,5 @@ int nbi_load(int argc, char **argv, const char *buf, off_t len,
+ void nbi_usage(void);
+
+ extern unsigned xen_e820_to_kexec_type(uint32_t type);
++extern uint64_t get_acpi_rsdp(void);
+ #endif /* KEXEC_X86_H */
+diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
+index b643c8b..057ee14 100644
+--- a/kexec/arch/i386/x86-linux-setup.c
++++ b/kexec/arch/i386/x86-linux-setup.c
+@@ -123,7 +123,6 @@ void setup_linux_bootloader_parameters_high(
+ cmdline_ptr[cmdline_len - 1] = '\0';
+ }
+
+-static int get_bootparam(void *buf, off_t offset, size_t size);
+ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
+ {
+ struct fb_fix_screeninfo fix;
+@@ -460,7 +459,7 @@ char *find_mnt_by_type(char *type)
+ return mntdir;
+ }
+
+-static int get_bootparam(void *buf, off_t offset, size_t size)
++int get_bootparam(void *buf, off_t offset, size_t size)
+ {
+ int data_file;
+ char *debugfs_mnt, *sysfs_mnt;
+@@ -910,4 +909,7 @@ void setup_linux_system_parameters(struct kexec_info *info,
+
+ /* fill the EDD information */
+ setup_edd_info(real_mode);
++
++ /* Always try to fill acpi_rsdp_addr */
++ real_mode->acpi_rsdp_addr = get_acpi_rsdp();
+ }
+diff --git a/kexec/arch/i386/x86-linux-setup.h b/kexec/arch/i386/x86-linux-setup.h
+index f5d23d3..0c651e5 100644
+--- a/kexec/arch/i386/x86-linux-setup.h
++++ b/kexec/arch/i386/x86-linux-setup.h
+@@ -21,6 +21,7 @@ static inline void setup_linux_bootloader_parameters(
+ }
+ void setup_linux_system_parameters(struct kexec_info *info,
+ struct x86_linux_param_header *real_mode);
++int get_bootparam(void *buf, off_t offset, size_t size);
+
+
+ #define SETUP_BASE 0x90000
+--
+2.21.0
+
diff --git a/kexec-tools.spec b/kexec-tools.spec
index b642543..5a050e8 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -76,6 +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-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch
+Patch102: kexec-tools-2.0.19-always-try-to-fill-acpi_rsdp_addr-in-boot-params.patch
#
# Patches 301 through 400 are meant for ppc64 kexec-tools enablement
@@ -107,8 +108,9 @@ mkdir -p -m755 kcp
tar -z -x -v -f %{SOURCE9}
tar -z -x -v -f %{SOURCE19}
-%patch601 -p1
%patch101 -p1
+%patch102 -p1
+%patch601 -p1
%ifarch ppc
%define archdef ARCH=ppc
--
2.21.0
3 years, 11 months
[PATCH] Run kdump capture service before initrd-parse-etc.service
by Hari Bathini
In FADump mode, when the dump targer is '/home', regular boot is failing
with logs like below:
Starting Reload Configuration from the Real Root...
[ 3.289716] EXT4-fs (dm-1): mounted filesystem with ordered data mode. Opts: (null)
[FAILED] Failed to mount /kdumproot/home.
See 'systemctl status kdumproot-home.mount' for details.
[DEPEND] Dependency failed for Local File Systems.
[ OK ] Stopped dracut pre-udev hook.
[ OK ] Stopped dracut initqueue hook.
Starting Kdump Emergency...
[ OK ] Stopped dracut cmdline hook.
[ OK ] Stopped dracut ask for additional cmdline parameters.
Starting Setup Virtual Console...
Starting Create Volatile Files and Directories...
[ OK ] Started Cleanup squashfs mounts when switch root.
[ OK ] Started Kdump Emergency.
and eventually ending up in emergency mode. 'kdumproot/home' seems to
be mounted successfully though. 'Reload from real root' is altering the
dependency graph leading to this mess. Updated kdump-capture.service
unit file to run before initrd-parse-etc.service to avoid running into
such problems. While here, dropped the deprecated 'OnFailureIsolate'
in favour of 'OnFailureJobMode'. Tested this change successfully in both
KDump and FADump modes with different dump methods (local, ssh, nfs).
Signed-off-by: Hari Bathini <hbathini(a)linux.ibm.com>
---
dracut-kdump-capture.service | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/dracut-kdump-capture.service b/dracut-kdump-capture.service
index 57139c9..df4a437 100644
--- a/dracut-kdump-capture.service
+++ b/dracut-kdump-capture.service
@@ -7,12 +7,11 @@
[Unit]
Description=Kdump Vmcore Save Service
-After=initrd.target initrd-parse-etc.service sysroot.mount
-After=dracut-initqueue.service dracut-pre-mount.service dracut-mount.service dracut-pre-pivot.service
-Before=initrd-cleanup.service
+After=initrd-root-fs.target remote-fs.target
+Before=initrd-parse-etc.service
ConditionPathExists=/etc/initrd-release
OnFailure=emergency.target
-OnFailureIsolate=yes
+OnFailureJobMode=isolate
[Service]
Environment=DRACUT_SYSTEMD=1
3 years, 11 months
[PATCH] dracut-kdump-capture.service: Use OnFailureJobMode= instead of deprecated OnFailureIsolate
by Pingfan Liu
systemd has the following message "OnFailureIsolate is deprecated. Please
use OnFailureJobMode= instead"
Changing the file to meet systemd's requirement
Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
---
dracut-kdump-capture.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dracut-kdump-capture.service b/dracut-kdump-capture.service
index 57139c9..3f20aba 100644
--- a/dracut-kdump-capture.service
+++ b/dracut-kdump-capture.service
@@ -12,7 +12,7 @@ After=dracut-initqueue.service dracut-pre-mount.service dracut-mount.service dra
Before=initrd-cleanup.service
ConditionPathExists=/etc/initrd-release
OnFailure=emergency.target
-OnFailureIsolate=yes
+OnFailureJobMode=isolate
[Service]
Environment=DRACUT_SYSTEMD=1
--
2.7.5
3 years, 12 months
[PATCH] makedumpfile: x86_64: Add support for AMD Secure Memory Encryption
by Lianbo Jiang
Backport from the makedumpfile devel branch in upstream.
commit d222b01e516bba73ef9fefee4146734a5f260fa1 (HEAD -> devel)
Author: Lianbo Jiang <lijiang(a)redhat.com>
Date: Wed Jan 30 10:48:53 2019 +0800
[PATCH] x86_64: Add support for AMD Secure Memory Encryption
On AMD machine with Secure Memory Encryption (SME) feature, if SME is
enabled, page tables contain a specific attribute bit (C-bit) in their
entries to indicate whether a page is encrypted or unencrypted.
So get NUMBER(sme_mask) from vmcoreinfo, which stores the value of
the C-bit position, and drop it to obtain the true physical address.
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
...-support-for-AMD-Secure-Memory-Encry.patch | 198 ++++++++++++++++++
kexec-tools.spec | 2 +
2 files changed, 200 insertions(+)
create mode 100644 kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch
diff --git a/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch b/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch
new file mode 100644
index 000000000000..662fd27a8e85
--- /dev/null
+++ b/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch
@@ -0,0 +1,198 @@
+From d222b01e516bba73ef9fefee4146734a5f260fa1 Mon Sep 17 00:00:00 2001
+From: Lianbo Jiang <lijiang(a)redhat.com>
+Date: Wed, 30 Jan 2019 10:48:53 +0800
+Subject: [PATCH] [PATCH] x86_64: Add support for AMD Secure Memory Encryption
+
+On AMD machine with Secure Memory Encryption (SME) feature, if SME is
+enabled, page tables contain a specific attribute bit (C-bit) in their
+entries to indicate whether a page is encrypted or unencrypted.
+
+So get NUMBER(sme_mask) from vmcoreinfo, which stores the value of
+the C-bit position, and drop it to obtain the true physical address.
+
+Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
+---
+ arch/x86_64.c | 30 +++++++++++++++++++-----------
+ makedumpfile.c | 4 ++++
+ makedumpfile.h | 1 +
+ 3 files changed, 24 insertions(+), 11 deletions(-)
+
+diff --git a/arch/x86_64.c b/arch/x86_64.c
+index 9db1f8139f28..46e93366f0be 100644
+--- a/makedumpfile-1.6.5/arch/x86_64.c
++++ b/makedumpfile-1.6.5/arch/x86_64.c
+@@ -297,6 +297,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
+ unsigned long page_dir, pgd, pud_paddr, pud_pte, pmd_paddr, pmd_pte;
+ unsigned long pte_paddr, pte;
+ unsigned long p4d_paddr, p4d_pte;
++ unsigned long entry_mask = ENTRY_MASK;
+
+ /*
+ * Get PGD.
+@@ -308,6 +309,9 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
+ return NOT_PADDR;
+ }
+
++ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER)
++ entry_mask &= ~(NUMBER(sme_mask));
++
+ if (check_5level_paging()) {
+ page_dir += pgd5_index(vaddr) * sizeof(unsigned long);
+ if (!readmem(PADDR, page_dir, &pgd, sizeof pgd)) {
+@@ -324,7 +328,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
+ /*
+ * Get P4D.
+ */
+- p4d_paddr = pgd & ENTRY_MASK;
++ p4d_paddr = pgd & entry_mask;
+ p4d_paddr += p4d_index(vaddr) * sizeof(unsigned long);
+ if (!readmem(PADDR, p4d_paddr, &p4d_pte, sizeof p4d_pte)) {
+ ERRMSG("Can't get p4d_pte (p4d_paddr:%lx).\n", p4d_paddr);
+@@ -337,7 +341,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
+ ERRMSG("Can't get a valid p4d_pte.\n");
+ return NOT_PADDR;
+ }
+- pud_paddr = p4d_pte & ENTRY_MASK;
++ pud_paddr = p4d_pte & entry_mask;
+ }else {
+ page_dir += pgd_index(vaddr) * sizeof(unsigned long);
+ if (!readmem(PADDR, page_dir, &pgd, sizeof pgd)) {
+@@ -351,7 +355,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
+ ERRMSG("Can't get a valid pgd.\n");
+ return NOT_PADDR;
+ }
+- pud_paddr = pgd & ENTRY_MASK;
++ pud_paddr = pgd & entry_mask;
+ }
+
+ /*
+@@ -370,13 +374,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
+ return NOT_PADDR;
+ }
+ if (pud_pte & _PAGE_PSE) /* 1GB pages */
+- return (pud_pte & ENTRY_MASK & PUD_MASK) +
++ return (pud_pte & entry_mask & PUD_MASK) +
+ (vaddr & ~PUD_MASK);
+
+ /*
+ * Get PMD.
+ */
+- pmd_paddr = pud_pte & ENTRY_MASK;
++ pmd_paddr = pud_pte & entry_mask;
+ pmd_paddr += pmd_index(vaddr) * sizeof(unsigned long);
+ if (!readmem(PADDR, pmd_paddr, &pmd_pte, sizeof pmd_pte)) {
+ ERRMSG("Can't get pmd_pte (pmd_paddr:%lx).\n", pmd_paddr);
+@@ -390,13 +394,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
+ return NOT_PADDR;
+ }
+ if (pmd_pte & _PAGE_PSE) /* 2MB pages */
+- return (pmd_pte & ENTRY_MASK & PMD_MASK) +
++ return (pmd_pte & entry_mask & PMD_MASK) +
+ (vaddr & ~PMD_MASK);
+
+ /*
+ * Get PTE.
+ */
+- pte_paddr = pmd_pte & ENTRY_MASK;
++ pte_paddr = pmd_pte & entry_mask;
+ pte_paddr += pte_index(vaddr) * sizeof(unsigned long);
+ if (!readmem(PADDR, pte_paddr, &pte, sizeof pte)) {
+ ERRMSG("Can't get pte (pte_paddr:%lx).\n", pte_paddr);
+@@ -409,7 +413,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
+ ERRMSG("Can't get a valid pte.\n");
+ return NOT_PADDR;
+ }
+- return (pte & ENTRY_MASK) + PAGEOFFSET(vaddr);
++ return (pte & entry_mask) + PAGEOFFSET(vaddr);
+ }
+
+ unsigned long long
+@@ -642,6 +646,7 @@ find_vmemmap_x86_64()
+ unsigned long pmd, tpfn;
+ unsigned long pvaddr = 0;
+ unsigned long data_addr = 0, last_data_addr = 0, start_data_addr = 0;
++ unsigned long pmask = PMASK;
+ /*
+ * data_addr is the paddr of the page holding the page structs.
+ * We keep lists of contiguous pages and the pfn's that their
+@@ -662,6 +667,9 @@ find_vmemmap_x86_64()
+ return FAILED;
+ }
+
++ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER)
++ pmask &= ~(NUMBER(sme_mask));
++
+ pagestructsize = size_table.page;
+ hugepagesize = PTRS_PER_PMD * info->page_size;
+ vaddr_base = info->vmemmap_start;
+@@ -692,7 +700,7 @@ find_vmemmap_x86_64()
+ }
+
+ /* mask the pgd entry for the address of the pud page */
+- pud_addr &= PMASK;
++ pud_addr &= pmask;
+ if (pud_addr == 0)
+ continue;
+ /* read the entire pud page */
+@@ -705,7 +713,7 @@ find_vmemmap_x86_64()
+ /* pudp points to an entry in the pud page */
+ for (pudp = (unsigned long *)pud_page, pudindex = 0;
+ pudindex < PTRS_PER_PUD; pudindex++, pudp++) {
+- pmd_addr = *pudp & PMASK;
++ pmd_addr = *pudp & pmask;
+ /* read the entire pmd page */
+ if (pmd_addr == 0)
+ continue;
+@@ -747,7 +755,7 @@ find_vmemmap_x86_64()
+ * - we discontiguous page is a string of valids
+ */
+ if (pmd) {
+- data_addr = (pmd & PMASK);
++ data_addr = (pmd & pmask);
+ if (start_range) {
+ /* first-time kludge */
+ start_data_addr = data_addr;
+diff --git a/makedumpfile.c b/makedumpfile.c
+index 7dfe70fb8792..590f759c84f1 100644
+--- a/makedumpfile-1.6.5/makedumpfile.c
++++ b/makedumpfile-1.6.5/makedumpfile.c
+@@ -993,6 +993,8 @@ next_page:
+ read_size = MIN(info->page_size - PAGEOFFSET(paddr), size);
+
+ pgaddr = PAGEBASE(paddr);
++ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER)
++ pgaddr = pgaddr & ~(NUMBER(sme_mask));
+ pgbuf = cache_search(pgaddr, read_size);
+ if (!pgbuf) {
+ ++cache_miss;
+@@ -2292,6 +2294,7 @@ write_vmcoreinfo_data(void)
+ WRITE_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES);
+ WRITE_NUMBER("N_ONLINE", N_ONLINE);
+ WRITE_NUMBER("pgtable_l5_enabled", pgtable_l5_enabled);
++ WRITE_NUMBER("sme_mask", sme_mask);
+
+ WRITE_NUMBER("PG_lru", PG_lru);
+ WRITE_NUMBER("PG_private", PG_private);
+@@ -2695,6 +2698,7 @@ read_vmcoreinfo(void)
+ READ_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES);
+ READ_NUMBER("N_ONLINE", N_ONLINE);
+ READ_NUMBER("pgtable_l5_enabled", pgtable_l5_enabled);
++ READ_NUMBER("sme_mask", sme_mask);
+
+ READ_NUMBER("PG_lru", PG_lru);
+ READ_NUMBER("PG_private", PG_private);
+diff --git a/makedumpfile.h b/makedumpfile.h
+index 2e73beca48c5..5ad38e9ae40c 100644
+--- a/makedumpfile-1.6.5/makedumpfile.h
++++ b/makedumpfile-1.6.5/makedumpfile.h
+@@ -1913,6 +1913,7 @@ struct number_table {
+ long NR_FREE_PAGES;
+ long N_ONLINE;
+ long pgtable_l5_enabled;
++ long sme_mask;
+
+ /*
+ * Page flags
+--
+2.17.1
+
diff --git a/kexec-tools.spec b/kexec-tools.spec
index b19b5342df24..b6425433e0af 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -75,6 +75,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-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch
#
# Patches 301 through 400 are meant for ppc64 kexec-tools enablement
@@ -107,6 +108,7 @@ tar -z -x -v -f %{SOURCE9}
tar -z -x -v -f %{SOURCE19}
%patch601 -p1
+%patch101 -p1
%ifarch ppc
%define archdef ARCH=ppc
--
2.17.1
3 years, 12 months