From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDBmC-0007ei-0Y for qemu-devel@nongnu.org; Mon, 19 Jan 2015 07:49:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDBm7-0001nG-AL for qemu-devel@nongnu.org; Mon, 19 Jan 2015 07:49:51 -0500 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:50905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDBm7-0001mr-0F for qemu-devel@nongnu.org; Mon, 19 Jan 2015 07:49:47 -0500 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 19 Jan 2015 12:49:44 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9BA751B08070 for ; Mon, 19 Jan 2015 12:49:42 +0000 (GMT) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t0JCnfEY56623322 for ; Mon, 19 Jan 2015 12:49:41 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t0JCnfro031429 for ; Mon, 19 Jan 2015 05:49:41 -0700 Date: Mon, 19 Jan 2015 13:49:37 +0100 From: Greg Kurz Message-ID: <20150119134937.6c58c242@bahia.local> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] virtio_tswaps() vs virtio_ld/st_p() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Stefan Hajnoczi , qemu-devel On Mon, 19 Jan 2015 11:45:39 +0000 Peter Maydell wrote: > On 19 January 2015 at 11:35, Stefan Hajnoczi wrote: > > What is the difference between the virtio_tswaps() and > > virtio_ld/st_p() families of functions? > > virtio_ld/st*_p() perform a load or store from memory pointed > to by the (host) pointer argument. > > virtio_tswap16 &c take a value, swap it as appropriate and > return a value. > > virtio_tswap16s &c do an in-place byteswap on the value pointed > to by the host pointer argument. > > (The tswap*/tswap*s pairs are a mirror of the equivalent families > of functions bswap16/bswap16s provided by bswap.h.) > > The most important distinction here is that the ld/st functions > will handle possibly unaligned accesses, whereas the tswap > functions will not. The former are intended for "fish this value > out from some guest RAM" and the latter for "we have a structure > we've copied from guest RAM already via memcpy and want to swizzle > the entries in it". > > -- PMM > Heh, not sure I would have provided such a comprehensive answer. :) Stefan, Feeling curious, what was the intent behind your question ? Cheers. -- Greg