Re: [PATCH net-next] vhost_net: add a missing error return

2018-09-20 Thread Michael S. Tsirkin
On Thu, Sep 20, 2018 at 01:01:59PM +0300, Dan Carpenter wrote:
> We accidentally left out this error return so it leads to some use after
> free bugs later on.
> 
> Fixes: 0a0be13b8fe2 ("vhost_net: batch submitting XDP buffers to underlayer 
> sockets")
> Signed-off-by: Dan Carpenter 

Ouch.

Acked-by: Michael S. Tsirkin 

> 
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index dd4e0a301635..1bff6bc8161a 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -1244,6 +1244,7 @@ static int vhost_net_open(struct inode *inode, struct 
> file *f)
>   kfree(vqs);
>   kvfree(n);
>   kfree(queue);
> + return -ENOMEM;
>   }
>   n->vqs[VHOST_NET_VQ_TX].xdp = xdp;
>  
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [RFC PATCH 2/2] virtio/s390: fix race in ccw_io_helper()

2018-09-20 Thread Cornelia Huck
On Wed, 19 Sep 2018 18:56:45 +0200
Halil Pasic  wrote:

> On 09/19/2018 04:07 PM, Cornelia Huck wrote:

> > Do you spot any other places where we may need to care about concurrent
> > processing (like for the ->config area in the previous patch)?
> >   
> 
> It is hard to tell, because:
> * Synchronization external to the transport could make things work
> out just fine.
> * virtio_config_ops does not document these requirements if any.
> * So it's up to the devices to use the stuff without shooting
>   themselves in the foot.
> * virtio-pci does not seem to do more to avoid such problems that
>   we do.
> 
> Back then when learning vritio-ccw I did ask myself such questions
> and based on vrito-pci and I was like looks similar, should be
> good enough.

Yep, I agree. If there's nothing obvious, I think we should just leave
it as it is now.
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH net-next] vhost_net: add a missing error return

2018-09-20 Thread Dan Carpenter
We accidentally left out this error return so it leads to some use after
free bugs later on.

Fixes: 0a0be13b8fe2 ("vhost_net: batch submitting XDP buffers to underlayer 
sockets")
Signed-off-by: Dan Carpenter 

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index dd4e0a301635..1bff6bc8161a 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -1244,6 +1244,7 @@ static int vhost_net_open(struct inode *inode, struct 
file *f)
kfree(vqs);
kvfree(n);
kfree(queue);
+   return -ENOMEM;
}
n->vqs[VHOST_NET_VQ_TX].xdp = xdp;
 
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [virtio-dev] [PATCH 2/2] drm/virtio: add iommu support.

2018-09-20 Thread Gerd Hoffmann
  Hi,

> void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
> uint32_t resource_id, uint64_t offset,
> ...
>  struct virtio_gpu_fbdev *vgfbdev = vgdev->vgfbdev;
>  struct virtio_gpu_framebuffer *fb = >vgfb;
>  struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(fb->base.obj[0]);

Ah, right.  Should have noticed this on review.  You sync the fbcon
framebuffer unconfitionally ...

> Is there better way to get to the virtio_gpu_object created in the
> virtio_gpu_mode_dumb_create() path from virtio_gpu_device or somehow from 
> drm_file
> via gem_handle down at the layer of virtio_gpu_cmd_transfer_to_host()?

Just pass it down, the call sites all know it (see patch just sent).

cheers,
  Gerd

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] drm/virtio: pass virtio_gpu_object to virtio_gpu_cmd_transfer_to_host_{2d, 3d}

2018-09-20 Thread Gerd Hoffmann
Pass virtio_gpu_object down to virtio_gpu_cmd_transfer_to_host_2d and
virtio_gpu_cmd_transfer_to_host_3d functions, instead of passing just
the virtio resource handle.

This is needed to lookup the scatter list of the object, for dma sync.

Signed-off-by: Gerd Hoffmann 
---
 drivers/gpu/drm/virtio/virtgpu_drv.h   |  6 --
 drivers/gpu/drm/virtio/virtgpu_fb.c|  2 +-
 drivers/gpu/drm/virtio/virtgpu_ioctl.c |  4 ++--
 drivers/gpu/drm/virtio/virtgpu_plane.c |  4 ++--
 drivers/gpu/drm/virtio/virtgpu_vq.c| 20 
 5 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h 
b/drivers/gpu/drm/virtio/virtgpu_drv.h
index a2d79e18bd..253fcf018d 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -270,7 +270,8 @@ void virtio_gpu_cmd_create_resource(struct 
virtio_gpu_device *vgdev,
 void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev,
   uint32_t resource_id);
 void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
-   uint32_t resource_id, uint64_t offset,
+   struct virtio_gpu_object *bo,
+   uint64_t offset,
__le32 width, __le32 height,
__le32 x, __le32 y,
struct virtio_gpu_fence **fence);
@@ -316,7 +317,8 @@ void virtio_gpu_cmd_transfer_from_host_3d(struct 
virtio_gpu_device *vgdev,
  struct virtio_gpu_box *box,
  struct virtio_gpu_fence **fence);
 void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
-   uint32_t resource_id, uint32_t ctx_id,
+   struct virtio_gpu_object *bo,
+   uint32_t ctx_id,
uint64_t offset, uint32_t level,
struct virtio_gpu_box *box,
struct virtio_gpu_fence **fence);
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c 
b/drivers/gpu/drm/virtio/virtgpu_fb.c
index b9678c4082..3364b0970d 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -95,7 +95,7 @@ static int virtio_gpu_dirty_update(struct 
virtio_gpu_framebuffer *fb,
 
offset = (y * fb->base.pitches[0]) + x * bpp;
 
-   virtio_gpu_cmd_transfer_to_host_2d(vgdev, obj->hw_res_handle,
+   virtio_gpu_cmd_transfer_to_host_2d(vgdev, obj,
   offset,
   cpu_to_le32(w),
   cpu_to_le32(h),
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c 
b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index 7bdf6f0e58..f16b875d6a 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -429,11 +429,11 @@ static int virtio_gpu_transfer_to_host_ioctl(struct 
drm_device *dev, void *data,
convert_to_hw_box(, >box);
if (!vgdev->has_virgl_3d) {
virtio_gpu_cmd_transfer_to_host_2d
-   (vgdev, qobj->hw_res_handle, offset,
+   (vgdev, qobj, offset,
 box.w, box.h, box.x, box.y, NULL);
} else {
virtio_gpu_cmd_transfer_to_host_3d
-   (vgdev, qobj->hw_res_handle,
+   (vgdev, qobj,
 vfpriv ? vfpriv->ctx_id : 0, offset,
 args->level, , );
reservation_object_add_excl_fence(qobj->tbo.resv,
diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c 
b/drivers/gpu/drm/virtio/virtgpu_plane.c
index 88f2fb8c61..682a977d68 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -158,7 +158,7 @@ static void virtio_gpu_primary_plane_update(struct 
drm_plane *plane,
handle = bo->hw_res_handle;
if (bo->dumb) {
virtio_gpu_cmd_transfer_to_host_2d
-   (vgdev, handle, 0,
+   (vgdev, bo, 0,
 cpu_to_le32(plane->state->src_w >> 16),
 cpu_to_le32(plane->state->src_h >> 16),
 cpu_to_le32(plane->state->src_x >> 16),
@@ -217,7 +217,7 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane 
*plane,
if (bo && bo->dumb && (plane->state->fb != old_state->fb)) {
/* new cursor -- update & wait */
virtio_gpu_cmd_transfer_to_host_2d
-   (vgdev, handle, 0,
+   (vgdev, bo, 0,