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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 60AF0C4338F for ; Mon, 16 Aug 2021 05:07:17 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5995F619E0 for ; Mon, 16 Aug 2021 05:07:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5995F619E0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D977E82EA5; Mon, 16 Aug 2021 07:07:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629090434; bh=0/7LVUwOCEgcGz6gJi9dfGX1oNQdbZsV4Aoc6LbWni4=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=DNrdH9ggJREWHwtUYu/SP5mw/zOT5TatYfPKpXwvLdob6xXIGl7I41DouN5XMkgGR AtnBYVGIIyzquiki0yorqDhO58EelSudUn60VWLWoiVXUwKQH5qwF9e2xu6VE4eHEA iFbI/jNNgno3CkxpmNNQJl5CG1fdHW1fYxVECaEJhXHfcpU0n3MPntWr1zWgG571vE ANIDeh305U+fjppmvrbLgZ8LKrv3KtXS3TgXf9Oetz0ZYqrK2VgISoECHXo1vpwTtm PVQ525nYXVtGeC+Li7+dmX8oPAkTyiTaOqhkJa/wEL7eQFj/tWfD+1AAkM1eTC6UKU rFLKZ+NGzzjcg== Received: from mail-internal.denx.de (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: noc@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 7AA0382DB4; Mon, 16 Aug 2021 07:07:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629090432; bh=0/7LVUwOCEgcGz6gJi9dfGX1oNQdbZsV4Aoc6LbWni4=; h=From:To:Cc:Subject:Date:From; b=jL0yPT3yz0uZbcQtJoXZ386ZG9Z6ha+hJKUKFW+Amn4691NIreKi7ZNpXOTKEYS86 wERls+swku2AeulXQOowNGqUYoghx6lvfvV3gkIkovdRiyYG8cuxOof/ORqRK2CKE4 VXcibXHv39efKeDSepW+IPpY5WaUTqVAcMlzripdw7UlTx3A9DjXE5AS9Yyw7BXnGZ uwQor5pSu6JE0SibS93zxVHVvGvfSxO/au8tK3K51Z4zrI2hras+Os+dLGBwAmUxUv wfJSQLUttaqc6O7L9KHSt1TsAdbgAeDzR0VXgKQZGXGeO3Rp4aHpcDpetI5ewwNDpz 2W7siK2D2vyWQ== Received: from pollux.denx.de (pollux [192.168.1.1]) by mail-internal.denx.de (Postfix) with ESMTP id C0C4218071E; Mon, 16 Aug 2021 07:07:08 +0200 (CEST) Received: by pollux.denx.de (Postfix, from userid 515) id 9E9281A8B9F; Mon, 16 Aug 2021 07:07:08 +0200 (CEST) From: Heiko Schocher To: U-Boot Mailing List Cc: Heiko Schocher , Alexandru Gagniuc , Fabio Estevam , Marek Vasut , Michal Simek , "NXP i.MX U-Boot Team" , "Peng Fan (OSS)" , Philippe Reynes , Simon Glass , Stefano Babic , Tim Harvey Subject: [PATCH v1] imx: spl: fix imx8m secure boot Date: Mon, 16 Aug 2021 07:07:06 +0200 Message-Id: <20210816050706.2665092-1-hs@denx.de> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean inspired from NXP code: 719d665a87c6: ("MLK-20467 imx8m: Fix issue for booting signed image through uuu") fix loading FIT buffer address to fix position CONFIG_SYS_TEXT_BASE - CONFIG_FIT_EXTERNAL_OFFSET and fix secure boot on imx8m based boards. Problem was that FIT header and so IVT header too, was loaded to memallocated address. So the ivt header address coded in IVT itself does not fit with the real position. Signed-off-by: Heiko Schocher --- replaces Series: https://lists.denx.de/pipermail/u-boot/2021-August/457308.html @Tim: could you please test this version on your hardware? azure build: https://dev.azure.com/hs0298/hs/_build/results?buildId=71&view=results (fetch error for rockchip, but this should be no problem for this patch. How do I restart one specific job on azure?) Works on sdcard and QSPI NOR boot on phycore-imx8mp board. arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/spl_fit.c | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c index 36033d611c..6991d88dbf 100644 --- a/arch/arm/mach-imx/spl.c +++ b/arch/arm/mach-imx/spl.c @@ -334,6 +334,17 @@ void board_spl_fit_post_load(const void *fit) } #endif +#if defined(CONFIG_FIT_EXTERNAL_OFFSET) +void *board_spl_fit_buffer_addr(ulong fit_size, int bl_len) +{ + /* + * use fix position + * TEXT_BASE - FIT_EXTERNAL_OFFSET + */ + return (void *)((CONFIG_SYS_TEXT_BASE - CONFIG_FIT_EXTERNAL_OFFSET)); +} +#endif + #endif #if defined(CONFIG_MX6) && defined(CONFIG_SPL_OS_BOOT) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index f41abca0cc..a4337d3c88 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -538,6 +538,11 @@ static void *spl_get_fit_load_buffer(size_t size) return buf; } +__weak void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len) +{ + return spl_get_fit_load_buffer(sectors * bl_len); +} + /* * Weak default function to allow customizing SPL fit loading for load-only * use cases by allowing to skip the parsing/processing of the FIT contents @@ -631,7 +636,7 @@ static int spl_simple_fit_read(struct spl_fit_info *ctx, * For FIT with external data, data is not loaded in this step. */ sectors = get_aligned_image_size(info, size, 0); - buf = spl_get_fit_load_buffer(sectors * info->bl_len); + buf = board_spl_fit_buffer_addr(size, sectors, info->bl_len); count = info->read(info, sector, sectors, buf); ctx->fit = buf; -- 2.31.1