Received: from eggs.gnu.org ([2001:4830:134:3::10]:56993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIKQD-0004Ee-VK for qemu-devel@nongnu.org; Tue, 25 Feb 2014 11:00:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WIKQ4-00017w-PS for qemu-devel@nongnu.org; Tue, 25 Feb 2014 10:59:53 -0500 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:57756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIKQ4-00017g-Hp for qemu-devel@nongnu.org; Tue, 25 Feb 2014 10:59:44 -0500 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Feb 2014 15:59:42 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 567A017D805A for ; Tue, 25 Feb 2014 16:00:13 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps3075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1PFxS301835512 for ; Tue, 25 Feb 2014 15:59:28 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s1PFxcAW022948 for ; Tue, 25 Feb 2014 08:59:40 -0700 Date: Tue, 25 Feb 2014 16:59:36 +0100 From: Greg Kurz Message-ID: <20140225165936.2f4e9e0f@bahia.local> In-Reply-To: <20140225152121.GA2374@stefanha-thinkpad.redhat.com> References: <20140221112802.15111.10669.stgit@bahia.local> <20140221112810.15111.5405.stgit@bahia.local> <20140225152121.GA2374@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, peter.maydell@linaro.org, thuth@linux.vnet.ibm.com, mst@redhat.com, marc.zyngier@arm.com, rusty@rustcorp.com.au, agraf@suse.de, qemu-devel@nongnu.org, anthony@codemonkey.ws, cornelia.huck@de.ibm.com, pbonzini@redhat.com, afaerber@suse.de On Tue, 25 Feb 2014 16:21:21 +0100 Stefan Hajnoczi wrote: > On Fri, Feb 21, 2014 at 12:28:11PM +0100, Greg Kurz wrote: > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > > index aeabf3a..4fd6ac2 100644 > > --- a/hw/virtio/virtio.c > > +++ b/hw/virtio/virtio.c > > @@ -19,6 +19,9 @@ > > #include "hw/virtio/virtio.h" > > #include "qemu/atomic.h" > > #include "hw/virtio/virtio-bus.h" > > +#include "hw/virtio/virtio-access.h" > > + > > +bool virtio_byteswap; > > > > /* > > * The alignment to use between consumer and producer parts of vring. > > @@ -546,6 +549,9 @@ void virtio_reset(void *opaque) > > > > virtio_set_status(vdev, 0); > > > > + /* We assume all devices are the same endian. */ > > + virtio_byteswap = virtio_get_byteswap(); > > + > > if (k->reset) { > > k->reset(vdev); > > } > > In the previous version it was pointed out that the global is nasty. > > A cleaner solution is a per-VirtIODevice enum device_endian value which > gets passed to lduw_phys_internal()/stl_phys_internal()/etc. > > Now the same code can be used for: > 1. Host == guest-endian > 2. Host != guest-endian > 3. "Everything is little-endian" (VIRTIO 1.0) > > Keeping it per-device means we can have both legacy and VIRTIO 1.0 > devices in a guest. > > That's better than hacking in a global now and having to undo it when > VIRTIO 1.0 support gets merged. > > Stefan > Stefan, I was unsure whether people wanted that global (nasty indeed) to be kicked out of the picture right now or later. Things are clearer now. :) I will come back with something more appropriate. Thanks for your time. Regards. -- Gregory Kurz kurzgreg@fr.ibm.com gkurz@linux.vnet.ibm.com Software Engineer @ IBM/Meiosys http://www.ibm.com Tel +33 (0)562 165 496 "Anarchy is about taking complete responsibility for yourself." Alan Moore.