From patchwork Fri Apr 28 17:18:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Snitselaar X-Patchwork-Id: 9705131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 65A6A602B7 for ; Fri, 28 Apr 2017 17:18:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FFCC28692 for ; Fri, 28 Apr 2017 17:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 446BA28695; Fri, 28 Apr 2017 17:18:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A3DAD28692 for ; Fri, 28 Apr 2017 17:18:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1d49X9-0001KA-7v; Fri, 28 Apr 2017 17:18:19 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1d49X8-0001K2-2k for tpmdd-devel@lists.sourceforge.net; Fri, 28 Apr 2017 17:18:18 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=jsnitsel@redhat.com; helo=mx1.redhat.com; Received: from mx1.redhat.com ([209.132.183.28]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1d49X7-00038I-1k for tpmdd-devel@lists.sourceforge.net; Fri, 28 Apr 2017 17:18:18 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 338016438B; Fri, 28 Apr 2017 17:18:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 338016438B Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jsnitsel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 338016438B Received: from localhost (ovpn-120-231.rdu2.redhat.com [10.10.120.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5811A2891; Fri, 28 Apr 2017 17:18:10 +0000 (UTC) Date: Fri, 28 Apr 2017 10:18:09 -0700 From: Jerry Snitselaar To: Jarkko Sakkinen Message-ID: <20170428171809.qtyb7naoezf7ern3@rhwork> Mail-Followup-To: Jarkko Sakkinen , tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Peter Huewe , Marcel Selhorst , Jason Gunthorpe References: <20170426223954.18365-1-jsnitsel@redhat.com> <20170428120149.jjxwbp6nmthk4y3q@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170428120149.jjxwbp6nmthk4y3q@intel.com> User-Agent: NeoMutt/20170421 (1.8.2) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 28 Apr 2017 17:18:11 +0000 (UTC) X-Headers-End: 1d49X7-00038I-1k Cc: tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [tpmdd-devel] [PATCH] tpm: print tpm error code in hex for TPM2.0 devices X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: Jerry Snitselaar List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP On Fri Apr 28 17, Jarkko Sakkinen wrote: >On Wed, Apr 26, 2017 at 03:39:54PM -0700, Jerry Snitselaar wrote: >> For easier decoding, output the error code returned >> from the tpm device in hex when the device is TPM2.0. >> >> Cc: Jarkko Sakkinen >> Cc: Peter Huewe >> Cc: Marcel Selhorst >> Cc: Jason Gunthorpe >> Reported-by: Ken Goldman >> Signed-off-by: Jerry Snitselaar >> --- >> drivers/char/tpm/tpm-interface.c | 11 ++++++++--- >> 1 file changed, 8 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c >> index bd2128e0b56c..b6c67eef9ae7 100644 >> --- a/drivers/char/tpm/tpm-interface.c >> +++ b/drivers/char/tpm/tpm-interface.c >> @@ -453,9 +453,14 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf, >> return -EFAULT; >> >> err = be32_to_cpu(header->return_code); >> - if (err != 0 && desc) >> - dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", err, >> - desc); >> + if (err != 0 && desc) { >> + if (chip->flags & TPM_CHIP_FLAG_TPM2) >> + dev_err(&chip->dev, "A TPM 2.0 error (0x%x) occurred %s\n", >> + err, desc); >> + else >> + dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", >> + err, desc); >> + } > >Is there a reason for not to apply this also to TPM 1.2? > >/Jarkko > The 2.0 spec lists the response codes in hex, while the 1.2 spec lists them in decimal. Maybe something like the following instead? index 158c1db83f05..1f433d56f53c 100644 >> if (err) >> return err; >> >> -- >> 2.13.0.rc0.45.ge2cb6ab84 >> ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Reviewed-by: Jarkko Sakkinen --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -526,8 +526,8 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space, err = be32_to_cpu(header->return_code); if (err != 0 && desc) - dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", err, - desc); + dev_err(&chip->dev, "A TPM error (%d (0x%x)) occurred %s\n", err, + err, desc); if (err) return err;