diff mbox

[04/35] drm: Forbid legacy MAP functions for DRIVER_MODESET

Message ID 1461691808-12414-5-git-send-email-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter April 26, 2016, 5:29 p.m. UTC
Like in

commit 0e975980d435d58df2d430d688b8c18778b42218
Author: Peter Antoine <peter.antoine@intel.com>
Date:   Tue Jun 23 08:18:49 2015 +0100

    drm: Turn off Legacy Context Functions

we need to again make an exception for nouveau, but everyone else
really doesn't need this.

Cc: Peter Antoine <peter.antoine@intel.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_bufs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Chris Wilson April 26, 2016, 9:23 p.m. UTC | #1
On Tue, Apr 26, 2016 at 07:29:37PM +0200, Daniel Vetter wrote:
> Like in
> 
> commit 0e975980d435d58df2d430d688b8c18778b42218
> Author: Peter Antoine <peter.antoine@intel.com>
> Date:   Tue Jun 23 08:18:49 2015 +0100
> 
>     drm: Turn off Legacy Context Functions
> 
> we need to again make an exception for nouveau, but everyone else
> really doesn't need this.
> 
> Cc: Peter Antoine <peter.antoine@intel.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

* mutters something about MODESET && !MODESET_LEGACY reading better.

Looks consistent, not going to comment on LEGACY though. There are no
direct users of the the addmap interface, so just whatever comes in
through an ioctl.
-Chris
Alex Deucher April 26, 2016, 9:35 p.m. UTC | #2
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Like in
>
> commit 0e975980d435d58df2d430d688b8c18778b42218
> Author: Peter Antoine <peter.antoine@intel.com>
> Date:   Tue Jun 23 08:18:49 2015 +0100
>
>     drm: Turn off Legacy Context Functions
>
> we need to again make an exception for nouveau, but everyone else
> really doesn't need this.
>
> Cc: Peter Antoine <peter.antoine@intel.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Not really familiar with why nouveau needs this, but the logic seems correct.
Acked-by: Alex Deucher <alexander.deucher@amd.com>


> ---
>  drivers/gpu/drm/drm_bufs.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index d92db7007f62..e8a12a4fd400 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -396,6 +396,10 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
>         if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
>                 return -EPERM;
>
> +       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> +           drm_core_check_feature(dev, DRIVER_MODESET))
> +               return -EINVAL;
> +
>         err = drm_addmap_core(dev, map->offset, map->size, map->type,
>                               map->flags, &maplist);
>
> @@ -438,6 +442,10 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
>         int idx;
>         int i;
>
> +       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> +           drm_core_check_feature(dev, DRIVER_MODESET))
> +               return -EINVAL;
> +
>         idx = map->offset;
>         if (idx < 0)
>                 return -EINVAL;
> @@ -569,6 +577,10 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
>         struct drm_map_list *r_list;
>         int ret;
>
> +       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> +           drm_core_check_feature(dev, DRIVER_MODESET))
> +               return -EINVAL;
> +
>         mutex_lock(&dev->struct_mutex);
>         list_for_each_entry(r_list, &dev->maplist, head) {
>                 if (r_list->map &&
> --
> 2.8.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter April 27, 2016, 6:46 a.m. UTC | #3
On Tue, Apr 26, 2016 at 05:35:42PM -0400, Alex Deucher wrote:
> On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> > Like in
> >
> > commit 0e975980d435d58df2d430d688b8c18778b42218
> > Author: Peter Antoine <peter.antoine@intel.com>
> > Date:   Tue Jun 23 08:18:49 2015 +0100
> >
> >     drm: Turn off Legacy Context Functions
> >
> > we need to again make an exception for nouveau, but everyone else
> > really doesn't need this.
> >
> > Cc: Peter Antoine <peter.antoine@intel.com>
> > Cc: Ben Skeggs <bskeggs@redhat.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> 
> Not really familiar with why nouveau needs this, but the logic seems correct.

Hm, I thought the referenced commit explained this, but now that I recheck
it doesn't. I'm not too sure again myself why I thought nouveau needs
this. The legacy ctx stuff is required because of some old kms nouveau ddx
that still used that stuff. I thought it also used legacy maps ... I'll
double check once more.
-Daniel

> Acked-by: Alex Deucher <alexander.deucher@amd.com>
> 
> 
> > ---
> >  drivers/gpu/drm/drm_bufs.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> > index d92db7007f62..e8a12a4fd400 100644
> > --- a/drivers/gpu/drm/drm_bufs.c
> > +++ b/drivers/gpu/drm/drm_bufs.c
> > @@ -396,6 +396,10 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
> >         if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
> >                 return -EPERM;
> >
> > +       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > +           drm_core_check_feature(dev, DRIVER_MODESET))
> > +               return -EINVAL;
> > +
> >         err = drm_addmap_core(dev, map->offset, map->size, map->type,
> >                               map->flags, &maplist);
> >
> > @@ -438,6 +442,10 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
> >         int idx;
> >         int i;
> >
> > +       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > +           drm_core_check_feature(dev, DRIVER_MODESET))
> > +               return -EINVAL;
> > +
> >         idx = map->offset;
> >         if (idx < 0)
> >                 return -EINVAL;
> > @@ -569,6 +577,10 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
> >         struct drm_map_list *r_list;
> >         int ret;
> >
> > +       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > +           drm_core_check_feature(dev, DRIVER_MODESET))
> > +               return -EINVAL;
> > +
> >         mutex_lock(&dev->struct_mutex);
> >         list_for_each_entry(r_list, &dev->maplist, head) {
> >                 if (r_list->map &&
> > --
> > 2.8.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter April 27, 2016, 6:56 a.m. UTC | #4
On Wed, Apr 27, 2016 at 08:46:31AM +0200, Daniel Vetter wrote:
> On Tue, Apr 26, 2016 at 05:35:42PM -0400, Alex Deucher wrote:
> > On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> > > Like in
> > >
> > > commit 0e975980d435d58df2d430d688b8c18778b42218
> > > Author: Peter Antoine <peter.antoine@intel.com>
> > > Date:   Tue Jun 23 08:18:49 2015 +0100
> > >
> > >     drm: Turn off Legacy Context Functions
> > >
> > > we need to again make an exception for nouveau, but everyone else
> > > really doesn't need this.
> > >
> > > Cc: Peter Antoine <peter.antoine@intel.com>
> > > Cc: Ben Skeggs <bskeggs@redhat.com>
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > 
> > Not really familiar with why nouveau needs this, but the logic seems correct.
> 
> Hm, I thought the referenced commit explained this, but now that I recheck
> it doesn't. I'm not too sure again myself why I thought nouveau needs
> this. The legacy ctx stuff is required because of some old kms nouveau ddx
> that still used that stuff. I thought it also used legacy maps ... I'll
> double check once more.

Ok, nouveau ddx indeed used legacy addmap and friends, but that code is
nuked since 2006. That's 10 years, which is the rule of thumb for when we
can drop support. I'll respin this patch.
-Daniel
Dave Airlie April 27, 2016, 7:12 a.m. UTC | #5
>> Hm, I thought the referenced commit explained this, but now that I recheck
>> it doesn't. I'm not too sure again myself why I thought nouveau needs
>> this. The legacy ctx stuff is required because of some old kms nouveau ddx
>> that still used that stuff. I thought it also used legacy maps ... I'll
>> double check once more.
>
> Ok, nouveau ddx indeed used legacy addmap and friends, but that code is
> nuked since 2006. That's 10 years, which is the rule of thumb for when we
> can drop support. I'll respin this patch.
> -Daniel

Nope,

commit b1a630b48210d6a3c44994fce1b73273000ace5c
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed Nov 7 14:45:14 2012 +1000

    nouveau: drop DRI1 device open interface.

Was when it was fixed.

Dave.
Daniel Vetter April 27, 2016, 7:55 a.m. UTC | #6
On Wed, Apr 27, 2016 at 05:12:22PM +1000, Dave Airlie wrote:
> >> Hm, I thought the referenced commit explained this, but now that I recheck
> >> it doesn't. I'm not too sure again myself why I thought nouveau needs
> >> this. The legacy ctx stuff is required because of some old kms nouveau ddx
> >> that still used that stuff. I thought it also used legacy maps ... I'll
> >> double check once more.
> >
> > Ok, nouveau ddx indeed used legacy addmap and friends, but that code is
> > nuked since 2006. That's 10 years, which is the rule of thumb for when we
> > can drop support. I'll respin this patch.
> > -Daniel
> 
> Nope,
> 
> commit b1a630b48210d6a3c44994fce1b73273000ace5c
> Author: Dave Airlie <airlied@redhat.com>
> Date:   Wed Nov 7 14:45:14 2012 +1000
> 
>     nouveau: drop DRI1 device open interface.
> 
> Was when it was fixed.

Oh right now I remember, the fun was in the X server, not in the DDX. I'll
amend the original commit message and merge.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index d92db7007f62..e8a12a4fd400 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -396,6 +396,10 @@  int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
 	if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
 		return -EPERM;
 
+	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
+	    drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	err = drm_addmap_core(dev, map->offset, map->size, map->type,
 			      map->flags, &maplist);
 
@@ -438,6 +442,10 @@  int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
 	int idx;
 	int i;
 
+	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
+	    drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	idx = map->offset;
 	if (idx < 0)
 		return -EINVAL;
@@ -569,6 +577,10 @@  int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
 	struct drm_map_list *r_list;
 	int ret;
 
+	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
+	    drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	mutex_lock(&dev->struct_mutex);
 	list_for_each_entry(r_list, &dev->maplist, head) {
 		if (r_list->map &&