From patchwork Wed Dec 16 00:09:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Gagniuc X-Patchwork-Id: 1416807 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; dmarc=pass (p=none dis=none) header.from=gmail.com 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=RVotChxJ; 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 4CwbCH3t6lz9sRf for ; Wed, 16 Dec 2020 11:11:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EF23482A64; Wed, 16 Dec 2020 01:10:31 +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="RVotChxJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8930482A4D; Wed, 16 Dec 2020 01:10:14 +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-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) (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 A4F7982A3C for ; Wed, 16 Dec 2020 01:10:05 +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-x342.google.com with SMTP id o11so21223442ote.4 for ; Tue, 15 Dec 2020 16:10:05 -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=Ank6mvAQogU8qPzKuqun+aq1l6VGh2oUX0kCygYEEJI=; b=RVotChxJf6RA1Rxja5/IANyzJCJ8+fuimQyfVoNsykb42w61Glc+Ki5D1ae8rIv8a4 n0C5id6fs/WwMUR7+ArQ9WqfdDN+BxBn+BoPK8xP0zPLR/ujcIXM47oVfnLxTA5LEy7J lVUx3qsNOt5zglOfuQXnnQHl9MulKCWQfchrlnengZme5YxdvLixsVLD7HQOSwS8784L DDAOU9sITI9jZrwBWcqmPnpTypL3pjBCkjrEX/n1rk5xB7XA0NgytaPjUB8DAsw7LGIg XBwSKMG4Hb+5rOfgYDlF5HNdQiOyNdOI6dziyp46lbiLSDLCcYWG3tYPHU8BjdzLmAVN heUw== 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=Ank6mvAQogU8qPzKuqun+aq1l6VGh2oUX0kCygYEEJI=; b=VB0gphhtMjt72HDm2h4JCxkAYtCC393G3RoWNC607sPGGwWwFiMsMuG9J7mYsdXePL bKQFcY/Y+od+2Z8X+M+f/rTuLc/28b8r2TXPPDU/AVQ68+NhZ+DUUMCQKHCCxzpngPuU xUxgRgI1KjoMQfyf1mBUChCwq+cMC7jIhjkm+UwtS5rt/fm49dePZ8DvUmKpduB3Rz9/ bKc2q2I/m23nceJAZiQfhRYaYUITfqYt4OQ1euZ9e5f5OJSZJSRAajQ8+dKAVz4fcdoe 9qxF5PzNyY/BJLH20rH7ChJS7m8bch4mxbckcYrDVWyWB4BDt0+nHrRJtB3v+TuskUUV fuyA== X-Gm-Message-State: AOAM531AUJS/eon5BSSxXcW+oNdbDFod2NiXmFGu/+h/X/jaqit33VHw wr3Vb1KW2t0ql2ThjFXFF5uXhU/FB6uETg== X-Google-Smtp-Source: ABdhPJzSpI44fvYaGHRPU+/KhoGi3xb9gBeREGXkpE0HJLQKlIGMTa3nGCMIXNCceQa0AG5saAwucw== X-Received: by 2002:a9d:620d:: with SMTP id g13mr24391639otj.56.1608077404269; Tue, 15 Dec 2020 16:10:04 -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 s23sm27319otr.59.2020.12.15.16.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 16:10:03 -0800 (PST) From: Alexandru Gagniuc To: u-boot@lists.denx.de Cc: Alexandru Gagniuc , trini@konsulko.com, marex@denx.de, Simon Glass , Jean-Jacques Hiblot , Michal Simek Subject: [PATCH 8/8] spl: fit: Load devicetree when a Linux payload is found Date: Tue, 15 Dec 2020 18:09:44 -0600 Message-Id: <20201216000944.2832585-9-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201216000944.2832585-1-mr.nuke.me@gmail.com> References: <20201216000944.2832585-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 ebfd5fa112..e64fde9e86 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) @@ -664,9 +676,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(spl_image->os)) { spl_fit_append_fdt(&image_info, info, sector, &ctx); spl_image->fdt_addr = image_info.fdt_addr; }