From patchwork Wed Jan 20 16:46:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Gagniuc X-Patchwork-Id: 1429329 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=En0Mw1LC; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DLWg65z28z9s24 for ; Thu, 21 Jan 2021 03:48:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F1B31829CF; Wed, 20 Jan 2021 17:47:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="En0Mw1LC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 61EA082807; Wed, 20 Jan 2021 17:47:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 182198286C for ; Wed, 20 Jan 2021 17:47:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-ot1-x329.google.com with SMTP id o11so23991993ote.4 for ; Wed, 20 Jan 2021 08:47:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HKu5a20Av5tR40aiLFleEe91wl/X12b7SaZjoYqRwFA=; b=En0Mw1LCgB6XEaIZmVvz424WDEt3OYst2GmqtS1XTNk1BOwu9m5+BPCCXpOp3UlLob K9WeBYRxewSEwfVhvV5n1AwtqvNA/HOZN71uuuGIVau2I9+6S5Jc6vsf6ZB14OZnoPFe 6hiNp/B4xUzrXcZ1tKwfU0m1HAcsNDUCGxacTks52WVOYsj2IHjaQrxsDXFqhZ5cEJwi TzyDRryxtrQ9Ri+tP/5b5V3VGcVbKMC5pJFTw4nXd0rpQJoSGk1JPhjfxzdB/TDKrOZU zIx2qBZRjLirpNYT4ynuzhtIjcP+AAosQyGvox27FL1JbW0TPYkfiPwYEeOL+y9mUVZB yxew== 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=HKu5a20Av5tR40aiLFleEe91wl/X12b7SaZjoYqRwFA=; b=aP+GihXYEJ6rhZIql8Ld4g9Hz56fb17vJMovNfh7j2c7M/VWAS/z6kBXvxQkwBB/zk BsDtR4BtvZXGEWjoYwd4+hfyHXPVoUIaqRhoZiOzpG2hBuevskLfJsrqT2W5yTrvigRj F1Nxp7XUL5tVhtsb4mP5bZw9eOx5tRESd1etkeGBGOoICX2lYgq/ud+ojsoJ7UYdgoTc 2Gvtm2mLEiwpLEl5GbSzYP+I7HUY0p/rgkbm4w7EOdB7Y949Pty2ql9SlQu4AU/KaxVN eW6dJCKV0VKkslygJGI5G+Py72pb51TziI0tbt9GJfrp9HUoEyNH0uBDGgbLDv2g9OAI wreg== X-Gm-Message-State: AOAM532Hv2Kwm4ZP3K8K3Ah0x7NcWmbBLKQvqnVDAq3VIiwpvCXHxjWx Jr3DqUhmwDZehB9ucGtQPY+EOCiN4zs= X-Google-Smtp-Source: ABdhPJyxZkJf12rGTvBl0y5yVzdHcFi698fM+M1OS0UC/gPOzJVkmzmUoUQlPn/YaGynfrwlPvBEag== X-Received: by 2002:a9d:650f:: with SMTP id i15mr7206741otl.347.1611161225607; Wed, 20 Jan 2021 08:47:05 -0800 (PST) Received: from nuclearis2-1.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id i9sm462972oii.34.2021.01.20.08.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 08:47:05 -0800 (PST) From: Alexandru Gagniuc To: u-boot@lists.denx.de Cc: Alexandru Gagniuc , trini@konsulko.com, marex@denx.de, sjg@chromium.org Subject: [PATCH v4 8/8] spl: fit: Load devicetree when a Linux payload is found Date: Wed, 20 Jan 2021 10:46:56 -0600 Message-Id: <20210120164656.1396639-9-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210120164656.1396639-1-mr.nuke.me@gmail.com> References: <20210120164656.1396639-1-mr.nuke.me@gmail.com> MIME-Version: 1.0 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.102.3 at phobos.denx.de X-Virus-Status: Clean When a FIT config specifies a devicetree, we should load it, no questions asked. In the case of the "simple" FIT loading path, a difficulty arises in selecting the load address of the FDT. The default FDT location is right after the "kernel" or "firmware" image. However, if that is an OP-TEE image, then the FDT may end up in secure DRAM, and not be accessible to normal world kernels. Although the best solution is to be more careful about the FDT address, a viable workaround is to only append the FDT after a u-boot or Linux image. This is identical to the previous logic, except that FDT loading is extended to IH_OS_LINUX images. Signed-off-by: Alexandru Gagniuc --- common/spl/spl_fit.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 5de36510b7..711a4f2959 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -335,6 +335,18 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, return 0; } +static bool os_takes_devicetree(uint8_t os) +{ + switch (os) { + case IH_OS_U_BOOT: + return true; + case IH_OS_LINUX: + return IS_ENABLED(CONFIG_SPL_OS_BOOT); + default: + return false; + } +} + static int spl_fit_append_fdt(struct spl_image_info *spl_image, struct spl_load_info *info, ulong sector, const struct spl_fit_info *ctx) @@ -661,9 +673,9 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, * Booting a next-stage U-Boot may require us to append the FDT. * We allow this to fail, as the U-Boot image might embed its FDT. */ - if (spl_image->os == IH_OS_U_BOOT) { + if (os_takes_devicetree(spl_image->os)) { ret = spl_fit_append_fdt(spl_image, info, sector, &ctx); - if (!IS_ENABLED(CONFIG_OF_EMBED) && ret < 0) + if (ret < 0 && spl_image->os != IH_OS_U_BOOT) return ret; } @@ -694,7 +706,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, if (!spl_fit_image_get_os(ctx.fit, node, &os_type)) debug("Loadable is %s\n", genimg_get_os_name(os_type)); - if (os_type == IH_OS_U_BOOT) { + if (os_takes_devicetree(os_type)) { spl_fit_append_fdt(&image_info, info, sector, &ctx); spl_image->fdt_addr = image_info.fdt_addr; }