提交 c02d7030 编写于 作者: G Greg Kurz 提交者: Michael S. Tsirkin

virtio: move bi-endian target support to a single location

Paolo's recent cpu.h cleanups broke legacy virtio for ppc64 LE guests (and
arm BE guests as well, even if I have not verified that). Especially, commit
"33c11879 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 changing
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_endian()
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: NGreg Kurz <gkurz@linux.vnet.ibm.com>
Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Acked-by: NCédric Le Goater <clg@kaod.org>
Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 9f318f8f
...@@ -767,15 +767,11 @@ static inline bool vhost_needs_vring_endian(VirtIODevice *vdev) ...@@ -767,15 +767,11 @@ static inline bool vhost_needs_vring_endian(VirtIODevice *vdev)
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
return false; return false;
} }
#ifdef TARGET_IS_BIENDIAN
#ifdef HOST_WORDS_BIGENDIAN #ifdef HOST_WORDS_BIGENDIAN
return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_LITTLE; return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_LITTLE;
#else #else
return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG; return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG;
#endif #endif
#else
return false;
#endif
} }
static int vhost_virtqueue_set_vring_endian_legacy(struct vhost_dev *dev, static int vhost_virtqueue_set_vring_endian_legacy(struct vhost_dev *dev,
......
...@@ -17,9 +17,13 @@ ...@@ -17,9 +17,13 @@
#include "hw/virtio/virtio.h" #include "hw/virtio/virtio.h"
#include "exec/address-spaces.h" #include "exec/address-spaces.h"
#if defined(TARGET_PPC64) || defined(TARGET_ARM)
#define LEGACY_VIRTIO_IS_BIENDIAN 1
#endif
static inline bool virtio_access_is_big_endian(VirtIODevice *vdev) 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); return virtio_is_big_endian(vdev);
#elif defined(TARGET_WORDS_BIGENDIAN) #elif defined(TARGET_WORDS_BIGENDIAN)
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
......
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
# define TARGET_LONG_BITS 32 # define TARGET_LONG_BITS 32
#endif #endif
#define TARGET_IS_BIENDIAN 1
#define CPUArchState struct CPUARMState #define CPUArchState struct CPUARMState
#include "qemu-common.h" #include "qemu-common.h"
......
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
#define TARGET_LONG_BITS 64 #define TARGET_LONG_BITS 64
#define TARGET_PAGE_BITS 12 #define TARGET_PAGE_BITS 12
#define TARGET_IS_BIENDIAN 1
/* Note that the official physical address space bits is 62-M where M /* 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 is implementation dependent. I've not looked up M for the set of
cpus we emulate at the system level. */ cpus we emulate at the system level. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册