RFC: drm: Restrict vblank ioctl to master
Subsystems (2)
PATCH 1/3 RFC: drm: Restrict vblank ioctl to master
Somehow this escaped us, this is a KMS ioctl which should only be used by the master (which is the thing that's also in control of kms resources). Everything else is bound to result in fail.
Clients shouldn't have a trouble coping with this, since a pile of drivers don't support vblank waits (or just randomly fall over when using them). Note that the big motivation for abusing this like mad seems to be that EGL doesn't have OML_sync, but somehow it didn't cross anyone's mind that adding OML_sync to EGL would be useful. This patch is meant to essentially start kicking that can from the back end.
--- drivers/gpu/drm/drm_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_ioctl.c +2 -2
@@ -529,9 +529,9 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_SG_ALLOC , drm_legacy_sg_alloc,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_IOCTL_SG_FREE , drm_legacy_sg_free,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ), -DRM_IOCTL_DEF (DRM_IOCTL_WAIT_VBLANK , drm_wait_vblank,DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_WAIT_VBLANK , drm_wait_vblank,DRM_MASTER |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODESET_CTL , drm_modeset_ctl,0 ), +DRM_IOCTL_DEF (DRM_IOCTL_MODESET_CTL , drm_modeset_ctl,DRM_MASTER ), DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
Signature · 6 lines
2.8.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/3 drm: Mark authmagic ioctls as unlocked
All protected by dev->master_mutex. And there's no driver callbacks, which means no need to sync with old dri1 horror show drivers at all. Hence safe to drop the drm legacy BKL from these paths.
--- drivers/gpu/drm/drm_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_ioctl.c +2 -2
@@ -467,7 +467,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_VERSION , drm_version,DRM_UNLOCKED |DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW ),DRM_IOCTL_DEF (DRM_IOCTL_GET_UNIQUE , drm_getunique,0 ), -DRM_IOCTL_DEF (DRM_IOCTL_GET_MAGIC , drm_getmagic,0 ), +DRM_IOCTL_DEF (DRM_IOCTL_GET_MAGIC , drm_getmagic,DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_IRQ_BUSID , drm_irq_by_busid,DRM_MASTER |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_IOCTL_GET_MAP , drm_legacy_getmap_ioctl,DRM_UNLOCKED ), DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DRM_UNLOCKED),
@@ -479,7 +479,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_SET_UNIQUE , drm_invalid_op,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_IOCTL_BLOCK , drm_noop,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_IOCTL_UNBLOCK , drm_noop,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ), -DRM_IOCTL_DEF (DRM_IOCTL_AUTH_MAGIC , drm_authmagic,DRM_AUTH |DRM_MASTER ), +DRM_IOCTL_DEF (DRM_IOCTL_AUTH_MAGIC , drm_authmagic,DRM_AUTH |DRM_UNLOCKED |DRM_MASTER ),DRM_IOCTL_DEF (DRM_IOCTL_ADD_MAP , drm_legacy_addmap_ioctl,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ), DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_legacy_rmmap_ioctl, DRM_AUTH),
Signature · 6 lines
2.8.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/3 drm: Mark set/drop master ioctl as unlocked.
In reply to Daniel VetterAgain this is neatly protected by the dev->master_mutex now. There is a driver callback both for set and drop, but it's only used by vmwgfx. And vmwgfx has it's own solid locking for shared resources (besides dev->master_mutex), hence is all safe. Let's drop another place where the drm legacy bkl is used.
--- drivers/gpu/drm/drm_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_ioctl.c +2 -2
@@ -487,8 +487,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_SET_SAREA_CTX , drm_legacy_setsareactx,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_IOCTL_GET_SAREA_CTX , drm_legacy_getsareactx,DRM_AUTH ), -DRM_IOCTL_DEF (DRM_IOCTL_SET_MASTER , drm_setmaster_ioctl,DRM_ROOT_ONLY ), -DRM_IOCTL_DEF (DRM_IOCTL_DROP_MASTER , drm_dropmaster_ioctl,DRM_ROOT_ONLY ), +DRM_IOCTL_DEF (DRM_IOCTL_SET_MASTER , drm_setmaster_ioctl,DRM_UNLOCKED |DRM_ROOT_ONLY ), +DRM_IOCTL_DEF (DRM_IOCTL_DROP_MASTER , drm_dropmaster_ioctl,DRM_UNLOCKED |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_IOCTL_ADD_CTX , drm_legacy_addctx,DRM_AUTH |DRM_ROOT_ONLY ), DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_legacy_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
Signature · 6 lines
2.8.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Ro.CI.BAT: failure for series starting with [1/3] RFC: drm: Restrict vblank ioctl to master
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: series starting with [1/3] RFC: drm: Restrict vblank ioctl to master
URL : https://patchwork.freedesktop.org/series/8674/
State : failure
== Summary ==
Applying: RFC: drm: Restrict vblank ioctl to master
Applying: drm: Mark authmagic ioctls as unlocked
fatal: sha1 information is lacking or useless (drivers/gpu/drm/drm_ioctl.c).
error: could not build fake ancestor
Patch failed at 0002 drm: Mark authmagic ioctls as unlocked
The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Finally we removed this code from Kodi.
Regards,
Rainer
Quoted 36 lines · Daniel Vetter
Somehow this escaped us, this is a KMS ioctl which should only be used by the master (which is the thing that's also in control of kms resources). Everything else is bound to result in fail.
Clients shouldn't have a trouble coping with this, since a pile of drivers don't support vblank waits (or just randomly fall over when using them). Note that the big motivation for abusing this like mad seems to be that EGL doesn't have
OML_sync, but somehow it didn't cross anyone's mind that addingOML_syncto EGL would be useful. This patch is meant to essentially start kicking that can from the back end.--- drivers/gpu/drm/drm_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_ioctl.c +2
-3@@ -529,9 +529,9 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_SG_ALLOC , drm_legacy_sg_alloc,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_IOCTL_SG_FREE , drm_legacy_sg_free,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ), -DRM_IOCTL_DEF (DRM_IOCTL_WAIT_VBLANK , drm_wait_vblank,DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_WAIT_VBLANK , drm_wait_vblank,DRM_MASTER |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODESET_CTL , drm_modeset_ctl,0 ), +DRM_IOCTL_DEF (DRM_IOCTL_MODESET_CTL , drm_modeset_ctl,DRM_MASTER ), DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), --
Quoted 2 lines
2.8.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Rainer,
Awesome, thanks a lot for doing this! Any idea for when this will ship in a release, and for how long your users are generally using older releases? Just to have a rough indication for when we could attempt to merge this patch here.
Cheers, Daniel
Quoted 44 lines · Rainer Hochecker
Finally we removed this code from Kodi.
Regards,
RainerQuoted 38 lines · Daniel Vetter
Somehow this escaped us, this is a KMS ioctl which should only be used by the master (which is the thing that's also in control of kms resources). Everything else is bound to result in fail.
Clients shouldn't have a trouble coping with this, since a pile of drivers don't support vblank waits (or just randomly fall over when using them). Note that the big motivation for abusing this like mad seems to be that EGL doesn't have
OML_sync, but somehow it didn't cross anyone's mind that addingOML_syncto EGL would be useful. This patch is meant to essentially start kicking that can from the back end.--- drivers/gpu/drm/drm_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_ioctl.c +2
-3@@ -529,9 +529,9 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_SG_ALLOC , drm_legacy_sg_alloc,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_IOCTL_SG_FREE , drm_legacy_sg_free,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ), -DRM_IOCTL_DEF (DRM_IOCTL_WAIT_VBLANK , drm_wait_vblank,DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_WAIT_VBLANK , drm_wait_vblank,DRM_MASTER |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODESET_CTL , drm_modeset_ctl,0 ), +DRM_IOCTL_DEF (DRM_IOCTL_MODESET_CTL , drm_modeset_ctl,DRM_MASTER ), DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), --2.8.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Daniel,
We are in beta for v18. I expect release in September.
I don't think we have to consider users who run older Kodi versions on systems with latest kernels. The feature the patch would disable won't make Kodi completely unusable when absent. I'd say you can merge the patch short after v18 has been released.
Cheers,
Rainer
Quoted 51 lines · Daniel Vetter
Hi Rainer,
Awesome, thanks a lot for doing this! Any idea for when this will ship in a release, and for how long your users are generally using older releases? Just to have a rough indication for when we could attempt to merge this patch here.
Cheers, Daniel
Quoted 41 lines · Rainer Hochecker
Finally we removed this code from Kodi.
Regards,
RainerQuoted 35 lines · Daniel Vetter
Somehow this escaped us, this is a KMS ioctl which should only be used by the master (which is the thing that's also in control of kms resources). Everything else is bound to result in fail.
Clients shouldn't have a trouble coping with this, since a pile of drivers don't support vblank waits (or just randomly fall over when using them). Note that the big motivation for abusing this like mad seems to be that EGL doesn't have
OML_sync, but somehow it didn't cross anyone's mind that addingOML_syncto EGL would be useful. This patch is meant to essentially start kicking that can from the back end.--- drivers/gpu/drm/drm_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_ioctl.c +2
-2@@ -529,9 +529,9 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_SG_ALLOC , drm_legacy_sg_alloc,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ),DRM_IOCTL_DEF (DRM_IOCTL_SG_FREE , drm_legacy_sg_free,DRM_AUTH |DRM_MASTER |DRM_ROOT_ONLY ), -DRM_IOCTL_DEF (DRM_IOCTL_WAIT_VBLANK , drm_wait_vblank,DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_WAIT_VBLANK , drm_wait_vblank,DRM_MASTER |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODESET_CTL , drm_modeset_ctl,0 ), +DRM_IOCTL_DEF (DRM_IOCTL_MODESET_CTL , drm_modeset_ctl,DRM_MASTER ), DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines
--
2.8.1--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx