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

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