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