Commit 9a191b11 authored by Dave Airlie's avatar Dave Airlie Committed by Gerd Hoffmann

virtio-gpu: fix ioctl and expose the fixed status to userspace.

This exposes to mesa that it can use the fixed ioctl for querying
later cap sets, cap set 1 is forever frozen in time.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180221015003.22884-1-airlied@gmail.comSigned-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 79d103a5
...@@ -197,6 +197,9 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data, ...@@ -197,6 +197,9 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data,
case VIRTGPU_PARAM_3D_FEATURES: case VIRTGPU_PARAM_3D_FEATURES:
value = vgdev->has_virgl_3d == true ? 1 : 0; value = vgdev->has_virgl_3d == true ? 1 : 0;
break; break;
case VIRTGPU_PARAM_CAPSET_QUERY_FIX:
value = 1;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -472,7 +475,7 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev, ...@@ -472,7 +475,7 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev,
{ {
struct virtio_gpu_device *vgdev = dev->dev_private; struct virtio_gpu_device *vgdev = dev->dev_private;
struct drm_virtgpu_get_caps *args = data; struct drm_virtgpu_get_caps *args = data;
int size; unsigned size, host_caps_size;
int i; int i;
int found_valid = -1; int found_valid = -1;
int ret; int ret;
...@@ -481,6 +484,10 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev, ...@@ -481,6 +484,10 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev,
if (vgdev->num_capsets == 0) if (vgdev->num_capsets == 0)
return -ENOSYS; return -ENOSYS;
/* don't allow userspace to pass 0 */
if (args->size == 0)
return -EINVAL;
spin_lock(&vgdev->display_info_lock); spin_lock(&vgdev->display_info_lock);
for (i = 0; i < vgdev->num_capsets; i++) { for (i = 0; i < vgdev->num_capsets; i++) {
if (vgdev->capsets[i].id == args->cap_set_id) { if (vgdev->capsets[i].id == args->cap_set_id) {
...@@ -496,11 +503,9 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev, ...@@ -496,11 +503,9 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev,
return -EINVAL; return -EINVAL;
} }
size = vgdev->capsets[found_valid].max_size; host_caps_size = vgdev->capsets[found_valid].max_size;
if (args->size > size) { /* only copy to user the minimum of the host caps size or the guest caps size */
spin_unlock(&vgdev->display_info_lock); size = min(args->size, host_caps_size);
return -EINVAL;
}
list_for_each_entry(cache_ent, &vgdev->cap_cache, head) { list_for_each_entry(cache_ent, &vgdev->cap_cache, head) {
if (cache_ent->id == args->cap_set_id && if (cache_ent->id == args->cap_set_id &&
......
...@@ -63,6 +63,7 @@ struct drm_virtgpu_execbuffer { ...@@ -63,6 +63,7 @@ struct drm_virtgpu_execbuffer {
}; };
#define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */ #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */
#define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */
struct drm_virtgpu_getparam { struct drm_virtgpu_getparam {
__u64 param; __u64 param;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment