Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1loYB0-0005s4-CZ for mharc-grub-devel@gnu.org; Wed, 02 Jun 2021 17:13:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loYAz-0005p6-71 for grub-devel@gnu.org; Wed, 02 Jun 2021 17:13:21 -0400 Received: from mail-lf1-f48.google.com ([209.85.167.48]:46900) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1loYAx-00046E-LE for grub-devel@gnu.org; Wed, 02 Jun 2021 17:13:20 -0400 Received: by mail-lf1-f48.google.com with SMTP id i9so5446263lfe.13 for ; Wed, 02 Jun 2021 14:13:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=juxVgWYoovkPWWAyxRrqCdZkQXMmVnee/cFl23KUJ+o=; b=jxK1zDi3ClUAj4ywNR7ce+y8w+gWBYXZL3/0mvRpzIiTIl2oWxxK8Mwovef+pQWNr+ b4wzPxDKZ5W2kfCTh36SWvbu0p83Xe7hdAmOiPLJZdbinQFQfaf8V3U+/+cmiL/Zt2Vw b9uz0L+5CuJp1RARo1FziJqCnJBInk48B54KMrocYVo61uaRqj67w6Y5QGO61X79QOm0 U4o4zwHXESUSJLF4iV+XstTuL1reHU8ajSqXhFdizWVAZW2YIJQEDiFWEDqmTj15/dv+ KC2Ft4Q90WOt5qcJ5QBawD+VXX3+c29XY695JGvHKseXqy1mViuHSb4rFY31yM3q+aRr PtsQ== X-Gm-Message-State: AOAM533j+yStAvRWYMwKDnW2hMjkCri/8gvK4lpNaUectJhhioZoG61B 8QbyhSu2RnE2G04ouGOnlfFHDs9VcPQcBCEu X-Google-Smtp-Source: ABdhPJxX7QH+E6e4c2nWJLFMYXZ2RQY4uFhII6sDc6bcHc0wAOp/Bdpc4XPpfAPvcikAAkTUrz0cTQ== X-Received: by 2002:a05:6512:3f1a:: with SMTP id y26mr22358639lfa.662.1622668397872; Wed, 02 Jun 2021 14:13:17 -0700 (PDT) Received: from localhost.localdomain ([2a00:1370:811f:4a8d:2d8:61ff:fed1:d10a]) by smtp.gmail.com with ESMTPSA id p3sm101361lfa.116.2021.06.02.14.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 14:13:17 -0700 (PDT) From: Nikita Ermakov To: GRUB development mailing list Cc: Ard Biesheuvel , Atish Patra , Daniel Kiper , Heinrich Schuchardt , Leif Lindholm , Nikita Ermakov Subject: [PATCH v2 4/7] linux: ignore FDT unless we need to modify it Date: Thu, 3 Jun 2021 00:12:32 +0300 Message-Id: <20210602211235.377366-5-arei@altlinux.org> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210602211235.377366-1-arei@altlinux.org> References: <20210602211235.377366-1-arei@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=209.85.167.48; envelope-from=coffe92@gmail.com; helo=mail-lf1-f48.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.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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: Wed, 02 Jun 2021 21:13:21 -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.29.3