From patchwork Wed May 10 07:43:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 680511 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2697389wrs; Wed, 10 May 2023 00:45:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7nWHX1+97kziZnKSxS6C8Y6YjFZMwQPlwApmV24ohHMklEAuNLJ9b0+XP1zuuniy/kplWh X-Received: by 2002:a05:6a20:160c:b0:102:a593:a162 with SMTP id l12-20020a056a20160c00b00102a593a162mr1590832pzj.4.1683704746358; Wed, 10 May 2023 00:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683704746; cv=none; d=google.com; s=arc-20160816; b=vrKp/GlfJqi4NFi0/jJZ+rOp41tiv48YKXfyEKIoafKeyUGOhhDqZxF62V9YqeyG5B y9VyqLCwrYWVYLy0WOtvxfB1BvvI9gW6lMF99iMgb7PBMvvHtpLdYuu+K5m8dqDTi/Rl LpaErkzYs9H2e0OSmNSG7Sll/f3u0UUQnD1CBes9gmZvHt5pwIYixBSDRL57Eq35BWsE e3qxMaSOxbjmFg7/gRVX8VZgKX2UNCUK6C3C5/0RB5PDVAijwYXo9o6yYf+mc8RMYptb /+YdNFSGISawIS4JALXZQVnTZB/lzZuUh3i3AIujW2aW+Ar/BLEdqu9zmD6NoWZT1GbO Ay/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lUl1U2Kf0TknbYjaLjC1V4Ce/FazHtmbfrDFNm1RhKk=; b=MQfQBz1z6tNXQc+i6oI5tM31/gOEd9C6guuPIyl1+YQtDEMlvbOeG8jMLN34oNh61v QGN5kMkq3Oo//xNm6LYt5uzFWHW0nORf3ZLZSs1OCMSDoiPCPK+1LMXe5q5P4/vR7H7D tmb88cKOdKx4O26944o702TL9G+BIUzg8YascmA1zc+TP5IHQ+31lSkRv+OretxJ8KCD u8lX0hfK3hYMzFYChnn60fz0jjU02wPwpkaQ0teiyHOWcg6yxE0PWLzQYZN3Ik6FfLUN 8lXzgu8FZ0kiSon3BcdXaf8YdoKfTJewhl81wlz+l9zavNqdEyItnfMeDOseJO6jPZ4H 5VHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aE1hwnwz; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id f3-20020a637543000000b0052c9896a41fsi3616842pgn.164.2023.05.10.00.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 00:45:46 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aE1hwnwz; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1D8A5860A6; Wed, 10 May 2023 09:44:45 +0200 (CEST) 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="aE1hwnwz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 25410860A4; Wed, 10 May 2023 09:44:44 +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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (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 13B3B86075 for ; Wed, 10 May 2023 09:44:39 +0200 (CEST) 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-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f42769a0c1so29132035e9.2 for ; Wed, 10 May 2023 00:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683704678; x=1686296678; 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=lUl1U2Kf0TknbYjaLjC1V4Ce/FazHtmbfrDFNm1RhKk=; b=aE1hwnwzUKIKbse+lL9lU010xGOAp62X+O8mxf9L9G2bAVgnXRSZLWeQSaiQbWIETy cQTqSMQjFZTozD7DfcrKzgo5dXD3PrzX8JiZz3vA75fuq5t1u193WubWEq9PmCrgQ8am WJkxT3VDkS4mycppPwAi8sMI9LpZrOJQcEo+E2RO0vuyfi2QbTkaqyzRS16PK45NuapJ kesg2IGUy/t7Nm9PQP9lt/OfAcaluyB2NmI8DU/n0P16DAvvUElL/d99/rT0oLkPKjq8 Ok23JMwfDkefP50N5rmkzhNQn45W74qsUzfxMaKwTZ+tHYtmEOY1GDTHa94agQlRTETK 10mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683704678; x=1686296678; 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=lUl1U2Kf0TknbYjaLjC1V4Ce/FazHtmbfrDFNm1RhKk=; b=SfP73c6M4TQ/vbFqn1qY00mYlFRCRe45soitsqYakUsqVlcMKUePloBsz5up75hNi6 pFMpGm2wbP0+Y9deU4v/5JMV8ZhzU+Q2A0kJzJN6Ic50KcX+IcX1aPqz0c9X3EApf1Zt PJo1Pc6k/hWvIvZ/5iNrFzaoD8/mnhBkWewanojkE++Q/7pW6F4eyX/t5FIpfnDBDQEs bGzMlwx3Nmma5d6/iVgLjPtIwoeR30WRB0waTKia4wyu2/ma5c/BxpY3aUW2tyQpdzIs 9Xo/SXaUnDrcIWqHzNxrELfHdMJdH33nB21C5UqRGQKCKswvfF35uUCmpX0y43isKQS4 cq/Q== X-Gm-Message-State: AC+VfDzwpiQCxzmRcJ1TLm5szbsv+w2HmhXdNos17Oui+XuaowONzPtW wJkNIuetLaiLdmccSRy4YgguOIMLma1gqPUufPP/MQ== X-Received: by 2002:a1c:f71a:0:b0:3f1:91ba:feb2 with SMTP id v26-20020a1cf71a000000b003f191bafeb2mr11134063wmh.2.1683704678553; Wed, 10 May 2023 00:44:38 -0700 (PDT) Received: from localhost.localdomain (ppp176092130041.access.hol.gr. [176.92.130.41]) by smtp.gmail.com with ESMTPSA id p20-20020a1c7414000000b003f435652aaesm2022446wmc.11.2023.05.10.00.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 00:44:38 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Heinrich Schuchardt , Robert Marko , Rasmus Villemoes , Dzmitry Sankouski , Eddie James , Michal Suchanek , Sean Anderson , Nikhil M Jain , Abdellatif El Khlifi , Andrew Davis , Safae Ouajih , Daniel Golle , Mattijs Korpershoek , Sughosh Ganu , Roger Knecht , Steven Lawrance , Marek Vasut , Rui Miguel Silva , Stephen Carlson , Linus Walleij , Kautuk Consul , Leo Yu-Chi Liang , Brandon Maier , Patrick Delaunay Subject: [PATCH 7/9] test: use a non system PCR for testing PCR extend Date: Wed, 10 May 2023 10:43:55 +0300 Message-Id: <20230510074359.2837818-7-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230510074359.2837818-1-ilias.apalodimas@linaro.org> References: <20230510074359.2837818-1-ilias.apalodimas@linaro.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.8 at phobos.denx.de X-Virus-Status: Clean We currently use PCR 0 for testing the PCR read/extend functionality in our selftests. How ever those PCRs are defined by the TCG spec for platform use. For example if the tests run *after* the efi subsystem initialization, which extends PCRs 0 & 7 it will give a false positive. So let's switch over to a PCR which is more suitable and is defined for OS use. It's worth noting that we are using PCR10 here, since PCR9 is used internally by U-Boot if we choose to measure the loaded DTB Signed-off-by: Ilias Apalodimas Reviewed-by: Simon Glass --- test/py/tests/test_tpm2.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/py/tests/test_tpm2.py b/test/py/tests/test_tpm2.py index d2ad6f9e73c0..bae3095393c2 100644 --- a/test/py/tests/test_tpm2.py +++ b/test/py/tests/test_tpm2.py @@ -245,7 +245,7 @@ def test_tpm2_dam_parameters(u_boot_console): def test_tpm2_pcr_read(u_boot_console): """Execute a TPM2_PCR_Read command. - Perform a PCR read of the 0th PCR. Must be zero. + Perform a PCR read of the 10th PCR. Must be zero. """ if is_sandbox(u_boot_console): tpm2_sandbox_init(u_boot_console) @@ -253,7 +253,7 @@ def test_tpm2_pcr_read(u_boot_console): force_init(u_boot_console) ram = u_boot_utils.find_ram_base(u_boot_console) - read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % ram) + read_pcr = u_boot_console.run_command('tpm2 pcr_read 10 0x%x' % ram) output = u_boot_console.run_command('echo $?') assert output.endswith('0') @@ -263,7 +263,7 @@ def test_tpm2_pcr_read(u_boot_console): updates = int(re.findall(r'\d+', str)[0]) # Check the output value - assert 'PCR #0 content' in read_pcr + assert 'PCR #10 content' in read_pcr assert '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' in read_pcr @pytest.mark.buildconfigspec('cmd_tpm_v2') @@ -281,13 +281,13 @@ def test_tpm2_pcr_extend(u_boot_console): force_init(u_boot_console) ram = u_boot_utils.find_ram_base(u_boot_console) - u_boot_console.run_command('tpm2 pcr_extend 0 0x%x' % ram) + u_boot_console.run_command('tpm2 pcr_extend 10 0x%x' % ram) output = u_boot_console.run_command('echo $?') assert output.endswith('0') # Read the value back into a different place so we can still use 'ram' as # our zero bytes - read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 0x20)) + read_pcr = u_boot_console.run_command('tpm2 pcr_read 10 0x%x' % (ram + 0x20)) output = u_boot_console.run_command('echo $?') assert output.endswith('0') assert 'f5 a5 fd 42 d1 6a 20 30 27 98 ef 6e d3 09 97 9b' in read_pcr @@ -297,11 +297,11 @@ def test_tpm2_pcr_extend(u_boot_console): new_updates = int(re.findall(r'\d+', str)[0]) assert (updates + 1) == new_updates - u_boot_console.run_command('tpm2 pcr_extend 0 0x%x' % ram) + u_boot_console.run_command('tpm2 pcr_extend 10 0x%x' % ram) output = u_boot_console.run_command('echo $?') assert output.endswith('0') - read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 0x20)) + read_pcr = u_boot_console.run_command('tpm2 pcr_read 10 0x%x' % (ram + 0x20)) output = u_boot_console.run_command('echo $?') assert output.endswith('0') assert '7a 05 01 f5 95 7b df 9c b3 a8 ff 49 66 f0 22 65' in read_pcr