From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932224AbdA3Omq (ORCPT ); Mon, 30 Jan 2017 09:42:46 -0500 Received: from smtp-out6.electric.net ([192.162.217.195]:59333 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932172AbdA3Omh (ORCPT ); Mon, 30 Jan 2017 09:42:37 -0500 From: David Laight To: "'Tyrel Datwyler'" , Benjamin Herrenschmidt , =?utf-8?B?TWljaGFsIFN1Y2jDoW5law==?= , Ashley Lai , Paul Mackerras , Michael Ellerman , Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , Jason Gunthorpe , "tpmdd-devel@lists.sourceforge.net" , "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Subject: RE: ibmvtpm byteswapping inconsistency Thread-Topic: ibmvtpm byteswapping inconsistency Thread-Index: AQHSeMeJ8lHqrdS2Gkm+aOCXywnIf6FRG3ew Date: Mon, 30 Jan 2017 14:42:25 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB0273BCA@AcuExch.aculab.com> References: <20170126212248.3f3e9103@kitsune.suse.cz> <1485481819.2980.82.camel@kernel.crashing.org> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuExch.aculab.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v0UEhID0025899 From: Tyrel Datwyler > Sent: 27 January 2017 18:03 > On 01/26/2017 05:50 PM, Benjamin Herrenschmidt wrote: > > On Thu, 2017-01-26 at 17:42 -0800, Tyrel Datwyler wrote: > >> On 01/26/2017 12:22 PM, Michal Suchnek wrote: > >>> Hello, > >>> > >>> building ibmvtpm I noticed gcc warning complaining that second word > >>> of > >>> struct ibmvtpm_crq in tpm_ibmvtpm_suspend is uninitialized. > >>> > >>> The structure is defined as > >>> > >>> struct ibmvtpm_crq { > >>> u8 valid; > >>> u8 msg; > >>> __be16 len; > >>> __be32 data; > >>> __be64 reserved; > >>> } __attribute__((packed, aligned(8))); > >>> > >>> initialized as > >>> > >>> struct ibmvtpm_crq crq; > >>> u64 *buf = (u64 *) &crq; > >>> ... > >>> crq.valid = (u8)IBMVTPM_VALID_CMD; > >>> crq.msg = (u8)VTPM_PREPARE_TO_SUSPEND; > >>> > >>> and submitted with > >>> > >>> rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(buf[0]), > >>> cpu_to_be64(buf[1])); Isn't the real fubar here the use of that memory layout structure at all? It would probably all be better if the call looked like: rc = ibmvtpm_send_crq(ibmvtpm->vdev, MAKE_REQ(IBMVTPM_VALID_CMD, VTPM_PREPARE_TO_SUSPEND, xxx_len, xxx_data), 0); and MAKE_REQ() did all the required endian independant shifts to generate the correct 32bit value. David