From patchwork Fri Sep 9 15:17:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676109 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=i1g8b3Sn; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKQL03dqz1yhP for ; Sat, 10 Sep 2022 01:18:49 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E29F984B66; Fri, 9 Sep 2022 17:18:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="i1g8b3Sn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4070C84B79; Fri, 9 Sep 2022 17:18:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) (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 4F5EB84B58 for ; Fri, 9 Sep 2022 17:18:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11eab59db71so4644912fac.11 for ; Fri, 09 Sep 2022 08:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=G3LRQTqeorZV/PtgmwxASFaEyXWCRDjBhvjl+TRR9p8=; b=i1g8b3Snr99LytqA2CVivxSTjL3zMW7FGT8v4nqFhW3pwyCcGTsE7KEe3y8Plo52WG /inXigQRQX+7BFlVlsWi8E54D+5utv2Q3w6DBDvPTTzApd6mvgStV/m/VswAwbymfTDR z8Ko5etQxs3Jzf8hQysU3bhRMibogiBdBPzUA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=G3LRQTqeorZV/PtgmwxASFaEyXWCRDjBhvjl+TRR9p8=; b=yJFIF5h9jNwcD/pX4SBTD+nnfCE5/ej8KjuX5VrZuPh3rFFi1SPhcNJSuJkJwCS3k6 zFjfDBJKkkHovULEJzjLNDzIO+4ej+roWRRva8s480wPzcRA1jMYgtMnr4/NbSTtvmzs GD+M+7DWeTuj/jSb3xZlMEY6kTWY4wV1+bAxd/d2u4XOJYS/mVw76qf2nn+V0dFtNoLd v39MZ5AChDE5JCWXN2qfqg3TVwmYGMteZLb1K7Xrq/PsTBUAxFKFdheFario/iwJ6gsY PomK4UTaSYJmSyn+oAebUx4oX4M84vk4Ey8DOB8ZFUgcr7/ni6TPiroEJiBFWo61Ci4M 6JbA== X-Gm-Message-State: ACgBeo1IpARbdEIbjTp4KWOeJnRF1sFBgRBARa811mEqJW0zHfmAhTa6 vLhB7T05sdXNFiTBOhOdeCLwfzIr9T9VSg== X-Google-Smtp-Source: AA6agR4NJoDHmXxiIyjKoNJdANes5u/i69WutlFqMkXBdaAuPDg2KYdMCdySehtyKHvcpYqsqoTAsA== X-Received: by 2002:a05:6870:b692:b0:11d:482f:3642 with SMTP id cy18-20020a056870b69200b0011d482f3642mr5062700oab.38.1662736719305; Fri, 09 Sep 2022 08:18:39 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:38 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 01/14] dm: core: Avoid registering an invalid tree in oftree_ensure() Date: Fri, 9 Sep 2022 09:17:48 -0600 Message-Id: <20220909151801.336551-2-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean If the tree is not valid we should not register it. Update the function to check this first. Signed-off-by: Simon Glass --- drivers/core/ofnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 6bdab6886b6..9a782e7b19f 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -51,7 +51,7 @@ static oftree oftree_ensure(void *fdt) oftree tree; int i; - if (gd->flags & GD_FLG_RELOC) { + if (fdt && (gd->flags & GD_FLG_RELOC)) { i = oftree_find(fdt); if (i == -1) { if (oftree_count == CONFIG_OFNODE_MULTI_TREE_MAX) { From patchwork Fri Sep 9 15:17:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676110 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=e+PDLepu; 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKQY1Q4Vz1yp6 for ; Sat, 10 Sep 2022 01:19:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A678184B73; Fri, 9 Sep 2022 17:18:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="e+PDLepu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 88E4784B5A; Fri, 9 Sep 2022 17:18:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) (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 55C7184B64 for ; Fri, 9 Sep 2022 17:18:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1278624b7c4so4710398fac.5 for ; Fri, 09 Sep 2022 08:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XMQTJa9X7yV5hq7SCnvir0MH5xnoOz/RpJ5z5Gxc9rw=; b=e+PDLepu1ENKI3MtBKCh4LrRFrIFpi84pYbsrKgK53iXhlDuQoqfUI49hj88jcapPW K8IB4+fCJNR5Jcasv3RHzPtQFEwToXNABS6D0buDQrT3BJtCl8BntMWfIblt9FmIv+n6 p3ozmRpEG5KJReQQnJMPeuceoXrYxaMabEcb8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XMQTJa9X7yV5hq7SCnvir0MH5xnoOz/RpJ5z5Gxc9rw=; b=aEHHYKA4jRXivnzvnEIU9sUVmDjyao1LksdPhFy9kCPCT2KoiWcIyuTTBktVxtorq0 0e03ifocnhbuxAiGhLZCEoC/UPkJltk1MOoKihH5yqZcRXxaklqpbqMubVtWKjrCbtff HaFwc54vSGUzCRHisj0ubzxk7sbHN3yMhxgXFreYYRsVtGnH+QR55B7o8Vf78IB2hJOg 5M/raC7/GSiMQz5f+JI0br/fAUacQMZz7U7Nc3DdBMIs5L3tZUL98OSJ0l9BKs5X3qNi UEXOMX5uf7N1s9YopeGFnECRb2t8PM5SAI5jf/TR69/m6duwgqRCuoSuOGyBNrXb8iwk Df4A== X-Gm-Message-State: ACgBeo08BdHd/bdcasJ0Yw74GylITP9YpQDbMTG2xU7GWu3wW6m07ljF rGM0C+YfOpanWOdLgeb63p0tpU5k8WfPrQ== X-Google-Smtp-Source: AA6agR7hVuZFHtKjaEbFxdqMKyk9D9pH4n0Zscq0P8soSqGzgidQ/CDXIwsi7yw3eUPjy+YUld/eyw== X-Received: by 2002:a05:6808:13c5:b0:344:96e8:82aa with SMTP id d5-20020a05680813c500b0034496e882aamr4076146oiw.67.1662736720503; Fri, 09 Sep 2022 08:18:40 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:40 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Alexandru Gagniuc , Artem Lapkin , Heinrich Schuchardt , Philippe Reynes , Sean Anderson Subject: [PATCH 02/14] bootm: Change incorrect 'unsupported' error Date: Fri, 9 Sep 2022 09:17:49 -0600 Message-Id: <20220909151801.336551-3-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean At present when bootm fails, it says: subcommand not supported and then prints help for the bootm command. This is not very useful, since generally the error is related to something else, such as fixups failing. It is quite confusing to see this in a test run. Change the error and show the error code. We could update the OS functions to return -ENOSYS when they do not support the bootm subcommand. But this involves some thought since this is arch-specific code and proper errno error codes are not always returned. Also, with the code as is, all required subcommands are of course supported - a problem would only come if someone added a new one or removed support for one from an existing OS. Therefore it seems better to leave that sort of effort for when our bootm tests are improved. Signed-off-by: Simon Glass --- boot/bootm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/bootm.c b/boot/bootm.c index f6713807fda..ed6b489c4b3 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -790,7 +790,7 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc, /* Check for unsupported subcommand. */ if (ret) { - puts("subcommand not supported\n"); + printf("subcommand failed (err=%d)\n", ret); return ret; } From patchwork Fri Sep 9 15:17:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676111 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=KvlqxTdt; 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKQk74Jhz1yhP for ; Sat, 10 Sep 2022 01:19:10 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3251684B77; Fri, 9 Sep 2022 17:18:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="KvlqxTdt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 859C584B82; Fri, 9 Sep 2022 17:18:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) (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 5E8ED84B3D for ; Fri, 9 Sep 2022 17:18:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-1225219ee46so4730017fac.2 for ; Fri, 09 Sep 2022 08:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=VNe4tmjEGFXaGzBnvHV94dSSr/8AwTj558ksztO0f24=; b=KvlqxTdtryBGu7Swk+0C/4WgWIlxFJ4t6UiZR17HDSJLUwqlZp1a5wC2450DAmKlgu ozJE/rVzwXq3+HWSDUUkeNCEXULHG1MFJEGBcrkcFAOQpYiWJ3CXOZ2LYh90f9D5DBGA CVjCQtWjV2YooH7KrAzVmqDGRdUK4sWr4W4NY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=VNe4tmjEGFXaGzBnvHV94dSSr/8AwTj558ksztO0f24=; b=cCiDv8N5W9eTefICbGZ8WfRTzn2F9iSFu6rRYmaDIqkRTwhwAzgD0L4yLk9PzLuUNl XvfhBkrsEwyWa0Ks1dHVfl1StwZV+ERPLHMnFi3oH45+CKdL3jkIXlLn0QU+gd3u61MN Z08wUezQ7no/7rMMXlVfMZwVnFMRmkBbC1WvncQmoW7hDWxAemP8JLR57+VTOI+kfTgj s0VEkz/JK1P0ShWgELtArNLsy3D8F0QSfD20ptj+/7lh07TSEmzTFH/lSfPvPiegT8gW WlvGfhbjSQ9DuD6QjFdVfHhFhjE5ot3YvJY0u0tFaOkNhQbXekr6fVj5DJNn1YpRnhtq 8NKQ== X-Gm-Message-State: ACgBeo2m8ufvMtf9Z/YkIdwF0n6HG91X/XHorhTd0mro96hVmylAt33I 47lK8A2xfm4NyxdUOertqBTWEpzNK2Mj9g== X-Google-Smtp-Source: AA6agR6ukAbCc4nk9QtpyEZfZur9n9UGbb7TUTwAplzVZdjvHft3jhM+ZSV93xrTSIqdtM9VjrUukA== X-Received: by 2002:a05:6808:bce:b0:344:f245:8a22 with SMTP id o14-20020a0568080bce00b00344f2458a22mr3957682oik.203.1662736721594; Fri, 09 Sep 2022 08:18:41 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:41 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Patrick Delaunay , Philippe Reynes , Stefan Roese Subject: [PATCH 03/14] bootm: Avoid returning error codes from command Date: Fri, 9 Sep 2022 09:17:50 -0600 Message-Id: <20220909151801.336551-4-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Functions which implement commands must return a CMD_RET_... error code. At present bootm can return a negative errno value in some cases, thus causing strange behaviour such as trying to exit the shell and printing usage information. Fix this by returning the correct value. Signed-off-by: Simon Glass --- cmd/bootm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/bootm.c b/cmd/bootm.c index d764a27002d..f09b41c2c16 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -111,7 +111,7 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, bootm_get_addr(argc, argv) + image_load_offset); #endif - return ret; + return ret ? CMD_RET_FAILURE : 0; } /*******************************************************************/ @@ -120,6 +120,8 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + int ret; + #ifdef CONFIG_NEEDS_MANUAL_RELOC static int relocated = 0; @@ -152,7 +154,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return do_bootm_subcommand(cmdtp, flag, argc, argv); } - return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START | + ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS | #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH @@ -163,6 +165,8 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) #endif BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO, &images, 1); + + return ret ? CMD_RET_FAILURE : 0; } int bootm_maybe_autostart(struct cmd_tbl *cmdtp, const char *cmd) From patchwork Fri Sep 9 15:17:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676113 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=QLbrKksM; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKR86r9Mz1yhP for ; Sat, 10 Sep 2022 01:19:32 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 28F1C84B92; Fri, 9 Sep 2022 17:18:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="QLbrKksM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F2DBE84B2C; Fri, 9 Sep 2022 17:18:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) (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 6E21484B73 for ; Fri, 9 Sep 2022 17:18:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-127ba06d03fso4722849fac.3 for ; Fri, 09 Sep 2022 08:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=4ZSHfzhvYKFxMTfrvsV9A2nsH0JUKVudWmFQIgKvA8c=; b=QLbrKksMC1DtNhgZRxKzV6+wCvv7SJavWKZCqKG7IdfOTRwyPR44thBzDSQI+uHpyd pnyQ7xaNZ+VWZIVW9ZxXkUIHsMxL2fxYO6BRkjZMjEhQt50FhWbfXSVTlg7tftiTgGIa yYKQLQNSQc9ugNbJ/qb9GyHrb8vEZAJqU8M+E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=4ZSHfzhvYKFxMTfrvsV9A2nsH0JUKVudWmFQIgKvA8c=; b=qW0Jacdr7W9Tnbu3W1vMIaOlGLxXV4iYyY1sYszFlt6Vfst+P1DtO71hBRUchmykZx ZlCeivdDbDrA6Sk29Fp/okGQoyNaE83jZEeXLoj0ZtnHqxk8Se2kKa0b3kxBW0znE2sv /Mv8l5Tnuv/pUavVFpXil5HuX5rRikFbq8HK+tLDSA1RzpjyWXa+ciwnxjA4V0uacDgr JGLi8lVlH138JtVZIPTOjFiiqJhYuaxXB8yJhC7CGWooUDkzh0SHSXlRKpifWKpHrI5s Jp1hlgAVcO8jOhXoLv3+vKnWsEsJn3GGcfFVqRbStGj9ox5BaWol84GqWH1NXonmtrCJ emlw== X-Gm-Message-State: ACgBeo06j2afQ6OoNiIKdyoVaWDy4z+aRDUCMyEKDx+Wa54vSGz9ziSx +oF9Hzy40twFBhfNMfkt+MGtTkVlNfshTQ== X-Google-Smtp-Source: AA6agR4vEoNJbi7PrCIE3wW6BcZuYlXsuMoq4x9tn3wByXixzu5P7g6EgtrCh37nklkAGLxXO2dmaw== X-Received: by 2002:a05:6870:1697:b0:127:5b5f:51bc with SMTP id j23-20020a056870169700b001275b5f51bcmr5009725oae.192.1662736722640; Fri, 09 Sep 2022 08:18:42 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:42 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Patrick Delaunay , Philippe Reynes , Stefan Roese Subject: [PATCH 04/14] bootm: Drop #ifdef from do_bootm() Date: Fri, 9 Sep 2022 09:17:51 -0600 Message-Id: <20220909151801.336551-5-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Drop the #ifdefs from this command by using a variable to hold the states that should be executed. Signed-off-by: Simon Glass --- cmd/bootm.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/bootm.c b/cmd/bootm.c index f09b41c2c16..37c2af96e08 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -120,6 +120,7 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + int states; int ret; #ifdef CONFIG_NEEDS_MANUAL_RELOC @@ -154,17 +155,15 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return do_bootm_subcommand(cmdtp, flag, argc, argv); } - ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START | - BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOTHER | - BOOTM_STATE_LOADOS | -#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH - BOOTM_STATE_RAMDISK | -#endif -#if defined(CONFIG_PPC) || defined(CONFIG_MIPS) - BOOTM_STATE_OS_CMDLINE | -#endif + states = BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD | + BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS | BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO | - BOOTM_STATE_OS_GO, &images, 1); + BOOTM_STATE_OS_GO; + if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH)) + states |= BOOTM_STATE_RAMDISK; + if (IS_ENABLED(CONFIG_PPC) || IS_ENABLED(CONFIG_MIPS)) + states |= BOOTM_STATE_OS_CMDLINE; + ret = do_bootm_states(cmdtp, flag, argc, argv, states, &images, 1); return ret ? CMD_RET_FAILURE : 0; } From patchwork Fri Sep 9 15:17:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676112 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=gTizvUPr; 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKQy01V8z1yhP for ; Sat, 10 Sep 2022 01:19:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4044484B65; Fri, 9 Sep 2022 17:18:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="gTizvUPr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A78DA84B67; Fri, 9 Sep 2022 17:18:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) (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 8230184B58 for ; Fri, 9 Sep 2022 17:18:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x334.google.com with SMTP id l5-20020a05683004a500b0063707ff8244so1242632otd.12 for ; Fri, 09 Sep 2022 08:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=nLrUWMGKbyWsmDXHDfKA7Cn/ngHcfm7SVYSk45lH228=; b=gTizvUPr+t4BqHUN6SZdOnITI8JlvoOoSXv7rkIGWEfawaEyju0bHuRwfFMa6vDqwX eXbiMXQ3T2V1SWU7Il/Y4numoRH9dUbFLMliuOyVoTwIEg0Fcz2ZiF4i4raJkpxJ3qot tCO2QMC4d6E+OvZxst6jWsYCbCX9yPGNyn4Bg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=nLrUWMGKbyWsmDXHDfKA7Cn/ngHcfm7SVYSk45lH228=; b=uXqhQFQ3o/xa4vcCMuZUwjWuOhmdGYDbINvuYj93JcE8TmymXNfvJpAQEbOLBSPPXN yUqzlbFXqMxUDo5edkjgE/sGDA4U5PAESGOVsjdDB7+QKBmthoQD86wSwBRNi8I7Juhv Wifmx8U85/RV1oiS1fSBG97ToY2yZHq4i7E4ze8v9xij1QNyZTlSsxBADlCSPgLXyEmc GlZQG+P/mH+6v2i6tUthmAtaecLrTBn01D2FT9ITiPYlomZeDJMnuSIUKl9GyAYp7lVE /N7+hZ1VEjIVJlZumA/0h+99l8+k+m/Tf1Qp65RekMPlbWdoBJwqQc0BRaciXwLNr3VY Oe7A== X-Gm-Message-State: ACgBeo1zaf2G9vWVPyk2+vzAE4n/Jb+tbroNvtsmgX+sTDpa2g+CmAws r5V+O4wtne8cDJg/PrIAArMWxZYriYFUuQ== X-Google-Smtp-Source: AA6agR70AnZz7uIqbZjL7A1ac0HWQPEfV0s9v+n6Y0i4km/1UvVRiw2NoOIfYcQ0I68BLLDH1nx1Zg== X-Received: by 2002:a9d:62d2:0:b0:637:2729:9bb8 with SMTP id z18-20020a9d62d2000000b0063727299bb8mr5661366otk.222.1662736723763; Fri, 09 Sep 2022 08:18:43 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:43 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Alexandru Gagniuc , Artem Lapkin , Daniel Golle , Heinrich Schuchardt , Marek Vasut Subject: [PATCH 05/14] boot: Correct handling of addresses in boot_relocate_fdt() Date: Fri, 9 Sep 2022 09:17:52 -0600 Message-Id: <20220909151801.336551-6-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean This code uses casts between addresses and pointers, so does not work with sandbox. Update it so we can allow sandbox to do device tree fixups. Signed-off-by: Simon Glass --- boot/image-fdt.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/boot/image-fdt.c b/boot/image-fdt.c index 884e089f2d8..f651940d9b4 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -186,24 +186,25 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size) /* If fdt_high is set use it to select the relocation address */ fdt_high = env_get("fdt_high"); if (fdt_high) { - void *desired_addr = (void *)hextoul(fdt_high, NULL); + ulong desired_addr = hextoul(fdt_high, NULL); + ulong addr; - if (((ulong) desired_addr) == ~0UL) { + if (desired_addr == ~0UL) { /* All ones means use fdt in place */ of_start = fdt_blob; - lmb_reserve(lmb, (ulong)of_start, of_len); + lmb_reserve(lmb, map_to_sysmem(of_start), of_len); disable_relocation = 1; } else if (desired_addr) { - of_start = - (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000, - (ulong)desired_addr); + addr = lmb_alloc_base(lmb, of_len, 0x1000, + desired_addr); + of_start = map_sysmem(addr, of_len); if (of_start == NULL) { puts("Failed using fdt_high value for Device Tree"); goto error; } } else { - of_start = - (void *)(ulong) lmb_alloc(lmb, of_len, 0x1000); + addr = lmb_alloc(lmb, of_len, 0x1000); + of_start = map_sysmem(addr, of_len); } } else { mapsize = env_get_bootm_mapsize(); @@ -224,9 +225,8 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size) * At least part of this DRAM bank is usable, try * using it for LMB allocation. */ - of_start = - (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000, - start + usable); + of_start = map_sysmem((ulong)lmb_alloc_base(lmb, + of_len, 0x1000, start + usable), of_len); /* Allocation succeeded, use this block. */ if (of_start != NULL) break; From patchwork Fri Sep 9 15:17:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676115 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=iCWzNl8N; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKRc1mBlz1yp8 for ; Sat, 10 Sep 2022 01:19:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 50E8584B9D; Fri, 9 Sep 2022 17:19:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="iCWzNl8N"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8AAF584B89; Fri, 9 Sep 2022 17:18:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) (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 D832B84B5A for ; Fri, 9 Sep 2022 17:18:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-127dca21a7dso4636025fac.12 for ; Fri, 09 Sep 2022 08:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=z6Jy7WTQMImA6LM/9bYUO4MpARv1mTbkBlW6SCcQ3CE=; b=iCWzNl8NrfVUSCkve1iw2v1iKRViSa+oxBvdNqXme+GjxNRt8/s5IzcMAv3VdOOgaQ BYWh/HumHowXU/xO+T2Eu9yAKvYS9buUqufPQWOoq+RCSqPsPTmZJwWnKMmaq1qWJGKT C+3pKkZ41/fQX+pE+jpFyMLHpscD4mTIy+lLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=z6Jy7WTQMImA6LM/9bYUO4MpARv1mTbkBlW6SCcQ3CE=; b=x/HSDEgglGi+q/V84yCIoUYtmRokF8e/qgYf8by1d+o9P+xAGzINQJS7hXgVdqky/e DMLCPXWNRY9/q4y9EGO8+agTkCOmRyoz53OmSbMFK0K2xtsIKsU4KCvfOv0SB+HEF+z0 SUhwbTW2XJPmKwy+px+zuRRpz8F9BAw+FXaPKTRF2c/0ieTF5ME9+NWOHTEHXI1M/VZR jsK+bN5kwr/Q/2neBDc2rOPVYDV/p1pYeUXuArSZISot/yp5dup2QnNV+xGcw8S4qxd/ WbXLcADIEM8tUYRwS+LEyBv37iv/ykIgsJq547PtE4sPewMALkbs4XF5vtR7hhpaaiHL 8N0w== X-Gm-Message-State: ACgBeo2fCSFbJG5tvopRTVMzFTI5D5ODOB/Xdp3BQL75QFpe0mdSaA+x MjQiSohk9kxcg8PeH6AOSjK4C2CEMSbMAQ== X-Google-Smtp-Source: AA6agR72I94eWZfQD/AmcKdpZ7Z03aH4B70v5T4r1MMcqh8gx0/CxQYUs/5c92P/mg372scUruuH3A== X-Received: by 2002:a05:6870:88a6:b0:126:b40a:1f2d with SMTP id m38-20020a05687088a600b00126b40a1f2dmr5078073oam.119.1662736724994; Fri, 09 Sep 2022 08:18:44 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:44 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Heinrich Schuchardt , =?utf-8?q?Marek_Beh=C3=BAn?= , =?utf-8?q?Pali_Roh=C3=A1r?= , Philippe Reynes , Qu Wenruo , Stefan Roese , linux-btrfs@vger.kernel.org Subject: [PATCH 06/14] fs: Quieten down the filesystems more Date: Fri, 9 Sep 2022 09:17:53 -0600 Message-Id: <20220909151801.336551-7-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean When looking for a filesystem on a partition we should do so quietly. At present if the filesystem is very small (e.g. 512 bytes) we get a host of messages. Update these to only show when debugging. Signed-off-by: Simon Glass --- disk/part_efi.c | 15 +++++++-------- fs/btrfs/disk-io.c | 7 ++++--- fs/ext4/ext4_common.c | 2 +- fs/fs_internal.c | 3 +-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 5090efd1192..911089f76dd 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -266,20 +266,19 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part, /* "part" argument must be at least 1 */ if (part < 1) { - printf("%s: Invalid Argument(s)\n", __func__); - return -1; + log_debug("Invalid Argument(s)\n"); + return -EINVAL; } /* This function validates AND fills in the GPT header and PTE */ if (find_valid_gpt(dev_desc, gpt_head, &gpt_pte) != 1) - return -1; + return -EINVAL; if (part > le32_to_cpu(gpt_head->num_partition_entries) || !is_pte_valid(&gpt_pte[part - 1])) { - debug("%s: *** ERROR: Invalid partition number %d ***\n", - __func__, part); + log_debug("*** ERROR: Invalid partition number %d ***\n", part); free(gpt_pte); - return -1; + return -EPERM; } /* The 'lbaint_t' casting may limit the maximum disk size to 2 TB */ @@ -302,8 +301,8 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part, info->type_guid, UUID_STR_FORMAT_GUID); #endif - debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s\n", __func__, - info->start, info->size, info->name); + log_debug("start 0x" LBAF ", size 0x" LBAF ", name %s\n", info->start, + info->size, info->name); /* Remember to free pte */ free(gpt_pte); diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8043abc1bd6..e2562877e0a 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ #include #include +#include #include #include #include "kernel-shared/btrfs_tree.h" @@ -912,9 +913,9 @@ static int btrfs_scan_fs_devices(struct blk_desc *desc, if (round_up(BTRFS_SUPER_INFO_SIZE + BTRFS_SUPER_INFO_OFFSET, desc->blksz) > (part->size << desc->log2blksz)) { - error("superblock end %u is larger than device size " LBAFU, - BTRFS_SUPER_INFO_SIZE + BTRFS_SUPER_INFO_OFFSET, - part->size << desc->log2blksz); + log_debug("superblock end %u is larger than device size " LBAFU, + BTRFS_SUPER_INFO_SIZE + BTRFS_SUPER_INFO_OFFSET, + part->size << desc->log2blksz); return -EINVAL; } diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index d49ba4a9954..1185cb2c046 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -2415,7 +2415,7 @@ int ext4fs_mount(unsigned part_length) return 1; fail: - printf("Failed to mount ext2 filesystem...\n"); + log_debug("Failed to mount ext2 filesystem...\n"); fail_noerr: free(data); ext4fs_root = NULL; diff --git a/fs/fs_internal.c b/fs/fs_internal.c index ae1cb8584c7..111f91b355d 100644 --- a/fs/fs_internal.c +++ b/fs/fs_internal.c @@ -29,8 +29,7 @@ int fs_devread(struct blk_desc *blk, struct disk_partition *partition, /* Check partition boundaries */ if ((sector + ((byte_offset + byte_len - 1) >> log2blksz)) >= partition->size) { - log_err("%s read outside partition " LBAFU "\n", __func__, - sector); + log_debug("read outside partition " LBAFU "\n", sector); return 0; } From patchwork Fri Sep 9 15:17:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676114 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=fN1OZf/v; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKRM3Vqxz1yhP for ; Sat, 10 Sep 2022 01:19:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BEB3E84B8F; Fri, 9 Sep 2022 17:18:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="fN1OZf/v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D2DEF84B89; Fri, 9 Sep 2022 17:18:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) (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 CF60A84B3D for ; Fri, 9 Sep 2022 17:18:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-1278a61bd57so4680642fac.7 for ; Fri, 09 Sep 2022 08:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=hqrAHzHCEzb4xBXPOms9TfcXH0j+zueMuJZ/TyrqY08=; b=fN1OZf/vYZLa+CeIAap8A2F7qq0lPUyBXOVk/2wnvUXdFuA/WI3UDZDHdLJds68tgL oveVcgjOd08qHzIGQRvGhfQnrJUm/lDA0Hrn0KSuQ31cKxaGC0Yqko8AGjCev2xBl2My Vv5jjchLWnduvMSRUuLcHUP8eRg3C4bHjIUzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=hqrAHzHCEzb4xBXPOms9TfcXH0j+zueMuJZ/TyrqY08=; b=PeRa4slPLqGKI9t8aSE1sN/nRaRVj5QcFVPwJ/H56dbKqo0XbztBmh78CX/oO3AO8v lMHNJpJeQ/2uuy6UNfxyF75qnJiLMVksR0FHaFoe9/GtsRfLNjh8EahHBAa2sbFkgBRB sxYEAloUmWtB4RATQY0waa2dMRnGlBHT4yzu5I4TEQmzGhuxzkCYPNEC3QkDuqm0+Gus sLcV/HPfdOhKI1jFNtOT8elBF3ET9oIf3VRllXP0/ZjhS7f9HwKAVs/C1Umc2jbcy9LR +J4cCwx+MFr0jKfbhdCOfHCb3MuCDL/p0SI1zkjOxJp8fHNFb6pA1MIuXdd7uCwVTWn/ 5Z3g== X-Gm-Message-State: ACgBeo3V54+QhcUiyoMsQ3dHEodhKXzfoENZe67dJCPiqt+kRFwHzU8D /ESaKR3oyH8A+eEFQ4mFgurRKhPDi3HX1Q== X-Google-Smtp-Source: AA6agR40qQciJH/sb9m1fOHRtDqQrBsas9ESrEWJ+IMxRhZ0TGMTXvv6lZeSKhNEtZeDpZ5P2GpL3g== X-Received: by 2002:a05:6870:9729:b0:127:529c:a04 with SMTP id n41-20020a056870972900b00127529c0a04mr5031097oaq.250.1662736726107; Fri, 09 Sep 2022 08:18:46 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:45 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Jerry Van Baren Subject: [PATCH 07/14] fdt: Show a message when the working FDT changes Date: Fri, 9 Sep 2022 09:17:54 -0600 Message-Id: <20220909151801.336551-8-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean The working FDT is the one which comes from the OS and is fixed up by U-Boot. When the bootm command runs, it sets up the working FDT to be the one it is about to pass to the OS, so that fixups can happen. This seems like an important step, so add a message indicating that the working FDT has changed. This is shown during the running of the bootm command. Signed-off-by: Simon Glass --- cmd/fdt.c | 1 + doc/usage/cmd/fdt.rst | 1 + test/cmd/fdt.c | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index 842e6cb634b..0afc7222c74 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -40,6 +40,7 @@ void set_working_fdt_addr(ulong addr) { void *buf; + printf("Working FDT set to %lx\n", addr); buf = map_sysmem(addr, 0); working_fdt = buf; env_set_hex("fdtaddr", addr); diff --git a/doc/usage/cmd/fdt.rst b/doc/usage/cmd/fdt.rst index 07fed732e45..36b8230877c 100644 --- a/doc/usage/cmd/fdt.rst +++ b/doc/usage/cmd/fdt.rst @@ -60,6 +60,7 @@ The second word shows the size of the FDT. Now set the working FDT to that address and expand it to 0xf000 in size:: => fdt addr 10000 f000 + Working FDT set to 10000 => md 10000 4 00010000: edfe0dd0 00f00000 78000000 7c270000 ...........x..'| diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 100a7ef5ebf..ba9eaa42c14 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -55,6 +55,7 @@ static int fdt_test_addr(struct unit_test_state *uts) /* The working fdt is not set, so this should fail */ set_working_fdt_addr(0); + ut_assert_nextline("Working FDT set to 0"); ut_asserteq(CMD_RET_FAILURE, run_command("fdt addr", 0)); ut_assert_nextline("libfdt fdt_check_header(): FDT_ERR_BADMAGIC"); ut_assertok(ut_check_console_end(uts)); @@ -63,18 +64,22 @@ static int fdt_test_addr(struct unit_test_state *uts) ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt))); addr = map_to_sysmem(fdt); set_working_fdt_addr(addr); + ut_assert_nextline("Working FDT set to %lx", addr); ut_assertok(run_command("fdt addr", 0)); ut_assert_nextline("Working fdt: %08lx", (ulong)map_to_sysmem(fdt)); ut_assertok(ut_check_console_end(uts)); /* Set the working FDT */ set_working_fdt_addr(0); + ut_assert_nextline("Working FDT set to 0"); ut_assertok(run_commandf("fdt addr %08x", addr)); + ut_assert_nextline("Working FDT set to %lx", addr); ut_asserteq(addr, map_to_sysmem(working_fdt)); ut_assertok(ut_check_console_end(uts)); set_working_fdt_addr(0); + ut_assert_nextline("Working FDT set to 0"); - /* Set the working FDT */ + /* Set the control FDT */ fdt_blob = gd->fdt_blob; gd->fdt_blob = NULL; ret = run_commandf("fdt addr -c %08x", addr); @@ -93,6 +98,7 @@ static int fdt_test_addr(struct unit_test_state *uts) /* Test detecting an invalid FDT */ fdt[0] = 123; set_working_fdt_addr(addr); + ut_assert_nextline("Working FDT set to %lx", addr); ut_asserteq(1, run_commandf("fdt addr")); ut_assert_nextline("libfdt fdt_check_header(): FDT_ERR_BADMAGIC"); ut_assertok(ut_check_console_end(uts)); @@ -115,16 +121,19 @@ static int fdt_test_resize(struct unit_test_state *uts) /* Test setting and resizing the working FDT to a larger size */ ut_assertok(console_record_reset_enable()); ut_assertok(run_commandf("fdt addr %08x %x", addr, newsize)); + ut_assert_nextline("Working FDT set to %lx", addr); ut_assertok(ut_check_console_end(uts)); /* Try shrinking it */ ut_assertok(run_commandf("fdt addr %08x %x", addr, sizeof(fdt) / 4)); + ut_assert_nextline("Working FDT set to %lx", addr); ut_assert_nextline("New length %d < existing length %d, ignoring", (int)sizeof(fdt) / 4, newsize); ut_assertok(ut_check_console_end(uts)); /* ...quietly */ ut_assertok(run_commandf("fdt addr -q %08x %x", addr, sizeof(fdt) / 4)); + ut_assert_nextline("Working FDT set to %lx", addr); ut_assertok(ut_check_console_end(uts)); /* We cannot easily provoke errors in fdt_open_into(), so ignore that */ From patchwork Fri Sep 9 15:17:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676117 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Lm4JRD+A; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKRy2XXbz1yhP for ; Sat, 10 Sep 2022 01:20:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BC4F484BA4; Fri, 9 Sep 2022 17:19:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Lm4JRD+A"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D41684B6B; Fri, 9 Sep 2022 17:18:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) (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 20FA884B92 for ; Fri, 9 Sep 2022 17:18:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-127dca21a7dso4636351fac.12 for ; Fri, 09 Sep 2022 08:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=AktCf4rbpkyB+pQT/FVQEoV03evQFTPlvYN09IDnnyA=; b=Lm4JRD+AJ54LW4JglcTKKshVQJELBBq2nDgdDBRAUdNYOBX/KO7Cznb+FYXBD/AcyY wS+AJQHZZMgRe35GRfkymHWxGaG9JFyEfiVJfI/9dvJ0bMdsKCpRcszIZ26tLHDqlrAy katDpkHvEiLB0g4NTlExaHqvwKdFjz4k6+d7E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=AktCf4rbpkyB+pQT/FVQEoV03evQFTPlvYN09IDnnyA=; b=Kqhkf02a6d9XCGC3ts3Xoy3rc2o/lwa+IBKxYdFxEqZKAecBjLL5eavL0ip/GKNhvf YbhBrtrArWJ6wdxO415lWQ+rG0SuXAMwutxWhTHkaREdQhFvHjuUnv7fPiWRUPGvK2vI tfEn6MnOKhU6vkiNhR8o0nuvftQe6xNmq3VAFHH8u/RZm2D9uHtyq4saHRe5Gh0v9xgL uGnHp4eB27APVbFc+Ccx76Pco/RuE3Vj/V+RFmaeCDKOMgFdSYnkg6iaGSZgvKcnys0/ 3Ec8vpNEavZrz2Fq8u/qIH7teXafy3En8cq4HeYzCYCQ4nTc7dcF5RVin4/bcxM2nHZ8 ku6w== X-Gm-Message-State: ACgBeo2+c9UYoPGGtc21jQnbZxY4vHKhsmBOi6gttiANMUTrCRfJP482 5/DOsQJpZ3acmN3KzLyRQOKlWDe2zAimUg== X-Google-Smtp-Source: AA6agR6JQru02QuOnCI6XjzmE8WQO5a1awzGJGU4hU8zBnKqMatMUdzzncc2vls+doQvBCJUQY+5Uw== X-Received: by 2002:a05:6870:2482:b0:101:52cf:d099 with SMTP id s2-20020a056870248200b0010152cfd099mr5426783oaq.44.1662736727237; Fri, 09 Sep 2022 08:18:47 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:46 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH 08/14] bootstd: Move VBE setup into a shared function Date: Fri, 9 Sep 2022 09:17:55 -0600 Message-Id: <20220909151801.336551-9-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean This information needs to be set up by the bootstd tests as well. Move it into a common function and ensure it is executed before any bootstd test is run. Make sure the 'images' parameter is set correctly for fixups. Signed-off-by: Simon Glass --- test/boot/bootstd_common.c | 48 ++++++++++++++++++++++++++++++++++++++ test/boot/bootstd_common.h | 16 +++++++++++++ test/boot/vbe_simple.c | 34 ++++----------------------- 3 files changed, 68 insertions(+), 30 deletions(-) diff --git a/test/boot/bootstd_common.c b/test/boot/bootstd_common.c index 05347d87106..59d46bef0c5 100644 --- a/test/boot/bootstd_common.c +++ b/test/boot/bootstd_common.c @@ -9,10 +9,46 @@ #include #include #include +#include +#include +#include #include #include +#include #include "bootstd_common.h" +bool vbe_setup_done; + +/* set up MMC for VBE tests */ +int bootstd_setup_for_tests(void) +{ + ALLOC_CACHE_ALIGN_BUFFER(u8, buf, MMC_MAX_BLOCK_LEN); + struct udevice *mmc; + struct blk_desc *desc; + int ret; + + /* Set up the version string */ + ret = uclass_get_device(UCLASS_MMC, 1, &mmc); + if (ret) + return log_msg_ret("mmc", -EIO); + desc = blk_get_by_device(mmc); + + memset(buf, '\0', MMC_MAX_BLOCK_LEN); + strcpy(buf, TEST_VERSION); + if (blk_dwrite(desc, VERSION_START_BLK, 1, buf) != 1) + return log_msg_ret("wr1", -EIO); + + /* Set up the nvdata */ + memset(buf, '\0', MMC_MAX_BLOCK_LEN); + buf[1] = ilog2(0x40) << 4 | 1; + *(u32 *)(buf + 4) = TEST_VERNUM; + buf[0] = crc8(0, buf + 1, 0x3f); + if (blk_dwrite(desc, NVDATA_START_BLK, 1, buf) != 1) + return log_msg_ret("wr2", -EIO); + + return 0; +} + int bootstd_test_drop_bootdev_order(struct unit_test_state *uts) { struct bootstd_priv *priv; @@ -30,6 +66,18 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd_test); const int n_ents = UNIT_TEST_SUITE_COUNT(bootstd_test); + if (!vbe_setup_done) { + int ret; + + ret = bootstd_setup_for_tests(); + if (ret) { + printf("Failed to set up for bootstd tests (err=%d)\n", + ret); + return CMD_RET_FAILURE; + } + vbe_setup_done = true; + } + return cmd_ut_category("bootstd", "bootstd_test_", tests, n_ents, argc, argv); } diff --git a/test/boot/bootstd_common.h b/test/boot/bootstd_common.h index 676ef0a57f9..c5e0fd1ceab 100644 --- a/test/boot/bootstd_common.h +++ b/test/boot/bootstd_common.h @@ -9,10 +9,17 @@ #ifndef __bootstd_common_h #define __bootstd_common_h +#include + /* Declare a new bootdev test */ #define BOOTSTD_TEST(_name, _flags) \ UNIT_TEST(_name, _flags, bootstd_test) +#define NVDATA_START_BLK ((0x400 + 0x400) / MMC_MAX_BLOCK_LEN) +#define VERSION_START_BLK ((0x400 + 0x800) / MMC_MAX_BLOCK_LEN) +#define TEST_VERSION "U-Boot v2022.04-local2" +#define TEST_VERNUM 0x00010002 + struct unit_test_state; /** @@ -24,4 +31,13 @@ struct unit_test_state; */ int bootstd_test_drop_bootdev_order(struct unit_test_state *uts); +/** + * bootstd_setup_for_tests() - Set up MMC data for VBE tests + * + * Some data is needed for VBE tests to work. This function sets that up. + * + * @return 0 if OK, -ve on error + */ +int bootstd_setup_for_tests(void); + #endif diff --git a/test/boot/vbe_simple.c b/test/boot/vbe_simple.c index 8acd777f4cd..faba9e8f90b 100644 --- a/test/boot/vbe_simple.c +++ b/test/boot/vbe_simple.c @@ -10,54 +10,27 @@ #include #include #include -#include -#include #include #include -#include -#include #include #include -#include #include "bootstd_common.h" -#define NVDATA_START_BLK ((0x400 + 0x400) / MMC_MAX_BLOCK_LEN) -#define VERSION_START_BLK ((0x400 + 0x800) / MMC_MAX_BLOCK_LEN) -#define TEST_VERSION "U-Boot v2022.04-local2" -#define TEST_VERNUM 0x00010002 - /* Basic test of reading nvdata and updating a fwupd node in the device tree */ static int vbe_simple_test_base(struct unit_test_state *uts) { - ALLOC_CACHE_ALIGN_BUFFER(u8, buf, MMC_MAX_BLOCK_LEN); const char *version, *bl_version; struct event_ft_fixup fixup; - struct udevice *dev, *mmc; + struct udevice *dev; struct device_node *np; - struct blk_desc *desc; char fdt_buf[0x400]; char info[100]; int node_ofs; ofnode node; u32 vernum; - /* Set up the version string */ - ut_assertok(uclass_get_device(UCLASS_MMC, 1, &mmc)); - desc = blk_get_by_device(mmc); - ut_assertnonnull(desc); - - memset(buf, '\0', MMC_MAX_BLOCK_LEN); - strcpy(buf, TEST_VERSION); - if (blk_dwrite(desc, VERSION_START_BLK, 1, buf) != 1) - return log_msg_ret("write", -EIO); - - /* Set up the nvdata */ - memset(buf, '\0', MMC_MAX_BLOCK_LEN); - buf[1] = ilog2(0x40) << 4 | 1; - *(u32 *)(buf + 4) = TEST_VERNUM; - buf[0] = crc8(0, buf + 1, 0x3f); - if (blk_dwrite(desc, NVDATA_START_BLK, 1, buf) != 1) - return log_msg_ret("write", -EIO); + /* Set up the VBE info */ + ut_assertok(bootstd_setup_for_tests()); /* Read the version back */ ut_assertok(vbe_find_by_any("firmware0", &dev)); @@ -90,6 +63,7 @@ static int vbe_simple_test_base(struct unit_test_state *uts) * * Two fix this we need image_setup_libfdt() is updated to use ofnode */ + fixup.images = NULL; ut_assertok(event_notify(EVT_FT_FIXUP, &fixup, sizeof(fixup))); node = oftree_path(fixup.tree, "/chosen/fwupd/firmware0"); From patchwork Fri Sep 9 15:17:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676116 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=KKvwdamQ; 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKRm0Gyxz1yhP for ; Sat, 10 Sep 2022 01:20:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8784684BA1; Fri, 9 Sep 2022 17:19:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="KKvwdamQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0DA7884B79; Fri, 9 Sep 2022 17:18:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) (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 39C5284B2C for ; Fri, 9 Sep 2022 17:18:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-127dca21a7dso4636516fac.12 for ; Fri, 09 Sep 2022 08:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=WaZqBf1YRz4t4/zjcqT+wiX3JTrEedQ4iUF6/SxkVF8=; b=KKvwdamQukTitq+6pDKFdL8422fF/XCLeWGwJn3rwSc01p91YNg5Iwfw4rFTqtkQYs 3Hs6pcbnrF+/WMcz8I4HOe9ewhKQiVfb6r7HnySdoYI+v0FQdyc0NRgdw3K8nM/LZ9Hu RARF5v5RkzVsdcq/7syDaqCMxlXCpt86KJ8c8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=WaZqBf1YRz4t4/zjcqT+wiX3JTrEedQ4iUF6/SxkVF8=; b=n8NtUSzzxpxQkrdZFioRANCJw1Up3d+M9DOl/XQGO/0azcmFq1twQn2/+YAA1fliOy 22WlmopQFXnQWM8JbYM3qQSk5672+qKCTUgyKAWhrTczDubfGoXkCjJKy/OT6BNzOp9+ kDT+wA+os1Bd7ehVdyKu2F57Ljp6xbQe/XzqUwgfMO+OHGE94F+mCbn+iDQHps9sr4nG A/nKLjmZHc9HerINuh89Xq2MWdX+0o1s9YgXzRblpQr7WwaIyEeuA7rZFE9QVWXZwkKl FlgEJzoFoXxQFoCvt05VXiJoxOPlUWN/UT7Wc0YEjkp1+c64B3Rga8pi7Z5T04cjVDQo aYjg== X-Gm-Message-State: ACgBeo3ynvj6EgbhYp9wdKah8xc7HtlJy8ZNX0XVHUXOom8bleNmiPBu lPZMGPXIFHNwQ+6NNd3ZBmhXxaKZfWFxpw== X-Google-Smtp-Source: AA6agR5IAdgXu7mPvdrpyS453B/imMx9bNkG6wlCueS1hZw3f+AzZBmwMl2YTapOFPcfXYr5DPghMg== X-Received: by 2002:a05:6870:d1c5:b0:127:4089:929d with SMTP id b5-20020a056870d1c500b001274089929dmr5272073oac.203.1662736728452; Fri, 09 Sep 2022 08:18:48 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:48 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH 09/14] sandbox: Support FDT fixups Date: Fri, 9 Sep 2022 09:17:56 -0600 Message-Id: <20220909151801.336551-10-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Add support for doing device tree fixups in sandbox. This allows us to test that functionality in CI. Signed-off-by: Simon Glass --- arch/sandbox/lib/bootm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c index c1742f94de7..28f4a746fb6 100644 --- a/arch/sandbox/lib/bootm.c +++ b/arch/sandbox/lib/bootm.c @@ -50,8 +50,25 @@ int bootz_setup(ulong image, ulong *start, ulong *end) return ret; } +/* Subcommand: PREP */ +static int boot_prep_linux(struct bootm_headers *images) +{ + int ret; + + if (CONFIG_IS_ENABLED(LMB)) { + ret = image_setup_linux(images); + if (ret) + return ret; + } + + return 0; +} + int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images) { + if (flag & BOOTM_STATE_OS_PREP) + return boot_prep_linux(images); + if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) { bootstage_mark(BOOTSTAGE_ID_RUN_OS); printf("## Transferring control to Linux (at address %08lx)...\n", From patchwork Fri Sep 9 15:17:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676118 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=RV2xu1/2; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKS90MRBz1yhP for ; Sat, 10 Sep 2022 01:20:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B15F484BA3; Fri, 9 Sep 2022 17:19:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="RV2xu1/2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 741DB84B82; Fri, 9 Sep 2022 17:18:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) (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 4D4BB84B65 for ; Fri, 9 Sep 2022 17:18:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11eab59db71so4646276fac.11 for ; Fri, 09 Sep 2022 08:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=sTfsNaRU7ePmWtnzvee2SqbzIQTIB6Lwpv9jzRGyqKI=; b=RV2xu1/2yYahQKPGpg4FtOCB0ra4jsalrdqmzgOebY1TdHf/eUOatQsBN6mF3cRbP2 2EjA70erOdM54QKMxtKcKzL6IOcwkvxs4obwiO2S9ZCEW7wcT/ezP1P/uSys1YKWIF1R 86dg8v7xJUTOM7L6Pzv9YJjh2DfS81oiT+6rE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=sTfsNaRU7ePmWtnzvee2SqbzIQTIB6Lwpv9jzRGyqKI=; b=6LRC4DBj3zpmqAurQLr/H8GL+TqlEZDLW9wfwuRFpM1pSFMxEOL/BPBFXvDYCFe6gq oFx6qO5T4uOX61LIedLCVywPnwx/gTJ54COeqyv09zSl1uQaYCngd9aRtJ99C0CpDQxP BgBkXpOqQlI/a9lOd/t2bj420y76Y+1r1LeIJ3yKfoyfeYANeRiNN5O08h38arVBtirl +592EnUkXld6aKsZUH6TAht2QNDqB1cl0TRsSAI+1PuLWXry3PACdZR/byw+GK2ZDMNc EJVh2RiBNIY/PEJFs/JgMb3mXYhmGXrMtGtQ4KZIw5mw3BdON4YSH3Sp8LPOSOnmauKy aE5A== X-Gm-Message-State: ACgBeo3b64x4YLUhXCwUarwE1QhqGiIpMnalL1bpu4nQE+c0GbVqXV9v aYxdj+Qiiesd/S6OoxYkUoZJAyfsGXSiTQ== X-Google-Smtp-Source: AA6agR7hfR8UNbyaULwiVVLfnc8wZcMRIgsYSHL9TvtOhWtmgyifk7f7PmIV4xxNWnrGFdAbXd0p4g== X-Received: by 2002:a05:6870:a925:b0:124:134c:159a with SMTP id eq37-20020a056870a92500b00124134c159amr5208257oab.223.1662736729539; Fri, 09 Sep 2022 08:18:49 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:49 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Alexandru Gagniuc , Daniel Golle , Heinrich Schuchardt , Marek Vasut Subject: [PATCH 10/14] boot: Pass the correct FDT to the EVT_FT_FIXUP event Date: Fri, 9 Sep 2022 09:17:57 -0600 Message-Id: <20220909151801.336551-11-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Now that we support multiple device trees with the ofnode interface, we can pass the correct FDT to this event. This allows the 'working' FDT to be fixed up, as expected, so long as OFNODE_MULTI_TREE is enabled. Also make sure we don't try to do this with livetree, which does not support fixups yet. Signed-off-by: Simon Glass --- boot/image-fdt.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/boot/image-fdt.c b/boot/image-fdt.c index f651940d9b4..b830a0ab418 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -665,15 +665,18 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, goto err; } } - if (CONFIG_IS_ENABLED(EVENT)) { + if (!of_live_active() && CONFIG_IS_ENABLED(EVENT)) { struct event_ft_fixup fixup; - fixup.tree = oftree_default(); + fixup.tree = oftree_from_fdt(blob); fixup.images = images; - ret = event_notify(EVT_FT_FIXUP, &fixup, sizeof(fixup)); - if (ret) { - printf("ERROR: fdt fixup event failed: %d\n", ret); - goto err; + if (oftree_valid(fixup.tree)) { + ret = event_notify(EVT_FT_FIXUP, &fixup, sizeof(fixup)); + if (ret) { + printf("ERROR: fdt fixup event failed: %d\n", + ret); + goto err; + } } } From patchwork Fri Sep 9 15:17:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676119 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Xw+uiCOu; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKSM2cxXz1yhP for ; Sat, 10 Sep 2022 01:20:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C431F84BB5; Fri, 9 Sep 2022 17:19:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Xw+uiCOu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 07F4884B85; Fri, 9 Sep 2022 17:18:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) (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 75DE084B7C for ; Fri, 9 Sep 2022 17:18:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-11e9a7135easo4690801fac.6 for ; Fri, 09 Sep 2022 08:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=HrV0En/9b/+RfZMIwu/tQeGyz7BMDfuSPX0BQT2bIrY=; b=Xw+uiCOulXZS7MgH/SZx8zdI66DrpFJeeSt7yuuQfFtgSwiRUUxj4x2bgg7riIbnKz vKH1nbShTk/Br4HYfOhAqu7rga99kjdE7qNLf1Hhwls8pWiJzHXp/o2sClnwArqcsKvD L5fTJgfdunhzUZoudCzXqVMzH7jTBfzQx+Zyg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=HrV0En/9b/+RfZMIwu/tQeGyz7BMDfuSPX0BQT2bIrY=; b=VXx9D/vs9YlMxvOhyU3m+nHwMdC6FFZbffRO+3fltyKgI9Waq3CXO59j+vq5VH3B9k mdtXSts/1uMNAJuhHtcL+MSeUV5RVux1AtiUnEOMY3ZNy6Gg1g011dz/FpmfG+/EBbfZ eSqBc6wr+UyoQHSj09dmpzgMwCLEpbBF+WENyMfaFNXYxeUBdH1t3yaIyfnodZTgjMNU I3+w/0+4X7tt9ipdNLXed7XgSDMDUMH7q9FOnKq8vxqo8M5j1rNXARH+y54S6cOz7D/L 15KaTpjo75rfXFynLq0Wg6mfOR46raVft/MhhXqWTGy5NTQwkpYjQx9pYPLFZrD9+oXb 6aRQ== X-Gm-Message-State: ACgBeo1cb1u8OOGAcsws1vrIE42znotCf94G78NUEfeRfPVa+3bOjb7s +IpbDeCbdWrO174dxevjobfwjx/915YkVA== X-Google-Smtp-Source: AA6agR7d6lZss4EOI+pjH/ADlbib8ZjVd7YJZ28I0lV7RujXao7LhtBBhsubHtBzpTvwgdETF+adpw== X-Received: by 2002:aca:1219:0:b0:343:58a:79a8 with SMTP id 25-20020aca1219000000b00343058a79a8mr3942968ois.143.1662736730606; Fri, 09 Sep 2022 08:18:50 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:50 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Heinrich Schuchardt Subject: [PATCH 11/14] boot: Tidy up logging and naming in vbe_simple Date: Fri, 9 Sep 2022 09:17:58 -0600 Message-Id: <20220909151801.336551-12-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Make sure the log_msg_ret() values are unique so that the log trace is unambiguous with LOG_ERROR_RETURN. Also avoid reusing the 'node' variable for two different nodes in bootmeth_vbe_simple_ft_fixup(), since this is confusing. Signed-off-by: Simon Glass --- boot/vbe_simple.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/boot/vbe_simple.c b/boot/vbe_simple.c index 61b6322ebe2..076b650c25a 100644 --- a/boot/vbe_simple.c +++ b/boot/vbe_simple.c @@ -6,6 +6,8 @@ * Written by Simon Glass */ +#define LOG_CATEGORY LOGC_BOOT + #include #include #include @@ -199,17 +201,17 @@ int vbe_simple_fixup_node(ofnode node, struct simple_state *state) version = strdup(state->fw_version); if (!version) - return log_msg_ret("ver", -ENOMEM); + return log_msg_ret("dup", -ENOMEM); ret = ofnode_write_string(node, "cur-version", version); if (ret) return log_msg_ret("ver", ret); ret = ofnode_write_u32(node, "cur-vernum", state->fw_vernum); if (ret) - return log_msg_ret("ver", ret); + return log_msg_ret("num", ret); ret = ofnode_write_string(node, "bootloader-version", version_string); if (ret) - return log_msg_ret("fix", ret); + return log_msg_ret("bl", ret); return 0; } @@ -233,7 +235,7 @@ static int bootmeth_vbe_simple_ft_fixup(void *ctx, struct event *event) */ for (vbe_find_first_device(&dev); dev; vbe_find_next_device(&dev)) { struct simple_state state; - ofnode node; + ofnode node, subnode; int ret; if (strcmp("vbe_simple", dev->driver->name)) @@ -243,8 +245,8 @@ static int bootmeth_vbe_simple_ft_fixup(void *ctx, struct event *event) node = oftree_path(tree, "/chosen/fwupd"); if (!ofnode_valid(node)) continue; - node = ofnode_find_subnode(node, dev->name); - if (!ofnode_valid(node)) + subnode = ofnode_find_subnode(node, dev->name); + if (!ofnode_valid(subnode)) continue; log_debug("Fixing up: %s\n", dev->name); @@ -255,7 +257,7 @@ static int bootmeth_vbe_simple_ft_fixup(void *ctx, struct event *event) if (ret) return log_msg_ret("read", ret); - ret = vbe_simple_fixup_node(node, &state); + ret = vbe_simple_fixup_node(subnode, &state); if (ret) return log_msg_ret("fix", ret); } From patchwork Fri Sep 9 15:17:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676120 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=CKYEPQOR; 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKSX6Ypcz1yj1 for ; Sat, 10 Sep 2022 01:20:44 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B0E9E84BAC; Fri, 9 Sep 2022 17:19:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CKYEPQOR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5058B84B8F; Fri, 9 Sep 2022 17:18:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) (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 9B63784B97 for ; Fri, 9 Sep 2022 17:18:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-127dca21a7dso4636915fac.12 for ; Fri, 09 Sep 2022 08:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=TE6DBcInihD+Ywj0ttVJmCSG1xzsvw9e6wmn19i/2lY=; b=CKYEPQORXjsGbF4JvdLafJh5QXytgHeTNqPMoAPKKOWtyQiDHZo9vJVyu69DIbdx79 1nDSDfmwhFIF2t/b9DJuvgZlQZ8kMcB2AbqGdg/mHVmviJR7oDaxELwQToYCWm+aL3V3 6c/c8IYwwuCmQPj9yi2xzBi9OqDrMXjwjQfHE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=TE6DBcInihD+Ywj0ttVJmCSG1xzsvw9e6wmn19i/2lY=; b=lz4FpoC8tKnEn/cHPQZJE+dbgH0bNKFm6OXCTwoqO3ZsNrrShhUnQjkBVzVBmKQqi7 deHK5S6GSiApFFyB2GVHUWcRqDfyUrofkj6g+ue8Ma4tmOITmNZrFS/UosD9obrM/Nnm ivJo6IHGIQAFAoelPdtZ/0Ty4V6dfkeEZ66Jlxtq2sLo4+2hAW+skPMS/jKayQ8Az33t apWP7iUFivz6sb1doeT4WHtFgQqu7LlfGAE6Hq56Q5u95SbKInjl0vK+hrGqoXWmKUia Cu0r999dmDfweY2Dp2qaCy4JdxdI47/H1UfFkHeCw+HL4N61nM6r7a6iXP9+QTlxmqlw dK5Q== X-Gm-Message-State: ACgBeo3GogNmj7VXILHmuBKYzSmv9peLvLJQ3THKPUal3roLaxhIZKo0 1Kprn0S9KvQkbbPeghGH6l4i+nNFKASboA== X-Google-Smtp-Source: AA6agR4OZYMrLh8KqPWL1a/zAEQldI3eLvVyz/5S+s0RCROKsD8VWM4KLTJWERLHKK92W3XBFzBuJw== X-Received: by 2002:a05:6808:1b25:b0:342:ff09:2c32 with SMTP id bx37-20020a0568081b2500b00342ff092c32mr3951717oib.26.1662736731715; Fri, 09 Sep 2022 08:18:51 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:51 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Philippe Reynes Subject: [PATCH 12/14] test: Move common FIT code into a separate fit_util file Date: Fri, 9 Sep 2022 09:17:59 -0600 Message-Id: <20220909151801.336551-13-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean To avoid duplicating code, create a new fit_util module which provides various utility functions for FIT. Move this code out from the existing test_fit.py and refactor it with addition parameters. Fix up pylint warnings in the conversion. This involves no functional change. Signed-off-by: Simon Glass --- test/boot/bootstd_common.c | 21 ++++----- test/py/tests/fit_util.py | 90 ++++++++++++++++++++++++++++++++++++++ test/py/tests/test_fit.py | 79 ++++----------------------------- 3 files changed, 110 insertions(+), 80 deletions(-) create mode 100644 test/py/tests/fit_util.py diff --git a/test/boot/bootstd_common.c b/test/boot/bootstd_common.c index 59d46bef0c5..7a40836507a 100644 --- a/test/boot/bootstd_common.c +++ b/test/boot/bootstd_common.c @@ -17,6 +17,7 @@ #include #include "bootstd_common.h" +/* tracks whether bootstd_setup_for_tests() has been run yet */ bool vbe_setup_done; /* set up MMC for VBE tests */ @@ -27,6 +28,9 @@ int bootstd_setup_for_tests(void) struct blk_desc *desc; int ret; + if (vbe_setup_done) + return 0; + /* Set up the version string */ ret = uclass_get_device(UCLASS_MMC, 1, &mmc); if (ret) @@ -46,6 +50,8 @@ int bootstd_setup_for_tests(void) if (blk_dwrite(desc, NVDATA_START_BLK, 1, buf) != 1) return log_msg_ret("wr2", -EIO); + vbe_setup_done = true; + return 0; } @@ -65,17 +71,12 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd_test); const int n_ents = UNIT_TEST_SUITE_COUNT(bootstd_test); + int ret; - if (!vbe_setup_done) { - int ret; - - ret = bootstd_setup_for_tests(); - if (ret) { - printf("Failed to set up for bootstd tests (err=%d)\n", - ret); - return CMD_RET_FAILURE; - } - vbe_setup_done = true; + ret = bootstd_setup_for_tests(); + if (ret) { + printf("Failed to set up for bootstd tests (err=%d)\n", ret); + return CMD_RET_FAILURE; } return cmd_ut_category("bootstd", "bootstd_test_", diff --git a/test/py/tests/fit_util.py b/test/py/tests/fit_util.py new file mode 100644 index 00000000000..fcec4c43c3c --- /dev/null +++ b/test/py/tests/fit_util.py @@ -0,0 +1,90 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2022 Google LLC + +"""Common utility functions for FIT tests""" + +import os + +import u_boot_utils as util + +def make_fname(cons, basename): + """Make a temporary filename + + Args: + cons (ConsoleBase): u_boot_console to use + basename (str): Base name of file to create (within temporary directory) + Return: + Temporary filename + """ + + return os.path.join(cons.config.build_dir, basename) + +def make_its(cons, base_its, params, basename='test.its'): + """Make a sample .its file with parameters embedded + + Args: + cons (ConsoleBase): u_boot_console to use + base_its (str): Template text for the .its file, typically containing + %() references + params (dict of str): Parameters to embed in the %() strings + basename (str): base name to write to (will be placed in the temp dir) + Returns: + str: Filename of .its file created + """ + its = make_fname(cons, basename) + with open(its, 'w', encoding='utf-8') as outf: + print(base_its % params, file=outf) + return its + +def make_fit(cons, mkimage, base_its, params, basename='test.fit'): + """Make a sample .fit file ready for loading + + This creates a .its script with the selected parameters and uses mkimage to + turn this into a .fit image. + + Args: + cons (ConsoleBase): u_boot_console to use + mkimage (str): Filename of 'mkimage' utility + base_its (str): Template text for the .its file, typically containing + %() references + params (dict of str): Parameters to embed in the %() strings + basename (str): base name to write to (will be placed in the temp dir) + Return: + Filename of .fit file created + """ + fit = make_fname(cons, basename) + its = make_its(cons, base_its, params) + util.run_and_log(cons, [mkimage, '-f', its, fit]) + return fit + +def make_kernel(cons, basename, text): + """Make a sample kernel with test data + + Args: + cons (ConsoleBase): u_boot_console to use + basename (str): base name to write to (will be placed in the temp dir) + text (str): Contents of the kernel file (will be repeated 100 times) + Returns: + str: Full path and filename of the kernel it created + """ + fname = make_fname(cons, basename) + data = '' + for i in range(100): + data += f'this {text} {i} is unlikely to boot\n' + with open(fname, 'w', encoding='utf-8') as outf: + print(data, file=outf) + return fname + +def make_dtb(cons, base_fdt, basename): + """Make a sample .dts file and compile it to a .dtb + + Returns: + cons (ConsoleBase): u_boot_console to use + Filename of .dtb file created + """ + src = make_fname(cons, f'{basename}.dts') + dtb = make_fname(cons, f'{basename}.dtb') + with open(src, 'w', encoding='utf-8') as outf: + outf.write(base_fdt) + util.run_and_log(cons, ['dtc', src, '-O', 'dtb', '-o', dtb]) + return dtb diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py index 5856960be23..f45848484eb 100755 --- a/test/py/tests/test_fit.py +++ b/test/py/tests/test_fit.py @@ -7,6 +7,7 @@ import os import pytest import struct import u_boot_utils as util +import fit_util # Define a base ITS which we can adjust using % and a dictionary base_its = ''' @@ -126,7 +127,6 @@ def test_fit(u_boot_console): Return: Temporary filename """ - return os.path.join(cons.config.build_dir, leaf) def filesize(fname): @@ -150,67 +150,6 @@ def test_fit(u_boot_console): with open(fname, 'rb') as fd: return fd.read() - def make_dtb(): - """Make a sample .dts file and compile it to a .dtb - - Returns: - Filename of .dtb file created - """ - src = make_fname('u-boot.dts') - dtb = make_fname('u-boot.dtb') - with open(src, 'w') as fd: - fd.write(base_fdt) - util.run_and_log(cons, ['dtc', src, '-O', 'dtb', '-o', dtb]) - return dtb - - def make_its(params): - """Make a sample .its file with parameters embedded - - Args: - params: Dictionary containing parameters to embed in the %() strings - Returns: - Filename of .its file created - """ - its = make_fname('test.its') - with open(its, 'w') as fd: - print(base_its % params, file=fd) - return its - - def make_fit(mkimage, params): - """Make a sample .fit file ready for loading - - This creates a .its script with the selected parameters and uses mkimage to - turn this into a .fit image. - - Args: - mkimage: Filename of 'mkimage' utility - params: Dictionary containing parameters to embed in the %() strings - Return: - Filename of .fit file created - """ - fit = make_fname('test.fit') - its = make_its(params) - util.run_and_log(cons, [mkimage, '-f', its, fit]) - with open(make_fname('u-boot.dts'), 'w') as fd: - fd.write(base_fdt) - return fit - - def make_kernel(filename, text): - """Make a sample kernel with test data - - Args: - filename: the name of the file you want to create - Returns: - Full path and filename of the kernel it created - """ - fname = make_fname(filename) - data = '' - for i in range(100): - data += 'this %s %d is unlikely to boot\n' % (text, i) - with open(fname, 'w') as fd: - print(data, file=fd) - return fname - def make_ramdisk(filename, text): """Make a sample ramdisk with test data @@ -321,10 +260,10 @@ def test_fit(u_boot_console): - run code coverage to make sure we are testing all the code """ # Set up invariant files - control_dtb = make_dtb() - kernel = make_kernel('test-kernel.bin', 'kernel') + control_dtb = fit_util.make_dtb(cons, base_fdt, 'u-boot') + kernel = fit_util.make_kernel(cons, 'test-kernel.bin', 'kernel') ramdisk = make_ramdisk('test-ramdisk.bin', 'ramdisk') - loadables1 = make_kernel('test-loadables1.bin', 'lenrek') + loadables1 = fit_util.make_kernel(cons, 'test-loadables1.bin', 'lenrek') loadables2 = make_ramdisk('test-loadables2.bin', 'ksidmar') kernel_out = make_fname('kernel-out.bin') fdt = make_fname('u-boot.dtb') @@ -372,7 +311,7 @@ def test_fit(u_boot_console): } # Make a basic FIT and a script to load it - fit = make_fit(mkimage, params) + fit = fit_util.make_fit(cons, mkimage, base_its, params) params['fit'] = fit cmd = base_script % params @@ -403,7 +342,7 @@ def test_fit(u_boot_console): # Now a kernel and an FDT with cons.log.section('Kernel + FDT load'): params['fdt_load'] = 'load = <%#x>;' % params['fdt_addr'] - fit = make_fit(mkimage, params) + fit = fit_util.make_fit(cons, mkimage, base_its, params) cons.restart_uboot() output = cons.run_command_list(cmd.splitlines()) check_equal(kernel, kernel_out, 'Kernel not loaded') @@ -415,7 +354,7 @@ def test_fit(u_boot_console): with cons.log.section('Kernel + FDT + Ramdisk load'): params['ramdisk_config'] = 'ramdisk = "ramdisk-1";' params['ramdisk_load'] = 'load = <%#x>;' % params['ramdisk_addr'] - fit = make_fit(mkimage, params) + fit = fit_util.make_fit(cons, mkimage, base_its, params) cons.restart_uboot() output = cons.run_command_list(cmd.splitlines()) check_equal(ramdisk, ramdisk_out, 'Ramdisk not loaded') @@ -427,7 +366,7 @@ def test_fit(u_boot_console): params['loadables1_addr']) params['loadables2_load'] = ('load = <%#x>;' % params['loadables2_addr']) - fit = make_fit(mkimage, params) + fit = fit_util.make_fit(cons, mkimage, base_its, params) cons.restart_uboot() output = cons.run_command_list(cmd.splitlines()) check_equal(loadables1, loadables1_out, @@ -441,7 +380,7 @@ def test_fit(u_boot_console): params['kernel'] = make_compressed(kernel) params['fdt'] = make_compressed(fdt) params['ramdisk'] = make_compressed(ramdisk) - fit = make_fit(mkimage, params) + fit = fit_util.make_fit(cons, mkimage, base_its, params) cons.restart_uboot() output = cons.run_command_list(cmd.splitlines()) check_equal(kernel, kernel_out, 'Kernel not loaded') From patchwork Fri Sep 9 15:18:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676121 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=LvIQq0BL; 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKSl33RWz1yhP for ; Sat, 10 Sep 2022 01:20:55 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A08584BB8; Fri, 9 Sep 2022 17:19:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LvIQq0BL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 02E0184B8F; Fri, 9 Sep 2022 17:18:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) (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 B162684B5A for ; Fri, 9 Sep 2022 17:18:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-12ab0eaa366so4627558fac.13 for ; Fri, 09 Sep 2022 08:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Mgsx8/9AsfwsFkqYyNTDhJIhyxrfaHvX/k1Nkf3f6/0=; b=LvIQq0BL4Dy5EhJ3VKL4+gP9nQz4yJd+B7vGnnf5aXFXJdgfdgGrHBf3PqUWi2XzXA o478EtkekNDiHhcKGHLeCtKllp1a6WK9MzGVj+adcuEJfTsOW+IcwCv7xFKsGq3yOO5a 8Fi6ehBWAL6atZXj0e55tdLb3jZWdNDcpZb10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Mgsx8/9AsfwsFkqYyNTDhJIhyxrfaHvX/k1Nkf3f6/0=; b=MqDO7fF8pwGc51MMt02d2E80/d7pkYYSXe1nTuVYXae954I7sCWu68Jx/zWXx3yYc5 hOIPkvfqSpWvu3X0qMSwF/zbXmXjtm47m+yb1mm9VNUGnRAVAfTjU7Ab4Ln87fyT7Goa KP2AppfRa2CORj7QuhmXm7qLNi3g2OIqjUxtW0Pzeh3Jywg6nAyKR6KMBDmV9ufr3lKN pXXHgRye744cmRVNxu19JyLXtFlwdX73jleEkUO0quqGQ1epRiDRKIbqdVJlqb8PUkHX xYKWTmmEmO9Kx5xsgJ4SOmXU6c37rliEX62xeXkPXvADU4D1MGsnkfa0cnkDZNCtOTk9 CJZA== X-Gm-Message-State: ACgBeo1gIkIed6UWMzElb4pjTjLrtqF3/qYFkSDn6yPyLbTXfRCkstUT eMzA2aUjReiTD5kthmeeQ8tTdISclsk4Jg== X-Google-Smtp-Source: AA6agR7UMMosOEJyMeKMX1fbEaOngecBhOLeBJyJ6LpfNtQJUkvUzRwzj88GAfpkZh58nGwzk49yfw== X-Received: by 2002:a05:6870:d354:b0:126:6b86:449d with SMTP id h20-20020a056870d35400b001266b86449dmr5224209oag.107.1662736732924; Fri, 09 Sep 2022 08:18:52 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:52 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Artem Lapkin , John Keeping , Philippe Reynes , Ramon Fried Subject: [PATCH 13/14] vbe: Add fixups for a basic set of OS requests Date: Fri, 9 Sep 2022 09:18:00 -0600 Message-Id: <20220909151801.336551-14-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean As a starting point, add support for providing random data, if requested by the OS. Also add ASLR, as a placeholder for now. Signed-off-by: Simon Glass --- boot/Makefile | 2 +- boot/vbe_fixup.c | 233 +++++++++++++++++++++++++++++++ test/py/tests/test_event_dump.py | 1 + 3 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 boot/vbe_fixup.c diff --git a/boot/Makefile b/boot/Makefile index 67e335255f1..dd45d786f8c 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -47,5 +47,5 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o endif -obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE) += vbe.o +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE) += vbe.o vbe_fixup.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE_SIMPLE) += vbe_simple.o diff --git a/boot/vbe_fixup.c b/boot/vbe_fixup.c new file mode 100644 index 00000000000..8cdff6972b1 --- /dev/null +++ b/boot/vbe_fixup.c @@ -0,0 +1,233 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Verified Boot for Embedded (VBE) device tree fixup functions + * + * Copyright 2022 Google LLC + * Written by Simon Glass + */ + +#define LOG_CATEGORY LOGC_BOOT + +#include +#include +#include +#include +#include +#include +#include + +#define VBE_PREFIX "vbe," +#define VBE_PREFIX_LEN (sizeof(VBE_PREFIX) - 1) +#define VBE_ERR_STR_LEN 128 +#define VBE_MAX_RAND_SIZE 256 + +struct vbe_result { + int errnum; + char err_str[VBE_ERR_STR_LEN]; +}; + +typedef int (*vbe_req_func)(ofnode node, struct vbe_result *result); + +static int handle_random_req(ofnode node, int default_size, + struct vbe_result *result) +{ + char buf[VBE_MAX_RAND_SIZE]; + struct udevice *dev; + u32 size; + int ret; + + if (!IS_ENABLED(CONFIG_DM_RNG)) + return -ENOTSUPP; + + if (ofnode_read_u32(node, "vbe,size", &size)) { + if (!default_size) { + snprintf(result->err_str, VBE_ERR_STR_LEN, + "Missing vbe,size property"); + return log_msg_ret("byt", -EINVAL); + } + size = default_size; + } + if (size > VBE_MAX_RAND_SIZE) { + snprintf(result->err_str, VBE_ERR_STR_LEN, + "vbe,size %#x exceeds max size %#x", size, + VBE_MAX_RAND_SIZE); + return log_msg_ret("siz", -E2BIG); + } + ret = uclass_first_device_check(UCLASS_RNG, &dev); + if (ret) { + snprintf(result->err_str, VBE_ERR_STR_LEN, + "Cannot find random-number device (err=%d)", ret); + return log_msg_ret("wr", ret); + } + ret = dm_rng_read(dev, buf, size); + if (ret) { + snprintf(result->err_str, VBE_ERR_STR_LEN, + "Failed to read random-number device (err=%d)", ret); + return log_msg_ret("rd", ret); + } + ret = ofnode_write_prop(node, "data", buf, size, true); + if (ret) + return log_msg_ret("wr", -EINVAL); + + return 0; +} + +static int vbe_req_random_seed(ofnode node, struct vbe_result *result) +{ + return handle_random_req(node, 0, result); +} + +static int vbe_req_aslr_move(ofnode node, struct vbe_result *result) +{ + return -ENOTSUPP; +} + +static int vbe_req_aslr_rand(ofnode node, struct vbe_result *result) +{ + return handle_random_req(node, 4, result); +} + +static int vbe_req_efi_runtime_rand(ofnode node, struct vbe_result *result) +{ + return handle_random_req(node, 4, result); +} + +static struct vbe_req { + const char *compat; + vbe_req_func func; +} vbe_reqs[] = { + /* address space layout randomization - move the OS in memory */ + { "aslr-move", vbe_req_aslr_move }, + + /* provide random data for address space layout randomization */ + { "aslr-rand", vbe_req_aslr_rand }, + + /* provide random data for EFI-runtime-services address */ + { "efi-runtime-rand", vbe_req_efi_runtime_rand }, + + /* generate random data bytes to see the OS's rand generator */ + { "random-rand", vbe_req_random_seed }, + +}; + +static int vbe_process_request(ofnode node, struct vbe_result *result) +{ + const char *compat, *req_name; + int i; + + compat = ofnode_read_string(node, "compatible"); + if (!compat) + return 0; + + if (strlen(compat) <= VBE_PREFIX_LEN || + strncmp(compat, VBE_PREFIX, VBE_PREFIX_LEN)) + return -EINVAL; + + req_name = compat + VBE_PREFIX_LEN; /* drop "vbe," prefix */ + for (i = 0; i < ARRAY_SIZE(vbe_reqs); i++) { + if (!strcmp(vbe_reqs[i].compat, req_name)) { + int ret; + + ret = vbe_reqs[i].func(node, result); + if (ret) + return log_msg_ret("req", ret); + return 0; + } + } + snprintf(result->err_str, VBE_ERR_STR_LEN, "Unknown request: %s", + req_name); + + return -ENOTSUPP; +} + +/** + * bootmeth_vbe_ft_fixup() - Process VBE OS requests and do device tree fixups + * + * If there are no images provided, this does nothing and returns 0. + * + * @ctx: Context for event + * @event: Event to process + * @return 0 if OK, -ve on error + */ +static int bootmeth_vbe_ft_fixup(void *ctx, struct event *event) +{ + const struct event_ft_fixup *fixup = &event->data.ft_fixup; + const struct bootm_headers *images = fixup->images; + ofnode parent, dest_parent, root, node; + oftree fit; + + if (!images || !images->fit_hdr_os) + return 0; + + /* Get the image node with requests in it */ + log_debug("fit=%p, noffset=%d\n", images->fit_hdr_os, + images->fit_noffset_os); + fit = oftree_from_fdt(images->fit_hdr_os); + root = oftree_root(fit); + if (of_live_active()) { + log_warning("Cannot fix up live tree\n"); + return 0; + } + if (!ofnode_valid(root)) + return log_msg_ret("rt", -EINVAL); + parent = noffset_to_ofnode(root, images->fit_noffset_os); + if (!ofnode_valid(parent)) + return log_msg_ret("img", -EINVAL); + dest_parent = oftree_path(fixup->tree, "/chosen"); + if (!ofnode_valid(dest_parent)) + return log_msg_ret("dst", -EINVAL); + + ofnode_for_each_subnode(node, parent) { + const char *name = ofnode_get_name(node); + struct vbe_result result; + ofnode dest; + int ret; + + log_debug("copy subnode: %s\n", name); + ret = ofnode_add_subnode(dest_parent, name, &dest); + if (ret && ret != -EEXIST) + return log_msg_ret("add", ret); + ret = ofnode_copy_props(node, dest); + if (ret) + return log_msg_ret("cp", ret); + + *result.err_str = '\0'; + ret = vbe_process_request(dest, &result); + if (ret) { + result.errnum = ret; + log_err("Failed to process VBE request %s (err=%d)\n", + ofnode_get_name(dest), ret); + if (*result.err_str) { + char *msg = strdup(result.err_str); + + if (!msg) + return log_msg_ret("msg", -ENOMEM); + ret = ofnode_write_string(dest, "vbe,error", + msg); + if (ret) { + free(msg); + return log_msg_ret("str", -ENOMEM); + } + } + if (result.errnum) { + ret = ofnode_write_u32(dest, "vbe,errnum", + result.errnum); + if (ret) + return log_msg_ret("num", -ENOMEM); + if (result.errnum != -ENOTSUPP) + return log_msg_ret("pro", + result.errnum); + if (result.errnum == -ENOTSUPP && + ofnode_read_bool(dest, "vbe,required")) { + log_err("Cannot handle required request: %s\n", + ofnode_get_name(dest)); + return log_msg_ret("req", + result.errnum); + } + } + } + } + + return 0; +} +EVENT_SPY(EVT_FT_FIXUP, bootmeth_vbe_ft_fixup); diff --git a/test/py/tests/test_event_dump.py b/test/py/tests/test_event_dump.py index bc54149e8f2..e63c25df537 100644 --- a/test/py/tests/test_event_dump.py +++ b/test/py/tests/test_event_dump.py @@ -16,6 +16,7 @@ def test_event_dump(u_boot_console): out = util.run_and_log(cons, ['scripts/event_dump.py', sandbox]) expect = '''.*Event type Id Source location -------------------- ------------------------------ ------------------------------ +EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*boot/vbe_fixup.c:.* EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*boot/vbe_simple.c:.* EVT_MISC_INIT_F sandbox_misc_init_f .*arch/sandbox/cpu/start.c:''' assert re.match(expect, out, re.MULTILINE) is not None From patchwork Fri Sep 9 15:18:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676122 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=L4luedTw; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKSy5jT3z1yhP for ; Sat, 10 Sep 2022 01:21:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F3B1184BBC; Fri, 9 Sep 2022 17:19:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="L4luedTw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 23C1084B89; Fri, 9 Sep 2022 17:19:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) (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 0C42C84B6B for ; Fri, 9 Sep 2022 17:18:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oo1-xc33.google.com with SMTP id c22-20020a4a4f16000000b00474a44441c8so293483oob.7 for ; Fri, 09 Sep 2022 08:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=x7O19AfEasIvQ+xvvCpUPQYe3OcePuZ+FtKp/73FtfM=; b=L4luedTwC+Z9dYXDITh9os3w0U/j5e3CR+gPs5tXftG2xXbx9rhuNN2387FbHYXCsu IGzir7qjIYD5/iNz7+PIONYtIHxOO8zpga5RWw6lMZnTAlVXu+zcCNl7ii7dNLJI/fnf 4MvU47v5f5U5IH0U63fIdT+qNo753GrwzK4xk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=x7O19AfEasIvQ+xvvCpUPQYe3OcePuZ+FtKp/73FtfM=; b=hENhf2xpAoXEXpHz8EsS/SdFbkKWBF04SnrZ1WE+p8Bdwbp2JROvUTQLUFcBcZyQmt Ohhj6pNCglpVuIiUDJQPB/lONbmY80TmyNj0cTlcOSkBf1EbZ92peP2czpkiVREBwbRW wxs+fPWAbtjhpmh+wcNAEmqZdoNoD8k/TB9lb+ZFZVkggJH+qs6fvVYJFJdnGEGz/+2k DIaaon5Q+U7rYIJcKexDe28lHzIBc9y0x4JCLAD1DV0K8sNMDJ4GooWXFpu4MX5YfmqX LqYBJ9HKsiYqVA55YwTA4uROqgCAKr3h/F4z2Msyc7uTwLF8wPeMyzNX2NPxgj5k6UH/ opVw== X-Gm-Message-State: ACgBeo0HZ7gQLZ8jxAIPabU5FgCDJb7dncCLKA1gddjFbyFdwAprUNq8 TrrxNjdaZ5vsyqVzZbGxv4N6cFPTyMnaRQ== X-Google-Smtp-Source: AA6agR4s8GAjwyePE45pGBWkZOyyTm//vM2D9EAq0IidO4GrmVOSYlLQjzJlV/4mMIMuokvnYyEVgg== X-Received: by 2002:a4a:be06:0:b0:472:9d27:695e with SMTP id l6-20020a4abe06000000b004729d27695emr1948209oop.36.1662736734125; Fri, 09 Sep 2022 08:18:54 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:53 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH 14/14] vbe: Add a test for VBE device tree fixups Date: Fri, 9 Sep 2022 09:18:01 -0600 Message-Id: <20220909151801.336551-15-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean When a FIT includes some OS requests, U-Boot should process these and add the requested info to corresponding subnodes of the /chosen node. Add a pytest for this, which sets up the FIT, runs bootm and then uses a C unit test to check that everything looks OK. The test needs to run on sandbox_flattree since we don't support device tree fixups on sandbox (live tree) yet. So enable BOOTMETH_VBE and disable bootflow_system(), since EFI is not supported on sandbox_flattree. Add a link to the initial documentation. Signed-off-by: Simon Glass --- configs/sandbox_flattree_defconfig | 2 +- doc/develop/vbe.rst | 3 +- test/boot/Makefile | 1 + test/boot/bootflow.c | 2 + test/boot/vbe_fixup.c | 59 ++++++++++++++ test/py/tests/fit_util.py | 5 +- test/py/tests/test_vbe.py | 123 +++++++++++++++++++++++++++++ 7 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 test/boot/vbe_fixup.c create mode 100644 test/py/tests/test_vbe.py diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index a8b439faa96..58fd4ad6395 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -11,7 +11,6 @@ CONFIG_DISTRO_DEFAULTS=y CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_FIT_VERBOSE=y -# CONFIG_BOOTMETH_VBE is not set CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y @@ -83,6 +82,7 @@ CONFIG_REGMAP=y CONFIG_SYSCON=y CONFIG_DEVRES=y CONFIG_DEBUG_DEVRES=y +CONFIG_OFNODE_MULTI_TREE=y CONFIG_ADC=y CONFIG_ADC_SANDBOX=y CONFIG_SYS_SATA_MAX_DEVICE=2 diff --git a/doc/develop/vbe.rst b/doc/develop/vbe.rst index 8f147fd9360..cca193c8fd4 100644 --- a/doc/develop/vbe.rst +++ b/doc/develop/vbe.rst @@ -19,8 +19,9 @@ listing methods and getting the status for a method. For a detailed overview of VBE, see vbe-intro_. A fuller description of bootflows is at vbe-bootflows_ and the firmware-update mechanism is described at -vbe-fwupdate_. +vbe-fwupdate_. VBE OS requests are described at vbe-osrequests_. .. _vbe-intro: https://docs.google.com/document/d/e/2PACX-1vQjXLPWMIyVktaTMf8edHZYDrEvMYD_iNzIj1FgPmKF37fpglAC47Tt5cvPBC5fvTdoK-GA5Zv1wifo/pub .. _vbe-bootflows: https://docs.google.com/document/d/e/2PACX-1vR0OzhuyRJQ8kdeOibS3xB1rVFy3J4M_QKTM5-3vPIBNcdvR0W8EXu9ymG-yWfqthzWoM4JUNhqwydN/pub .. _vbe-fwupdate: https://docs.google.com/document/d/e/2PACX-1vTnlIL17vVbl6TVoTHWYMED0bme7oHHNk-g5VGxblbPiKIdGDALE1HKId8Go5f0g1eziLsv4h9bocbk/pub +.. _vbe-osrequests: https://docs.google.com/document/d/e/2PACX-1vTHhxX7WSZe68i9rAkW-DHdx6koU-jxYHhamLhZn9GQ9QT2_epSBosMV1_r7yPHOXZccx71rF_t0PXL/pub diff --git a/test/boot/Makefile b/test/boot/Makefile index 9e9d5ae21f3..5bb3f889759 100644 --- a/test/boot/Makefile +++ b/test/boot/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o ifdef CONFIG_OF_LIVE obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.o endif +obj-$(CONFIG_BOOTMETH_VBE) += vbe_fixup.o diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 85305234e01..1e8ea754bcd 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -329,6 +329,8 @@ static int bootflow_system(struct unit_test_state *uts) { struct udevice *dev; + if (!IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) + return 0; ut_assertok(uclass_get_device_by_name(UCLASS_BOOTMETH, "efi_mgr", &dev)); sandbox_set_fake_efi_mgr_dev(dev, true); diff --git a/test/boot/vbe_fixup.c b/test/boot/vbe_fixup.c new file mode 100644 index 00000000000..1b488e25ab6 --- /dev/null +++ b/test/boot/vbe_fixup.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for VBE device tree fix-ups + * + * Copyright 2022 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include "bootstd_common.h" + +/* Basic test of reading nvdata and updating a fwupd node in the device tree */ +static int vbe_test_fixup(struct unit_test_state *uts) +{ + ofnode chosen, node; + const char *data; + oftree tree; + int size; + + /* + * This test works when called from test_vbe.py and it must use the + * flat tree, since device tree fix-ups do not yet support live tree. + */ + if (!working_fdt) + return 0; + + tree = oftree_from_fdt(working_fdt); + ut_assert(oftree_valid(tree)); + + chosen = oftree_path(tree, "/chosen"); + ut_assert(ofnode_valid(chosen)); + + /* check the things set up for the FIT in test_vbe.py */ + node = ofnode_find_subnode(chosen, "random"); + + /* ignore if this test is run on its own */ + if (!ofnode_valid(node)) + return 0; + data = ofnode_read_prop(node, "data", &size); + ut_asserteq(0x40, size); + + node = ofnode_find_subnode(chosen, "aslr2"); + ut_assert(ofnode_valid(node)); + data = ofnode_read_prop(node, "data", &size); + ut_asserteq(4, size); + + node = ofnode_find_subnode(chosen, "efi-runtime"); + ut_assert(ofnode_valid(node)); + data = ofnode_read_prop(node, "data", &size); + ut_asserteq(4, size); + + return 0; +} +BOOTSTD_TEST(vbe_test_fixup, + UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE); diff --git a/test/py/tests/fit_util.py b/test/py/tests/fit_util.py index fcec4c43c3c..79718d431a0 100644 --- a/test/py/tests/fit_util.py +++ b/test/py/tests/fit_util.py @@ -36,7 +36,7 @@ def make_its(cons, base_its, params, basename='test.its'): print(base_its % params, file=outf) return its -def make_fit(cons, mkimage, base_its, params, basename='test.fit'): +def make_fit(cons, mkimage, base_its, params, basename='test.fit', base_fdt=None): """Make a sample .fit file ready for loading This creates a .its script with the selected parameters and uses mkimage to @@ -55,6 +55,9 @@ def make_fit(cons, mkimage, base_its, params, basename='test.fit'): fit = make_fname(cons, basename) its = make_its(cons, base_its, params) util.run_and_log(cons, [mkimage, '-f', its, fit]) + if base_fdt: + with open(make_fname(cons, 'u-boot.dts'), 'w') as fd: + fd.write(base_fdt) return fit def make_kernel(cons, basename, text): diff --git a/test/py/tests/test_vbe.py b/test/py/tests/test_vbe.py new file mode 100644 index 00000000000..559c2918868 --- /dev/null +++ b/test/py/tests/test_vbe.py @@ -0,0 +1,123 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2022 Google LLC +# +# Test addition of VBE + +import pytest + +import fit_util + +# Define a base ITS which we can adjust using % and a dictionary +base_its = ''' +/dts-v1/; + +/ { + description = "Example kernel"; + + images { + kernel-1 { + data = /incbin/("%(kernel)s"); + type = "kernel"; + arch = "sandbox"; + os = "linux"; + load = <0x40000>; + entry = <0x8>; + compression = "%(compression)s"; + + random { + compatible = "vbe,random-rand"; + vbe,size = <0x40>; + vbe,required; + }; + aslr1 { + compatible = "vbe,aslr-move"; + vbe,align = <0x100000>; + }; + aslr2 { + compatible = "vbe,aslr-rand"; + }; + efi-runtime { + compatible = "vbe,efi-runtime-rand"; + }; + wibble { + compatible = "vbe,wibble"; + }; + }; + + fdt-1 { + description = "snow"; + data = /incbin/("%(fdt)s"); + type = "flat_dt"; + arch = "sandbox"; + load = <%(fdt_addr)#x>; + compression = "%(compression)s"; + }; + }; + configurations { + default = "conf-1"; + conf-1 { + kernel = "kernel-1"; + fdt = "fdt-1"; + }; + }; +}; +''' + +# Define a base FDT - currently we don't use anything in this +base_fdt = ''' +/dts-v1/; + +/ { + chosen { + }; +}; +''' + +# This is the U-Boot script that is run for each test. First load the FIT, +# then run the 'bootm' command, then run the unit test which checks that the +# working tree has the required things filled in according to the OS requests +# above (random, aslr2, etc.) +base_script = ''' +host load hostfs 0 %(fit_addr)x %(fit)s +fdt addr %(fit_addr)x +bootm start %(fit_addr)x +bootm loados +bootm prep +fdt addr +fdt print +ut bootstd vbe_test_fixup +''' + +@pytest.mark.boardspec('sandbox_flattree') +@pytest.mark.requiredtool('dtc') +def test_vbe(u_boot_console): + cons = u_boot_console + kernel = fit_util.make_kernel(cons, 'vbe-kernel.bin', 'kernel') + fdt = fit_util.make_dtb(cons, base_fdt, 'vbe-fdt') + fdt_out = fit_util.make_fname(cons, 'fdt-out.dtb') + + params = { + 'fit_addr' : 0x1000, + + 'kernel' : kernel, + + 'fdt' : fdt, + 'fdt_out' : fdt_out, + 'fdt_addr' : 0x80000, + 'fdt_size' : 0x1000, + + 'compression' : 'none', + } + mkimage = cons.config.build_dir + '/tools/mkimage' + fit = fit_util.make_fit(cons, mkimage, base_its, params, 'test-vbe.fit', + base_fdt) + params['fit'] = fit + cmd = base_script % params + + with cons.log.section('Kernel load'): + output = cons.run_command_list(cmd.splitlines()) + + # This is a little wonky since there are two tests running in CI. The final + # one is the 'ut bootstd' command above + failures = [line for line in output if 'Failures' in line] + assert len(failures) >= 1 and 'Failures: 0' in failures[-1]