c78952
From e48a4c0b9e475b16366ff6c375de5186432eb1f7 Mon Sep 17 00:00:00 2001
bc092b
From: Mark Salter <msalter@redhat.com>
bc092b
Date: Mon, 17 Apr 2017 08:44:29 -0400
31cddd
Subject: [PATCH] arm64: make sure fdt has #address-cells and
bc092b
 #size-cells properties
bc092b
bc092b
Recent upstream changes to kexec-tools relies on #address-cells
bc092b
and #size-cells properties in the FDT. If grub2 needs to create
bc092b
a chosen node, it is likely because firmware did not provide one.
bc092b
In that case, set #address-cells and #size-cells properties to
bc092b
make sure they exist.
bc092b
---
bc092b
 grub-core/loader/arm64/linux.c | 16 +++++++++++++++-
bc092b
 1 file changed, 15 insertions(+), 1 deletion(-)
bc092b
bc092b
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
ec4acb
index ad39a301527..59ff9cc05b4 100644
bc092b
--- a/grub-core/loader/arm64/linux.c
bc092b
+++ b/grub-core/loader/arm64/linux.c
bbc6a8
@@ -79,7 +79,21 @@ finalize_params_linux (void)
bc092b
 
bc092b
   node = grub_fdt_find_subnode (fdt, 0, "chosen");
bc092b
   if (node < 0)
bc092b
-    node = grub_fdt_add_subnode (fdt, 0, "chosen");
bc092b
+    {
bc092b
+      /*
bc092b
+       * If we have to create a chosen node, Make sure we
bc092b
+       * have #address-cells and #size-cells properties.
bc092b
+       */
bc092b
+      retval = grub_fdt_set_prop32(fdt, 0, "#address-cells", 2);
bc092b
+      if (retval)
bc092b
+	goto failure;
bc092b
+
bc092b
+      retval = grub_fdt_set_prop32(fdt, 0, "#size-cells", 2);
bc092b
+      if (retval)
bc092b
+	goto failure;
bc092b
+
bc092b
+      node = grub_fdt_add_subnode (fdt, 0, "chosen");
bc092b
+    }
bc092b
 
bc092b
   if (node < 1)
bc092b
     goto failure;