mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: Constify struct nouveau_job_ops
@ 2024-06-14 16:08 Christophe JAILLET
  2024-06-17 15:27 ` Danilo Krummrich
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2024-06-14 16:08 UTC (permalink / raw)
  To: Karol Herbst, Lyude Paul, Danilo Krummrich, David Airlie, Daniel Vetter
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, dri-devel, nouveau

"struct nouveau_job_ops" is not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increase overall security.

In order to do it, "struct nouveau_job" and "struct nouveau_job_args" also
need to be adjusted to this new const qualifier.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   5570	    152	      0	   5722	   165a	drivers/gpu/drm/nouveau/nouveau_exec.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   5630	    112	      0	   5742	   166e	drivers/gpu/drm/nouveau/nouveau_exec.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/gpu/drm/nouveau/nouveau_exec.c  | 2 +-
 drivers/gpu/drm/nouveau/nouveau_sched.h | 4 ++--
 drivers/gpu/drm/nouveau/nouveau_uvmm.c  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_exec.c b/drivers/gpu/drm/nouveau/nouveau_exec.c
index e65c0ef23bc7..a0b5f1b16e8b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_exec.c
+++ b/drivers/gpu/drm/nouveau/nouveau_exec.c
@@ -188,7 +188,7 @@ nouveau_exec_job_timeout(struct nouveau_job *job)
 	return DRM_GPU_SCHED_STAT_NOMINAL;
 }
 
-static struct nouveau_job_ops nouveau_exec_job_ops = {
+static const struct nouveau_job_ops nouveau_exec_job_ops = {
 	.submit = nouveau_exec_job_submit,
 	.armed_submit = nouveau_exec_job_armed_submit,
 	.run = nouveau_exec_job_run,
diff --git a/drivers/gpu/drm/nouveau/nouveau_sched.h b/drivers/gpu/drm/nouveau/nouveau_sched.h
index e1f01a23e6f6..20cd1da8db73 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sched.h
+++ b/drivers/gpu/drm/nouveau/nouveau_sched.h
@@ -42,7 +42,7 @@ struct nouveau_job_args {
 		u32 count;
 	} out_sync;
 
-	struct nouveau_job_ops *ops;
+	const struct nouveau_job_ops *ops;
 };
 
 struct nouveau_job {
@@ -73,7 +73,7 @@ struct nouveau_job {
 		u32 count;
 	} out_sync;
 
-	struct nouveau_job_ops {
+	const struct nouveau_job_ops {
 		/* If .submit() returns without any error, it is guaranteed that
 		 * armed_submit() is called.
 		 */
diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
index ee02cd833c5e..9402fa320a7e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
@@ -1534,7 +1534,7 @@ nouveau_uvmm_bind_job_cleanup(struct nouveau_job *job)
 	nouveau_uvmm_bind_job_put(bind_job);
 }
 
-static struct nouveau_job_ops nouveau_bind_job_ops = {
+static const struct nouveau_job_ops nouveau_bind_job_ops = {
 	.submit = nouveau_uvmm_bind_job_submit,
 	.armed_submit = nouveau_uvmm_bind_job_armed_submit,
 	.run = nouveau_uvmm_bind_job_run,
-- 
2.45.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/nouveau: Constify struct nouveau_job_ops
  2024-06-14 16:08 [PATCH] drm/nouveau: Constify struct nouveau_job_ops Christophe JAILLET
@ 2024-06-17 15:27 ` Danilo Krummrich
  0 siblings, 0 replies; 2+ messages in thread
From: Danilo Krummrich @ 2024-06-17 15:27 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: linux-kernel, kernel-janitors, dri-devel, nouveau, Karol Herbst,
	Lyude Paul, David Airlie, Daniel Vetter

On 6/14/24 18:08, Christophe JAILLET wrote:
> "struct nouveau_job_ops" is not modified in these drivers.
> 
> Constifying this structure moves some data to a read-only section, so
> increase overall security.
> 
> In order to do it, "struct nouveau_job" and "struct nouveau_job_args" also
> need to be adjusted to this new const qualifier.
> 
> On a x86_64, with allmodconfig:
> Before:
> ======
>     text	   data	    bss	    dec	    hex	filename
>     5570	    152	      0	   5722	   165a	drivers/gpu/drm/nouveau/nouveau_exec.o
> 
> After:
> =====
>     text	   data	    bss	    dec	    hex	filename
>     5630	    112	      0	   5742	   166e	drivers/gpu/drm/nouveau/nouveau_exec.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied to drm-misc-next, thanks!

> ---
>   drivers/gpu/drm/nouveau/nouveau_exec.c  | 2 +-
>   drivers/gpu/drm/nouveau/nouveau_sched.h | 4 ++--
>   drivers/gpu/drm/nouveau/nouveau_uvmm.c  | 2 +-
>   3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_exec.c b/drivers/gpu/drm/nouveau/nouveau_exec.c
> index e65c0ef23bc7..a0b5f1b16e8b 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_exec.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_exec.c
> @@ -188,7 +188,7 @@ nouveau_exec_job_timeout(struct nouveau_job *job)
>   	return DRM_GPU_SCHED_STAT_NOMINAL;
>   }
>   
> -static struct nouveau_job_ops nouveau_exec_job_ops = {
> +static const struct nouveau_job_ops nouveau_exec_job_ops = {
>   	.submit = nouveau_exec_job_submit,
>   	.armed_submit = nouveau_exec_job_armed_submit,
>   	.run = nouveau_exec_job_run,
> diff --git a/drivers/gpu/drm/nouveau/nouveau_sched.h b/drivers/gpu/drm/nouveau/nouveau_sched.h
> index e1f01a23e6f6..20cd1da8db73 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_sched.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_sched.h
> @@ -42,7 +42,7 @@ struct nouveau_job_args {
>   		u32 count;
>   	} out_sync;
>   
> -	struct nouveau_job_ops *ops;
> +	const struct nouveau_job_ops *ops;
>   };
>   
>   struct nouveau_job {
> @@ -73,7 +73,7 @@ struct nouveau_job {
>   		u32 count;
>   	} out_sync;
>   
> -	struct nouveau_job_ops {
> +	const struct nouveau_job_ops {
>   		/* If .submit() returns without any error, it is guaranteed that
>   		 * armed_submit() is called.
>   		 */
> diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
> index ee02cd833c5e..9402fa320a7e 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
> @@ -1534,7 +1534,7 @@ nouveau_uvmm_bind_job_cleanup(struct nouveau_job *job)
>   	nouveau_uvmm_bind_job_put(bind_job);
>   }
>   
> -static struct nouveau_job_ops nouveau_bind_job_ops = {
> +static const struct nouveau_job_ops nouveau_bind_job_ops = {
>   	.submit = nouveau_uvmm_bind_job_submit,
>   	.armed_submit = nouveau_uvmm_bind_job_armed_submit,
>   	.run = nouveau_uvmm_bind_job_run,


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-17 15:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-14 16:08 [PATCH] drm/nouveau: Constify struct nouveau_job_ops Christophe JAILLET
2024-06-17 15:27 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®