diff options
author | Cédric Le Goater <clg@fr.ibm.com> | 2014-06-16 11:51:01 +0200 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2014-08-08 19:25:54 +1000 |
commit | 633558ee62202f7ad931732f44df07b5fe6bdd16 (patch) | |
tree | e2981f21a83dbb018e4b0c80abcc882a2191080f | |
parent | fd07bd4b157940c1b5af2c2a0e1bffe36396a482 (diff) | |
download | powerpc-633558ee62202f7ad931732f44df07b5fe6bdd16.tar.gz |
vhost: Add VHOST_VRING_F_BYTESWAP flag
The VHOST_VRING_F_BYTESWAP flag is used by the host to byteswap
data of the vring when the guest and the host have a different
endian order.
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
(cherry picked from commit 28936b89d8e5faa76ef424b2ec356c8ee67c884e)
Signed-off-by: Scott E. Garfinkle <seg@us.ibm.com>
-rw-r--r-- | drivers/vhost/vhost.c | 4 | ||||
-rw-r--r-- | drivers/vhost/vhost.h | 1 | ||||
-rw-r--r-- | include/uapi/linux/vhost.h | 3 |
3 files changed, 7 insertions, 1 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index e1a061e308aee1..c43277ebadd0e7 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -676,7 +676,8 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp) r = -EFAULT; break; } - if (a.flags & ~(0x1 << VHOST_VRING_F_LOG)) { + if (a.flags & ~(0x1 << VHOST_VRING_F_LOG | + 0x1 << VHOST_VRING_F_BYTESWAP)) { r = -EOPNOTSUPP; break; } @@ -722,6 +723,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp) vq->avail = (void __user *)(unsigned long)a.avail_user_addr; vq->log_addr = a.log_guest_addr; vq->used = (void __user *)(unsigned long)a.used_user_addr; + vq->byteswap = !!(a.flags & (0x1 << VHOST_VRING_F_BYTESWAP)); break; case VHOST_SET_VRING_KICK: if (copy_from_user(&f, argp, sizeof f)) { diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 64adcf99ff3389..2e715623cdb068 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -112,6 +112,7 @@ struct vhost_virtqueue { /* Log write descriptors */ void __user *log_base; struct vhost_log *log; + bool byteswap; }; struct vhost_dev { diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index bb6a5b4cb3c558..17854fae1df0bd 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -34,6 +34,9 @@ struct vhost_vring_addr { /* Flag values: */ /* Whether log address is valid. If set enables logging. */ #define VHOST_VRING_F_LOG 0 + /* Whether vring memory accesses should be byte-swapped. + * required when the guest has a different endianess */ +#define VHOST_VRING_F_BYTESWAP 1 /* Start of array of descriptors (virtually contiguous) */ __u64 desc_user_addr; |