From patchwork Thu Nov 5 21:58:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 320692 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp807172ilc; Thu, 5 Nov 2020 13:59:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKljBcykBfy/Es4lK4pQn1+Wl6ggHfMkAFNKIQ1Ikbvyk2GGgtDBJVt3rVfDkJeeKDXfNg X-Received: by 2002:a05:6402:195:: with SMTP id r21mr4721342edv.164.1604613540450; Thu, 05 Nov 2020 13:59:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604613540; cv=none; d=google.com; s=arc-20160816; b=uPojzOQuxQat63D4ZPOBhWVE52PaRGwSqbivf1JbAk5vJGZG9OmVNyel55vB8pOsQ3 LzmzjLlxVJAd0gyfPm3TeXpHbKTaZ0+pbx7lMFTNQCqJjHagesEtScktSHM9WyXKkX/N pk3BmpDzksNvng6+JtriUN1969q0RpvH9vgeNu8/jWKxzvrwZeKbQYzyoG+xtZY5k436 6K4ByONceTBQEhGPF8HZ/n3oP1+UNN4xhLnXYnHfhE62e+nvtSKwWe309VfyEnUu5TSw HXIDsJRh2BtStHytNvFcTa4t4xjkyDLFqqPhb35jYedVxT/cYi552Qo2FVP1l7ipa31v Ub7g== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=vxiDkTZMvfvWGtZAeZBENIR8sbr+ypoN8IsIedLSNq0=; b=vImNZnxr1G2r4TW52Tm4UXgbAIMuvZRdfrOPeDlyOdh5E/g2DgrpEQbQD/JUBe50UW lYz+G7qnworNgxSpmQ6/4NSbyyj/Wq1Tblwr5M+o4DwzaOJbRKTDHqWwYX1HBwzxPb4Y z5CNDxa9BxyxSwuHl7N508jpG88Lrq07z4DbvVLz3J44t/J2K1OJPvrpagAsi3ACfbpQ nDQl4JvuwBXyNOzkSWXASjn5k1vggGaj6A4jSgFddGly3XI3GnM18L8y6xDP9F8ATcYB K0t1eGBZuJG23FrzLP5KW2UdIyTv2lE1SBVgS5566LFNmPNp88rNJxnDQYIsrvDsUCBQ 89Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xvyoL32o; 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 dn22si2306287edb.239.2020.11.05.13.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 13:59:00 -0800 (PST) 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=xvyoL32o; 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 E6EB2825C7; Thu, 5 Nov 2020 22:58:57 +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="xvyoL32o"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 52F0A825C8; Thu, 5 Nov 2020 22:58:53 +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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) (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 49E9B825BE for ; Thu, 5 Nov 2020 22:58:50 +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-x542.google.com with SMTP id w1so3167399edv.11 for ; Thu, 05 Nov 2020 13:58:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vxiDkTZMvfvWGtZAeZBENIR8sbr+ypoN8IsIedLSNq0=; b=xvyoL32ooWlHLBDQa2R0I2PQ8+hQmYhLgX/5DQNfrUASwXOyVwBw2zxmvcAxJ7AyVG gVas2Q5LINKan7dJOVbM2ExgQmDF3lYi8OUTUh3bInvt+U5oUAU5+U9tzrKKzxZ29NQm FtwEMHuDRJwnBFrlLAnzulRRc92Ptqt0A8IXisoxXIX9AGOg9rzlgkV/CKUgGAJinjbo 1WYSbHu3SZjgo15H5kA8rARqAg4jfCT6/uUiB3KIFDrfFX09qxlw8dw+2I7yMzB+A9Ps UI+dbesD2DtI1iZ3dxgAQI6uaFK3lYjRRDaHUnP9Pqs6NvjvRZb5eUp3s+7+Nb3rt1co kWWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vxiDkTZMvfvWGtZAeZBENIR8sbr+ypoN8IsIedLSNq0=; b=jN9oucJZqPjt2AvnUkXwZeK/CSiRLHkhXbKwuxhNLFXG+6ebBPnh9P7czVP2HH5WpQ St82PlBmsXVeSLsXSolt0g/A+m9Y6wnbPMVQM7yCmXlwVL/1asFIGO3qaeUA45CGC95F FKVH26jyau+4YWFnrod5aXgPoZH5qhz24sRLmWg+2qE/wNFjr/wU10wbzRcaKRROuFzh BQmUJMXcoCz6kbeEm7P/XsiWXjISYfqq8m+BZFys/DUxmieUYqIGHskaTKJvguKXXARv HCAU0EqRDwBuCQWtMnFmjVdTTuQzxGZQ8G82Gr10uHfHvs1rnilb5MhxIaHmNt5Lb6k5 IbQw== X-Gm-Message-State: AOAM532Lzm2d5iM+j0MHNUacOGiGfqY535alF7+dF9ESCnc3ic1wtngn D8Ghf8hIcMWLK31SkH+rKbzshg== X-Received: by 2002:a05:6402:2d7:: with SMTP id b23mr4637926edx.196.1604613529461; Thu, 05 Nov 2020 13:58:49 -0800 (PST) Received: from apalos.home ([2a02:587:4615:c071:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id o1sm1744383ejc.81.2020.11.05.13.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 13:58:48 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: ard.biesheuvel@arm.com, Ilias Apalodimas , Alexander Graf , Miquel Raynal , Philippe Reynes , Simon Glass , Dhananjay Phadke , Bin Meng , u-boot@lists.denx.de Subject: [PATCH 1/3 v2] tpm: Change response length of tpm2_get_capability() Date: Thu, 5 Nov 2020 23:58:43 +0200 Message-Id: <20201105215846.1017178-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean For implementing the EFI_TCG2_PROTOCOL we need the count field returned by the TPM when reading capabilities via tpm2_get_capability(). Adjust the implementation of the 'tpm2 get_capability' command accordingly. Suggested-by: Heinrich Schuchardt Signed-off-by: Ilias Apalodimas --- Changes since v1: - Unconditionally get the extra 4 bytes on the response and account for them in do_tpm_get_capability() cmd/tpm-v2.c | 4 ++-- lib/tpm-v2.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- 2.29.2 Reviewed-by: Simon Glass diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c index e6742656f578..5fa4788a72de 100644 --- a/cmd/tpm-v2.c +++ b/cmd/tpm-v2.c @@ -191,10 +191,10 @@ static int do_tpm_get_capability(struct cmd_tbl *cmdtp, int flag, int argc, for (i = 0; i < count; i++) { printf("Property 0x"); for (j = 0; j < 4; j++) - printf("%02x", data[(i * 8) + j]); + printf("%02x", data[(i * 8) + j + sizeof(u32)]); printf(": 0x"); for (j = 4; j < 8; j++) - printf("%02x", data[(i * 8) + j]); + printf("%02x", data[(i * 8) + j + sizeof(u32)]); printf("\n"); } diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c index a4c352e3ef75..91759068cf03 100644 --- a/lib/tpm-v2.c +++ b/lib/tpm-v2.c @@ -184,10 +184,10 @@ u32 tpm2_get_capability(struct udevice *dev, u32 capability, u32 property, /* * In the response buffer, the properties are located after the: * tag (u16), response size (u32), response code (u32), - * YES/NO flag (u8), TPM_CAP (u32) and TPMU_CAPABILITIES (u32). + * YES/NO flag (u8), TPM_CAP (u32). */ properties_off = sizeof(u16) + sizeof(u32) + sizeof(u32) + - sizeof(u8) + sizeof(u32) + sizeof(u32); + sizeof(u8) + sizeof(u32); memcpy(buf, &response[properties_off], response_len - properties_off); return 0;