Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iQCro-0005t8-7t for mharc-grub-devel@gnu.org; Thu, 31 Oct 2019 12:00:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34376) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQCrd-0004hR-Nr for grub-devel@gnu.org; Thu, 31 Oct 2019 11:59:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQCrc-0001ac-Bh for grub-devel@gnu.org; Thu, 31 Oct 2019 11:59:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34914) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iQCrc-0001YB-2V for grub-devel@gnu.org; Thu, 31 Oct 2019 11:59:56 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A1CCD81F0D for ; Thu, 31 Oct 2019 15:59:54 +0000 (UTC) Received: by mail-wr1-f72.google.com with SMTP id e25so3632609wra.9 for ; Thu, 31 Oct 2019 08:59:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Vlgw6w3xHJMBo0fQcoycNkkEoxpLm99b/hrFr96qA/I=; b=BGjtSq75LDvEGO95cJ75aj0QdjL2OYt7MzZXBR+39X5fJo0BbYPoes8yAHAGysud06 A8ZEqPiwDTR+OfpeEBm8PCHqNjqQ5i20dc0WkSfGGj3KmeaWvQOJ41bret032Qqaxlgb Hefqhr80733T9rP1nfvAxA5kEUcAune3HcZrZb7xbjvBzK+BNleBBupELg0obvKexDBF FktaELiDr4SNszFaj6YTBpxOLA4ycKoEFSWfncTw7Nuy25ebIVud3t0WzTWHd+R9LkOP mo9QcXACtGCGsJNlKkweKG5oFX0uz6K54X98hrK4ZxhpxKOUQy8nIRShmHYy+D8s09Ok enqA== X-Gm-Message-State: APjAAAXlOLCTrJGSXK4LTKW3i3JeS6aTn7nIsteSVuHqhAOlM6GKAwFD qWugxc0k7llRBN5ZKT75H0G3QnCzKrcOKEWQp+yxNswonhwve6PkV7s81NMjWvarvG4h3QF9eKu 7A8+nckZwgpY= X-Received: by 2002:a05:6000:1621:: with SMTP id v1mr6711105wrb.62.1572537593437; Thu, 31 Oct 2019 08:59:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNF0kBhBwStlwusOs6ilVbVFxU+H0ayvfb8yO1Sq6YSeCWa7zMNnIDhFDneTfNV4O+c7keJw== X-Received: by 2002:a05:6000:1621:: with SMTP id v1mr6711086wrb.62.1572537593206; Thu, 31 Oct 2019 08:59:53 -0700 (PDT) Received: from [192.168.1.13] ([90.168.169.92]) by smtp.gmail.com with ESMTPSA id p10sm4525281wrx.2.2019.10.31.08.59.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 31 Oct 2019 08:59:52 -0700 (PDT) Subject: Re: [PATCH] arm64: make sure fdt has #address-cells and #size-cells properties To: The development of GNU GRUB , Vladimir 'phcoder' Serbinenko References: <20191031103740.5400-1-javierm@redhat.com> Cc: Mark Salter From: Javier Martinez Canillas Message-ID: <8a4c2abd-cf49-53dc-3e64-49d676de7f64@redhat.com> Date: Thu, 31 Oct 2019 16:59:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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 16:00:07 -0000 On 10/31/19 12:56 PM, Vladimir 'phcoder' Serbinenko wrote: > This patch looks incomplete. What if "chosen" is there but does not contain > the relevant fields? > My understanding is that if there's a chosen node already defined in the Device Tree but without #address-cells and #size-cells properties, then is a malformed DT and is not up to GRUB to correct it. But if GRUB is adding a child node as is the case of the chosen node, then is up to GRUB to make sure that there are #address-cells and #size-cells properties also defined so the child nodes are addressed correctly. But maybe I'm wrong on this, so I'll let Mark comment since he authored the patch and knows better what's the problem that's fixing. > 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 >> >> Best regards, -- Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat