From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85432C43461 for ; Wed, 9 Sep 2020 17:19:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30A0A2166E for ; Wed, 9 Sep 2020 17:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599671974; bh=dBf3kT0+IU1h02iNcg1o94zReimfahA8wuaiLSo0fhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uZz01xtv7c3cReNCl7j+p8uZt+7vNZLv5m6PuazRo2DBb4JJidztxzg9MUydCdlty S7ZNrgPn9hbLCSr7F01zCkEAPIcDC4dZPoq+AyQvJ0PnIFUFYOSLmlt9ee1UYT48Ar 0XZdC/SpJKXXhOE/wFpUheso30pHv3JM3RGjhY1Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729911AbgIIRTU (ORCPT ); Wed, 9 Sep 2020 13:19:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:54606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729789AbgIIP1Y (ORCPT ); Wed, 9 Sep 2020 11:27:24 -0400 Received: from e123331-lin.nice.arm.com (adsl-204.109.242.29.tellas.gr [109.242.29.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A636422269; Wed, 9 Sep 2020 15:16:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599664618; bh=dBf3kT0+IU1h02iNcg1o94zReimfahA8wuaiLSo0fhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dPe4pGxLiN3gkvZppqhigagtgKy6YWfDjJDJNWKM1COef61kJRWvXRmQOodnWV/pG mmBxCi+fGWoQXvbcWYszlUIYMe4py5b9uDOejI5OKGOL3yWz+C3UkJEXz4a8a+8uLw 5Cs085rzV9uOgKWN9qtgpriPC6Nqiihf1LNj7eLk= From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Maxim Uvarov , Heinrich Schuchardt , Atish Patra , Palmer Dabbelt , Jens Wiklander , Francois Ozog , Etienne CARRIERE , Takahiro Akashi , Patrice CHOTARD , Sumit Garg , Grant Likely , Ilias Apalodimas , Christophe Priouzeau , Rouven Czerwinski , Patrick DELAUNAY Subject: [PATCH RFC/RFT 3/3] efi/libstub: base FDT and initrd placement on image address not DRAM base Date: Wed, 9 Sep 2020 18:16:23 +0300 Message-Id: <20200909151623.16153-4-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200909151623.16153-1-ardb@kernel.org> References: <20200909151623.16153-1-ardb@kernel.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org The way we use the base of DRAM in the EFI stub is problematic as it is ill defined what the base of DRAM actually means. There are some restrictions on the placement of FDT and initrd which are defined in terms of dram_base, but given that the placement of the kernel in memory is what defines these boundaries, it is better to use the image address in these cases, and disregard dram_base altogether. In a future patch, we should be able to get rid of dram_base entirely, but at the moment, RISC-V support is in flight in another tree, so we keep it around for now. Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/efi.h | 6 +++--- arch/arm64/include/asm/efi.h | 2 +- drivers/firmware/efi/libstub/efi-stub.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h index 5dcf3c6011b7..9e481b362227 100644 --- a/arch/arm/include/asm/efi.h +++ b/arch/arm/include/asm/efi.h @@ -75,16 +75,16 @@ static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt) #define MIN_ZIMAGE_OFFSET MAX_UNCOMP_KERNEL_SIZE /* on ARM, the FDT should be located in the first 128 MB of RAM */ -static inline unsigned long efi_get_max_fdt_addr(unsigned long dram_base) +static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr) { - return dram_base + ZIMAGE_OFFSET_LIMIT; + return image_addr + ZIMAGE_OFFSET_LIMIT; } /* on ARM, the initrd should be loaded in a lowmem region */ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base, unsigned long image_addr) { - return dram_base + SZ_512M; + return image_addr + SZ_512M; } struct efi_arm_entry_state { diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index d4ab3f73e7a3..27c2e8959ab6 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -65,7 +65,7 @@ efi_status_t __efi_rt_asm_wrapper(void *, const char *, ...); (SEGMENT_ALIGN > THREAD_ALIGN ? SEGMENT_ALIGN : THREAD_ALIGN) /* on arm64, the FDT may be located anywhere in system RAM */ -static inline unsigned long efi_get_max_fdt_addr(unsigned long dram_base) +static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr) { return ULONG_MAX; } diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c index a5a405d8ab44..76ce60065f10 100644 --- a/drivers/firmware/efi/libstub/efi-stub.c +++ b/drivers/firmware/efi/libstub/efi-stub.c @@ -306,7 +306,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, install_memreserve_table(); status = allocate_new_fdt_and_exit_boot(handle, &fdt_addr, - efi_get_max_fdt_addr(dram_base), + efi_get_max_fdt_addr(image_addr), initrd_addr, initrd_size, cmdline_ptr, fdt_addr, fdt_size); if (status != EFI_SUCCESS) -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14399C10DAA for ; Wed, 9 Sep 2020 15:18:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B00B122285 for ; Wed, 9 Sep 2020 15:18:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TxjJWnSx"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="dPe4pGxL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B00B122285 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wZDO2WOuJDSwzbgEcXtGotf/wyw27PHeaMVmkkAxdII=; b=TxjJWnSx9rZVM0qNaoOt6iEVeB Y8LDUCH88u3VbC65lcw9m9M1XBPw6/oXjEHtXYtVu2RX3n1xkZU5oh9sNzGH80S0tGTvVIxlM9wW6 7uksamjpqQ4+b0vzRE9KABhu3OiefhFBkgevSzKDjZ7pTywF7nYCoBiwT4fBKrPMFShd3VFGvLLE7 bA6OrL/8lCSarvVA0tQBN+iVPeMDywpkGi61s91a9s/Q64mIUacNb/ti09LwWp+/3cEMa8Pjbx81t bblhbrlQVz0RGNz3WdWwd7ab+HAHeXYIfWiADIgMG11XZA/GH0NnPG4lfLgVrmNPVeyaI8qj8gJCE rV7JGkfg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kG1qI-00014Z-0D; Wed, 09 Sep 2020 15:17:02 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kG1qE-00013L-Oz for linux-arm-kernel@lists.infradead.org; Wed, 09 Sep 2020 15:16:59 +0000 Received: from e123331-lin.nice.arm.com (adsl-204.109.242.29.tellas.gr [109.242.29.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A636422269; Wed, 9 Sep 2020 15:16:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599664618; bh=dBf3kT0+IU1h02iNcg1o94zReimfahA8wuaiLSo0fhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dPe4pGxLiN3gkvZppqhigagtgKy6YWfDjJDJNWKM1COef61kJRWvXRmQOodnWV/pG mmBxCi+fGWoQXvbcWYszlUIYMe4py5b9uDOejI5OKGOL3yWz+C3UkJEXz4a8a+8uLw 5Cs085rzV9uOgKWN9qtgpriPC6Nqiihf1LNj7eLk= From: Ard Biesheuvel To: linux-efi@vger.kernel.org Subject: [PATCH RFC/RFT 3/3] efi/libstub: base FDT and initrd placement on image address not DRAM base Date: Wed, 9 Sep 2020 18:16:23 +0300 Message-Id: <20200909151623.16153-4-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200909151623.16153-1-ardb@kernel.org> References: <20200909151623.16153-1-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200909_111658_964768_D6C6FE56 X-CRM114-Status: GOOD ( 18.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Etienne CARRIERE , Francois Ozog , Maxim Uvarov , Rouven Czerwinski , Takahiro Akashi , Heinrich Schuchardt , Ilias Apalodimas , Patrice CHOTARD , Patrick DELAUNAY , Jens Wiklander , Atish Patra , Grant Likely , Palmer Dabbelt , Christophe Priouzeau , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, Sumit Garg MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The way we use the base of DRAM in the EFI stub is problematic as it is ill defined what the base of DRAM actually means. There are some restrictions on the placement of FDT and initrd which are defined in terms of dram_base, but given that the placement of the kernel in memory is what defines these boundaries, it is better to use the image address in these cases, and disregard dram_base altogether. In a future patch, we should be able to get rid of dram_base entirely, but at the moment, RISC-V support is in flight in another tree, so we keep it around for now. Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/efi.h | 6 +++--- arch/arm64/include/asm/efi.h | 2 +- drivers/firmware/efi/libstub/efi-stub.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h index 5dcf3c6011b7..9e481b362227 100644 --- a/arch/arm/include/asm/efi.h +++ b/arch/arm/include/asm/efi.h @@ -75,16 +75,16 @@ static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt) #define MIN_ZIMAGE_OFFSET MAX_UNCOMP_KERNEL_SIZE /* on ARM, the FDT should be located in the first 128 MB of RAM */ -static inline unsigned long efi_get_max_fdt_addr(unsigned long dram_base) +static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr) { - return dram_base + ZIMAGE_OFFSET_LIMIT; + return image_addr + ZIMAGE_OFFSET_LIMIT; } /* on ARM, the initrd should be loaded in a lowmem region */ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base, unsigned long image_addr) { - return dram_base + SZ_512M; + return image_addr + SZ_512M; } struct efi_arm_entry_state { diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index d4ab3f73e7a3..27c2e8959ab6 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -65,7 +65,7 @@ efi_status_t __efi_rt_asm_wrapper(void *, const char *, ...); (SEGMENT_ALIGN > THREAD_ALIGN ? SEGMENT_ALIGN : THREAD_ALIGN) /* on arm64, the FDT may be located anywhere in system RAM */ -static inline unsigned long efi_get_max_fdt_addr(unsigned long dram_base) +static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr) { return ULONG_MAX; } diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c index a5a405d8ab44..76ce60065f10 100644 --- a/drivers/firmware/efi/libstub/efi-stub.c +++ b/drivers/firmware/efi/libstub/efi-stub.c @@ -306,7 +306,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, install_memreserve_table(); status = allocate_new_fdt_and_exit_boot(handle, &fdt_addr, - efi_get_max_fdt_addr(dram_base), + efi_get_max_fdt_addr(image_addr), initrd_addr, initrd_size, cmdline_ptr, fdt_addr, fdt_size); if (status != EFI_SUCCESS) -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel