Displaying 20 results from an estimated 250 matches for "vhost16_to_cpu".
2018 May 21
2
[RFC PATCH net-next 10/12] vhost_net: build xdp buff
...oc_frag->page,
> + alloc_frag->offset + sizeof(int), sock_hlen, from);
> + if (copied != sock_hlen)
> + return -EFAULT;
> +
> + gso = (struct virtio_net_hdr *)(buf + sizeof(int));
> +
> + if ((gso->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
> + vhost16_to_cpu(vq, gso->csum_start) +
> + vhost16_to_cpu(vq, gso->csum_offset) + 2 >
> + vhost16_to_cpu(vq, gso->hdr_len)) {
> + gso->hdr_len = cpu_to_vhost16(vq,
> + vhost16_to_cpu(vq, gso->csum_start) +
> + vhost16_to_cpu(vq, gso->csum_offset) + 2);...
2018 May 21
0
[RFC PATCH net-next 10/12] vhost_net: build xdp buff
...+ */
+ copied = copy_page_from_iter(alloc_frag->page,
+ alloc_frag->offset + sizeof(int), sock_hlen, from);
+ if (copied != sock_hlen)
+ return -EFAULT;
+
+ gso = (struct virtio_net_hdr *)(buf + sizeof(int));
+
+ if ((gso->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
+ vhost16_to_cpu(vq, gso->csum_start) +
+ vhost16_to_cpu(vq, gso->csum_offset) + 2 >
+ vhost16_to_cpu(vq, gso->hdr_len)) {
+ gso->hdr_len = cpu_to_vhost16(vq,
+ vhost16_to_cpu(vq, gso->csum_start) +
+ vhost16_to_cpu(vq, gso->csum_offset) + 2);
+
+ if (vhost16_to_cpu(...
2017 Jan 06
2
[PATCH V4 net-next 1/3] vhost: better detection of available buffers
...tqueue *vq)
> __virtio16 avail_idx;
> int r;
>
> + if (vq->avail_idx != vq->last_avail_idx)
> + return false;
> +
> r = vhost_get_user(vq, avail_idx, &vq->avail->idx);
> - if (r)
> + if (unlikely(r))
> return false;
> + vq->avail_idx = vhost16_to_cpu(vq, avail_idx);
>
> - return vhost16_to_cpu(vq, avail_idx) == vq->avail_idx;
> + return vq->avail_idx == vq->last_avail_idx;
> }
> EXPORT_SYMBOL_GPL(vhost_vq_avail_empty);
So again, this did not address the issue I pointed out in v1:
if we have 1 buffer in RX queue and...
2017 Jan 06
2
[PATCH V4 net-next 1/3] vhost: better detection of available buffers
...tqueue *vq)
> __virtio16 avail_idx;
> int r;
>
> + if (vq->avail_idx != vq->last_avail_idx)
> + return false;
> +
> r = vhost_get_user(vq, avail_idx, &vq->avail->idx);
> - if (r)
> + if (unlikely(r))
> return false;
> + vq->avail_idx = vhost16_to_cpu(vq, avail_idx);
>
> - return vhost16_to_cpu(vq, avail_idx) == vq->avail_idx;
> + return vq->avail_idx == vq->last_avail_idx;
> }
> EXPORT_SYMBOL_GPL(vhost_vq_avail_empty);
So again, this did not address the issue I pointed out in v1:
if we have 1 buffer in RX queue and...
2015 Feb 20
0
[PATCH 3/3] vhost_net: fix virtio_net header endianness
...ost/net.c
+++ b/drivers/vhost/net.c
@@ -288,6 +288,16 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success)
rcu_read_unlock_bh();
}
+static void fix_virtio_net_hdr(struct vhost_virtqueue *vq)
+{
+ struct virtio_net_hdr *hdr = vq->iov[0].iov_base;
+
+ hdr->hdr_len = vhost16_to_cpu(vq, hdr->hdr_len);
+ hdr->gso_size = vhost16_to_cpu(vq, hdr->gso_size);
+ hdr->csum_start = vhost16_to_cpu(vq, hdr->csum_start);
+ hdr->csum_offset = vhost16_to_cpu(vq, hdr->csum_offset);
+}
+
/* Expects to be always run from workqueue - which acts as
* read-size critical s...
2015 Feb 20
0
[PATCH 3/3] vhost_net: fix virtio_net header endianness
...ost/net.c
+++ b/drivers/vhost/net.c
@@ -288,6 +288,16 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success)
rcu_read_unlock_bh();
}
+static void fix_virtio_net_hdr(struct vhost_virtqueue *vq)
+{
+ struct virtio_net_hdr *hdr = vq->iov[0].iov_base;
+
+ hdr->hdr_len = vhost16_to_cpu(vq, hdr->hdr_len);
+ hdr->gso_size = vhost16_to_cpu(vq, hdr->gso_size);
+ hdr->csum_start = vhost16_to_cpu(vq, hdr->csum_start);
+ hdr->csum_offset = vhost16_to_cpu(vq, hdr->csum_offset);
+}
+
/* Expects to be always run from workqueue - which acts as
* read-size critical s...
2014 Nov 24
2
[PATCH v3 26/41] vhost: virtio 1.0 endian-ness support
...ed_used_valid = false;
- return get_user(vq->last_used_idx, &vq->used->idx);
+ if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx))
+ return -EFAULT;
+ r = __get_user(last_used_idx, &vq->used->idx);
+ if (r)
+ return r;
+ vq->last_used_idx = vhost16_to_cpu(vq, last_used_idx);
+ return 0;
}
EXPORT_SYMBOL_GPL(vhost_init_used);
@@ -1087,16 +1094,16 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len,
/* Each buffer in the virtqueues is actually a chain of descriptors. This
* function returns the next descriptor in the chai...
2014 Nov 24
2
[PATCH v3 26/41] vhost: virtio 1.0 endian-ness support
...ed_used_valid = false;
- return get_user(vq->last_used_idx, &vq->used->idx);
+ if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx))
+ return -EFAULT;
+ r = __get_user(last_used_idx, &vq->used->idx);
+ if (r)
+ return r;
+ vq->last_used_idx = vhost16_to_cpu(vq, last_used_idx);
+ return 0;
}
EXPORT_SYMBOL_GPL(vhost_init_used);
@@ -1087,16 +1094,16 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len,
/* Each buffer in the virtqueues is actually a chain of descriptors. This
* function returns the next descriptor in the chai...
2018 Sep 06
2
[PATCH net-next 11/11] vhost_net: batch submitting XDP buffers to underlayer sockets
...e,
> + alloc_frag->offset + sizeof(int),
> + sock_hlen, from);
> + if (copied != sock_hlen)
> + return -EFAULT;
> +
> + gso = (struct virtio_net_hdr *)(buf + sizeof(int));
> +
> + if ((gso->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
> + vhost16_to_cpu(vq, gso->csum_start) +
> + vhost16_to_cpu(vq, gso->csum_offset) + 2 >
> + vhost16_to_cpu(vq, gso->hdr_len)) {
> + gso->hdr_len = cpu_to_vhost16(vq,
> + vhost16_to_cpu(vq, gso->csum_start) +
> + vhost16_to_cpu(vq, gso->csum_offset) + 2);...
2018 Sep 06
2
[PATCH net-next 11/11] vhost_net: batch submitting XDP buffers to underlayer sockets
...e,
> + alloc_frag->offset + sizeof(int),
> + sock_hlen, from);
> + if (copied != sock_hlen)
> + return -EFAULT;
> +
> + gso = (struct virtio_net_hdr *)(buf + sizeof(int));
> +
> + if ((gso->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
> + vhost16_to_cpu(vq, gso->csum_start) +
> + vhost16_to_cpu(vq, gso->csum_offset) + 2 >
> + vhost16_to_cpu(vq, gso->hdr_len)) {
> + gso->hdr_len = cpu_to_vhost16(vq,
> + vhost16_to_cpu(vq, gso->csum_start) +
> + vhost16_to_cpu(vq, gso->csum_offset) + 2);...
2017 Jan 09
2
[PATCH V4 net-next 1/3] vhost: better detection of available buffers
...(vq->avail_idx != vq->last_avail_idx)
> > > + return false;
> > > +
> > > r = vhost_get_user(vq, avail_idx, &vq->avail->idx);
> > > - if (r)
> > > + if (unlikely(r))
> > > return false;
> > > + vq->avail_idx = vhost16_to_cpu(vq, avail_idx);
> > > - return vhost16_to_cpu(vq, avail_idx) == vq->avail_idx;
> > > + return vq->avail_idx == vq->last_avail_idx;
> > > }
> > > EXPORT_SYMBOL_GPL(vhost_vq_avail_empty);
> > So again, this did not address the issue I pointed out...
2017 Jan 09
2
[PATCH V4 net-next 1/3] vhost: better detection of available buffers
...(vq->avail_idx != vq->last_avail_idx)
> > > + return false;
> > > +
> > > r = vhost_get_user(vq, avail_idx, &vq->avail->idx);
> > > - if (r)
> > > + if (unlikely(r))
> > > return false;
> > > + vq->avail_idx = vhost16_to_cpu(vq, avail_idx);
> > > - return vhost16_to_cpu(vq, avail_idx) == vq->avail_idx;
> > > + return vq->avail_idx == vq->last_avail_idx;
> > > }
> > > EXPORT_SYMBOL_GPL(vhost_vq_avail_empty);
> > So again, this did not address the issue I pointed out...
2015 Feb 20
8
[PATCH 0/3] vhost_net: support for cross endian guests
Hi,
This patchset allows vhost_net to be used with legacy virtio
when guest and host have a different endianness. It is based
on previous work by C?dric Le Goater:
https://www.mail-archive.com/kvm-ppc at vger.kernel.org/msg09848.html
As suggested by MST:
- the API now asks for a specific format (big endian) instead of the hint
whether byteswap is needed or not (patch 1)
- rebased on top of
2015 Feb 20
8
[PATCH 0/3] vhost_net: support for cross endian guests
Hi,
This patchset allows vhost_net to be used with legacy virtio
when guest and host have a different endianness. It is based
on previous work by C?dric Le Goater:
https://www.mail-archive.com/kvm-ppc at vger.kernel.org/msg09848.html
As suggested by MST:
- the API now asks for a specific format (big endian) instead of the hint
whether byteswap is needed or not (patch 1)
- rebased on top of
2017 Dec 01
2
[PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
...st/vhost.c
index 33ac2b186b85..78b5940a415a 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1877,12 +1877,7 @@ static unsigned next_desc(struct vhost_virtqueue *vq, struct vring_desc *desc)
return -1U;
/* Check they're not leading us off end of descriptors. */
- next = vhost16_to_cpu(vq, desc->next);
- /* Make sure compiler knows to grab that: we don't want it changing! */
- /* We will use the result as an index in an array, so most
- * architectures only need a compiler barrier here. */
- read_barrier_depends();
-
+ next = vhost16_to_cpu(vq, READ_ONCE(desc->next));...
2017 Dec 01
2
[PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
...st/vhost.c
index 33ac2b186b85..78b5940a415a 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1877,12 +1877,7 @@ static unsigned next_desc(struct vhost_virtqueue *vq, struct vring_desc *desc)
return -1U;
/* Check they're not leading us off end of descriptors. */
- next = vhost16_to_cpu(vq, desc->next);
- /* Make sure compiler knows to grab that: we don't want it changing! */
- /* We will use the result as an index in an array, so most
- * architectures only need a compiler barrier here. */
- read_barrier_depends();
-
+ next = vhost16_to_cpu(vq, READ_ONCE(desc->next));...
2018 Sep 06
0
[PATCH net-next 11/11] vhost_net: batch submitting XDP buffers to underlayer sockets
...pied = copy_page_from_iter(alloc_frag->page,
+ alloc_frag->offset + sizeof(int),
+ sock_hlen, from);
+ if (copied != sock_hlen)
+ return -EFAULT;
+
+ gso = (struct virtio_net_hdr *)(buf + sizeof(int));
+
+ if ((gso->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
+ vhost16_to_cpu(vq, gso->csum_start) +
+ vhost16_to_cpu(vq, gso->csum_offset) + 2 >
+ vhost16_to_cpu(vq, gso->hdr_len)) {
+ gso->hdr_len = cpu_to_vhost16(vq,
+ vhost16_to_cpu(vq, gso->csum_start) +
+ vhost16_to_cpu(vq, gso->csum_offset) + 2);
+
+ if (vhost16_to_cpu(...
2014 Nov 30
3
[PATCH v7 31/46] vhost: virtio 1.0 endian-ness support
...ed_used_valid = false;
- return get_user(vq->last_used_idx, &vq->used->idx);
+ if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx))
+ return -EFAULT;
+ r = __get_user(last_used_idx, &vq->used->idx);
+ if (r)
+ return r;
+ vq->last_used_idx = vhost16_to_cpu(vq, last_used_idx);
+ return 0;
}
EXPORT_SYMBOL_GPL(vhost_init_used);
@@ -1087,16 +1094,16 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len,
/* Each buffer in the virtqueues is actually a chain of descriptors. This
* function returns the next descriptor in the chai...
2014 Nov 30
3
[PATCH v7 31/46] vhost: virtio 1.0 endian-ness support
...ed_used_valid = false;
- return get_user(vq->last_used_idx, &vq->used->idx);
+ if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx))
+ return -EFAULT;
+ r = __get_user(last_used_idx, &vq->used->idx);
+ if (r)
+ return r;
+ vq->last_used_idx = vhost16_to_cpu(vq, last_used_idx);
+ return 0;
}
EXPORT_SYMBOL_GPL(vhost_init_used);
@@ -1087,16 +1094,16 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len,
/* Each buffer in the virtqueues is actually a chain of descriptors. This
* function returns the next descriptor in the chai...
2018 Sep 12
0
[PATCH net-next V2 11/11] vhost_net: batch submitting XDP buffers to underlayer sockets
...from_iter(alloc_frag->page,
+ alloc_frag->offset +
+ offsetof(struct tun_xdp_hdr, gso),
+ sock_hlen, from);
+ if (copied != sock_hlen)
+ return -EFAULT;
+
+ hdr = buf;
+ gso = &hdr->gso;
+
+ if ((gso->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
+ vhost16_to_cpu(vq, gso->csum_start) +
+ vhost16_to_cpu(vq, gso->csum_offset) + 2 >
+ vhost16_to_cpu(vq, gso->hdr_len)) {
+ gso->hdr_len = cpu_to_vhost16(vq,
+ vhost16_to_cpu(vq, gso->csum_start) +
+ vhost16_to_cpu(vq, gso->csum_offset) + 2);
+
+ if (vhost16_to_cpu(...