From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUCpW-0003cf-8j for qemu-devel@nongnu.org; Fri, 02 Nov 2012 04:42:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TUCpU-0004T4-FU for qemu-devel@nongnu.org; Fri, 02 Nov 2012 04:42:18 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:43617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUCpM-0004O1-K3 for qemu-devel@nongnu.org; Fri, 02 Nov 2012 04:42:16 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Nov 2012 18:39:36 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qA28flCb65798336 for ; Fri, 2 Nov 2012 19:41:49 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qA28fl7W024625 for ; Fri, 2 Nov 2012 19:41:47 +1100 Date: Fri, 2 Nov 2012 19:43:03 +1100 From: David Gibson Message-ID: <20121102084303.GR27695@truffula.fritz.box> References: <1351823524-7149-1-git-send-email-david@gibson.dropbear.id.au> <509376CB.8000905@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <509376CB.8000905@redhat.com> Subject: Re: [Qemu-devel] [PATCH] xhci: Fix some DMA host endian bugs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org On Fri, Nov 02, 2012 at 08:31:23AM +0100, Gerd Hoffmann wrote: > Hi, > > > +static inline void xhci_dma_write_u32s(XHCIState *xhci, dma_addr_t addr, > > + uint32_t *buf, size_t len) > > +{ > > + int i; > > + > > + for (i = 0; i < (len / sizeof(uint32_t)); i++) { > > + buf[i] = cpu_to_le32(buf[i]); > > + } > > + pci_dma_write(&xhci->pci_dev, addr, buf, len); > > +} > > I think we should use a temporary buffer here, otherwise you leave the > values byteswapped in buf which likely has unwanted side effects. Yeah, I wondered about that. I did check that the side-effect doesn't matter in any of the existing callers, so I left it that way to avoid the extra copies. But you're right, it's a pretty subtle constraint that could easily be broken by future changes. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson