summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric DeVolder <eric.devolder@oracle.com>2023-09-27 14:11:33 -0400
committerSimon Horman <horms@kernel.org>2023-10-04 14:04:02 +0200
commit75ac71fd94fff254cc86b31c55d5f75dda423ea3 (patch)
tree86b1544925a30417449d03ad4b90d2e3068bd4cc
parentd6cfd298484451508817757b3d75820ea1f7d919 (diff)
downloadkexec-tools-75ac71fd94fff254cc86b31c55d5f75dda423ea3.tar.gz
crashdump: setup general hotplug support
To allow direct modification of the elfcorehdr by the kernel, in response to CPU and memory hot un/plug and/or online/offline events, the following conditions must occur: - the elfcorehdr buffer must be excluded from the purgatory checksum/digest, and - the elfcorehdr segment must be large enough, and - the kernel must be notified that it can modify the elfcorehdr Excluding the elfcorehdr buffer from the digest occurs in patch "crashdump: exclude elfcorehdr segment from digest for hotplug". If this is not done, a change to the elfcorehdr will cause the purgatory check at panic time to fail, and kdump capture kernel does not start. For hotplug, the size of the elfcorehdr segment is obtained from the kernel via the /sys/kernel/crash_elforehdr_size node. The KEXEC_UPDATE_ELFCOREHDR flag indicates to the kernel that it can make direct modifications to the elfcorehdr. Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Signed-off-by: Simon Horman <horms@kernel.org>
-rw-r--r--kexec/kexec.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/kexec/kexec.c b/kexec/kexec.c
index d7907488..02076081 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -1631,6 +1631,24 @@ int main(int argc, char *argv[])
die("--load-live-update can only be used with xen\n");
}
+ /* NOTE: Xen KEXEC_LIVE_UPDATE and KEXEC_UPDATE_ELFCOREHDR collide */
+ if (do_hotplug) {
+ const char *ces = "/sys/kernel/crash_elfcorehdr_size";
+ char *buf, *endptr = NULL;
+ off_t nread = 0;
+ buf = slurp_file_len(ces, sizeof(buf)-1, &nread);
+ if (buf) {
+ if (buf[nread-1] == '\n')
+ buf[nread-1] = '\0';
+ elfcorehdrsz = strtoul(buf, &endptr, 0);
+ }
+ if (!elfcorehdrsz || (endptr && *endptr != '\0'))
+ die("Path %s does not exist, the kernel needs CONFIG_CRASH_HOTPLUG\n", ces);
+ dbgprintf("ELFCOREHDR_SIZE %lu\n", elfcorehdrsz);
+ /* Indicate to the kernel it is ok to modify the elfcorehdr */
+ kexec_flags |= KEXEC_UPDATE_ELFCOREHDR;
+ }
+
fileind = optind;
/* Reset getopt for the next pass; called in other source modules */
opterr = 1;