{"id":2230152,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2230152/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260429134142.2.25391578ae16ae38c90974bea552726dbe0153aa@changeid/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.1/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260429134142.2.25391578ae16ae38c90974bea552726dbe0153aa@changeid>","date":"2026-04-29T11:41:42","name":"[2/3] tpm: make pcr_read command more useful","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"3f97eaf6771e939461a1af7a597d6e6515f85513","submitter":{"id":90265,"url":"http://patchwork.ozlabs.org/api/1.1/people/90265/?format=json","name":"Ludwig Nussel","email":"ludwig.nussel@siemens.com"},"delegate":{"id":96103,"url":"http://patchwork.ozlabs.org/api/1.1/users/96103/?format=json","username":"apalos","first_name":"Ilias","last_name":"Apalodimas","email":"apalos@gmail.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260429134142.2.25391578ae16ae38c90974bea552726dbe0153aa@changeid/mbox/","series":[{"id":502040,"url":"http://patchwork.ozlabs.org/api/1.1/series/502040/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=502040","date":"2026-04-29T11:41:40","name":"Improve U-Boot's TPM handling in the non-EFI case","version":1,"mbox":"http://patchwork.ozlabs.org/series/502040/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230152/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2230152/checks/","tags":{},"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=siemens.com header.i=ludwig.nussel@siemens.com\n header.a=rsa-sha256 header.s=fm2 header.b=Geo83Kkg;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=pass (p=reject dis=none) header.from=siemens.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (2048-bit key;\n secure) header.d=siemens.com header.i=ludwig.nussel@siemens.com\n header.b=\"Geo83Kkg\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=reject dis=none) header.from=siemens.com","phobos.denx.de;\n spf=pass smtp.mailfrom=ludwig.nussel@siemens.com"],"Received":["from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5FnB5kT6z1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 21:43:42 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id DCDE884852;\n\tWed, 29 Apr 2026 13:43:18 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id B50D48483A; Wed, 29 Apr 2026 13:43:16 +0200 (CEST)","from mta-64-226.siemens.flowmailer.net\n (mta-64-226.siemens.flowmailer.net [185.136.64.226])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 5250D84836\n for <u-boot@lists.denx.de>; Wed, 29 Apr 2026 13:43:12 +0200 (CEST)","by mta-64-226.siemens.flowmailer.net with ESMTPSA id\n 202604291143117e354aeef1000207a6 for <u-boot@lists.denx.de>;\n Wed, 29 Apr 2026 13:43:11 +0200"],"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_MED,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,\n RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,\n SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2;\n d=siemens.com; i=ludwig.nussel@siemens.com;\n h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To;\n bh=AHIgTov4iH2cbkVIYbiUnveFllqjEuDgGcUg/08aCeI=;\n b=Geo83KkgrmJKxXJPowEeS1yS3PwraB3oUD511aUw5l81Mp7xeEQZLW3Uu+WAO/GZz0JAPC\n O6hA9C6fYb/zhwytuESa5CinfRUvjHqMaP0htGQW0BY4ImwC+aUaiixuJyId5yhXhaUXq12a\n Vdyqbk4umLBN7apOrai+yvbPSybOmww5wKQ4aR8ZV99suC+FHwBAozMtHwqVKKwtY39q0ipm\n YxkXPhG7FARjJ50R4QTvbDZUU8J6+PdsADU46Eqt89v5ZqYHmNm+TgmkfVDtJdoXJOSrR4To\n dlkFfPRLMlLizYRfAivNaZdRL2Xs8ZbEfp07oubfroX4rqUt/i1/JEuw==;","From":"Ludwig Nussel <ludwig.nussel@siemens.com>","To":"u-boot@lists.denx.de","Cc":"Ludwig Nussel <ludwig.nussel@siemens.com>,\n Andrew Goodbody <andrew.goodbody@linaro.org>,\n Heiko Schocher <hs@nabladev.com>,\n Ilias Apalodimas <ilias.apalodimas@linaro.org>,\n Tom Rini <trini@konsulko.com>","Subject":"[PATCH 2/3] tpm: make pcr_read command more useful","Date":"Wed, 29 Apr 2026 13:41:42 +0200","Message-ID":"\n <20260429134142.2.25391578ae16ae38c90974bea552726dbe0153aa@changeid>","In-Reply-To":"<20260429114250.791663-1-ludwig.nussel@siemens.com>","References":"<20260429114250.791663-1-ludwig.nussel@siemens.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Flowmailer-Platform":"Siemens","Feedback-ID":"519:519-1328817:519-21489:flowmailer","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"Output now more similar to Linux userspace tool \"tpm2_pcrread\".\n\nWithout arguments the command now prints contents of all PCR registers\n\nSigned-off-by: Ludwig Nussel <ludwig.nussel@siemens.com>\n\n---\n\n cmd/tpm-v2.c | 54 ++++++++++++++++++++++++++++++++++------------------\n 1 file changed, 36 insertions(+), 18 deletions(-)","diff":"diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c\nindex 847b2691581..3bcb11a8de6 100644\n--- a/cmd/tpm-v2.c\n+++ b/cmd/tpm-v2.c\n@@ -8,6 +8,7 @@\n #include <dm.h>\n #include <log.h>\n #include <mapmem.h>\n+#include <malloc.h>\n #include <tpm-common.h>\n #include <tpm-v2.h>\n #include \"tpm-user-utils.h\"\n@@ -150,10 +151,11 @@ static int do_tpm_pcr_read(struct cmd_tbl *cmdtp, int flag, int argc,\n \tu32 index, rc;\n \tint algo_len;\n \tunsigned int updates;\n-\tvoid *data;\n+\tu8 *data;\n \tint ret;\n+\tu32 pcr_start, pcr_end;\n \n-\tif (argc < 3 || argc > 4)\n+\tif (argc > 4)\n \t\treturn CMD_RET_USAGE;\n \tif (argc == 4) {\n \t\talgo = tpm2_name_to_algorithm(argv[3]);\n@@ -164,28 +166,44 @@ static int do_tpm_pcr_read(struct cmd_tbl *cmdtp, int flag, int argc,\n \n \tret = get_tpm(&dev);\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto out;\n \n \tpriv = dev_get_uclass_priv(dev);\n \tif (!priv)\n-\t\treturn -EINVAL;\n-\n-\tindex = simple_strtoul(argv[1], NULL, 0);\n-\tif (index >= priv->pcr_count)\n-\t\treturn -EINVAL;\n-\n-\tdata = map_sysmem(simple_strtoul(argv[2], NULL, 0), 0);\n+\t\tgoto out;\n \n-\trc = tpm2_pcr_read(dev, index, priv->pcr_select_min, algo,\n-\t\t\t   data, algo_len, &updates);\n-\tif (!rc) {\n-\t\tprintf(\"PCR #%u %s %d byte content (%u known updates):\\n\", index,\n-\t\t       tpm2_algorithm_name(algo), algo_len, updates);\n-\t\tprint_byte_string(data, algo_len);\n+\tif (argc >= 2) {\n+\t\tpcr_start = simple_strtoul(argv[1], NULL, 0);\n+\t\tif (pcr_start >= priv->pcr_count)\n+\t\t\treturn -EINVAL;\n+\t\tpcr_end = pcr_start + 1;\n+\t} else {\n+\t\tpcr_start = 0;\n+\t\tpcr_end = priv->pcr_count;\n \t}\n \n-\tunmap_sysmem(data);\n+\tif (argc >= 3)\n+\t\tdata = map_sysmem(simple_strtoul(argv[2], NULL, 0), 0);\n+\telse\n+\t\tdata = malloc(algo_len);\n+\n+\tprintf(\"%8s:\\n\", tpm2_algorithm_name(algo));\n+\tfor (index = pcr_start; index < pcr_end; ++index) {\n+\t\trc = tpm2_pcr_read(dev, index, priv->pcr_select_min, algo,\n+\t\t\t\t   data, algo_len, &updates);\n+\t\tif (!rc) {\n+\t\t\tprintf(\"%6u: 0x\", index);\n+\t\t\tfor (int i = 0; i < algo_len; ++i)\n+\t\t\t\tprintf(\"%02X\", data[i]);\n+\t\t\tprintf(\" (%u known updates)\\n\", updates);\n+\t\t}\n+\t}\n+\tif (argc >= 3)\n+\t\tunmap_sysmem(data);\n+\telse\n+\t\tfree(data);\n \n+out:\n \treturn report_return_code(rc);\n }\n \n@@ -548,7 +566,7 @@ U_BOOT_CMD(tpm2, CONFIG_SYS_MAXARGS, 1, do_tpm, \"Issue a TPMv2.x command\",\n \"    Extend PCR #<pcr> with digest at <digest_addr> with digest_algo.\\n\"\n \"    <pcr>: index of the PCR\\n\"\n \"    <digest_addr>: address of digest of digest_algo type (defaults to SHA256)\\n\"\n-\"pcr_read <pcr> <digest_addr> [<digest_algo>]\\n\"\n+\"pcr_read [<pcr> [<digest_addr> [<digest_algo>]]]\\n\"\n \"    Read PCR #<pcr> to memory address <digest_addr> with <digest_algo>.\\n\"\n \"    <pcr>: index of the PCR\\n\"\n \"    <digest_addr>: address of digest of digest_algo type (defaults to SHA256)\\n\"\n","prefixes":["2/3"]}