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: 756505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3wF0rx358Dz9s89 for ; Sat, 29 Apr 2017 03:18:25 +1000 (AEST) 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-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 0.0 AWL AWL: Adjusted score from AWL reputation of From: address 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 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;