From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1okrv3-0007TC-29 for mharc-grub-devel@gnu.org; Tue, 18 Oct 2022 15:06:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okruW-0007NT-Nb for grub-devel@gnu.org; Tue, 18 Oct 2022 15:05:58 -0400 Received: from dfw.source.kernel.org ([139.178.84.217]:46538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okruE-0000mU-2r for grub-devel@gnu.org; Tue, 18 Oct 2022 15:05:41 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 879A9616B6; Tue, 18 Oct 2022 19:05:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD8DAC433D6; Tue, 18 Oct 2022 19:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666119936; bh=Lre+SQxPP0nQ19bcaPzB+nUh65LA6VW3clTnik/5vB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Or0bCC/ql+0lMu/Ne2PhafmBIbpejGNyxWlv55yfXgY+Ad0hOI9yLnlc13zkNR6LF aB45yAZne9dWOWjz5PfXPOHy+pbUkbCmWkVzfd6rLys+1cp/Yyf4Di1a99/reXYSzC VyNqXbBzt3oEoiGqU4x3ey+gB7dYl9BQIC9W8z76LfIqzEZJZvHpa0eewC/bXMb53M RNLXx+6r/ux8iRXgNyNc9Peu94al/ukV6M1UvwTHowkU9Xu36QuaF1JaIcGL9wR5Xg BN+Og/UC5doElCOEX3k/0pE23xWeKdi5zI4K+S8DIx0WMVe9R5hOV73EfZ+6DGTSaa whOBW1r1XFGJA== From: Ard Biesheuvel To: grub-devel@gnu.org Cc: Ard Biesheuvel , Daniel Kiper , Leif Lindholm , Nikita Ermakov , Atish Patra , Huacai Chen , Heinrich Schuchardt , dann frazier , Julian Andres Klode , Ilias Apalodimas Subject: [PATCH v5 6/6] linux: ignore FDT unless we need to modify it Date: Tue, 18 Oct 2022 21:05:07 +0200 Message-Id: <20221018190508.177568-7-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221018190508.177568-1-ardb@kernel.org> References: <20221018190508.177568-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2784; i=ardb@kernel.org; h=from:subject; bh=Lre+SQxPP0nQ19bcaPzB+nUh65LA6VW3clTnik/5vB8=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjTvjiEL/ftXtWn4dgpdVbsxHjZkDphuHxAoDvyUAs 39KbAyaJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY0744gAKCRDDTyI5ktmPJE/FC/ 9n6f61WdHHxtH0+YDk3/00sQ2iEti/H0t0PbVgMD2jAeEI53RGxj7dsbjFs52IkBIZaWerlgNOuNXN EwKvDB7TDZva5GdgcKz9Ci4D9TOdi2qysxRINSM1vI5r4+OilW+iBapN1bNM3ZV5qsgy1UQYt5UA48 AADVfKzin8s2P/tI6hphV4d/ZuURepLM/lBHCEHLUhNJM66fLqD7FIvVJb4Vv5MQ93mQBvZXNXor12 Wmps/diFcxQ3hDu5s5iRiLT0qo6sh102o0P+Z8/pwDFjpaav3388TI27c6aDJpKRZ5unqwwCBwSeEC 3/wAfvEBkIX5a0jAgi3CDuDneMVrI4ZccrZjm9oiOaLIBQQ1+FDu1Q7uNUsCnn96y06+5GCzaES3iZ 5MSeaJUYueiQSVxlOUJUsQoEcx+2lCQEv0/rElJgK+xqUQLyeqtwqB4ailkfi7YZ605/uoyfrzlCwn wNQm9vibyhHiCR0P9im1EVl0999O8TCR/Zpcci9SNApJ8= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=139.178.84.217; envelope-from=ardb@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -73 X-Spam_score: -7.4 X-Spam_bar: ------- X-Spam_report: (-7.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.256, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2022 19:06:00 -0000 Now that we implemented support for the LoadFile2 protocol for initrd loading, there is no longer a need to pass the initrd parameters via the device tree. This means that when the LoadFile2 protocol is being used, there is no reason to update the device tree in the first place, and so we can ignore it entirely. The only remaining reason to deal with the devicetree is if we are using the 'devicetree' command to load one from disk, so tweak the logic in grub_fdt_install() to take that into account. Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/linux.c | 22 ++++++++++---------- grub-core/loader/efi/fdt.c | 7 +++++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 9a4522d2f7bf..9d0bacc85419 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -134,21 +134,21 @@ finalize_params_linux (void) void *fdt; - fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE); + /* Set initrd info */ + if (initrd_start && initrd_end > initrd_start) + { + fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE); - if (!fdt) - goto failure; + if (!fdt) + goto failure; - node = grub_fdt_find_subnode (fdt, 0, "chosen"); - if (node < 0) - node = grub_fdt_add_subnode (fdt, 0, "chosen"); + node = grub_fdt_find_subnode (fdt, 0, "chosen"); + if (node < 0) + node = grub_fdt_add_subnode (fdt, 0, "chosen"); - if (node < 1) - goto failure; + if (node < 1) + goto failure; - /* Set initrd info */ - if (initrd_start && initrd_end > initrd_start) - { grub_dprintf ("linux", "Initrd @ %p-%p\n", (void *) initrd_start, (void *) initrd_end); diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c index 80d70887474a..35a3be2e5cda 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -89,13 +89,16 @@ grub_fdt_install (void) static grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; grub_efi_status_t status; + if (fdt == NULL && loaded_fdt == NULL) + return GRUB_ERR_NONE; + b = grub_efi_system_table->boot_services; - status = b->install_configuration_table (&fdt_guid, fdt); + status = b->install_configuration_table (&fdt_guid, fdt ? fdt : loaded_fdt); if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_IO, "failed to install FDT"); grub_dprintf ("fdt", "Installed/updated FDT configuration table @ %p\n", - fdt); + fdt ? fdt : loaded_fdt); return GRUB_ERR_NONE; } -- 2.35.1