From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9Y0W-0003cR-IO for qemu-devel@nongnu.org; Sun, 05 Jun 2016 09:22:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9Y0V-00053p-Cc for qemu-devel@nongnu.org; Sun, 05 Jun 2016 09:22:24 -0400 Date: Sun, 5 Jun 2016 16:22:11 +0300 From: "Michael S. Tsirkin" Message-ID: <1465132825-14242-26-git-send-email-mst@redhat.com> References: <1465132825-14242-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1465132825-14242-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 25/25] virtio: move bi-endian target support to a single location List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Greg Kurz , =?us-ascii?B?PT9VVEYtOD9xP0M9QzM9QTlkcmljPTIwTGU9MjBHb2F0ZXI/PQ==?= , Paolo Bonzini , David Gibson , Alexander Graf , qemu-arm@nongnu.org, qemu-ppc@nongnu.org From: Greg Kurz Paolo's recent cpu.h cleanups broke legacy virtio for ppc64 LE guests (an= d arm BE guests as well, even if I have not verified that). Especially, com= mit "33c11879fd42 qemu-common: push cpu.h inclusion out of qemu-common.h" has the side-effect of silently hiding the TARGET_IS_BIENDIAN macro from the virtio memory accessors, and thus fully disabling support of endian chang= ing targets. To be sure this cannot happen again, let's gather all the bi-endian bits where they belong in include/hw/virtio/virtio-access.h. The changes in hw/virtio/vhost.c are safe because vhost_needs_vring_endia= n() is not called on a hot path and non bi-endian targets will return false anyway. While here, also rename TARGET_IS_BIENDIAN to be more precise: it is only= for legacy virtio and bi-endian guests. Signed-off-by: Greg Kurz Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: C=E9dric Le Goater Reviewed-by: Paolo Bonzini --- include/hw/virtio/virtio-access.h | 6 +++++- target-arm/cpu.h | 2 -- target-ppc/cpu.h | 2 -- hw/virtio/vhost.c | 4 ---- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio= -access.h index 8dc84f5..4b28038 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -17,9 +17,13 @@ #include "hw/virtio/virtio.h" #include "exec/address-spaces.h" =20 +#if defined(TARGET_PPC64) || defined(TARGET_ARM) +#define LEGACY_VIRTIO_IS_BIENDIAN 1 +#endif + static inline bool virtio_access_is_big_endian(VirtIODevice *vdev) { -#if defined(TARGET_IS_BIENDIAN) +#if defined(LEGACY_VIRTIO_IS_BIENDIAN) return virtio_is_big_endian(vdev); #elif defined(TARGET_WORDS_BIGENDIAN) if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { diff --git a/target-arm/cpu.h b/target-arm/cpu.h index c741b53..60971e1 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -29,8 +29,6 @@ # define TARGET_LONG_BITS 32 #endif =20 -#define TARGET_IS_BIENDIAN 1 - #define CPUArchState struct CPUARMState =20 #include "qemu-common.h" diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 98a24a5..db7ee0c 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -28,8 +28,6 @@ #define TARGET_LONG_BITS 64 #define TARGET_PAGE_BITS 12 =20 -#define TARGET_IS_BIENDIAN 1 - /* Note that the official physical address space bits is 62-M where M is implementation dependent. I've not looked up M for the set of cpus we emulate at the system level. */ diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 4400718..81cc5b0 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -767,15 +767,11 @@ static inline bool vhost_needs_vring_endian(VirtIOD= evice *vdev) if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { return false; } -#ifdef TARGET_IS_BIENDIAN #ifdef HOST_WORDS_BIGENDIAN return vdev->device_endian =3D=3D VIRTIO_DEVICE_ENDIAN_LITTLE; #else return vdev->device_endian =3D=3D VIRTIO_DEVICE_ENDIAN_BIG; #endif -#else - return false; -#endif } =20 static int vhost_virtqueue_set_vring_endian_legacy(struct vhost_dev *dev= , --=20 MST