From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750898AbdBBEli convert rfc822-to-8bit (ORCPT ); Wed, 1 Feb 2017 23:41:38 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46231 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750776AbdBBElh (ORCPT ); Wed, 1 Feb 2017 23:41:37 -0500 Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: ibmvtpm byteswapping inconsistency From: Vicky In-Reply-To: <024dadba-a75c-ab59-9d12-a9bea81f9bda@gmail.com> Date: Wed, 1 Feb 2017 23:40:33 -0500 Cc: Jason Gunthorpe , Michal Such??nek , Nayna Jain , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , tpmdd-devel@lists.sourceforge.net, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT References: <20170126212248.3f3e9103@kitsune.suse.cz> <20170126220536.GB31937@obsidianresearch.com> <024dadba-a75c-ab59-9d12-a9bea81f9bda@gmail.com> To: Ashley Lai X-Mailer: Apple Mail (2.3124) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020204-0008-0000-0000-000001061846 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020204-0009-0000-0000-000008FC70BD Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-02-02_03:,, 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-1612050000 definitions=main-1702020041 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Jan 26, 2017, at 5:58 PM, Ashley Lai wrote: > > Adding Vicky from IBM. > > > On 01/26/2017 04:05 PM, Jason Gunthorpe wrote: >> On Thu, Jan 26, 2017 at 09:22:48PM +0100, Michal Such??nek wrote: >> >>> This is repeated a few times in the driver so I added memset to quiet >>> gcc and make behavior deterministic in case the unused fields get some >>> meaning in the future. >> Yep, reserved certainly needs to be zeroed.. Can you send a patch? >> memset is overkill... >> >>> However, in tpm_ibmvtpm_send the structure is initialized as >>> >>> struct ibmvtpm_crq crq; >>> __be64 *word = (__be64 *)&crq; >>> ... >>> crq.valid = (u8)IBMVTPM_VALID_CMD; >>> crq.msg = (u8)VTPM_TPM_COMMAND; >>> crq.len = cpu_to_be16(count); >>> crq.data = cpu_to_be32(ibmvtpm->rtce_dma_handle); >>> >>> and submitted with >>> >>> rc = ibmvtpm_send_crq(ibmvtpm->vdev, be64_to_cpu(word[0]), >>> be64_to_cpu(word[1])); >>> meaning it is swapped twice. >> No idea, Nayna may know. >> >> My guess is that '__be64 *word' should be 'u64 *word'... >> >> Jason > I don’t think we want ‘word' to be changed back to be of type ‘u64’. Please see commit 62dfd912ab3b5405b6fe72d0135c37e9648071f1 Vicky