From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iQ94H-0004K9-Dt for mharc-grub-devel@gnu.org; Thu, 31 Oct 2019 07:56:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53063) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQ94D-0004Ek-4x for grub-devel@gnu.org; Thu, 31 Oct 2019 07:56:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQ94B-0007m3-Lq for grub-devel@gnu.org; Thu, 31 Oct 2019 07:56:41 -0400 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]:36536) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iQ94B-0007lh-CG for grub-devel@gnu.org; Thu, 31 Oct 2019 07:56:39 -0400 Received: by mail-ed1-x542.google.com with SMTP id f7so1437814edq.3 for ; Thu, 31 Oct 2019 04:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=7zfhUgUnhwKoWBivx2HHzLEq5TJTCVkCay0pNxUu03M=; b=AD7ajFbljuLVTBLwxF8zSPqeC5GIWm151Jdas4rYiBEma2rF8s3qBzBWS5bALn0L0B 3rfXmWpvOylbGOL2zIL3ZuJeEodGLEryKq9pw/58DlifwM8qsyOYvno46kBsQaOLvHV7 bLr6nclu0uXSu7ni3K0eQm0Ek/WQZO64kMGb9VmSLZxK/N6we38Uuw9BK2IoHjnoiPf/ z5p3h1Q7YnYIek38se7mhH2L3smHD2CXIay4tBG09U2tzBdlOkeBpXVkYshbN4r5yjaP Vt2xnrYvfvff75uTQhLXXBruNtbEQp7l74hnJxik783b9idxBHFPgCu7hs5kqu0CUB9X BAjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=7zfhUgUnhwKoWBivx2HHzLEq5TJTCVkCay0pNxUu03M=; b=aO5tViAosZPWZww4aZZ7lT3hXFRsXSkaIywWg37JE/Srli7rjg5M3Uwh3sJq5V9CKy WgwinT6rdPui386Pc8z8aiuYVeEx5c51zl9qR77VM0VZIM3agEnyHfwlZkhiqFuckDMI ycODrzfRblxvmVKhjUKMIwxYo8SMLaG7XlaGTPGwSvpSHfYuqEniL1GtY75ERyp+wLMN pp2NoWqkcqsGbAVYBUh+FLmIrWgJ+YjQGr+vpNav8apa+0PEHAGUVfAXk49dILjfiY7w TXCMGOm7Gja1YXUPVTl21kvtwH62pKU7oNNvMjGPsLd2BDzkOpohqVHvhJT8KOK+RkaD B7zg== X-Gm-Message-State: APjAAAVI6H7icecJDUgQH4MFt/a7nCGwZuOQGaNWsIBey192GsyEnfwf s6nPb8ZAtbmS97jsPpMxlENPp4atY5F56LNNfC3GaybeH5w= X-Google-Smtp-Source: APXvYqxZVreDJPiASU516pFooufEWAgTxZGEuJy4QdsglaeSkbB+4kgqQcO15e41ZgDyyh3zAPi9eO+EfoldiIKftc8= X-Received: by 2002:a50:d80c:: with SMTP id o12mr5473907edj.251.1572522997304; Thu, 31 Oct 2019 04:56:37 -0700 (PDT) MIME-Version: 1.0 References: <20191031103740.5400-1-javierm@redhat.com> In-Reply-To: <20191031103740.5400-1-javierm@redhat.com> From: "Vladimir 'phcoder' Serbinenko" Date: Thu, 31 Oct 2019 12:56:25 +0100 Message-ID: Subject: Re: [PATCH] arm64: make sure fdt has #address-cells and #size-cells properties To: The development of GNU GRUB Content-Type: multipart/alternative; boundary="000000000000a7d3090596338ae2" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::542 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Oct 2019 11:56:44 -0000 --000000000000a7d3090596338ae2 Content-Type: text/plain; charset="UTF-8" This patch looks incomplete. What if "chosen" is there but does not contain the relevant fields? On Thu, 31 Oct 2019, 11:39 Javier Martinez Canillas, wrote: > From: Mark Salter > > Recent upstream changes to kexec-tools relies on #address-cells > and #size-cells properties in the FDT. If grub2 needs to create > a chosen node, it is likely because firmware did not provide one. > In that case, set #address-cells and #size-cells properties to > make sure they exist. > > Signed-off-by: Mark Salter > Signed-off-by: Javier Martinez Canillas > --- > > grub-core/loader/arm64/linux.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git grub-core/loader/arm64/linux.c grub-core/loader/arm64/linux.c > index ef3e9f9444c..24d73732d89 100644 > --- grub-core/loader/arm64/linux.c > +++ grub-core/loader/arm64/linux.c > @@ -78,7 +78,21 @@ finalize_params_linux (void) > > node = grub_fdt_find_subnode (fdt, 0, "chosen"); > if (node < 0) > - node = grub_fdt_add_subnode (fdt, 0, "chosen"); > + { > + /* > + * If we have to create a chosen node, Make sure we > + * have #address-cells and #size-cells properties. > + */ > + retval = grub_fdt_set_prop32(fdt, 0, "#address-cells", 2); > + if (retval) > + goto failure; > + > + retval = grub_fdt_set_prop32(fdt, 0, "#size-cells", 2); > + if (retval) > + goto failure; > + > + node = grub_fdt_add_subnode (fdt, 0, "chosen"); > + } > > if (node < 1) > goto failure; > -- > 2.21.0 > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel > --000000000000a7d3090596338ae2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This patch looks incomplete. What if "chosen" i= s there but does not contain the relevant fields?

On Thu, 31 Oct 2019, 11:39= Javier Martinez Canillas, <javier= m@redhat.com> wrote:
From: M= ark Salter <msalter@redhat.com>

Recent upstream changes to kexec-tools relies on #address-cells
and #size-cells properties in the FDT. If grub2 needs to create
a chosen node, it is likely because firmware did not provide one.
In that case, set #address-cells and #size-cells properties to
make sure they exist.

Signed-off-by: Mark Salter <msalter@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

=C2=A0grub-core/loader/arm64/linux.c | 16 +++++++++++++++-
=C2=A01 file changed, 15 insertions(+), 1 deletion(-)

diff --git grub-core/loader/arm64/linux.c grub-core/loader/arm64/linux.c index ef3e9f9444c..24d73732d89 100644
--- grub-core/loader/arm64/linux.c
+++ grub-core/loader/arm64/linux.c
@@ -78,7 +78,21 @@ finalize_params_linux (void)

=C2=A0 =C2=A0node =3D grub_fdt_find_subnode (fdt, 0, "chosen"); =C2=A0 =C2=A0if (node < 0)
-=C2=A0 =C2=A0 node =3D grub_fdt_add_subnode (fdt, 0, "chosen");<= br> +=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 /*
+=C2=A0 =C2=A0 =C2=A0 =C2=A0* If we have to create a chosen node, Make sure= we
+=C2=A0 =C2=A0 =C2=A0 =C2=A0* have #address-cells and #size-cells propertie= s.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0*/
+=C2=A0 =C2=A0 =C2=A0 retval =3D grub_fdt_set_prop32(fdt, 0, "#address= -cells", 2);
+=C2=A0 =C2=A0 =C2=A0 if (retval)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto failure;
+
+=C2=A0 =C2=A0 =C2=A0 retval =3D grub_fdt_set_prop32(fdt, 0, "#size-ce= lls", 2);
+=C2=A0 =C2=A0 =C2=A0 if (retval)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 goto failure;
+
+=C2=A0 =C2=A0 =C2=A0 node =3D grub_fdt_add_subnode (fdt, 0, "chosen&q= uot;);
+=C2=A0 =C2=A0 }

=C2=A0 =C2=A0if (node < 1)
=C2=A0 =C2=A0 =C2=A0goto failure;
--
2.21.0


_______________________________________________
Grub-devel mailing list
= Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/g= rub-devel
--000000000000a7d3090596338ae2--