From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kVwTY-000840-M4 for mharc-grub-devel@gnu.org; Fri, 23 Oct 2020 08:47:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVwTV-0007yv-RK for grub-devel@gnu.org; Fri, 23 Oct 2020 08:47:17 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42843) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVwTT-00056Z-Kg for grub-devel@gnu.org; Fri, 23 Oct 2020 08:47:17 -0400 Received: by mail-wr1-x444.google.com with SMTP id j7so1653004wrt.9 for ; Fri, 23 Oct 2020 05:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=teGfWDMc4tg7gJOc+NSlRBxm4270R4Ay0Auhg+Y3mzw=; b=E8S0rwEEKUkP2HNzt3RXe0oKSRVKMF3HTz3pn2TnQe61AJyteKi8U80dJJ9wakCSSS U2vO2jP7FSEKw5FOnNR3bNe33Mh7bTCkDLizYPn/wa3+dPo/gKEEmi4PZ9u2yTwAZuVJ 4cq1662XFrKB4Iw/yRyGubkSW5wyZGqusrI5lUwt+1jdF4HhZg1tvoOZ88dpB6NZmsNK 8N1NZ7XSQg3m12xZLZjHbX9/eI2ivyyAMPY2d9SnU/M4RcrProoE6EvPnbZwnQEnm7HI I4W9SnpHEltZN3vUElKPpZtYmM+/V1+dkbcOz0fyeM3iVxmf9qIOovCsM3MCnpVVnMgk 0J5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=teGfWDMc4tg7gJOc+NSlRBxm4270R4Ay0Auhg+Y3mzw=; b=L2X23vcCQrhuyyuRAzCP6O350PUEuy8UizOCSOgYshGWpyYEzfnjzvyhnspFawOWRR uIGVmGVYmXY6b8PuqvptF2dqrl9flXIAbcydYcxhd9WbAbTX/y7vL+bzIfEW1v6bC2ng /wvJEgLEsnrmSCXZb9HEUepg47NTxDRjYVk6beJpdFiZPOfRaqhlGOcEGwGTxH/dlE6l mCQqCwD5Tli+p9k/2UXthtyPZR51S1vkz+Rsdn238oJJgH6P9MWITOSLP+4Y6n0u4EBU cUgFsOB/BV564Z6BCh8b0JELOSif8lI3MJcfZxh8XUjM9m7Hr8joAf1EdzpvjYxfaFFo OG7A== X-Gm-Message-State: AOAM533jWr489hC2wpZKvw7OrYIT7AAO0zPPRc12prZXAor4uvYPft74 ytEss7LVGD45GS7XksAJ+pzWmw== X-Google-Smtp-Source: ABdhPJwuBzIbPqKO25sGmGQnl8kjVxQGYVYB+7Kno95ik/SbbKHOylDjwCxmisOyTeIzd4H700QQgQ== X-Received: by 2002:adf:fc8b:: with SMTP id g11mr2454658wrr.300.1603457232984; Fri, 23 Oct 2020 05:47:12 -0700 (PDT) Received: from vanye (cpc92880-cmbg19-2-0-cust79.5-4.cable.virginm.net. [82.27.104.80]) by smtp.gmail.com with ESMTPSA id i33sm3189489wri.79.2020.10.23.05.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 05:47:12 -0700 (PDT) Date: Fri, 23 Oct 2020 13:47:10 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, grub-devel@gnu.org, daniel.kiper@oracle.com Subject: Re: [PATCH 4/4] linux: ignore FDT unless we need to modify it Message-ID: <20201023124710.GD1664@vanye> References: <20201023120825.30466-1-ard.biesheuvel@arm.com> <20201023120825.30466-5-ard.biesheuvel@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201023120825.30466-5-ard.biesheuvel@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=leif@nuviainc.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Oct 2020 12:47:18 -0000 On Fri, Oct 23, 2020 at 14:08:25 +0200, Ard Biesheuvel wrote: > 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. There is a change in behaviour here which I don't think matters, but I'll call it out anyway: If there was ever a kernel out there with an EFI stub that depended on a chosen node existing in the DT, and the one provide by firmware did not contain one, that setup would break from this *if* it didn't use an initrd. / Leif > 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 285422c7bd43..9e282b6660fe 100644 > --- a/grub-core/loader/arm64/linux.c > +++ b/grub-core/loader/arm64/linux.c > @@ -93,21 +93,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 ee9c5592c700..ab900b27d927 100644 > --- a/grub-core/loader/efi/fdt.c > +++ b/grub-core/loader/efi/fdt.c > @@ -85,13 +85,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.17.1 >