From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mgC5G-0006h4-QP for mharc-grub-devel@gnu.org; Thu, 28 Oct 2021 16:33:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgC53-0006VJ-8e for grub-devel@gnu.org; Thu, 28 Oct 2021 16:32:59 -0400 Received: from mail-lj1-f182.google.com ([209.85.208.182]:45613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgC50-0004WB-97 for grub-devel@gnu.org; Thu, 28 Oct 2021 16:32:56 -0400 Received: by mail-lj1-f182.google.com with SMTP id k13so12738687ljj.12 for ; Thu, 28 Oct 2021 13:32:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dIdM7e5o7SttIv/25upKuKbBqgwOu9ueT/fqcnHexTM=; b=GVEDGbBHgGPNKccdfMJ4cqoOcTgVmcDUlWuO18BU/g7Tdk74jzF6brKsQYWHwdUGvj FjO5sHSu+7fiKe6im314T/O6lcs+ov/DhQTxGAKl6vWXBYPTpyWJwFwb8DFOzJI1X1cu dHofnD9ViqMho1fVczd9To9l0ju1QUnLuZXf9MJbZtYJBoDjw3tBDBS+fEiQffgrnUFs NCt2qS3ED0YySBHpELow7QwaRTnzRcpfjGzIhWpBkACeoWOEE350TshwYjDe6dBOBKpe npt3KkIpTgmz6ad2PptAvExghOKK8CZXNQmKXuPZZsDH6dN3EAcMohvhe7oiz80SGWis ZeCg== X-Gm-Message-State: AOAM53219vmHiKtADa8JMdcJ/hqFErgO6fHxb/uFN9CIFa9tptauHUkZ XWUmEYh6dzToCbKNhCuRCqOp63sDZdvR9iia X-Google-Smtp-Source: ABdhPJwtL2dJA329RDhhBlxHuLGkOaQ5MYilif/HNVmdrwa7xxMs8gWvTcpZnhv/iDVqACot2EgTiQ== X-Received: by 2002:a2e:96c4:: with SMTP id d4mr7123716ljj.59.1635453170214; Thu, 28 Oct 2021 13:32:50 -0700 (PDT) Received: from amanita.localdomain ([2a00:1370:811f:5cd1:1618:c3ff:fe69:39f3]) by smtp.gmail.com with ESMTPSA id v22sm291719lfr.175.2021.10.28.13.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 13:32:49 -0700 (PDT) From: Nikita Ermakov To: GRUB development mailing list Cc: Ard Biesheuvel , Atish Patra , Daniel Kiper , Heinrich Schuchardt , Leif Lindholm , Fu Wei Subject: [PATCH v3 4/7] linux: ignore FDT unless we need to modify it Date: Thu, 28 Oct 2021 23:31:17 +0300 Message-Id: <20211028203118.7908-5-arei@altlinux.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028203118.7908-1-arei@altlinux.org> References: <20211028203118.7908-1-arei@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=209.85.208.182; envelope-from=coffe92@gmail.com; helo=mail-lj1-f182.google.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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, 28 Oct 2021 20:32:59 -0000 From: Ard Biesheuvel Now that we implemented supported for the LoadFile2 protocol for initrd loading, there is no longer a need to pass the initrd parameters via the device tree. This means there is no longer a 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 --- 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 6b03455d1..65f1275fb 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -95,21 +95,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 c86f283d7..771d455c7 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -89,13 +89,16 @@ grub_fdt_install (void) grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; grub_efi_status_t status; + if (!fdt && !loaded_fdt) + 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 ?: 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 ?: loaded_fdt); return GRUB_ERR_NONE; } -- 2.33.1