From patchwork Tue Oct 11 15:47:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688709 X-Patchwork-Delegate: sjg@chromium.org 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=ONLxouz9; 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 4Mn0YX2lTdz1yqk for ; Wed, 12 Oct 2022 02:48:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B15B384F1B; Tue, 11 Oct 2022 17:48:12 +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="ONLxouz9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3BDDD84F16; Tue, 11 Oct 2022 17:48:10 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 50159840AE for ; Tue, 11 Oct 2022 17:48:07 +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-il1-x12c.google.com with SMTP id a2so7345387iln.13 for ; Tue, 11 Oct 2022 08:48:07 -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 :message-id:reply-to; bh=Jo3RRbbQvE09JxJtmZBCPvErobFfiQdhbScPAwCAblE=; b=ONLxouz9easxnPnViURM5ptbOQBJKL4N56Kbqt3aVA2ws6TQopPSi67SBSSh3jFXJA v1mQUNe4biJD1Dm8Xtk09A/LeQEWI7ZveOK67AgKNKjCF8dGKpdbwuEKyN+FD5eaaC5u ijLuqi+JHepAz0wMUSFQsTXJSIfsXf9jQBIkw= 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:message-id:reply-to; bh=Jo3RRbbQvE09JxJtmZBCPvErobFfiQdhbScPAwCAblE=; b=C9+fVqwlqNhDnAkglNS3k459rAe58g7wFgJ4Dg/y4LYtrg/DH7bcdTCCSRysCnydc5 0A0qPinG2pAdRzAjVJmroYIEFg8XUmv6W3xY/WPxRQaCPCZTg0AohcnghOYpJrljyRNU azEoj86BVcnTH0RmuMWfiFEWU8VkD2KQeciDZRoICvryOumaeQ8A8D3e2FXPawNCBCci U7zvBcM6FpL4INQk1Yfxs2ZJw4iG2iPYuBem/jzNC5tKjGstNrfKsCvtcFW2oDFFOyrI 36HK+mN5AcbmdJPbLjJXq6eRIMgoxBOI0f0FJXQFAxKrfFGS7EzCPkV+GZm0S/WLNuPS T46g== X-Gm-Message-State: ACrzQf2asn99/RLv4GYN0qtJ6vFh2Gm9g7JoJgZconqfF1jj+PKcdpDG 0NFfhfVpqA9r0Lk6MRRpzbnbzC0kGsO09g== X-Google-Smtp-Source: AMsMyM69C2QhtjP5mCmzAxVtQJwnED4zTbHW9FLfDArRZc3Eqgy5DsjQrMo6eGhEIlr1nlemPGIBMA== X-Received: by 2002:a05:6e02:178d:b0:2fa:951e:2c67 with SMTP id y13-20020a056e02178d00b002fa951e2c67mr12270583ilu.46.1665503285521; Tue, 11 Oct 2022 08:48:05 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:05 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Artem Lapkin , Daniel Golle , Heinrich Schuchardt , =?utf-8?q?Pali_Roh=C3=A1r?= , Philippe Reynes Subject: [PATCH v2 01/14] bootm: Change incorrect 'unsupported' error Date: Tue, 11 Oct 2022 09:47:07 -0600 Message-Id: <20221011154720.550320-2-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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. Note: v1 of this patch generated a discussion[1] about printing error strings automatically using printf(). That is outside the scope of this patch but will be dealt with separately. [1] https://patchwork.ozlabs.org/project/uboot/patch/20220909151801.336551-3-sjg@chromium.org/ Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) boot/bootm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/bootm.c b/boot/bootm.c index 5b20b418dba..a4c0870c0fe 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 Tue Oct 11 15:47:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688711 X-Patchwork-Delegate: sjg@chromium.org 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=OcIslC30; 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 4Mn0Yz3ZwTz1yqk for ; Wed, 12 Oct 2022 02:48:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C420B84F28; Tue, 11 Oct 2022 17:48: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="OcIslC30"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F0F7A84F1C; Tue, 11 Oct 2022 17:48:12 +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 autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 7006E84F00 for ; Tue, 11 Oct 2022 17:48: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=sjg@chromium.org Received: by mail-il1-x130.google.com with SMTP id o13so7357623ilc.7 for ; Tue, 11 Oct 2022 08:48:08 -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 :message-id:reply-to; bh=AlGepdqjkbokziLnHATgsy2fnckl/vDNuDCJXiv9roI=; b=OcIslC30C4mui5IgdbOy4XZVHM+G3EWNrhV0ZR1meTbQ2CWIovveD2KIXX75kGoYgz TyKGrOr5jan8TWctAJtTVUm0lh1zF7/sA2atRqBt/dssRY72Z84sRiro6KP+hj2Q3t0p ROprWqDlDPGNCrX4q7P/Mnk0d7Ul6MZQT44zo= 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:message-id:reply-to; bh=AlGepdqjkbokziLnHATgsy2fnckl/vDNuDCJXiv9roI=; b=QL6/iWsJLfC3YE2+JT/yrEb4vh9Z9qeUBaLCdWeg3PwB3sTx5gvFlSo6KLCsUvEjO8 GbPD0NSHMuBB5RGdvSmtASWtmcTQ8+cU9EzSC6XgkV1/31lTPatpCl4BA0EoWIP6CnDp CUrCbyPstoJ/8YZ14D4K/q5yKCWzwrMX3VdeO9cgr+wnET35FFGimijIynWTrNZz5NWD dE+lNULQ9zZ22jVPTs98J9uF/b0c/IyqAY2YVpnPaBx8dsMobXB6L4wWm03liXbJOHMt j8lvcRWsORR+4u8dwC0jHkLspruc0tYXW9mx0nt2p4uSbCr97ViMQ9jkiRBHmxGNQdRm vYlg== X-Gm-Message-State: ACrzQf31GvZMO/DSg3aYBKdDD88E7Sgy8rZKDKjEa2VfvRKYlAzbnFXV prmiGxQV68Er6+36uYVxui+V11epxl0BjQ== X-Google-Smtp-Source: AMsMyM4kuGnskSo1BfJberoVNDpV8jBzmY5R/JS+qOijopDTG9R4vsLDOhDrPlWTTElUZyI4RjDfBA== X-Received: by 2002:a05:6e02:1054:b0:2fa:a73:cfa1 with SMTP id p20-20020a056e02105400b002fa0a73cfa1mr12716733ilj.203.1665503286587; Tue, 11 Oct 2022 08:48:06 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:06 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Patrick Delaunay , Philippe Reynes , Stefan Roese Subject: [PATCH v2 02/14] bootm: Avoid returning error codes from command Date: Tue, 11 Oct 2022 09:47:08 -0600 Message-Id: <20221011154720.550320-3-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 Tue Oct 11 15:47:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688710 X-Patchwork-Delegate: sjg@chromium.org 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=hWZ8QL2l; 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 4Mn0Ym21RSz1yqk for ; Wed, 12 Oct 2022 02:48:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C88CD84F20; Tue, 11 Oct 2022 17:48:16 +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="hWZ8QL2l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 467C884F00; Tue, 11 Oct 2022 17:48:13 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (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 7169084F14 for ; Tue, 11 Oct 2022 17:48:09 +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-il1-x12e.google.com with SMTP id 8so7372586ilj.4 for ; Tue, 11 Oct 2022 08:48:09 -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 :message-id:reply-to; bh=qHQeAOMoWsoj8HuGM4BnuNbYplchhqCV/CoIQ9r1ZpY=; b=hWZ8QL2lolXt8zbPgCBFE2/mzsV6b+bw2OUevxTG6iyoCzKs1cG5R6BE+zF8mGXKo6 Y6tRe00eSTHX9hIUUTbMnjMIFIcHWOr8NxgSRLqGcWNCDizOvetiLAPHjf0Mr357aEMp iNrYHgmavteomI/Y6kfoPPV3XFuLWGAOQmY+c= 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:message-id:reply-to; bh=qHQeAOMoWsoj8HuGM4BnuNbYplchhqCV/CoIQ9r1ZpY=; b=0hSmm2g1NISL2YPejXQodWrh8FBNARveOH7PwqCBCAk8cbD38TwIlz2SY4ioYuxhSt JWEbwV0UlNOibEUUIcBAPpTjQJgeieHNcI3pMddx7fLzWxqZSGeWOhwAmi/xmFI5edyJ bUoLrbfYRUlcqY595US4JyzEIJ/ORXL38AmjwMo4LQ/q4Ww1hf5uQsiVgFoQDzCLf9oH zW3r1VOgMJI4jGjyJdLAN9wBVYNLazG0v+CtUw5J0arpKRvyVVw++MS65BRrQJpZ5VE3 IM31LPQ+vOju66GU4r9xLz5l8SV9iT2ulIt/WPE0DB715dGNONZc1m6EhBXtGOYRU9LX Md2Q== X-Gm-Message-State: ACrzQf0onAQ82SlIfH1045foQRXxTqHYMBg5czdPyIITMUwwr971n0j/ o/S4t8C+sCaUFVvda4SJO2Jxexq+NyTHDQ== X-Google-Smtp-Source: AMsMyM5FqbIVdX05ZOu78uz5SNL1x9KcKQZqKIpmh9HL/nJCCcar/zyeUZqaBOcUTzaAicfcc3NAvg== X-Received: by 2002:a05:6e02:15c4:b0:2e1:986c:91a1 with SMTP id q4-20020a056e0215c400b002e1986c91a1mr12229015ilu.22.1665503287657; Tue, 11 Oct 2022 08:48:07 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:07 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Patrick Delaunay , Philippe Reynes , Stefan Roese Subject: [PATCH v2 03/14] bootm: Drop #ifdef from do_bootm() Date: Tue, 11 Oct 2022 09:47:09 -0600 Message-Id: <20221011154720.550320-4-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 Tue Oct 11 15:47:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688712 X-Patchwork-Delegate: sjg@chromium.org 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=XruiJjy2; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mn0ZC2bBbz1yqk for ; Wed, 12 Oct 2022 02:48:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E6E4384F19; Tue, 11 Oct 2022 17:48:24 +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="XruiJjy2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5C9BC84F10; Tue, 11 Oct 2022 17:48:15 +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 autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 9A862840AE for ; Tue, 11 Oct 2022 17:48:10 +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-il1-x12f.google.com with SMTP id q18so4584258ils.12 for ; Tue, 11 Oct 2022 08:48:10 -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 :message-id:reply-to; bh=xC+rYjlWyR2eoGYYArTS1JsbsunBHAx0z621q7ewdW4=; b=XruiJjy2ojdSSrGZPWof2BcXmZomaa2ghrFTUHdZudgzgnodRZvqeYiv9B+LeGEwAT n2ryIAt+v/AJPH5NDvBx+m3GHxLceSlkcIFHGtbP/sagv/VyI37SMTPUOvaGMz2Mrh56 ro3ZtTE+Zy/4w8PTN2BMUD1rPXl4prx6NT/Ls= 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:message-id:reply-to; bh=xC+rYjlWyR2eoGYYArTS1JsbsunBHAx0z621q7ewdW4=; b=ScRFDReLTqgXamQ8a03vWDvMBvGCXh33WWSqOK+q7y7LUZcF6vnWttzF+dC+U8jDNA po/S+VzqMJXFAxNA+nh6lcmz1Fs3lAZQyrhEhNUAHzcteW/ghusMQBrA1uniAcory97a 2QY9iKfitIDoPTQgeNi3ZJlcTTYeMbKZ39b81Q+8qbWuK5s7IhNziRS1NwG7cuqKs6Cn 9jeKgyifC9mp4BBPNTjBKVU7Y5756mAWB5aCgd4D/UX9AQvDcp5OKp9BRqOUp/x57GnP bvLi/qIKlkFLfE8+fcwKFM+L5bc+UPqdE7SvCZKw2PsQQCSVN22ktwLG9MF2esvvhQCL 7kHA== X-Gm-Message-State: ACrzQf0VP1Mx8cVFUbARvVMxd1RGEZhcb8qkBtiWJJBveqSIJ9l5rWHG yFEnbb39oLGlbx1ojMh+mS1a7Bbr80ESKw== X-Google-Smtp-Source: AMsMyM5wq9+Y7wxo4RUUWRL6DoQrn3Qj5UzGgXiKv1GHxJC6iNLuH/q4ZBFUa3ZK6jVdpyAuVjA6lA== X-Received: by 2002:a05:6e02:12e1:b0:2fc:2163:5077 with SMTP id l1-20020a056e0212e100b002fc21635077mr7070703iln.105.1665503288788; Tue, 11 Oct 2022 08:48:08 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:08 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Artem Lapkin , Daniel Golle , Heinrich Schuchardt , Marek Vasut Subject: [PATCH v2 04/14] boot: Correct handling of addresses in boot_relocate_fdt() Date: Tue, 11 Oct 2022 09:47:10 -0600 Message-Id: <20221011154720.550320-5-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 Tue Oct 11 15:47:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688715 X-Patchwork-Delegate: sjg@chromium.org 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=LK4fRajv; 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 4Mn0Zr3xHzz1yqk for ; Wed, 12 Oct 2022 02:49:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A5A584EDE; Tue, 11 Oct 2022 17:48:38 +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="LK4fRajv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D6B05840AE; Tue, 11 Oct 2022 17:48:19 +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 autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 EBA0684F16 for ; Tue, 11 Oct 2022 17:48: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=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id y17so7353841ilq.8 for ; Tue, 11 Oct 2022 08:48:11 -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 :message-id:reply-to; bh=ZDmZu8dsnx5R+YVKV7Fd0nTlKmj3LngBBHmQCaeFvXk=; b=LK4fRajv3ZLADgDpK0WbaBToe+g2TmV00aBlAwYcSF47TABlqFpqkSaSWcvVMtPemC zocYhKUrYwsoiDhzE4KkNP/r3WH2fEJzrbwuvYKNiGxjq0wqSTUy2Ke9I2POZKI2ddRe WG9oOJ/yDmjfaGlQX73a8wHu3ZPKmQFTlOpuk= 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:message-id:reply-to; bh=ZDmZu8dsnx5R+YVKV7Fd0nTlKmj3LngBBHmQCaeFvXk=; b=qnshMJrF0sT2n1uDxhcNWZQdlcQBiIS0FtZzilYhXYurf5QefLdzBjdQc5eE5PZPzO 6TmlMmxdCMCNGRs70X4xfFnhAEub/wk5UaNiIq886AT6IMiElUxxE5inVzshalHSwM4d WhvEFEozlTtF9Bhw0PmnSBBQC+4sb25GKyDX5EShyzmJOP4mzuDCL/ejaSJ3013Ykndi v3YP6nPuncFpYk/b42xYFn4I/Q1uKbEwpYdCp5lgdvHfPv8cDNbtHluRI9TZo8xbhtQB MHDXOaTMEMV35IjlQlqwdDCbMs3Jnff2YM2t9Lyhi1hFk2DvPtlBhFmR3QhpZpjm9dhl e1JA== X-Gm-Message-State: ACrzQf3yciBMj0Bp0gS14q7w6HElyYPbcOS/3dUXnie4N39XRgZI9gne iXbE13wGpOd7GX30evLllFH+c998bJIjYw== X-Google-Smtp-Source: AMsMyM7RnYSbsk92Uua8JwXakVve0ylm2UFa63P7i1PVXII8067gfD7/aKYP4D1EN5/AQfYRYUZfNg== X-Received: by 2002:a05:6e02:1a6f:b0:2fa:8b33:de50 with SMTP id w15-20020a056e021a6f00b002fa8b33de50mr13193996ilv.267.1665503289842; Tue, 11 Oct 2022 08:48:09 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:09 -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 v2 05/14] fs: Quieten down the filesystems more Date: Tue, 11 Oct 2022 09:47:11 -0600 Message-Id: <20221011154720.550320-6-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 ad94504ed90..26738a57d5d 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -264,20 +264,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 */ @@ -300,8 +299,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 c80f8e80283..3f0d9f1c113 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" @@ -910,9 +911,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 Tue Oct 11 15:47:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688713 X-Patchwork-Delegate: sjg@chromium.org 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=SUs0l/Lp; 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 4Mn0ZQ0Gcdz1yqk for ; Wed, 12 Oct 2022 02:49:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1E59684F26; Tue, 11 Oct 2022 17:48:29 +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="SUs0l/Lp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4434884F28; Tue, 11 Oct 2022 17:48:18 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 B067F84F1A for ; Tue, 11 Oct 2022 17:48:12 +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-io1-xd36.google.com with SMTP id p16so5457848iod.6 for ; Tue, 11 Oct 2022 08:48:12 -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 :message-id:reply-to; bh=F4xIJaS3Fmkq6nfTSGNWG1fcsTsJqkwu2eFmz4w1tOE=; b=SUs0l/Lp1uZwTCqklB1K8a3uD8y/kQie42YgZC1jN9PAKcnQlcNDzXI6hZadYvgJbk 2V51c/ezUPqJsGDFDrWzDH82HqLmJU6WMfnPXP88y84Bpv+988wQYmi8yeHUbSVPcfoj WdqTDwO+QyDRjaMsCPqZrwCJR2wyhV+/Ko67c= 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:message-id:reply-to; bh=F4xIJaS3Fmkq6nfTSGNWG1fcsTsJqkwu2eFmz4w1tOE=; b=IBI+PZtRGG5JxOfIizLI24nV+p8VovnUjP5QVyieI+AIU+4ECgxLz8ldQx88CydcSJ akgMbb4NFoMooK37InYeuTjfvUYFVC7GKuWx+bvFD/v1TF69cepPftuYLEoE4k53wu7y z8k6r9Am/dnWE/03NVG+rcqMQLV8eU7EKqsnd80M8OBEskEspQYacqZoYLSeCxm0SmhY irZirckpMKr2XjQtdSu6PrZXsI90ApSraxh/bAJwXBiWHlYpoYh6dqRLBesgeiTGNvLb YVhMNrpznaaRrhLtyilZqcW2FKlSFVSPQmQX3LJiNZYvUNVbERGu7RJuB2CjukZ82KOk BmVg== X-Gm-Message-State: ACrzQf3ZtShILkoih16lTLOKjVTqulsBsI7I+SvZTSBPylCsuy8mvBI5 2D/paQD+LvDWamP2RdyLVGF+ubfUt7JTCA== X-Google-Smtp-Source: AMsMyM7onscEqID1rkq3PLQYtlmERa6DwM3EWCkuCPn+VPDnub6hwOPurHKn0LhQKmzobSXSQ+4Qjw== X-Received: by 2002:a05:6602:2f13:b0:6a1:730a:dd9d with SMTP id q19-20020a0566022f1300b006a1730add9dmr12145387iow.114.1665503290834; Tue, 11 Oct 2022 08:48:10 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:10 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Jerry Van Baren Subject: [PATCH v2 06/14] fdt: Show a message when the working FDT changes Date: Tue, 11 Oct 2022 09:47:12 -0600 Message-Id: <20221011154720.550320-7-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 --- (no changes since v1) 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 6fbd9205d38..4b2dcfec863 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 Tue Oct 11 15:47:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688714 X-Patchwork-Delegate: sjg@chromium.org 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=fsBIueRO; 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 4Mn0Zf3z09z1yqk for ; Wed, 12 Oct 2022 02:49:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 683F984F07; Tue, 11 Oct 2022 17:48:34 +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="fsBIueRO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2BCCA84F2B; Tue, 11 Oct 2022 17:48:19 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 DE9C184F15 for ; Tue, 11 Oct 2022 17:48:13 +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-io1-xd2b.google.com with SMTP id n73so6328744iod.13 for ; Tue, 11 Oct 2022 08:48:13 -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 :message-id:reply-to; bh=dqP5yM0LcN7KE8zMe8qsQeuQIhOuEzeBKkoQLBFVR4c=; b=fsBIueROrWL3CWoz/EBa9UW9yxYIsmFG6qXgvhGZEDOPpbNdv99MD3wTge7H9o2N9J cEMFOR7ii5Dtc8LnBe9bbQbtuO6EYU5VjX1REZZyRorTHuPeG/wMR6yZsb7SYbo1VHFX bKPqLo88qUfMBKfJYeKXYrQmg981mO5HToipE= 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:message-id:reply-to; bh=dqP5yM0LcN7KE8zMe8qsQeuQIhOuEzeBKkoQLBFVR4c=; b=lxr1taTovVD7CLSgKPvnfhTyJe498Phg0H0Rf931ugwViauT0/KsmPOCsKppZqoMsS jygKxFOpiSbjm2DURAA1fbUKsqx0sbdEt871kdZF50QTc7B8jEcVvfOWtc75fYkXseCl +cBQlYO/CebG5yTd5aRSAo88hnkC0YHrZeLjsIf9UQJhT8Lpg/ffA0/97cxSb6Ts68g9 Ejg5CAcCthqR9DVv0qNl29bGCeRV9m7wuBZi9PMoKnq36OUFKgkRE9ZSjFIh5cSaPfVC kmJzxQ+N4XIoFA5eFgVDMfqeXDXtr9UbsSf372Zn95W83aNIwdxPQxbCGcYNoKR0rBk9 HxuA== X-Gm-Message-State: ACrzQf0jZ9bGARiWc/qobIwEUxccQ3EN47bBVRqcf/qheLu4lKqaVS0v OyxEa/w1vDCWsbaOcpUZXUutwInOBdpekA== X-Google-Smtp-Source: AMsMyM5JUfszyF92cpuD2csX8kyXtpiCKXa+np36HGXsOj0KoiTq5onyqAjwYhPoEXOZhWLedWmOjg== X-Received: by 2002:a05:6638:35a0:b0:363:a6b5:c1bc with SMTP id v32-20020a05663835a000b00363a6b5c1bcmr8701185jal.229.1665503291954; Tue, 11 Oct 2022 08:48:11 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:11 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v2 07/14] bootstd: Move VBE setup into a shared function Date: Tue, 11 Oct 2022 09:47:13 -0600 Message-Id: <20221011154720.550320-8-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 Tue Oct 11 15:47:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688716 X-Patchwork-Delegate: sjg@chromium.org 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=ckbWU3ir; 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 4Mn0b41FHCz1yqk for ; Wed, 12 Oct 2022 02:49:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2C62584D9F; Tue, 11 Oct 2022 17:48: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=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="ckbWU3ir"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B92CB84F07; Tue, 11 Oct 2022 17:48:19 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 0255F84F0F for ; Tue, 11 Oct 2022 17:48: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=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id g13so7393549ile.0 for ; Tue, 11 Oct 2022 08:48:14 -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 :message-id:reply-to; bh=LKtSCkjdqjQAmAE+aw4+DPw0J4mhO7o/SALYbwgKuR0=; b=ckbWU3ir9uNfBAzIugEfdOD9E28/jPiC7YwAlIyAjkP8qOqkDjNb58NNkicfqr3tsc AStDLMgMfwJg+eA3CkUvlvEEzQRivvmTz+tvMQl8gYPlPzbHtmq788BwD3V34VwrFWPA O/C6mfmp1v304u9bFXfxgyGaXRpwhRRj3AahM= 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:message-id:reply-to; bh=LKtSCkjdqjQAmAE+aw4+DPw0J4mhO7o/SALYbwgKuR0=; b=k00MXO0YwGG8sD7PkRswJuEKW0F3H4yo4+ITSlnKLfolKzamrCLf7ZmjQEhRJXttZg gj+cQJfrPpfmezO8WeAudMruySM/44f2LEF50lmANG9/gDaH0BNeDmT5/dEbhkC+RVKt kvC+CzLoloQHWIS6sL2G5VNVNabhCGLuKPu2o2GPUhaodUHcj1dPsreWg3GiOTZ+O+qH B4BNKveA8o9y/b+SoIetEj2qUGIzT2oxKq+Vvf1E3GID8PHNLr3NQXwhP2tuDn1jOLHr vBHEOyEsU+wM68LAxQwB0nZ7rhUYftLq42mFSZ2cKo+ao/ujJE3Bq7b2jb6Tz5nVMljT StqA== X-Gm-Message-State: ACrzQf3/9QH4XVdaraucCEFmlmTYpxkd+XCRy62S8Jm70Wolv2yZgblS yBeryFfs3mEMAgfQnq5TPIL9+9EZkYGOSg== X-Google-Smtp-Source: AMsMyM4j/b4QsL/1rpEu4fFqS8DiIN6VR7x0AOfoZnSC4jSExuIEt2HOtmdRyC/tQSaOr7JtvBxfJw== X-Received: by 2002:a05:6e02:b27:b0:2fc:2925:ee8f with SMTP id e7-20020a056e020b2700b002fc2925ee8fmr6312092ilu.229.1665503293092; Tue, 11 Oct 2022 08:48:13 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:12 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v2 08/14] sandbox: Support FDT fixups Date: Tue, 11 Oct 2022 09:47:14 -0600 Message-Id: <20221011154720.550320-9-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 Tue Oct 11 15:47:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688718 X-Patchwork-Delegate: sjg@chromium.org 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=CPdZqB4r; 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 4Mn0bS73FVz1yqk for ; Wed, 12 Oct 2022 02:49:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 63D6C84F2A; Tue, 11 Oct 2022 17:48: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="CPdZqB4r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1B0E284F1C; Tue, 11 Oct 2022 17:48:25 +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 autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 1CFCA84F11 for ; Tue, 11 Oct 2022 17:48:16 +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-io1-xd32.google.com with SMTP id 187so11141380iov.10 for ; Tue, 11 Oct 2022 08:48:16 -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 :message-id:reply-to; bh=wQDPqofHgMMwNl9IE29uGJLP1XLqhxiKh+XKBiyMdLU=; b=CPdZqB4rjNgqKoAtUQuCSB/GkKANrpM7VP6kL4YNFKe2rVOcP6V1HQCWil9M9AnD4y AiCtWGiSHm3lBNl1r1QU6n4wkYEvNL2YDyyHz3ZcXE1lUiRzybr3y88epddXb7xANGpg P/9lUIRGkmUZU0Xuk8lbC5YTykKmg3G6nqmik= 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:message-id:reply-to; bh=wQDPqofHgMMwNl9IE29uGJLP1XLqhxiKh+XKBiyMdLU=; b=rBBCDVjPkgZvUi+o7qh6eJjKJnqEE1ITnCjnNu7y7UaU6WcW2ese7C7EGgmMqyJJVt VFvZjZT1wQrEHtfu940yej8nf/ibDtCoqZkd1/q1cFMFDmC31/DcRFi8Q7HAuSt586q4 uGzxCo6WXckj3FtvCPaEV01x3oRCurbextYd7Od1RrWIZ11zhva2X5W99EZQihf34D/t y7pB0yp6DJXPiZIMzCXBQr7JppN8cCTEQAMzdVH+fbI5cJRnoshQ/Ok9mJ7p9VHNJMDf mYyiSvgGHfx9mTe93wLjhRKWFIMVwqFCD05wSSUX4HJgR5QK4l8qY+8GnWlI0D9ZZRPy 24QA== X-Gm-Message-State: ACrzQf1nDlI2aEBaCw0d3vjwfy36lsJUAaEHcPzB5zDgrayNChUsZjH4 MBfw0b2GTaeWsUazTytg4K/XMserMu/x8g== X-Google-Smtp-Source: AMsMyM5CeLPYxekZmIaDHr9lPA733I/xMh86piDvCi1NDhQZha8KFzQJpHj5BQoDoJSUo/mujPSRqw== X-Received: by 2002:a05:6602:2c54:b0:6bc:9749:9096 with SMTP id x20-20020a0566022c5400b006bc97499096mr694527iov.157.1665503294198; Tue, 11 Oct 2022 08:48:14 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:13 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Artem Lapkin , Daniel Golle , Heinrich Schuchardt , Marek Vasut Subject: [PATCH v2 09/14] boot: Pass the correct FDT to the EVT_FT_FIXUP event Date: Tue, 11 Oct 2022 09:47:15 -0600 Message-Id: <20221011154720.550320-10-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 Tue Oct 11 15:47:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688717 X-Patchwork-Delegate: sjg@chromium.org 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=h3FGJg2Y; 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 4Mn0bH1659z1yqk for ; Wed, 12 Oct 2022 02:49:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4556084F1F; Tue, 11 Oct 2022 17:48: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="h3FGJg2Y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 22F1E84F24; Tue, 11 Oct 2022 17:48:24 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 449AE84F19 for ; Tue, 11 Oct 2022 17:48:16 +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-il1-x12d.google.com with SMTP id y17so7353997ilq.8 for ; Tue, 11 Oct 2022 08:48:16 -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 :message-id:reply-to; bh=CvN101E0YBuqFtaXKfToou9giIsKybVBzZd8RR1qDfc=; b=h3FGJg2YpgLvCVgp5k9m/Yo5vIlntlSw/7fZcvY+uWN4cTHMRKo2+Rc5yE7YsWjJnI uniGGWYFVOhaTmShef9hbP8xfndYtX6ZUUa4xzfGSswF7E1A/hOPo8Dif7vIt45xr8sG wJVgIulMIsMZi7EkJKN1sPK0E3GpdUFzSpBbo= 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:message-id:reply-to; bh=CvN101E0YBuqFtaXKfToou9giIsKybVBzZd8RR1qDfc=; b=FOlTxcGN07tBdFJdBXWjKU4YASYqWFjHWkVzHg71UKaw2omauodNCqV0szt9T7pJhn x07D+BNVm2l7WfIXtE1kTW0YpwVUzaA3azZWcQbbx8yRTqT8qGTdOmLiKQrO2SmQ6/US 3+sj6G5veqac9B4bi0Spporh6flME5i4pV+Y5yLXdiI+r3VcLolM3VZ5oBgiC6oXZszx g/TXcnlkbvawHmCzExxbjGlve88dy2cZAAC+9JelMowkFpmDd1R2t7oA7F4CrE9Mr5Kt b+ixvehrWnVQwkR+5RDpANK9sqICP8E5vT7Lkhyn/A6WBnbMp38mSqTkfGNKz0UIT48k kUqw== X-Gm-Message-State: ACrzQf0CyJRREqvEYQRFyMHanQgwkGE9wyGg5gxiQYQHwZ0p1m7dPLys dysTEULzGAcLK+/Op5sDlhfcNXfFLy5g3A== X-Google-Smtp-Source: AMsMyM6ixu+hikcvqF76V+IMYbR3ZRqMDMrPRtjgryqInR7LBTT9zcfsaDJYf11mswpGL0ceX5pFrA== X-Received: by 2002:a05:6e02:160c:b0:2fc:1bc4:1811 with SMTP id t12-20020a056e02160c00b002fc1bc41811mr7027988ilu.306.1665503295385; Tue, 11 Oct 2022 08:48:15 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:14 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Heinrich Schuchardt Subject: [PATCH v2 10/14] boot: Tidy up logging and naming in vbe_simple Date: Tue, 11 Oct 2022 09:47:16 -0600 Message-Id: <20221011154720.550320-11-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 Tue Oct 11 15:47:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688719 X-Patchwork-Delegate: sjg@chromium.org 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=BWlWUv5/; 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 4Mn0bh2Jjvz23jn for ; Wed, 12 Oct 2022 02:50:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A689F84F38; Tue, 11 Oct 2022 17:48: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="BWlWUv5/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9FFBD84F1F; Tue, 11 Oct 2022 17:48:26 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 7AF0384EDE for ; Tue, 11 Oct 2022 17:48: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=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id y17so7354026ilq.8 for ; Tue, 11 Oct 2022 08:48:17 -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 :message-id:reply-to; bh=pzz0k0VClXUVIjjXdp+sKgSjtDGCtTdoNUYAv0YvQz4=; b=BWlWUv5/458bARc1f2y0Pd6Rz1b5Z95fhFL6Hk5TbK2R1uedaC/mt+9aYdxyAFREFV v86dOrx4wrS4z80ACax5ZTE3nJUmfs86uZgpVQ3niWDgsD+IwAIrQShk7cGqUShYR5uw VRv1aqQRpqM2tSNKi0JILJ8wbKkwuwcLT+B1M= 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:message-id:reply-to; bh=pzz0k0VClXUVIjjXdp+sKgSjtDGCtTdoNUYAv0YvQz4=; b=PbF9/9WsBY95J2bkMByUQNQwEYj3LC5ETPR89LOFwjFQotkp0hwJNXt7t7Nj+CrlOw /h1k/fNiq06V9Bu/T613TGJIzdEV6ZgQzn1m8FZygRWmG7fGdKGDyFRJU9jAADUA7hHc pa/leLnwHECYIj65/hDcsMPErmFr5SbcmafthlJX2Bh/cgs6xl7SaVlOOT7wA5YDASvR 48c8/wUI3k4iC/MKBzusbZC8EBdvKCYPX6SOj+GPoVLPwxxbGxH9hhYK6L5ML7q76HsI 88vDSSFOhMRAI51tUn/02mVroatA+U/zld/i6r2re8R0FqoFoFig7RbBTg+rDo2cUitS 4G7Q== X-Gm-Message-State: ACrzQf3DUd3dWfKPBrydoe7d5k6zOeqTJQUxzIzR1iY/PUQkEvFlCpvd 8jyGzhvKYrGomPH53b2bGl2TRTuPJP+xQA== X-Google-Smtp-Source: AMsMyM4PQvwtXyI5NYX7+EI1r9+/LDRwRYr60EznfF5a1ro8JFq9FR7cEjZ8KXuXM28ZBo/+hYop2w== X-Received: by 2002:a05:6e02:12e6:b0:2f5:fb2a:cc8a with SMTP id l6-20020a056e0212e600b002f5fb2acc8amr12077434iln.14.1665503296562; Tue, 11 Oct 2022 08:48:16 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Philippe Reynes Subject: [PATCH v2 11/14] test: Move common FIT code into a separate fit_util file Date: Tue, 11 Oct 2022 09:47:17 -0600 Message-Id: <20221011154720.550320-12-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 Tue Oct 11 15:47:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688720 X-Patchwork-Delegate: sjg@chromium.org 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=RTsLg0HO; 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 4Mn0bv4G3Dz23jn for ; Wed, 12 Oct 2022 02:50:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C54BE84F35; Tue, 11 Oct 2022 17:48: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="RTsLg0HO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7737384F24; Tue, 11 Oct 2022 17:48:29 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 D3F9A84F1A for ; Tue, 11 Oct 2022 17:48:18 +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-il1-x12c.google.com with SMTP id a2so7345731iln.13 for ; Tue, 11 Oct 2022 08:48:18 -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 :message-id:reply-to; bh=xqSx67PGF+Nq2GO/M9/A4761WheT1TjkNxJWesTgONQ=; b=RTsLg0HOV1HfLoShFq33usAUmkkWtw+0GV6Y2lHmttQBpDx4TxLt7+drFMtL00zB5p IeO1LF7cFIaGxtUV+ZNpCFwxhsQolRfEmsSyXCsc3gfsJmxPpkfbTD3iRnj2VKg/4kEc kMcShcjKvZFSSflOMRGSkYdDJPdzojQaIv17Y= 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:message-id:reply-to; bh=xqSx67PGF+Nq2GO/M9/A4761WheT1TjkNxJWesTgONQ=; b=f5gbiqoyfeeTyJe51RXWTXOGcBW3W2Nc5Lrly/88ot48uv6i6Kx/JlwBqKPkYDAiFE oRbWITS5XPpM2ugS3Ak12WKK9J1aZxkKzkfm8sTEq/CTiMNyx6leFkYS12M1N+9cIiDO xUFU1VB7CvRAnHGX2AuBTyvOTbttB5hpunTsqQYcJcOuBLDLCQdWwaQb5h4qERlIXNPE hNk5hRsvueUyLOompqJXy4f12xztpV4DH8uAoy4arz7ttulR6JsA8ZpjjdvOj4fAkF47 j7gfgOH2Dzl8wN/uvOphnfWm5sIFLZUPECZt+YtFcDaDLsn5QO7LmIv4G5CLqRHin5an /ebw== X-Gm-Message-State: ACrzQf11XjYbNnjxUYRnpcb3OX/zqtKlV8CU7+ACVt39QeUtXz30VJnX P7fgxv1AvTA6MJDZP2VLTH058CWK66Wi3A== X-Google-Smtp-Source: AMsMyM6HlNcJgzPX/9bS6HTsvMh5HNp4+pBEiHhspKP4Cg4VUbaesdapQLUw9h/7Ix+ldb2nBPyNUg== X-Received: by 2002:a92:cdab:0:b0:2fa:7113:8506 with SMTP id g11-20020a92cdab000000b002fa71138506mr11801047ild.93.1665503297860; Tue, 11 Oct 2022 08:48:17 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:17 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Artem Lapkin , John Keeping , Philippe Reynes , Ramon Fried Subject: [PATCH v2 12/14] vbe: Add fixups for a basic set of OS requests Date: Tue, 11 Oct 2022 09:47:18 -0600 Message-Id: <20221011154720.550320-13-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 Tue Oct 11 15:47:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688721 X-Patchwork-Delegate: sjg@chromium.org 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=FOtTbVjL; 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 4Mn0c65CV8z23jn for ; Wed, 12 Oct 2022 02:50:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6B0CE84F3B; Tue, 11 Oct 2022 17:49:00 +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="FOtTbVjL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D5E5884F14; Tue, 11 Oct 2022 17:48:29 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 DB0FF84F0F for ; Tue, 11 Oct 2022 17:48:19 +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-il1-x12f.google.com with SMTP id q18so4584557ils.12 for ; Tue, 11 Oct 2022 08:48:19 -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 :message-id:reply-to; bh=L74AhKXwm2P0J2P6pSdZEt4m4wXqTcEGX/fuR7dheRU=; b=FOtTbVjLV0UZDJ6T5n368uszuVVEf3e+y4WJ2M2j5KdjoLxG88mtnKtWbI/TIXTBrU 9dZqK6QrdOHnlf/tZHa/wYfHmWetokri5zS39IVUFpZ/TQ992kwkTrRk7jT/4xTst0sF gbV1wTEs1CBKZ+mStPh3VAn9QHLXUa2tco6Ks= 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:message-id:reply-to; bh=L74AhKXwm2P0J2P6pSdZEt4m4wXqTcEGX/fuR7dheRU=; b=LuyMbwzsSB9Wbbx2bbvdrYjgAzS/1Kr+ID2kpwphGh0jNapGCV7LzzgiVrrP2iz9uk Kkl6H/1kQKH9Lj+Qt2le9QoARQPP6knI4jXgsaA6Jxm7op28n5AqOfBUjs2xE48UMSDL VHUMoAzkgK8Eue3p4NPNOrG81le0Lv8bLSgNrmC56fnXP13PvqoxMFpiRxy2FWHXL1Or 9OXXtHYpjJ81P4Jb5fViY4F5tHToUWT/gIgSDI4Z8k7/GDfAg1vn5fZbv6LlwIJHJxmM HzrtohNRcqo02iQloHHIc3YArbx//Y0Naey1d7oPe2P8dMLJVio08oA9LfC6/VGTwvYp 3UIQ== X-Gm-Message-State: ACrzQf2w66bq38H2w8PR07UM+FLDCMc9Hm5/qdoOL76UDbbLdwFKaEO6 WEmVopXPqI/NcseorCOFQtL4gyFbtdbX7A== X-Google-Smtp-Source: AMsMyM6gls1/kHKIKuCYZvGH6ja4YAy8ItgUZu2TR1ykHuScU+gbRS7/Edm1bF8jqjPGSJOIOLR7sQ== X-Received: by 2002:a05:6e02:18cd:b0:2f9:e186:e673 with SMTP id s13-20020a056e0218cd00b002f9e186e673mr12950681ilu.297.1665503299147; Tue, 11 Oct 2022 08:48:19 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:18 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH v2 13/14] dm: core: Update docs about oftree_from_fdt() Date: Tue, 11 Oct 2022 09:47:19 -0600 Message-Id: <20221011154720.550320-14-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Update this function's comment and also the livetree documentation, so it is clear when to use the function. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v2: - Add new patch to update docs about oftree_from_fdt() doc/develop/driver-model/livetree.rst | 2 +- include/dm/ofnode.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/develop/driver-model/livetree.rst b/doc/develop/driver-model/livetree.rst index 55aa3eac929..579eef5ca9f 100644 --- a/doc/develop/driver-model/livetree.rst +++ b/doc/develop/driver-model/livetree.rst @@ -255,7 +255,7 @@ So long as OF_LIVE is disabled, it is possible to do fixups using the ofnode interface. The OF_LIVE support required addition of the flattening step at the end. -See dm_test_ofnode_root() for some examples. The ofnode_path_root() function +See dm_test_ofnode_root() for some examples. The oftree_from_fdt() function causes a flat device tree to be 'registered' such that it can be used by the ofnode interface. diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 7aae2c29ef1..fa9865602d8 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -59,6 +59,9 @@ __attribute_const__ int ofnode_to_offset(ofnode node); /** * oftree_from_fdt() - Returns an oftree from a flat device tree pointer * + * If @fdt is not already registered in the list of current device trees, it is + * added to the list. + * * @fdt: Device tree to use * * Returns: reference to the given node From patchwork Tue Oct 11 15:47:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688722 X-Patchwork-Delegate: sjg@chromium.org 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=k4kOS7uf; 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 4Mn0cK1DCNz23jn for ; Wed, 12 Oct 2022 02:50:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C468484F44; Tue, 11 Oct 2022 17:49:09 +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="k4kOS7uf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6B82984EDE; Tue, 11 Oct 2022 17:48:36 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 1939E84F2B for ; Tue, 11 Oct 2022 17:48:22 +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-io1-xd32.google.com with SMTP id 137so6923935iou.9 for ; Tue, 11 Oct 2022 08:48:22 -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 :message-id:reply-to; bh=TH4z8vQTnebNrHpfNZbqQ4fXYSNlEqa1xPkuk7vuLAo=; b=k4kOS7ufjTg6pQCBMj/iV70kDiGWIMznWFidJAA3C+vEa8sNw5BKTPYM2+PGLKVUtR EGDqql9d5PDNEdj6ZCwrz0LA65Gao8VdlUZwbwTyjwwDUsgwdLa0gOFHPGIdfts7VsJR jWF8RVcMMFgUrdT2Yd0LcGfJruKffi0sCWELs= 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:message-id:reply-to; bh=TH4z8vQTnebNrHpfNZbqQ4fXYSNlEqa1xPkuk7vuLAo=; b=HaXeHyoXietz75Pk2rTJRiI1AJknRB8NT0f0UbGwZKrpdhigYUAi7L2yCmEIfXuDUk Xnv5y0m4T3fLH+6qPmpbeCfVV+OZWBKqpF9LKQpPMhxy6cr4GMBMrRL54Sq6WmcaVBZ7 u/v27SCB9fSCmyaGCwRd0FBShHkFgDAl3itntZOMKTBg416uHJcdHpG9yw96qLy8C1td QElg4f4UHPg0zQKV9AL7vL/VjO0kbjWVMghDDGZ32cjyH+1ihVmnZA2HaggPT0UtnnSo xMHzcG3udVekRZxwhzOIbFDJC427dy/+sXjyZWF0B4bLzx8RfeaG62Bp08Hr/BydrHYt ff7g== X-Gm-Message-State: ACrzQf2gaZ0dJVFZ5zWqbuyrLm+Og5wYXMqM413UjolrVs3AtRJ4YpmK TWkwNLNhFZrHWEQXkjmuG6SBXUcOiAHR3g== X-Google-Smtp-Source: AMsMyM6wFNvzeQSzbx8CGKK46taorsPniEZf0aExArapmf8DxEDGDeelCfjrFC6emogt4KK8UMD6RQ== X-Received: by 2002:a02:2711:0:b0:35a:4fb3:efcf with SMTP id g17-20020a022711000000b0035a4fb3efcfmr12868925jaa.14.1665503300213; Tue, 11 Oct 2022 08:48:20 -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 r12-20020a922a0c000000b002f9b55e7e92sm4988680ile.0.2022.10.11.08.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 08:48:19 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v2 14/14] vbe: Add a test for VBE device tree fixups Date: Tue, 11 Oct 2022 09:47:20 -0600 Message-Id: <20221011154720.550320-15-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011154720.550320-1-sjg@chromium.org> References: <20221011154720.550320-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 Signed-off-by: Simon Glass --- (no changes since v1) 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 a2eb7afcf9b..0d8e3132320 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_AXI=y 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]