@@ -2078,6 +2078,14 @@ config KEXEC_FILE_FDT
This option enables passing existent Flattened Device Tree to the new
kernel when kexec is invoked by the file based system call.
+config KEXEC_FILE_FDT_CALLBACK
+ bool "Enable kexec fdt modification support"
+ depends on KEXEC_FILE_FDT
+ select LIBFDT
+ help
+ This option enables Flattened Device Tree modification (and creation
+ if needed) by kernel subsystems, registered corresponding callback.
+
config ARCH_HAS_KEXEC_PURGATORY
def_bool KEXEC_FILE
@@ -384,11 +384,50 @@ static int bzImage64_probe(const char *buf, unsigned long len)
return ret;
}
#ifdef CONFIG_KEXEC_FILE_FDT
+#ifdef CONFIG_KEXEC_FILE_FDT_CALLBACK
+static void *fdt_get_runtime(void)
+{
+ void *fdt;
+ size_t fdt_size = SZ_2M;
+ int status;
+
+ /* It's nothing to do without existent fdt and any callbacks */
+ if (!initial_boot_params && kexec_fdt_notify_list_empty())
+ return NULL;
+
+ fdt = kzalloc(fdt_size, GFP_KERNEL);
+ if (!fdt)
+ return NULL;
+
+ if (initial_boot_params)
+ status = fdt_open_into(initial_boot_params, fdt, fdt_size);
+ else
+ status = fdt_create_empty_tree(fdt, fdt_size);
+ if (status != 0) {
+ pr_err("failed to get fdt\n");
+ goto free_fdt;
+ }
+
+ status = kexec_fdt_notify(fdt);
+ if (status) {
+ pr_err("fdt notification failed\n");
+ goto free_fdt;
+ }
+
+ fdt_pack(fdt);
+
+ return fdt;
+
+free_fdt:
+ kfree(fdt);
+ return NULL;
+}
+#else
static void *fdt_get_runtime(void)
{
return initial_boot_params;
}
-
+#endif
static int kexec_setup_fdt(struct kexec_buf *kbuf, struct boot_params *params)
{
void *fdt;