nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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