diff mbox series

[v2,1/2] drm/vmwgfx: add local DRM_AUTH check for PRIME TO/FROM HANDLE

Message ID 20190802170117.10942-1-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/2] drm/vmwgfx: add local DRM_AUTH check for PRIME TO/FROM HANDLE | expand

Commit Message

Emil Velikov Aug. 2, 2019, 5:01 p.m. UTC
From: Emil Velikov <emil.velikov@collabora.com>

Realistically no drivers, but vmwgfx care about the DRM_AUTH flag here.

Follow-up work in this driver will properly isolate primary clients from
different master realms, thus we'll no longer need to parse _any_ ioctl
flags.

Until that work lands, add a local workaround.

v2: Use bitwise or (Deepak)

Cc: VMware Graphics <linux-graphics-maintainer@vmware.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Cc: Deepak Singh Rawat <drawat@vmware.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
I'd like to merge this and the next patch hrough the drm-misc tree. Ack
and rb are appreciated.

Thanks
Emil
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Deepak Singh Rawat Aug. 5, 2019, 3:37 p.m. UTC | #1
Hi Emil,

Thanks for doing this. Looks good to me. By the way I think Thomas had
a patch to get rid of legacy locking mechanism. I don't know when it
will go upstream. With that we no need for the below check.

Reviewed-by: Deepak Rawat <drawat@vmware.com>

On Fri, 2019-08-02 at 18:01 +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov@collabora.com>
> 
> Realistically no drivers, but vmwgfx care about the DRM_AUTH flag
> here.
> 
> Follow-up work in this driver will properly isolate primary clients
> from
> different master realms, thus we'll no longer need to parse _any_
> ioctl
> flags.
> 
> Until that work lands, add a local workaround.
> 
> v2: Use bitwise or (Deepak)
> 
> Cc: VMware Graphics <linux-graphics-maintainer@vmware.com>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> Cc: Deepak Singh Rawat <drawat@vmware.com>
> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
> ---
> I'd like to merge this and the next patch hrough the drm-misc tree.
> Ack
> and rb are appreciated.
> 
> Thanks
> Emil
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index cd0d49d8a8da..53afb1d597e8 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -1134,6 +1134,15 @@ static long vmw_generic_ioctl(struct file
> *filp, unsigned int cmd,
>  	} else if (!drm_ioctl_flags(nr, &flags))
>  		return -EINVAL;
>  
> +	/*
> +	 * Little workaround until the vmwgfx patches providing
> isolation of
> +	 * primary clients from different master realms land.
> +	 * With that work, we'll no longer need to parse _any_ ioctl
> flags.
> +	 */
> +	if (nr == 0x2d /* DRM_IOCTL_PRIME_HANDLE_TO_FD */ ||
> +	    nr == 0x2e /* DRM_IOCTL_PRIME_FD_TO_HANDLE */)
> +		flags |= DRM_AUTH;
> +
>  	vmaster = vmw_master_check(dev, file_priv, flags);
>  	if (IS_ERR(vmaster)) {
>  		ret = PTR_ERR(vmaster);
Emil Velikov Aug. 6, 2019, 9:31 a.m. UTC | #2
On Mon, 5 Aug 2019 at 16:37, Deepak Singh Rawat <drawat@vmware.com> wrote:
>
> Hi Emil,
>
> Thanks for doing this. Looks good to me. By the way I think Thomas had
> a patch to get rid of legacy locking mechanism. I don't know when it
> will go upstream. With that we no need for the below check.
>
Agreed the patches were part of the 5.3-rc1 pull request to Linus.
Sadly the whole vmwgfx branch was reverted [1] :-(

Once that re-lands, we can remove this temporary workaround.

> Reviewed-by: Deepak Rawat <drawat@vmware.com>
>
Great, thank you.

-Emil

[1] https://lists.freedesktop.org/archives/dri-devel/2019-July/226542.html
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index cd0d49d8a8da..53afb1d597e8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1134,6 +1134,15 @@  static long vmw_generic_ioctl(struct file *filp, unsigned int cmd,
 	} else if (!drm_ioctl_flags(nr, &flags))
 		return -EINVAL;
 
+	/*
+	 * Little workaround until the vmwgfx patches providing isolation of
+	 * primary clients from different master realms land.
+	 * With that work, we'll no longer need to parse _any_ ioctl flags.
+	 */
+	if (nr == 0x2d /* DRM_IOCTL_PRIME_HANDLE_TO_FD */ ||
+	    nr == 0x2e /* DRM_IOCTL_PRIME_FD_TO_HANDLE */)
+		flags |= DRM_AUTH;
+
 	vmaster = vmw_master_check(dev, file_priv, flags);
 	if (IS_ERR(vmaster)) {
 		ret = PTR_ERR(vmaster);