From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67D33C6379F for ; Tue, 21 Feb 2023 13:04:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE29685A32; Tue, 21 Feb 2023 14:04:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="iQuPyG4Z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0DEF785A3C; Tue, 21 Feb 2023 14:04:08 +0100 (CET) Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 A3613859D5 for ; Tue, 21 Feb 2023 14:04:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x530.google.com with SMTP id h16so17097653edz.10 for ; Tue, 21 Feb 2023 05:04:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Ux1NU5p/EOr+a5QacqZDDvnXlCoIhGurVlxPyCK1LQg=; b=iQuPyG4Zd5sQl5DTQeUJ33jQKjpB2DoG7Kb7JHs7KC2WNauOSozLJ8+3yr7nJLKLXK I71aU9A3LIGE3u9LwumgnWcnHvSYxDWYQP1ryF7gZIPQRSusK5DWtDUUXkL7NzYJ/G2K 2yLduKOf0lKbpKbnfBroV8Bh5CAUZi0EusQGbkUksYGg2j7zgjkovFyQVylbV1+pyBmB KfrXKNgWrg+FyofXJy85myAWDCpU1wCPktDDDqtYGRaxRLsDnlSk9yHZnmpI+8xbIuN2 y0NmoDMDfr/Nnxh4lB/UJnwR1fmgpoOMZc4aTdM4DUy1CkVXQ3CI+dwbI5p6iQG3C6qX G8kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Ux1NU5p/EOr+a5QacqZDDvnXlCoIhGurVlxPyCK1LQg=; b=Gxwk++W0eIKw7KfG5AwJKjJoho5bG9FM3ulifSlyX9AO55UjNLnKgV+4aIKATU3g4v KHaUmZh1xaCpEeD5GVYk5T9MU6Ce6WyoHIS+WSHBk0+IiCj+KyiU4IUfOamOH+F0VeSr PL5030hkHpoMLEfTnL9WgBeefCsadiT2slwPP0BP4r8etyHdg8nDOPn9Fl7dMd3zBxHR h/A8shmY5kt4JvninzFgmREOTiY/QT/JlmXKvko3wbI9INtKh2sbG6J0nyrVmQxBewLu IwM0W30z7lnTvWRjcOgbr81ibWXHcHpkkQvK91e99llwBJL+bPZaeYs0KGxpztHL3zuk AArQ== X-Gm-Message-State: AO0yUKUoAio4hQJ/SIvq1rhS7N7bR0kqjSo/dmfFZINZGn4th5BuxaGO tYuLnLC7Kf0O/3bisYhnEjtqsQ== X-Google-Smtp-Source: AK7set/h4jfVJtKQgJU3ObUN/echAkBKjGDpStB3HOYTUquK0eUmo0l+NIqnkjiYeFisqvEJJTprpg== X-Received: by 2002:aa7:d491:0:b0:4ad:7cfe:f0a with SMTP id b17-20020aa7d491000000b004ad7cfe0f0amr4907507edr.34.1676984644153; Tue, 21 Feb 2023 05:04:04 -0800 (PST) Received: from hera (ppp176092130041.access.hol.gr. [176.92.130.41]) by smtp.gmail.com with ESMTPSA id 19-20020a508e13000000b004aef609f747sm3169752edw.3.2023.02.21.05.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 05:04:03 -0800 (PST) Date: Tue, 21 Feb 2023 15:04:01 +0200 From: Ilias Apalodimas To: Simon Glass Cc: U-Boot Mailing List , Andrew Scull , Dzmitry Sankouski , Etienne Carriere , Marek =?iso-8859-1?Q?Beh=FAn?= , Nikhil M Jain , Ramon Fried , Sean Anderson Subject: Re: [PATCH 1/2] tpm: Separate out the TPM tests for v1 and v2 Message-ID: References: <20230220212736.885114-1-sjg@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230220212736.885114-1-sjg@chromium.org> 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 On Mon, Feb 20, 2023 at 02:27:35PM -0700, Simon Glass wrote: > Currently there is only one test and it only works on TPM v2. Update it > to work on v1.2 as well, using a new function to pick up the required > TPM. > > Update sandbox to include both a v1.2 and v2 TPM so that this works. > Split out the existing test into two pieces, one for init and one for > the v2-only report_state feature. > > Signed-off-by: Simon Glass > --- > > arch/sandbox/dts/test.dts | 4 +++ > test/dm/tpm.c | 60 +++++++++++++++++++++++++++++++++------ > 2 files changed, 55 insertions(+), 9 deletions(-) > > diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts > index 05e09128a38..d72d7a567a7 100644 > --- a/arch/sandbox/dts/test.dts > +++ b/arch/sandbox/dts/test.dts > @@ -1367,6 +1367,10 @@ > compatible = "sandbox,tpm2"; > }; > > + tpm { > + compatible = "google,sandbox-tpm"; > + }; > + > uart0: serial { > compatible = "sandbox,serial"; > bootph-all; > diff --git a/test/dm/tpm.c b/test/dm/tpm.c > index dca540bb561..7d880012090 100644 > --- a/test/dm/tpm.c > +++ b/test/dm/tpm.c > @@ -11,24 +11,66 @@ > #include > #include > > -/* Basic test of the TPM uclass */ > +/* > + * get_tpm_version() - Get a TPM of the given version > + * > + * @version: Version to get > + * @devp: Returns the TPM device > + * Returns: 0 if OK, -ENODEV if not found > + */ > +static int get_tpm_version(enum tpm_version version, struct udevice **devp) > +{ > + struct udevice *dev; > + > + /* > + * For now we have to probe each TPM, since the version is set up in > + * of_to_plat(). We could require TPMs to declare their version when > + * probed, to avoid this > + */ > + uclass_foreach_dev_probe(UCLASS_TPM, dev) { > + if (tpm_get_version(dev) == version) { > + *devp = dev; > + return 0; > + } > + } > + > + return -ENODEV; > +} > + > +/* Basic test of initing a TPM */ > +static int test_tpm_init(struct unit_test_state *uts, enum tpm_version version) > +{ > + struct udevice *dev; > + > + /* check probe success */ > + ut_assertok(get_tpm_version(version, &dev)); > + > + ut_assertok(tpm_init(dev)); > + > + return 0; > +} > + > static int dm_test_tpm(struct unit_test_state *uts) > +{ > + ut_assertok(test_tpm_init(uts, TPM_V1)); > + ut_assertok(test_tpm_init(uts, TPM_V2)); > + > + return 0; > +} > +DM_TEST(dm_test_tpm, UT_TESTF_SCAN_FDT); > + > +/* Test report_state */ > +static int dm_test_tpm_report_state(struct unit_test_state *uts) > { > struct udevice *dev; > char buf[50]; > > /* check probe success */ > - ut_assertok(uclass_first_device_err(UCLASS_TPM, &dev)); > - ut_assert(tpm_is_v2(dev)); > + ut_assertok(get_tpm_version(TPM_V2, &dev)); > > ut_assert(tpm_report_state(dev, buf, sizeof(buf))); > ut_asserteq_str("init_done=0", buf); > > - ut_assertok(tpm_init(dev)); > - /* > - * tpm_auto_start will rerun tpm_init, but handles the > - * -EBUSY return code internally. > - */ > ut_assertok(tpm_auto_start(dev)); > > ut_assert(tpm_report_state(dev, buf, sizeof(buf))); > @@ -36,4 +78,4 @@ static int dm_test_tpm(struct unit_test_state *uts) > > return 0; > } > -DM_TEST(dm_test_tpm, UT_TESTF_SCAN_FDT); > +DM_TEST(dm_test_tpm_report_state, UT_TESTF_SCAN_FDT); > -- > 2.39.2.637.g21b0678d19-goog > Acked-by: Ilias Apalodimas