* [Qemu-devel] [PATCH 0/2] vhost: support for cross endian
@ 2015-02-20 10:32 Greg Kurz
2015-02-20 10:32 ` [Qemu-devel] [PATCH 1/2] vhost: add VHOST_VRING_F_LEGACY_BIG_ENDIAN flag Greg Kurz
2015-02-20 10:33 ` [Qemu-devel] [PATCH 2/2] vhost_net: re-enable when cross endian Greg Kurz
0 siblings, 2 replies; 3+ messages in thread
From: Greg Kurz @ 2015-02-20 10:32 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Cedric Le Goater, qemu-devel
This patchset allows vhost_net to be used with legacy virtio when guest and
host have different endianness. It depends on the following kernel patchset:
https://lists.linuxfoundation.org/pipermail/virtualization/2015-February/029347.html
---
Cédric Le Goater (1):
vhost_net: re-enable when cross endian
Greg Kurz (1):
vhost: add VHOST_VRING_F_LEGACY_BIG_ENDIAN flag
hw/net/vhost_net.c | 19 -------------------
hw/virtio/vhost.c | 10 +++++++++-
include/hw/virtio/vhost.h | 1 +
linux-headers/linux/vhost.h | 2 ++
4 files changed, 12 insertions(+), 20 deletions(-)
--
Greg
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH 1/2] vhost: add VHOST_VRING_F_LEGACY_BIG_ENDIAN flag
2015-02-20 10:32 [Qemu-devel] [PATCH 0/2] vhost: support for cross endian Greg Kurz
@ 2015-02-20 10:32 ` Greg Kurz
2015-02-20 10:33 ` [Qemu-devel] [PATCH 2/2] vhost_net: re-enable when cross endian Greg Kurz
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kurz @ 2015-02-20 10:32 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Cedric Le Goater, qemu-devel
When the guest and the host have a different endian order, the data
being accessed in the vring queues needs to be byteswapped if we run
in legacy mode.
This patch adds a flag to inform the vhost kernel backend about the
endianness to use.
This patch is based on previous work by Cédric Le Goater.
Cc: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
hw/virtio/vhost.c | 10 +++++++++-
include/hw/virtio/vhost.h | 1 +
| 2 ++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 5a12861..bd442f1 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -539,7 +539,13 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *dev,
.log_guest_addr = vq->used_phys,
.flags = enable_log ? (1 << VHOST_VRING_F_LOG) : 0,
};
- int r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_ADDR, &addr);
+ int r;
+
+ if (vq->legacy_big_endian) {
+ addr.flags |= (1 << VHOST_VRING_F_LEGACY_BIG_ENDIAN);
+ }
+
+ r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_ADDR, &addr);
if (r < 0) {
return -errno;
}
@@ -707,6 +713,8 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
goto fail_alloc_ring;
}
+ vq->legacy_big_endian = virtio_is_big_endian(vdev);
+
r = vhost_virtqueue_set_addr(dev, vq, vhost_vq_index, dev->log_enabled);
if (r < 0) {
r = -errno;
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index d5593d1..991fa20 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -20,6 +20,7 @@ struct vhost_virtqueue {
unsigned long long ring_phys;
unsigned ring_size;
EventNotifier masked_notifier;
+ bool legacy_big_endian; /* Only used with legacy virtio devices */
};
typedef unsigned long vhost_log_chunk_t;
--git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h
index c656f61..ffbb8ee 100644
--- a/linux-headers/linux/vhost.h
+++ b/linux-headers/linux/vhost.h
@@ -34,6 +34,8 @@ struct vhost_vring_addr {
/* Flag values: */
/* Whether log address is valid. If set enables logging. */
#define VHOST_VRING_F_LOG 0
+ /* Whether we have a big-endian legacy virtio device. */
+#define VHOST_VRING_F_LEGACY_BIG_ENDIAN 1
/* Start of array of descriptors (virtually contiguous) */
__u64 desc_user_addr;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH 2/2] vhost_net: re-enable when cross endian
2015-02-20 10:32 [Qemu-devel] [PATCH 0/2] vhost: support for cross endian Greg Kurz
2015-02-20 10:32 ` [Qemu-devel] [PATCH 1/2] vhost: add VHOST_VRING_F_LEGACY_BIG_ENDIAN flag Greg Kurz
@ 2015-02-20 10:33 ` Greg Kurz
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kurz @ 2015-02-20 10:33 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Cedric Le Goater, qemu-devel
From: Cédric Le Goater <clg@fr.ibm.com>
revert 371df9f5e0f1 "vhost-net: disable when cross-endian"
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
hw/net/vhost_net.c | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 4e3a061..721fb2d 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -271,19 +271,6 @@ static void vhost_net_stop_one(struct vhost_net *net,
vhost_dev_disable_notifiers(&net->dev, dev);
}
-static bool vhost_net_device_endian_ok(VirtIODevice *vdev)
-{
-#ifdef TARGET_IS_BIENDIAN
-#ifdef HOST_WORDS_BIGENDIAN
- return virtio_is_big_endian(vdev);
-#else
- return !virtio_is_big_endian(vdev);
-#endif
-#else
- return true;
-#endif
-}
-
int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
int total_queues)
{
@@ -292,12 +279,6 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
int r, e, i;
- if (!vhost_net_device_endian_ok(dev)) {
- error_report("vhost-net does not support cross-endian");
- r = -ENOSYS;
- goto err;
- }
-
if (!k->set_guest_notifiers) {
error_report("binding does not support guest notifiers");
r = -ENOSYS;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-20 10:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-20 10:32 [Qemu-devel] [PATCH 0/2] vhost: support for cross endian Greg Kurz
2015-02-20 10:32 ` [Qemu-devel] [PATCH 1/2] vhost: add VHOST_VRING_F_LEGACY_BIG_ENDIAN flag Greg Kurz
2015-02-20 10:33 ` [Qemu-devel] [PATCH 2/2] vhost_net: re-enable when cross endian Greg Kurz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).