[PATCH] fbdev: Constify struct sbus_mmap_map

Enrico Weigelt, metux IT consult lkml at metux.net
Tue Oct 29 16:20:21 UTC 2024


On 13.10.24 13:48, Christophe JAILLET wrote:
> 'struct sbus_mmap_map' are not modified in these drivers.
>
> Constifying this structure moves some data to a read-only section, so
> increases overall security.
>
> Update sbusfb_mmap_helper() accordingly.
>
> On a x86_64, with allmodconfig, as an example:
> Before:
> ======
>     text	   data	    bss	    dec	    hex	filename
>     2452	    536	     16	   3004	    bbc	drivers/video/fbdev/bw2.o
>
> After:
> =====
>     text	   data	    bss	    dec	    hex	filename
>     2500	    483	     16	   2999	    bb7	drivers/video/fbdev/bw2.o

Cool.

It's just a few bytes, but better than nothing :)


--mtx


>
> Signed-off-by: Christophe JAILLET <christophe.jaillet at wanadoo.fr>
> ---
> Compile tested only with a cross compiler for sparc.
> ---
>   drivers/video/fbdev/bw2.c     | 2 +-
>   drivers/video/fbdev/cg14.c    | 2 +-
>   drivers/video/fbdev/cg3.c     | 2 +-
>   drivers/video/fbdev/cg6.c     | 2 +-
>   drivers/video/fbdev/ffb.c     | 2 +-
>   drivers/video/fbdev/leo.c     | 2 +-
>   drivers/video/fbdev/p9100.c   | 2 +-
>   drivers/video/fbdev/sbuslib.c | 2 +-
>   drivers/video/fbdev/sbuslib.h | 2 +-
>   drivers/video/fbdev/tcx.c     | 2 +-
>   10 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/video/fbdev/bw2.c b/drivers/video/fbdev/bw2.c
> index 4a64940e0c00..e757462af0a6 100644
> --- a/drivers/video/fbdev/bw2.c
> +++ b/drivers/video/fbdev/bw2.c
> @@ -147,7 +147,7 @@ bw2_blank(int blank, struct fb_info *info)
>   	return 0;
>   }
>
> -static struct sbus_mmap_map bw2_mmap_map[] = {
> +static const struct sbus_mmap_map bw2_mmap_map[] = {
>   	{
>   		.size = SBUS_MMAP_FBSIZE(1)
>   	},
> diff --git a/drivers/video/fbdev/cg14.c b/drivers/video/fbdev/cg14.c
> index 430e1a7b352b..5389f8f07346 100644
> --- a/drivers/video/fbdev/cg14.c
> +++ b/drivers/video/fbdev/cg14.c
> @@ -360,7 +360,7 @@ static void cg14_init_fix(struct fb_info *info, int linebytes,
>   	info->fix.accel = FB_ACCEL_SUN_CG14;
>   }
>
> -static struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] = {
> +static const struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] = {
>   	{
>   		.voff	= CG14_REGS,
>   		.poff	= 0x80000000,
> diff --git a/drivers/video/fbdev/cg3.c b/drivers/video/fbdev/cg3.c
> index e4c53c6632ba..a58a483014e6 100644
> --- a/drivers/video/fbdev/cg3.c
> +++ b/drivers/video/fbdev/cg3.c
> @@ -209,7 +209,7 @@ static int cg3_blank(int blank, struct fb_info *info)
>   	return 0;
>   }
>
> -static struct sbus_mmap_map cg3_mmap_map[] = {
> +static const struct sbus_mmap_map cg3_mmap_map[] = {
>   	{
>   		.voff	= CG3_MMAP_OFFSET,
>   		.poff	= CG3_RAM_OFFSET,
> diff --git a/drivers/video/fbdev/cg6.c b/drivers/video/fbdev/cg6.c
> index 0b60df51e7bc..56d74468040a 100644
> --- a/drivers/video/fbdev/cg6.c
> +++ b/drivers/video/fbdev/cg6.c
> @@ -545,7 +545,7 @@ static int cg6_blank(int blank, struct fb_info *info)
>   	return 0;
>   }
>
> -static struct sbus_mmap_map cg6_mmap_map[] = {
> +static const struct sbus_mmap_map cg6_mmap_map[] = {
>   	{
>   		.voff	= CG6_FBC,
>   		.poff	= CG6_FBC_OFFSET,
> diff --git a/drivers/video/fbdev/ffb.c b/drivers/video/fbdev/ffb.c
> index 0b7e7b38c05a..34b6abff9493 100644
> --- a/drivers/video/fbdev/ffb.c
> +++ b/drivers/video/fbdev/ffb.c
> @@ -710,7 +710,7 @@ static int ffb_blank(int blank, struct fb_info *info)
>   	return 0;
>   }
>
> -static struct sbus_mmap_map ffb_mmap_map[] = {
> +static const struct sbus_mmap_map ffb_mmap_map[] = {
>   	{
>   		.voff	= FFB_SFB8R_VOFF,
>   		.poff	= FFB_SFB8R_POFF,
> diff --git a/drivers/video/fbdev/leo.c b/drivers/video/fbdev/leo.c
> index 271e2e8c6a84..b9fb059df2c7 100644
> --- a/drivers/video/fbdev/leo.c
> +++ b/drivers/video/fbdev/leo.c
> @@ -338,7 +338,7 @@ static int leo_blank(int blank, struct fb_info *info)
>   	return 0;
>   }
>
> -static struct sbus_mmap_map leo_mmap_map[] = {
> +static const struct sbus_mmap_map leo_mmap_map[] = {
>   	{
>   		.voff	= LEO_SS0_MAP,
>   		.poff	= LEO_OFF_SS0,
> diff --git a/drivers/video/fbdev/p9100.c b/drivers/video/fbdev/p9100.c
> index 124468f0e9ef..0bc0f78fe4b9 100644
> --- a/drivers/video/fbdev/p9100.c
> +++ b/drivers/video/fbdev/p9100.c
> @@ -206,7 +206,7 @@ p9100_blank(int blank, struct fb_info *info)
>   	return 0;
>   }
>
> -static struct sbus_mmap_map p9100_mmap_map[] = {
> +static const struct sbus_mmap_map p9100_mmap_map[] = {
>   	{ CG3_MMAP_OFFSET,	0,		SBUS_MMAP_FBSIZE(1) },
>   	{ 0,			0,		0		    }
>   };
> diff --git a/drivers/video/fbdev/sbuslib.c b/drivers/video/fbdev/sbuslib.c
> index 634e3d159452..4c79654bda30 100644
> --- a/drivers/video/fbdev/sbuslib.c
> +++ b/drivers/video/fbdev/sbuslib.c
> @@ -38,7 +38,7 @@ static unsigned long sbusfb_mmapsize(long size, unsigned long fbsize)
>   	return fbsize * (-size);
>   }
>
> -int sbusfb_mmap_helper(struct sbus_mmap_map *map,
> +int sbusfb_mmap_helper(const struct sbus_mmap_map *map,
>   		       unsigned long physbase,
>   		       unsigned long fbsize,
>   		       unsigned long iospace,
> diff --git a/drivers/video/fbdev/sbuslib.h b/drivers/video/fbdev/sbuslib.h
> index 6466b4cbcd7b..e9af2dc93f94 100644
> --- a/drivers/video/fbdev/sbuslib.h
> +++ b/drivers/video/fbdev/sbuslib.h
> @@ -19,7 +19,7 @@ struct sbus_mmap_map {
>
>   extern void sbusfb_fill_var(struct fb_var_screeninfo *var,
>   			    struct device_node *dp, int bpp);
> -extern int sbusfb_mmap_helper(struct sbus_mmap_map *map,
> +extern int sbusfb_mmap_helper(const struct sbus_mmap_map *map,
>   			      unsigned long physbase, unsigned long fbsize,
>   			      unsigned long iospace,
>   			      struct vm_area_struct *vma);
> diff --git a/drivers/video/fbdev/tcx.c b/drivers/video/fbdev/tcx.c
> index 6eb8bb2e3501..f9a0085ad72b 100644
> --- a/drivers/video/fbdev/tcx.c
> +++ b/drivers/video/fbdev/tcx.c
> @@ -236,7 +236,7 @@ tcx_blank(int blank, struct fb_info *info)
>   	return 0;
>   }
>
> -static struct sbus_mmap_map __tcx_mmap_map[TCX_MMAP_ENTRIES] = {
> +static const struct sbus_mmap_map __tcx_mmap_map[TCX_MMAP_ENTRIES] = {
>   	{
>   		.voff	= TCX_RAM8BIT,
>   		.size	= SBUS_MMAP_FBSIZE(1)

--
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info at metux.net -- +49-151-27565287


More information about the dri-devel mailing list