From patchwork Wed Jan 31 14:14:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weizhao Ouyang X-Patchwork-Id: 1893515 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=OKJWiGHP; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TQ3vq6lyxz1yQ0 for ; Thu, 1 Feb 2024 01:15:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 748FA87C39; Wed, 31 Jan 2024 15:14:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OKJWiGHP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 64C6787C13; Wed, 31 Jan 2024 15:14:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (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 3E0CE87D3B for ; Wed, 31 Jan 2024 15:14:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=o451686892@gmail.com Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2907a17fa34so4047870a91.1 for ; Wed, 31 Jan 2024 06:14:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706710485; x=1707315285; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/AajSOxFiOBeFhM/Afxcu3V3V1Jg+uEpIRi/E2vkK7c=; b=OKJWiGHPbdOCnj9/DpTRmOH5R29P5YFmEMiP9/nWdguN62Qpe+q7q8M918zeZcDACk zMEQWTiUEyyKrW6MyrDFB/udw7W8F3yYUynXzBys1+GD+WXAFPgiR2xqL4Yea2FOpUt+ SfGHrwnnsunwNRfF+RrJE2uxO47nqAkBgNkIk7CXM2YWrw2keQYHZi9yeKEgSYVAmLe2 HhySrThydQiQWjpytrkI8fHENzl3ptPF7XmhnzVKjG+lDNjdV8zR2WMSevDY2pajvjIh E8dcSvAtpJvGbSgs0rtl7Nn2pMRlow+MiLrte4OnvhH+PXLMwsJqAoPdVIO2VvJZ/3Od bpuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706710485; x=1707315285; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/AajSOxFiOBeFhM/Afxcu3V3V1Jg+uEpIRi/E2vkK7c=; b=UQazvXyGclNiGWA1kHI+odcjpZ0NKVvqGKiBsPgMnEToBvoYc+GYZ98Ch4BxRaRVxN +bmfJevO+HRwrhJu4Rvtkt1bS1C2Pk4/nRkc0eUDZQXcysoxsIEpFl73yzQg3ulUlc8J bt0FNQ5RR65ZTf8b7ziVfBvswm3JPoAZbaoGGKRNAdof1TQGy2WyNEgPF6CM9L0KM1yP ++Yqj219eKAzS2++or7R6TIDYtvg5wPyKz6Xe1NSaHUZJzqP2iSQrEgITlMmAnCMChfx BCZBSsb8auRKeG42Wn98+LdmxcRCGlbUnLvvjLkPjhG9rNZmOtnPR9F5OPO+K33h2kfz QgSw== X-Gm-Message-State: AOJu0Yzk4ZyEltahxrOAOgYrX7zLiScN5zo1uNMLGbYDTE9Z5QO4S1sE tw93djYQHl1mQM4P0DvEq9QQ3Wv3ZZGeLGXscDwBE81957D5pkUV X-Google-Smtp-Source: AGHT+IHvN211vXyASPN2FFrt3qSPEAbw5e+g1zcbAJcG7jlEeetNF2YtTrcCtXskz/qEWWPf1mUJyA== X-Received: by 2002:a17:90a:cb97:b0:295:b0cd:9be6 with SMTP id a23-20020a17090acb9700b00295b0cd9be6mr1761173pju.30.1706710484978; Wed, 31 Jan 2024 06:14:44 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWSRDIJyNYzSzcwtCPTrCPSZspgv7rnZ7YAsNLIVE4kcHUwXQf+JWyZtxq31vdxAiFdWuWN1qB8Ir4rUDNF4F7/F8v7ZZaKnVZWNsm18osWPqBUPWySMIYF7jq4n9Wt//+orV9IqBw1URNHben3epADXui++cwuyn+wM6Br7TwLMSd/yAd7Fo8og3Tfi0Sm4pctlVFTnO88BNaA6yqqWUKH/3cQWSC6yqyRpvExerNpYoHbWFCEHMuPB0eZdUBdFuXG7BxaHtJDCoAC69N+E85fxVgG412cvPL8rvd1dhhoHVgAuG0Dlo0lH3zIEbFk4zaMJGTMW6uJ5MW28yGC0V7BaEi7SDs83s7AONikk6Mpyyl8MAPfzqfwHg== Received: from ownia.localdomain ([8.210.91.195]) by smtp.gmail.com with ESMTPSA id mm3-20020a17090b358300b00295bafadb4fsm1534954pjb.57.2024.01.31.06.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 06:14:44 -0800 (PST) From: Weizhao Ouyang To: Sughosh Ganu , Heinrich Schuchardt , Tom Rini , Etienne Carriere , Weizhao Ouyang , Simon Glass , Peng Fan , Ilias Apalodimas , Jens Wiklander , Abdellatif El Khlifi , u-boot@lists.denx.de Subject: [PATCH v3 1/3] firmware: psci: Fix bind_smccc_features psci check Date: Wed, 31 Jan 2024 14:14:24 +0000 Message-Id: <20240131141426.34926-2-o451686892@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131141426.34926-1-o451686892@gmail.com> References: <20240131141426.34926-1-o451686892@gmail.com> 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.8 at phobos.denx.de X-Virus-Status: Clean According to PSCI specification DEN0022F, PSCI_FEATURES is used to check whether the SMCCC is implemented by discovering SMCCC_VERSION. Signed-off-by: Weizhao Ouyang Reviewed-by: Igor Opaniuk --- v3: remove fallback smc call v2: check SMCCC_ARCH_FEATURES --- drivers/firmware/psci.c | 5 ++++- include/linux/arm-smccc.h | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index c6b9efab41..03544d76ed 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -135,10 +135,13 @@ static int bind_smccc_features(struct udevice *dev, int psci_method) PSCI_VERSION_MAJOR(psci_0_2_get_version()) == 0) return 0; - if (request_psci_features(ARM_SMCCC_ARCH_FEATURES) == + if (request_psci_features(ARM_SMCCC_VERSION) == PSCI_RET_NOT_SUPPORTED) return 0; + if (invoke_psci_fn(ARM_SMCCC_VERSION, 0, 0, 0) < ARM_SMCCC_VERSION_1_1) + return 0; + if (psci_method == PSCI_METHOD_HVC) pdata->invoke_fn = smccc_invoke_hvc; else diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index f44e9e8f93..da3d29aabe 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -55,8 +55,14 @@ #define ARM_SMCCC_QUIRK_NONE 0 #define ARM_SMCCC_QUIRK_QCOM_A6 1 /* Save/restore register a6 */ +#define ARM_SMCCC_VERSION 0x80000000 #define ARM_SMCCC_ARCH_FEATURES 0x80000001 +#define ARM_SMCCC_VERSION_1_0 0x10000 +#define ARM_SMCCC_VERSION_1_1 0x10001 +#define ARM_SMCCC_VERSION_1_2 0x10002 +#define ARM_SMCCC_VERSION_1_3 0x10003 + #define ARM_SMCCC_RET_NOT_SUPPORTED ((unsigned long)-1) #ifndef __ASSEMBLY__ From patchwork Wed Jan 31 14:14:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weizhao Ouyang X-Patchwork-Id: 1893516 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=l9GMosDF; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TQ3w31rJbz23g7 for ; Thu, 1 Feb 2024 01:15:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0117087D6C; Wed, 31 Jan 2024 15:14:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="l9GMosDF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C44A387C13; Wed, 31 Jan 2024 15:14:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 A0CA087D58 for ; Wed, 31 Jan 2024 15:14:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=o451686892@gmail.com Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-295efc0b337so293250a91.3 for ; Wed, 31 Jan 2024 06:14:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706710489; x=1707315289; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=LerXxWm6BeZsqPxtIYv9MKySaKGCH1Bknwa4+se9+fk=; b=l9GMosDFmC9LCqBOGq31hYyZiixDYfG7F7YzhYU5FCL+Y/5kAQ0sGCNrGaTKunR5y+ 5rGTbZKsAOjPhzfPlqJY0dLr2vyF7ycTcf/8XAIgUBFIVegOOERxCaZckYSOishCs4h6 vU1krADmhA5oX/eUTmuNXc52o8FQihbIQ8mSF4+BWTwdQxSw7TSrgS8AdIddnRziEL2W ODgfdbvqFQbVzScE2xuSuO2VdJLLSOi+DNz9RYyupm4Bn25dxjAyBbCdm9Z0ErQnKKl4 b6kpDrEs1kwOFesrhu90tF/AaWA7V+QAlfI9i5GoleRFEg7b0k6TYqeZz1NwQpmwT7fv xuxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706710489; x=1707315289; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LerXxWm6BeZsqPxtIYv9MKySaKGCH1Bknwa4+se9+fk=; b=fEOIvzlkUNe3g7Qil0KK9MIDK/mjHKhMgmN3UImh8W5J7/QW9qqyPHarAxy5VnaRu8 gZ2NbNZzp+WXQDjzBKr/YTJqTGT9u1i4IK7RvDL4+UrdngC9Z8oKmoyEJtqUKm6XAaPE eK5pfN8Xzr2T4lEKLITljZGZO/HMFm6YW9DWF68iODzh+NMg/Yvl1LZEu+fptqJFNqTc 60xYPPZaBovTJ6iNe58LMvhifYdCvJqoHE+GhN8AbXFEncxeX1IiHDJU1QG8/DfJz8AU rHIUxsGIebYSx71NVx/L7TDBwBp2M4Cp7qac/MNZLkz150tvN4viD+v2IDChd8Vjx3VZ L/FA== X-Gm-Message-State: AOJu0Yyifq6dcFzRaU946k1dUHYHsRsJaemCd58c/gLVh5k4uhVDLLb0 bOlOiKacIGd6nhv7ul+pF9/YhNMoNpHKEm4HE7PIWBiU+mRCuinl X-Google-Smtp-Source: AGHT+IHvPB/XwMC8uPaJRuQi+VZW5OkqlmxaGEb467SAnrS1IoC5bxh1LC5jPKvwSmoKqh4rNOItng== X-Received: by 2002:a17:90a:bb96:b0:294:9d68:228 with SMTP id v22-20020a17090abb9600b002949d680228mr1730560pjr.1.1706710488441; Wed, 31 Jan 2024 06:14:48 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXzgHg10v/lRkvFoJ/P7DlnbhiSemy2AfsUb2t9CjhlYzYkd0hw+z/SIoQc9bychNGaXk1Fad0XJtTcw+JBS5hSSVi7jLDBT7EXLIBUzjHvFFJ1qu7ugLV99SucJfwZmxe6UigSkSGJLi/lS9S1wl9hNt0c7Np01D0Li9fDCKd8kpLYeiJOW18AG0+yXUDkXw3Btlog+AaUzpVESjJV7TKAET4LciC+BERSoyEXMOKRiGqSrPANeUL2oOMUp9VN9DcIYQrhHsTlTiYEO23FMpwonL3ZXhL+ceAr0sCT/chBYi1lWcP4np1S6eQnYmlIz4hq9tcsCHARBkMbjOcgO3hV3IGursbhpzE/uWJWyvNJ6OHXN8XH7MSQiA== Received: from ownia.localdomain ([8.210.91.195]) by smtp.gmail.com with ESMTPSA id mm3-20020a17090b358300b00295bafadb4fsm1534954pjb.57.2024.01.31.06.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 06:14:48 -0800 (PST) From: Weizhao Ouyang To: Sughosh Ganu , Heinrich Schuchardt , Tom Rini , Etienne Carriere , Weizhao Ouyang , Simon Glass , Peng Fan , Ilias Apalodimas , Jens Wiklander , Abdellatif El Khlifi , u-boot@lists.denx.de Subject: [PATCH v3 2/3] driver: rng: Fix SMCCC TRNG crash Date: Wed, 31 Jan 2024 14:14:25 +0000 Message-Id: <20240131141426.34926-3-o451686892@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131141426.34926-1-o451686892@gmail.com> References: <20240131141426.34926-1-o451686892@gmail.com> 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.8 at phobos.denx.de X-Virus-Status: Clean Fix a SMCCC TRNG null pointer crash due to a failed smccc feature binding. Fixes: 53355bb86c25 ("drivers: rng: add smccc trng driver") Reviewed-by: Heinrich Schuchardt Signed-off-by: Weizhao Ouyang Reviewed-by: Matthias Brugger --- v3: add Fixes tag --- drivers/rng/smccc_trng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rng/smccc_trng.c b/drivers/rng/smccc_trng.c index 3a4bb33941..3087cb991a 100644 --- a/drivers/rng/smccc_trng.c +++ b/drivers/rng/smccc_trng.c @@ -166,7 +166,7 @@ static int smccc_trng_probe(struct udevice *dev) struct smccc_trng_priv *priv = dev_get_priv(dev); struct arm_smccc_res res; - if (!(smccc_trng_is_supported(smccc->invoke_fn))) + if (!smccc || !(smccc_trng_is_supported(smccc->invoke_fn))) return -ENODEV; /* At least one of 64bit and 32bit interfaces is available */ From patchwork Wed Jan 31 14:14:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weizhao Ouyang X-Patchwork-Id: 1893517 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=OTz7sqQu; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TQ3wG1Zlvz23g7 for ; Thu, 1 Feb 2024 01:15:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 77BB087D88; Wed, 31 Jan 2024 15:14:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OTz7sqQu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B7A687D88; Wed, 31 Jan 2024 15:14:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) (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 F0D1787D67 for ; Wed, 31 Jan 2024 15:14:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=o451686892@gmail.com Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-29080973530so4194319a91.1 for ; Wed, 31 Jan 2024 06:14:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706710492; x=1707315292; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=CuP93CYwzP9yQnUWNs+A0plEMcmZDayNh7fHrs8JGi4=; b=OTz7sqQujjKlTSUNFhLzdJ+A3i/iCuyTHqGvOPqKN2g2GKtA44h4Snt+5l5aS2q4VX FLsPiRckTZuxRElEb9q6W6Es1ALu2u/aC7HTLzQz1pspg7BLhiJmKO770sd7+Sf//XwV zTkcTFEv8dEyM/R389d0pz+xKY0ltGrYInwATmZvxRkzOgX4/OawqxYqa7qMXFvAfb0/ vtitkUyoJ+LAPpPoe8wFkqpN66NnjUyw1McUZJW0zwJAOrONUsNNX+aJ3UnT0Y0sh2wR zdmWzsPdNfYPMnM3qzs63/Cl0hMJvsR6f+r+Kl7O2LHU+l90zNpcfB3D5aHIwH+P5b5y bipg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706710492; x=1707315292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CuP93CYwzP9yQnUWNs+A0plEMcmZDayNh7fHrs8JGi4=; b=kalvjHk/GuMH7evLS4SIoDJkLrdDncNysrqHumvJ3gAz4euGdhk6FMGwFx2irThk79 yABogxRACzQwmh6Y76bpHSbeH7CvYmiMiYGH/5E9U7ywskccm/ZkCZzCkYkgUfAxI0Jw NyI0lOqBd9dS4mDfYNvwqNdhnb/TDC1Ux+ZRNaFGjGOsxzareuif0c9BcmJkJiiIr0l8 rqWQUGapoyzWOYaY3K4aUrwaiQkeX5g/cvmwbNxc4W9twC/c3yMEE/TWsc+WQq4zMnH2 MLpikgrdIJiwrN0PTHmkLCr8RIuWiUV2yG+Tdlh7t/60lykhB3vcZmbzQnaESb/L1cKF WoGg== X-Gm-Message-State: AOJu0YzxODjoCTp0WOltb/nHGE+No8DeOO/hXerxmiZJHeVexusl9iKa oLVfiHhAr+68olXczxoYqdsLEXUKhPLa+td2PU67cwYjKnXErPSw X-Google-Smtp-Source: AGHT+IFzLMFtnBYfrWKJtGdC47j9Z4x4nioRrRxl2Xa0mZ+4e2jNNTrjgw55lToA+Qluefwk623aHw== X-Received: by 2002:a17:90a:cb8d:b0:295:c0dd:cb2e with SMTP id a13-20020a17090acb8d00b00295c0ddcb2emr1927242pju.25.1706710491722; Wed, 31 Jan 2024 06:14:51 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX49srJKIiac4NH9Gd4pvohOBrQwH49WYbHH7HKz5oI413AP3Nq/TQNZuxIbe+kXr0KBCS2wxiHryqB2IT/H4/5Pf0/L4AaZ93GnF3WeyJoOVD3yq+XhD5KR/CVcxQqhT9HUXNndjzlK7gkQudTurB5amPc3gwMNx7xZm7c1ZDygMRz+qDRUSCTy3lu+EPdERMG8zoR5XwV94/7oP+Chi63GslaY5X/E7iZ1fwgv1PZQmKowAELUoMXZDmxcnjPRVkY/zQNWamOHhi47wuJLTA6KZJEVVLjEdswweRZ3lylwtsOSlRomRswO2ud5wUZyEbBPUCbcI8CaNd0YS9rJ0+kCgF+ZO3S3ripPb294rTRHuPbr/gmSxwcbQ== Received: from ownia.localdomain ([8.210.91.195]) by smtp.gmail.com with ESMTPSA id mm3-20020a17090b358300b00295bafadb4fsm1534954pjb.57.2024.01.31.06.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 06:14:51 -0800 (PST) From: Weizhao Ouyang To: Sughosh Ganu , Heinrich Schuchardt , Tom Rini , Etienne Carriere , Weizhao Ouyang , Simon Glass , Peng Fan , Ilias Apalodimas , Jens Wiklander , Abdellatif El Khlifi , u-boot@lists.denx.de Subject: [PATCH v3 3/3] cmd: rng: Add rng list command Date: Wed, 31 Jan 2024 14:14:26 +0000 Message-Id: <20240131141426.34926-4-o451686892@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131141426.34926-1-o451686892@gmail.com> References: <20240131141426.34926-1-o451686892@gmail.com> 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.8 at phobos.denx.de X-Virus-Status: Clean The 'rng list' command probes all RNG devices and list those devices that are successfully probed. Also update the help info. Reviewed-by: Heinrich Schuchardt Signed-off-by: Weizhao Ouyang Reviewed-by: Matthias Brugger Reviewed-by: Igor Opaniuk --- cmd/rng.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/cmd/rng.c b/cmd/rng.c index 52f722c7af..b073a6c849 100644 --- a/cmd/rng.c +++ b/cmd/rng.c @@ -19,6 +19,22 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct udevice *dev; int ret = CMD_RET_SUCCESS; + if (argc == 2 && !strcmp(argv[1], "list")) { + int idx = 0; + + uclass_foreach_dev_probe(UCLASS_RNG, dev) { + idx++; + printf("RNG #%d - %s\n", dev->seq_, dev->name); + } + + if (!idx) { + log_err("No RNG device\n"); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; + } + switch (argc) { case 1: devnum = 0; @@ -56,12 +72,9 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return ret; } -U_BOOT_LONGHELP(rng, - "[dev [n]]\n" - " - print n random bytes(max 64) read from dev\n"); - U_BOOT_CMD( rng, 3, 0, do_rng, "print bytes from the hardware random number generator", - rng_help_text + "list - list all the probed rng devices\n" + "rng [dev] [n] - print n random bytes(max 64) read from dev\n" );