Thread (11 messages) flat view 11 messages, 2 authors, 2022-06-22
STALE1512d

Revision v5 of 4 in this series.

Revisions (4)
  1. v5 current
  2. v5 [diff vs current]
  3. v7 [diff vs current]
  4. v8 [diff vs current]

[PATCH v5 4/5] powerpc/crash hp: add crash hotplug support for kexec_load

From: Sourabh Jain <hidden>
Date: 2022-06-20 07:04:56
Also in: kexec
Subsystem: linux for powerpc (32-bit and 64-bit), the rest · Maintainers: Madhavan Srinivasan, Linus Torvalds

A common crash hotplug handler is used for both kexec_load and
kexec_file_load, which is already implemented in earlier patches while
adding support for kexec_file_load.

To enable the crash hotplug handler to work for kexec_load case the
fdt_index attribute of kimage_arch needs to be populated with index of
FDT segment in kexec segment array.

After loading kexec segments the FDT segment is identified by looping
through all the kexec segments and fdt_index is updated accordingly.

Signed-off-by: Sourabh Jain <redacted>
---
 arch/powerpc/kexec/core_64.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
index 6d448b55dfad..373cb46bcc0e 100644
--- a/arch/powerpc/kexec/core_64.c
+++ b/arch/powerpc/kexec/core_64.c
@@ -74,6 +74,31 @@ int machine_kexec_prepare(struct kimage *image)
 	return 0;
 }
 
+#if defined(CONFIG_HOTPLUG_CPU)
+int machine_kexec_post_load(struct kimage *kimage)
+{
+	int i;
+	void *ptr;
+	unsigned long mem;
+
+	if (kimage->type != KEXEC_TYPE_CRASH)
+		return 0;
+
+	/* Mark fdt_index invalid */
+	kimage->arch.fdt_index = -1;
+
+	for (i = 0; i < kimage->nr_segments; i++) {
+		mem = kimage->segment[i].mem;
+		ptr = __va(mem);
+
+		if (ptr && fdt_magic(ptr) == FDT_MAGIC)
+			kimage->arch.fdt_index = i;
+	}
+
+	return 0;
+}
+#endif
+
 /* Called during kexec sequence with MMU off */
 static notrace void copy_segments(unsigned long ind)
 {
-- 
2.36.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help