From patchwork Sat Feb 6 21:23:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1437060 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=bS29hOkB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DY50H0Rtnz9sVb for ; Sun, 7 Feb 2021 08:24:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BEBB782483; Sat, 6 Feb 2021 22:24:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bS29hOkB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 48C0F82483; Sat, 6 Feb 2021 22:23:58 +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.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 D688082483 for ; Sat, 6 Feb 2021 22:23:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd36.google.com with SMTP id x21so11031364iog.10 for ; Sat, 06 Feb 2021 13:23:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5wiQaeciCqfhFrcsAQjXZBiH6H0eE1bDCv5C8Akw2As=; b=bS29hOkBtPxTseyJAEM6pjRLstv81HFLXMZ6dR0PzppD4jCSDycw1fTdwCf+birS0h zelyGMEAutLLyeFAToSnoJItakTPPVImr40kZRYIWjiwsdaFtD0O3RQR4RoUtzKw3wmk BoL0qF8C+W3dTr3SuAJ5x3umGxpn36XCiSeGo= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=5wiQaeciCqfhFrcsAQjXZBiH6H0eE1bDCv5C8Akw2As=; b=R05Uj4O5HJYbnhCfJ6ZzUWhNaQC1iqLLA9kIV04Aw890ChfI84KZnBIfAKHuvX1uin kW0fxiWa+c/WsZn2lE5juoVVsMHuk5PvG9LonoYA29vv7d8xN+orlj5FLFfcXcHpYnHS UywuNOYMMDj8axvV3RqTGD/txhC7yE3yph+8fJa99Jw0mUz0xkJZkCMC8HH2qOtpvau9 CdmiiTNK6XmFjs9lX3Rsb4+PT6U23wsGNfMm695H25ev5VDYvzHdh3daIb2ycc7tuucF mP3OmNZehhWE2hsIpjMqJ49yy+EIPjLTFAUkDkJ9BlIBnuHx70UqOCtgzgorsR24KV9b jP8A== X-Gm-Message-State: AOAM533rynKeLx7UUH8zjf8WYsl5/k7jR0E1p4FK0+3RNwN2nh2r+88C J6UMm3WAqAnDTl4IqDED598MPWeC2svjTvLv X-Google-Smtp-Source: ABdhPJzm1lfJ5nryiMxQTJOCORkrCoZclaelr5kGG3jLD69MrDiSvHpQ6GVNgvVFRziWknRwVr9vhA== X-Received: by 2002:a05:6638:3c6:: with SMTP id r6mr10921786jaq.115.1612646630563; Sat, 06 Feb 2021 13:23:50 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id n10sm6582512ila.69.2021.02.06.13.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Feb 2021 13:23:50 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Simon Glass Subject: [PATCH v4 03/11] tpm: Add debugging of request in tpm_sendrecv_command() Date: Sat, 6 Feb 2021 14:23:34 -0700 Message-Id: <20210206212343.3567308-4-sjg@chromium.org> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog In-Reply-To: <20210206212343.3567308-1-sjg@chromium.org> References: <20210206212343.3567308-1-sjg@chromium.org> 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 The response is shown but not the request. Update the code to show both if debugging is enabled. Use a 'uint' type for size so it matches the register-word size on both 32- and 64-bit machines. Signed-off-by: Simon Glass --- Changes in v4: - Use uint type for size and explain it in the commit message lib/tpm-common.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/tpm-common.c b/lib/tpm-common.c index e4af87f76aa..4277846fdd0 100644 --- a/lib/tpm-common.c +++ b/lib/tpm-common.c @@ -166,6 +166,7 @@ u32 tpm_sendrecv_command(struct udevice *dev, const void *command, u8 response_buffer[COMMAND_BUFFER_SIZE]; size_t response_length; int i; + uint size; if (response) { response_length = *size_ptr; @@ -174,8 +175,13 @@ u32 tpm_sendrecv_command(struct udevice *dev, const void *command, response_length = sizeof(response_buffer); } - err = tpm_xfer(dev, command, tpm_command_size(command), - response, &response_length); + size = tpm_command_size(command); + log_debug("TPM request [size:%d]: ", size); + for (i = 0; i < size; i++) + log_debug("%02x ", ((u8 *)command)[i]); + log_debug("\n"); + + err = tpm_xfer(dev, command, size, response, &response_length); if (err < 0) return err;