[PATCH v2 3/6] crashdump: setup hotplug support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 buffer containing the:
 - elfcorehdr must be excluded from the purgatory checksum/digest
   (see "crashdump: exclude elfcorehdr segment from digest for
   hotplug")
 - the elfcorehdr segment must be large enough, and
 - the kernel must be permitted to modify the elfcorehdr

For hotplug, the size of the elfcorehdr segment is obtained from the
kernel, or from the command line option.

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@xxxxxxxxxx>
---
 kexec/kexec.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index 4a64e53..c59e795 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -1626,6 +1626,28 @@ 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";
+		if (!elfcorehdrsz) {
+			unsigned long ul;
+			char *buf;
+			off_t nread = 0;
+			buf = slurp_file_len(ces, sizeof(buf)-1, &nread);
+			if (buf) {
+			    ul = strtoul(buf, NULL, 0);
+				elfcorehdrsz = ul;
+			}
+		}
+		if (!elfcorehdrsz) {
+			die("If path %s does not exist, must specify the\n"
+				"--elfcorehdrsz= option\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;
-- 
2.31.1


_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux