From patchwork Wed May 10 07:43:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 680512 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2697444wrs; Wed, 10 May 2023 00:45:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6WUWZryafXduubpwlQOvNXssIOjfo2fx8KM2BvnSI54aaYUZFnUr2UDBqUGReJ+TaowVhK X-Received: by 2002:a17:90a:e50d:b0:247:6a31:d59d with SMTP id t13-20020a17090ae50d00b002476a31d59dmr16558960pjy.1.1683704757893; Wed, 10 May 2023 00:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683704757; cv=none; d=google.com; s=arc-20160816; b=TJ+tkSGXPqNFlBCYuGaEaCjiNwv0DA/Z22diE73UwHuz7cyQYP5gsiNHNF0nFEsZ5B rRlrcGvedKHuZMkJJz60P1MiPZr9AaK6jUY11WVA4tVTD6ePJtijolrnH3snbQzt53W9 jEYwzzRemnxc9qFYP5+oH7R7Sb3MrSJt6+YfrnGQJrFC/vel4BoCkSMh65fZLmUC6Q/F TOVCL5DfvTaCeHjkp2FdWGI9KdBBdNIt/F/TThl7PU6P7pX1xS7DIvczpjt7gtWt+Td9 vt4fDDkRceNmzta8HW4nNe9w2E5hnKAQXDU4+z5tJ3PRm+YCpg8r4x+rkysMwJpqInGX TKNA== 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=vlNXpObnaJ73wNYY0OY7oEd2FKXem8m8mfVlgI4kwWA=; b=HecnxynUY8VqUzt1+K5Zy4sjIqWBdxB7jkERpUTE6gsExnN7Y2GwYPByk4ElZqXujl uJfIhU/NEs5GyFThXv3aacg6hNXrWVJLgqefQZfHdv84ClAzZ81b1KycrJnlRR1szsNI 4Z+2IfNftKCqOKqSqoLlPmXg55IpVRU/UHND7rdYsOPMQJJB/lZYNDJZfIWTuPDqJUVz DJfrxiF3KBKX82OH3XLiPBKPkfWY7nh+brPhIMq2A2fP9fODSc2a862ErYFESyIWdwBT OcPVv+H5jQaVHfePhvZ/Ec9BVaw7NxxqfwPw6K8gO+h4L6xwvwt+RNgYo6fp4Gpm8Oij FroQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ht6pphU4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 80-20020a630153000000b005077dda0477si3543184pgb.802.2023.05.10.00.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 00:45:57 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ht6pphU4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 02D9E8609C; Wed, 10 May 2023 09:44:48 +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="Ht6pphU4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4CADE860A7; Wed, 10 May 2023 09:44:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (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 E1E1E8603A for ; Wed, 10 May 2023 09:44:42 +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-wr1-x432.google.com with SMTP id ffacd0b85a97d-304935cc79bso6392429f8f.2 for ; Wed, 10 May 2023 00:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683704682; x=1686296682; 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=vlNXpObnaJ73wNYY0OY7oEd2FKXem8m8mfVlgI4kwWA=; b=Ht6pphU4uAd0T8NbdHdCGjAN9XdmAKXKbnSQXhtsamPaqsdN3lZ7lTsmfPIDMybSOp ZHlZ5W8ICCsJ3/rxj/qRSNB9KZsBUwiNFbVcBLaH3+gkBlK9ABwB9XwM5vCn1Sz1+ttV Ot5pmFLdS1Ebyf7FWNieovXcWpO41exM83DPNEf48br61QT4heGv2brnygPmXW/uW3Yk HTWc9ZFI/ybd6oTT3K6qBGDBU+8bjQC6nZ9SmOkYw0y1TNjysz16lKfg2Q8q0TasmtKL yDLvCfJ+xYtGMvDHx3024GKy/RodVApoL5bPkhn0S0yphvgtM0QiczXiZo82BWEsw5DZ ydfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683704682; x=1686296682; 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=vlNXpObnaJ73wNYY0OY7oEd2FKXem8m8mfVlgI4kwWA=; b=hESn7bbjgQO7czXhBowhlFJSJYL7Tw+PNw9z18bHZhwOWyW0N5j5fddc/aR/mZx29A oi2qJi852VQFtVOUAd2ZcPbkdoJn6PqmCZnNwGE7bTo18AWAOUD8GSdqQMZj5iu2pxgM SQol2ZzlxWqAGCpobzMrTu/+qGaoqSXl1s8Tlrd4EHOhlXXMAL8siECP/GVU2MWrsT+L E677zTPRB+U8IFuGlSTuKswacuZSM6vGSbP5jVfV/9oF6njPkcpQD9FyaezdlD18dNcb CbI1ZL7rkhI39/fNncuNc6SnY9se6xW63Fzq5XGVjdoLEBGhtVNLzBQzMxsIl0vC+M5u tt2g== X-Gm-Message-State: AC+VfDwokFufA49GrnaUKNjyho0IkI2qZoJdUxN6GsPMZbQB5MkYMKxA 8OAViJbxuVck+XLyMbMBdadVvK1h4wnhhVTOL3z27w== X-Received: by 2002:a5d:500b:0:b0:2e4:6197:21b3 with SMTP id e11-20020a5d500b000000b002e4619721b3mr11878634wrt.55.1683704682321; Wed, 10 May 2023 00:44:42 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 00:44:42 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Heinrich Schuchardt , Eddie James , Robert Marko , Dzmitry Sankouski , Rasmus Villemoes , Michal Suchanek , Sean Anderson , Nikhil M Jain , Abdellatif El Khlifi , Andrew Davis , Mattijs Korpershoek , Safae Ouajih , Daniel Golle , =?utf-8?q?Pali_Roh=C3=A1r?= , Roger Knecht , Sughosh Ganu , Steven Lawrance , Rui Miguel Silva , Linus Walleij , Stephen Carlson , Marek Vasut , Kautuk Consul , Leo Yu-Chi Liang , Brandon Maier , Patrick Delaunay Subject: [PATCH 8/9] test: Account PCR updates properly during testing Date: Wed, 10 May 2023 10:43:56 +0300 Message-Id: <20230510074359.2837818-8-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 Currently we only read the pcr updates once on test_tpm2_pcr_read(). It turns out that the tpm init sequence of force_init() which consists of: - tpm2 init - tpm2 startup TPM2_SU_CLEAR - tpm2 self_test full - tpm2 clear TPM2_RH_LOCKOUT also counts as an update. Running this in the console verifies the update bump => tpm2 init => tpm2 startup TPM2_SU_CLEAR => tpm2 self_test full => tpm pcr_read 10 $loadaddr PCR #10 content (28 known updates): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 => tpm2 clear TPM2_RH_LOCKOUT => tpm pcr_read 10 $loadaddr PCR #10 content (29 known updates): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 => Instead of relying on the initial read do a read just before updating the PCR to ensure we read the correct values before testing Signed-off-by: Ilias Apalodimas Reviewed-by: Simon Glass --- test/py/tests/test_tpm2.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/py/tests/test_tpm2.py b/test/py/tests/test_tpm2.py index bae3095393c2..57722fdc5977 100644 --- a/test/py/tests/test_tpm2.py +++ b/test/py/tests/test_tpm2.py @@ -281,6 +281,12 @@ def test_tpm2_pcr_extend(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 10 0x%x' % (ram + 0x20)) + output = u_boot_console.run_command('echo $?') + assert output.endswith('0') + str = re.findall(r'\d+ known updates', read_pcr)[0] + updates = int(re.findall(r'\d+', str)[0]) + u_boot_console.run_command('tpm2 pcr_extend 10 0x%x' % ram) output = u_boot_console.run_command('echo $?') assert output.endswith('0')