Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751569AbdGYRgT (ORCPT ); Tue, 25 Jul 2017 13:36:19 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42843 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbdGYRgS (ORCPT ); Tue, 25 Jul 2017 13:36:18 -0400 Subject: Re: [tpmdd-devel] tpm: read burstcount from TPM_STS in one 32-bit transaction From: James Bottomley To: Michal =?ISO-8859-1?Q?Such=E1nek?= , Christophe Ricard , linux-kernel@vger.kernel.org, tpmdd-devel@lists.sourceforge.net, Jarkko Sakkinen , apronin@chromium.org Date: Tue, 25 Jul 2017 10:36:11 -0700 In-Reply-To: <20170725150443.7cf8fc91@kitsune.suse.cz> References: <20170725150443.7cf8fc91@kitsune.suse.cz> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 17072517-0056-0000-0000-000003AC82DA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007424; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00892769; UDB=6.00446260; IPR=6.00672933; BA=6.00005492; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016372; XFM=3.00000015; UTC=2017-07-25 17:36:16 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17072517-0057-0000-0000-000007E2A0C1 Message-Id: <1501004171.3689.25.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-25_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707250276 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 887 Lines: 20 On Tue, 2017-07-25 at 15:04 +0200, Michal Suchánek wrote: > Hello, > > in commit 9754d45e9970 ("tpm: read burstcount from TPM_STS in one > 32-bit transaction") you change reading of two 8-bit values to one > 32bit read. This is obviously wrong wrt endianess unless the > underlying tpm_tis_read32 does endian conversion.  Some of the bus read primitives do do endianness conversions.  The problem is with the SPI attachment, which has unclear endianness.  A standard PCI bus attachment uses ioread32() which automatically transforms from a little endian bus to the cpu endianness, however SPI is forced to transfer the bytes one at a time over the serial bus and then transform.  The assumption seems to be that the TIS TPM is replying in little endian format when SPI connected. We can probably get the PPC people to confirm this, I believe they have a SPI attached TPM. James