dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0238-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch

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