dataplane vs. endianness
v2 cover dataplane vs. endianness
Stefan:
Here's v2 of my endianness patch for dataplane, with the extraneous vdev argument dropped from get_desc().
I orginally planned to send my virtio-1 patchset as well, but I haven't found the time for it; therefore, I think this should be applied independently.
David: I take it your r-b still holds?
Cornelia Huck (1):
dataplane: endianness-aware accesses
hw/block/dataplane/virtio-blk.c | 4 +- hw/scsi/virtio-scsi-dataplane.c | 2 +- hw/virtio/Makefile.objs | 2 +- hw/virtio/dataplane/Makefile.objs | 2 +- hw/virtio/dataplane/vring.c | 53 ++++++++++++------- include/hw/virtio/dataplane/vring-accessors.h | 75 +++++++++++++++++++++++++++ include/hw/virtio/dataplane/vring.h | 14 +---- 7 files changed, 117 insertions(+), 35 deletions(-) create mode 100644 include/hw/virtio/dataplane/vring-accessors.h
Signature · 1 line
2.1.4
PATCH v2 1/1 dataplane: endianness-aware accesses
The vring.c code currently assumes that guest and host endianness match, which is not true for a number of cases:
- emulating targets with a different endianness than the host
- bi-endian targets, where the correct endianness depends on the virtio device
- upcoming support for the virtio-1 standard mandates little-endian accesses even for big-endian targets and hosts
Make sure to use accessors that depend on the virtio device.
Note that dataplane now needs to be built per-target.
--- hw/block/dataplane/virtio-blk.c | 4 +- hw/scsi/virtio-scsi-dataplane.c | 2 +- hw/virtio/Makefile.objs | 2 +- hw/virtio/dataplane/Makefile.objs | 2 +- hw/virtio/dataplane/vring.c | 53 ++++++++++++------- include/hw/virtio/dataplane/vring-accessors.h | 75 +++++++++++++++++++++++++++ include/hw/virtio/dataplane/vring.h | 14 +---- 7 files changed, 117 insertions(+), 35 deletions(-) create mode 100644 include/hw/virtio/dataplane/vring-accessors.h
hw/block/dataplane/virtio-blk.c +3 -1
@@ -16,7 +16,9 @@#include "qemu/iov.h" #include "qemu/thread.h" #include "qemu/error-report.h" +#include "hw/virtio/virtio-access.h" #include "hw/virtio/dataplane/vring.h" +#include "hw/virtio/dataplane/vring-accessors.h" #include "sysemu/block-backend.h" #include "hw/virtio/virtio-blk.h" #include "virtio-blk.h"
@@ -75,7 +77,7 @@ static void complete_request_vring(VirtIOBlockReq *req, unsigned char status)VirtIOBlockDataPlane *s = req->dev->dataplane;stb_p (&req->in->status, status); -vring_push (&req->dev->dataplane->vring, &req->elem, +vring_push (s->vdev, &req->dev->dataplane->vring, &req->elem, req->qiov.size +sizeof (*req->in));/* Suppress notification to guest by BH and its scheduled
hw/scsi/virtio-scsi-dataplane.c +1 -1
@@ -94,7 +94,7 @@ void virtio_scsi_vring_push_notify(VirtIOSCSIReq *req) {VirtIODevice *vdev =VIRTIO_DEVICE (req->vring->parent); -vring_push (&req->vring->vring, &req->elem, +vring_push (vdev, &req->vring->vring, &req->elem, req->qsgl.size + req->resp_iov.size);if (vring_should_notify (vdev, &req->vring->vring)) {
hw/virtio/Makefile.objs +1 -1
@@ -2,7 +2,7 @@ common-obj-y += virtio-rng.o common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o common-obj-y += virtio-bus.o common-obj-y += virtio-mmio.o -common-obj-$(CONFIG_VIRTIO) += dataplane/ +obj-$(CONFIG_VIRTIO) += dataplane/ obj-y += virtio.o virtio-balloon.o obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o
hw/virtio/dataplane/Makefile.objs +1 -1
@@ -1 +1 @@ -common-obj-y += vring.o +obj-y += vring.o
hw/virtio/dataplane/vring.c +34 -19
143 lines not on this page · raw message
include/hw/virtio/dataplane/vring-accessors.h new file +75 -0
75 lines not on this page · raw message
include/hw/virtio/dataplane/vring.h +2 -12
@@ -31,17 +31,6 @@ typedef struct {bool broken;/* was there a fatal error? */ } Vring; -static inline unsigned int vring_get_num (Vring *vring) -{ -return vring->vr.num; -} - -/* Are there more descriptors available? */ -static inline bool vring_more_avail (Vring *vring) -{ -return vring->vr.avail->idx != vring->last_avail_idx; -} -/* Fail future vring_pop() and vring_push() calls until reset */ static inline void vring_set_broken (Vring *vring) {
@@ -54,6 +43,7 @@ void vring_disable_notification(VirtIODevice *vdev, Vring *vring);bool vring_enable_notification (VirtIODevice *vdev,Vring *vring);bool vring_should_notify (VirtIODevice *vdev,Vring *vring);int vring_pop (VirtIODevice *vdev,Vring *vring,VirtQueueElement *elem); -void vring_push (Vring *vring,VirtQueueElement *elem,int len); +void vring_push (VirtIODevice *vdev,Vring *vring,VirtQueueElement *elem, +int len);#endif /* VRING_H */
Signature · 1 line
2.1.4
Quoted 10 lines · Cornelia Huck
Stefan:
Here's v2 of my endianness patch for dataplane, with the extraneous vdev argument dropped from
get_desc().I orginally planned to send my virtio-1 patchset as well, but I haven't found the time for it; therefore, I think this should be applied independently.
David: I take it your r-b still holds?
Yes. I also retested this version and it still works fine.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 10 lines · David Gibson
Quoted 9 lines · Cornelia Huck
Stefan:
Here's v2 of my endianness patch for dataplane, with the extraneous vdev argument dropped from
get_desc().I orginally planned to send my virtio-1 patchset as well, but I haven't found the time for it; therefore, I think this should be applied independently.
Quoted 5 lines
Quoted 1 line
David: I take it your r-b still holds?
Yes. I also retested this version and it still works fine.
Tested-by David Gibson <[email protected]>
Any word on getting this merged?
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 14 lines · Cornelia Huck
Stefan:
Here's v2 of my endianness patch for dataplane, with the extraneous vdev argument dropped from
get_desc().I orginally planned to send my virtio-1 patchset as well, but I haven't found the time for it; therefore, I think this should be applied independently.
David: I take it your r-b still holds?
Cornelia Huck (1):
dataplane: endianness-aware accesses
Quoted 9 lines
hw/block/dataplane/virtio-blk.c | 4 +- hw/scsi/virtio-scsi-dataplane.c | 2 +- hw/virtio/Makefile.objs | 2 +- hw/virtio/dataplane/Makefile.objs | 2 +- hw/virtio/dataplane/vring.c | 53 ++++++++++++------- include/hw/virtio/dataplane/vring-accessors.h | 75 +++++++++++++++++++++++++++ include/hw/virtio/dataplane/vring.h | 14 +---- 7 files changed, 117 insertions(+), 35 deletions(-) create mode 100644 include/hw/virtio/dataplane/vring-accessors.h
I will merge this into the block tree for the Friday, 13th of February pull request.
Stefan Hajnoczi
AppliedQuoted 14 lines · Cornelia Huck
Stefan:
Here's v2 of my endianness patch for dataplane, with the extraneous vdev argument dropped from
get_desc().I orginally planned to send my virtio-1 patchset as well, but I haven't found the time for it; therefore, I think this should be applied independently.
David: I take it your r-b still holds?
Cornelia Huck (1):
dataplane: endianness-aware accesses
Quoted 14 lines
hw/block/dataplane/virtio-blk.c | 4 +- hw/scsi/virtio-scsi-dataplane.c | 2 +- hw/virtio/Makefile.objs | 2 +- hw/virtio/dataplane/Makefile.objs | 2 +- hw/virtio/dataplane/vring.c | 53 ++++++++++++------- include/hw/virtio/dataplane/vring-accessors.h | 75 +++++++++++++++++++++++++++ include/hw/virtio/dataplane/vring.h | 14 +---- 7 files changed, 117 insertions(+), 35 deletions(-) create mode 100644 include/hw/virtio/dataplane/vring-accessors.hSignature · 1 line
2.1.4
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan