2022-09-15 18:41:44

by kernel test robot

[permalink] [raw]
Subject: drivers/gpu/drm/omapdrm/dss/dsi.c:1126:1: warning: the frame size of 1060 bytes is larger than 1024 bytes

Hi Arnd,

First bad commit (maybe != root cause):

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3245cb65fd91cd514801bf91f5a3066d562f0ac4
commit: 3d427228f7370894680580fcd0381c0349624fa1 ARM: ixp4xx: enable multiplatform support
date: 5 months ago
config: arm-randconfig-r035-20220915 (https://download.01.org/0day-ci/archive/20220916/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3d427228f7370894680580fcd0381c0349624fa1
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 3d427228f7370894680580fcd0381c0349624fa1
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/gpu/drm/omapdrm/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

drivers/gpu/drm/omapdrm/dss/dsi.c: In function 'dsi_dump_dsi_irqs':
>> drivers/gpu/drm/omapdrm/dss/dsi.c:1126:1: warning: the frame size of 1060 bytes is larger than 1024 bytes [-Wframe-larger-than=]
1126 | }
| ^
In file included from include/linux/string.h:253,
from include/linux/bitmap.h:11,
from include/linux/cpumask.h:12,
from include/linux/smp.h:13,
from include/linux/lockdep.h:14,
from include/linux/rcupdate.h:29,
from include/linux/rbtree.h:24,
from include/linux/regmap.h:14,
from drivers/gpu/drm/omapdrm/dss/dsi.c:11:
In function 'fortify_memcpy_chk',
inlined from 'omap_dsi_irq_handler' at drivers/gpu/drm/omapdrm/dss/dsi.c:460:2:
include/linux/fortify-string.h:336:25: warning: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
336 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +1126 drivers/gpu/drm/omapdrm/dss/dsi.c

a72b64b99918ee drivers/video/omap2/dss/dsi.c Archit Taneja 2011-05-12 1124
f33656e1fe5aba drivers/gpu/drm/omapdrm/dss/dsi.c Laurent Pinchart 2018-02-13 1125 return 0;
5a8b572d832772 drivers/video/omap2/dss/dsi.c Archit Taneja 2011-05-12 @1126 }
5a8b572d832772 drivers/video/omap2/dss/dsi.c Archit Taneja 2011-05-12 1127 #endif
5a8b572d832772 drivers/video/omap2/dss/dsi.c Archit Taneja 2011-05-12 1128

:::::: The code at line 1126 was first introduced by commit
:::::: 5a8b572d832772722c3b3b7578e7fb968560fcf3 OMAP4: DSS2: DSI: Changes for DSI2 on OMAP4

:::::: TO: Archit Taneja <[email protected]>
:::::: CC: Tomi Valkeinen <[email protected]>

--
0-DAY CI Kernel Test Service
https://01.org/lkp


2022-09-15 18:58:41

by Arnd Bergmann

[permalink] [raw]
Subject: Re: drivers/gpu/drm/omapdrm/dss/dsi.c:1126:1: warning: the frame size of 1060 bytes is larger than 1024 bytes

On Thu, Sep 15, 2022, at 8:17 PM, kernel test robot wrote:
> Hi Arnd,
> tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> master
> head: 3245cb65fd91cd514801bf91f5a3066d562f0ac4
> commit: 3d427228f7370894680580fcd0381c0349624fa1 ARM: ixp4xx: enable
> multiplatform support

This did not cause the problem, the bisection just landed on a
commit that enabled additional configuraitons.

> drivers/gpu/drm/omapdrm/dss/dsi.c: In function 'dsi_dump_dsi_irqs':
>>> drivers/gpu/drm/omapdrm/dss/dsi.c:1126:1: warning: the frame size of 1060 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> 1126 | }

I think hte problem is that struct dsi_irq_stats is just too
large, at 776 bytes. The interrupts are disabled during a copy
from 'dsi->irq_stats' into 'stats'. A trivial workaround would
avoid the local copy and keep interrupts disabled through
the entire function so it can operate directly on the source
data, but that would introduce a longer time with irqs disabled,
which might be bad as well.

Since this is only called from a debugfs file, and reading that
file is probably not performance critical itself, maybe
using kmalloc on the large structure would be best.

Arnd

2022-09-16 08:52:07

by Tomi Valkeinen

[permalink] [raw]
Subject: Re: drivers/gpu/drm/omapdrm/dss/dsi.c:1126:1: warning: the frame size of 1060 bytes is larger than 1024 bytes

On 15/09/2022 21:49, Arnd Bergmann wrote:
> On Thu, Sep 15, 2022, at 8:17 PM, kernel test robot wrote:
>> Hi Arnd,
>> tree:
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>> master
>> head: 3245cb65fd91cd514801bf91f5a3066d562f0ac4
>> commit: 3d427228f7370894680580fcd0381c0349624fa1 ARM: ixp4xx: enable
>> multiplatform support
>
> This did not cause the problem, the bisection just landed on a
> commit that enabled additional configuraitons.
>
>> drivers/gpu/drm/omapdrm/dss/dsi.c: In function 'dsi_dump_dsi_irqs':
>>>> drivers/gpu/drm/omapdrm/dss/dsi.c:1126:1: warning: the frame size of 1060 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>> 1126 | }
>
> I think hte problem is that struct dsi_irq_stats is just too
> large, at 776 bytes. The interrupts are disabled during a copy
> from 'dsi->irq_stats' into 'stats'. A trivial workaround would
> avoid the local copy and keep interrupts disabled through
> the entire function so it can operate directly on the source
> data, but that would introduce a longer time with irqs disabled,
> which might be bad as well.
>
> Since this is only called from a debugfs file, and reading that
> file is probably not performance critical itself, maybe
> using kmalloc on the large structure would be best.

I think that makes sense. I have sent a patch using kmalloc.

Oddly enough, I was not able to reproduce the warning with my normal
toolchain, gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf. I even
reduced the frame size limit to 700, and saw warnings from other places,
but not from omapdrm.

Tomi

2022-09-16 09:18:41

by Arnd Bergmann

[permalink] [raw]
Subject: Re: drivers/gpu/drm/omapdrm/dss/dsi.c:1126:1: warning: the frame size of 1060 bytes is larger than 1024 bytes

On Fri, Sep 16, 2022, at 10:24 AM, Tomi Valkeinen wrote:
> On 15/09/2022 21:49, Arnd Bergmann wrote:
>> On Thu, Sep 15, 2022, at 8:17 PM, kernel test robot wrote:
>> I think hte problem is that struct dsi_irq_stats is just too
>> large, at 776 bytes. The interrupts are disabled during a copy
>> from 'dsi->irq_stats' into 'stats'. A trivial workaround would
>> avoid the local copy and keep interrupts disabled through
>> the entire function so it can operate directly on the source
>> data, but that would introduce a longer time with irqs disabled,
>> which might be bad as well.
>>
>> Since this is only called from a debugfs file, and reading that
>> file is probably not performance critical itself, maybe
>> using kmalloc on the large structure would be best.
>
> I think that makes sense. I have sent a patch using kmalloc.
>
> Oddly enough, I was not able to reproduce the warning with my normal
> toolchain, gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf. I even
> reduced the frame size limit to 700, and saw warnings from other places,
> but not from omapdrm.

I had another look and found that this only happens with
CONFIG_INIT_STACK_ALL_PATTERN=y or CONFIG_INIT_STACK_ALL_ZERO=y,
which are only available with gcc-12.x or clang.

It looks like without that, gcc can reduce the size of the
on-stack variable by only copying the members that it actually
needs, see https://pastebin.com/8dDRE1bX for the gcc-11
output.

Arnd