All of lore.kernel.org
 help / color / mirror / Atom feed
* gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
@ 2022-06-03  2:03 ` Naresh Kamboju
  0 siblings, 0 replies; 10+ messages in thread
From: Naresh Kamboju @ 2022-06-03  2:03 UTC (permalink / raw)
  To: Linux ARM, open list, regressions, lkft-triage
  Cc: Catalin Marinas, Will Deacon, Andrew Morton, John Donnelly,
	Huacai Chen, Bjorn Andersson, Andy Shevchenko, David Hildenbrand,
	Guilherme G. Piccoli, Zhen Lei, Anshuman Khandual, Kefeng Wang

While building Linux kernel with gcc-12 for arm64 the following warnings/errors
noticed. These are specific to gcc-12 builds.

Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>

make --silent --keep-going --jobs=8
O=/home/tuxbuild/.cache/tuxmake/builds/2/build
CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- ARCH=arm64
CROSS_COMPILE=aarch64-linux-gnu- 'CC=sccache aarch64-linux-gnu-gcc'
'HOSTCC=sccache gcc'
In file included from arch/arm64/include/asm/thread_info.h:17,
                 from include/linux/thread_info.h:60,
                 from arch/arm64/include/asm/preempt.h:6,
                 from include/linux/preempt.h:78,
                 from include/linux/smp.h:110,
                 from include/linux/lockdep.h:14,
                 from include/linux/mutex.h:17,
                 from include/linux/kernfs.h:11,
                 from include/linux/sysfs.h:16,
                 from include/linux/kobject.h:20,
                 from include/linux/of.h:17,
                 from include/linux/irqdomain.h:35,
                 from include/linux/acpi.h:13,
                 from arch/arm64/kernel/setup.c:9:
In function 'request_standard_resources',
    inlined from 'setup_arch' at arch/arm64/kernel/setup.c:350:2:
arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is
outside array bounds of 'char[]' [-Warray-bounds]
  225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);

steps to reproduce:
# To install tuxmake on your system globally:
# sudo pip3 install -U tuxmake

tuxmake --runtime podman --target-arch arm64 --toolchain gcc-12
--kconfig tinyconfig CROSS_COMPILE_COMPAT=arm-linux-gnueabihf-

Build link:
https://builds.tuxbuild.com/2A2iyFqotDfgkLynaKzmpf8H7Nf/

--
Linaro LKFT
https://lkft.linaro.org

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

* gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
@ 2022-06-03  2:03 ` Naresh Kamboju
  0 siblings, 0 replies; 10+ messages in thread
From: Naresh Kamboju @ 2022-06-03  2:03 UTC (permalink / raw)
  To: Linux ARM, open list, regressions, lkft-triage
  Cc: Catalin Marinas, Will Deacon, Andrew Morton, John Donnelly,
	Huacai Chen, Bjorn Andersson, Andy Shevchenko, David Hildenbrand,
	Guilherme G. Piccoli, Zhen Lei, Anshuman Khandual, Kefeng Wang

While building Linux kernel with gcc-12 for arm64 the following warnings/errors
noticed. These are specific to gcc-12 builds.

Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>

make --silent --keep-going --jobs=8
O=/home/tuxbuild/.cache/tuxmake/builds/2/build
CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- ARCH=arm64
CROSS_COMPILE=aarch64-linux-gnu- 'CC=sccache aarch64-linux-gnu-gcc'
'HOSTCC=sccache gcc'
In file included from arch/arm64/include/asm/thread_info.h:17,
                 from include/linux/thread_info.h:60,
                 from arch/arm64/include/asm/preempt.h:6,
                 from include/linux/preempt.h:78,
                 from include/linux/smp.h:110,
                 from include/linux/lockdep.h:14,
                 from include/linux/mutex.h:17,
                 from include/linux/kernfs.h:11,
                 from include/linux/sysfs.h:16,
                 from include/linux/kobject.h:20,
                 from include/linux/of.h:17,
                 from include/linux/irqdomain.h:35,
                 from include/linux/acpi.h:13,
                 from arch/arm64/kernel/setup.c:9:
In function 'request_standard_resources',
    inlined from 'setup_arch' at arch/arm64/kernel/setup.c:350:2:
arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is
outside array bounds of 'char[]' [-Warray-bounds]
  225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);

steps to reproduce:
# To install tuxmake on your system globally:
# sudo pip3 install -U tuxmake

tuxmake --runtime podman --target-arch arm64 --toolchain gcc-12
--kconfig tinyconfig CROSS_COMPILE_COMPAT=arm-linux-gnueabihf-

Build link:
https://builds.tuxbuild.com/2A2iyFqotDfgkLynaKzmpf8H7Nf/

--
Linaro LKFT
https://lkft.linaro.org

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
  2022-06-03  2:03 ` Naresh Kamboju
@ 2022-06-03  7:40   ` Arnd Bergmann
  -1 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2022-06-03  7:40 UTC (permalink / raw)
  To: Naresh Kamboju
  Cc: Linux ARM, open list, regressions, lkft-triage, Catalin Marinas,
	Will Deacon, Andrew Morton, John Donnelly, Huacai Chen,
	Bjorn Andersson, Andy Shevchenko, David Hildenbrand,
	Guilherme G. Piccoli, Zhen Lei, Anshuman Khandual, Kefeng Wang

On Fri, Jun 3, 2022 at 4:03 AM Naresh Kamboju <naresh.kamboju@linaro.org> wrote:
>     inlined from 'setup_arch' at arch/arm64/kernel/setup.c:350:2:
> arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is
> outside array bounds of 'char[]' [-Warray-bounds]
>   225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);
>

Is this the only warning of this type that you get for arm64?

I think the easy fix would be to reword this line to

       kernel_code.end     = __pa_symbol(__init_begin) - 1;


        Arnd

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

* Re: gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
@ 2022-06-03  7:40   ` Arnd Bergmann
  0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2022-06-03  7:40 UTC (permalink / raw)
  To: Naresh Kamboju
  Cc: Linux ARM, open list, regressions, lkft-triage, Catalin Marinas,
	Will Deacon, Andrew Morton, John Donnelly, Huacai Chen,
	Bjorn Andersson, Andy Shevchenko, David Hildenbrand,
	Guilherme G. Piccoli, Zhen Lei, Anshuman Khandual, Kefeng Wang

On Fri, Jun 3, 2022 at 4:03 AM Naresh Kamboju <naresh.kamboju@linaro.org> wrote:
>     inlined from 'setup_arch' at arch/arm64/kernel/setup.c:350:2:
> arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is
> outside array bounds of 'char[]' [-Warray-bounds]
>   225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);
>

Is this the only warning of this type that you get for arm64?

I think the easy fix would be to reword this line to

       kernel_code.end     = __pa_symbol(__init_begin) - 1;


        Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
  2022-06-03  7:40   ` Arnd Bergmann
@ 2022-06-06  9:01     ` Maxime Ripard
  -1 siblings, 0 replies; 10+ messages in thread
From: Maxime Ripard @ 2022-06-06  9:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Naresh Kamboju, Linux ARM, open list, regressions, lkft-triage,
	Catalin Marinas, Will Deacon, Andrew Morton, John Donnelly,
	Huacai Chen, Bjorn Andersson, Andy Shevchenko, David Hildenbrand,
	Guilherme G. Piccoli, Zhen Lei, Anshuman Khandual, Kefeng Wang

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

Hi,

On Fri, Jun 03, 2022 at 09:40:07AM +0200, Arnd Bergmann wrote:
> On Fri, Jun 3, 2022 at 4:03 AM Naresh Kamboju <naresh.kamboju@linaro.org> wrote:
> >     inlined from 'setup_arch' at arch/arm64/kernel/setup.c:350:2:
> > arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is
> > outside array bounds of 'char[]' [-Warray-bounds]
> >   225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);
> >
> 
> Is this the only warning of this type that you get for arm64?

In that function, both kernel_code.end and kernel_data_end show a
similar warning in 5.19-rc1

> I think the easy fix would be to reword this line to
> 
>        kernel_code.end     = __pa_symbol(__init_begin) - 1;

Doing this for both fix the warnings.

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
@ 2022-06-06  9:01     ` Maxime Ripard
  0 siblings, 0 replies; 10+ messages in thread
From: Maxime Ripard @ 2022-06-06  9:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Naresh Kamboju, Linux ARM, open list, regressions, lkft-triage,
	Catalin Marinas, Will Deacon, Andrew Morton, John Donnelly,
	Huacai Chen, Bjorn Andersson, Andy Shevchenko, David Hildenbrand,
	Guilherme G. Piccoli, Zhen Lei, Anshuman Khandual, Kefeng Wang


[-- Attachment #1.1: Type: text/plain, Size: 773 bytes --]

Hi,

On Fri, Jun 03, 2022 at 09:40:07AM +0200, Arnd Bergmann wrote:
> On Fri, Jun 3, 2022 at 4:03 AM Naresh Kamboju <naresh.kamboju@linaro.org> wrote:
> >     inlined from 'setup_arch' at arch/arm64/kernel/setup.c:350:2:
> > arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is
> > outside array bounds of 'char[]' [-Warray-bounds]
> >   225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);
> >
> 
> Is this the only warning of this type that you get for arm64?

In that function, both kernel_code.end and kernel_data_end show a
similar warning in 5.19-rc1

> I think the easy fix would be to reword this line to
> 
>        kernel_code.end     = __pa_symbol(__init_begin) - 1;

Doing this for both fix the warnings.

Maxime

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
  2022-06-03  7:40   ` Arnd Bergmann
@ 2022-06-06  9:41     ` Mark Rutland
  -1 siblings, 0 replies; 10+ messages in thread
From: Mark Rutland @ 2022-06-06  9:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Naresh Kamboju, Linux ARM, open list, regressions, lkft-triage,
	Catalin Marinas, Will Deacon, Andrew Morton, John Donnelly,
	Huacai Chen, Bjorn Andersson, Andy Shevchenko, David Hildenbrand,
	Guilherme G. Piccoli, Zhen Lei, Anshuman Khandual, Kefeng Wang

On Fri, Jun 03, 2022 at 09:40:07AM +0200, Arnd Bergmann wrote:
> On Fri, Jun 3, 2022 at 4:03 AM Naresh Kamboju <naresh.kamboju@linaro.org> wrote:
> >     inlined from 'setup_arch' at arch/arm64/kernel/setup.c:350:2:
> > arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is
> > outside array bounds of 'char[]' [-Warray-bounds]
> >   225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);
> >
> 
> Is this the only warning of this type that you get for arm64?

There are a handful of those subscript warnings. Looking at v5.19-rc1
defconfig, using the kernel.org GCC 12.1.0 cross toolchain:

| [mark@lakrids:~/src/linux]% usekorg 12.1.0 make ARCH=arm64 CROSS_COMPILE=aarch64-linux- -j50 2>&1 | grep -A1 subscript
| arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
|   225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);
| --
| arch/arm64/kernel/setup.c:227:48: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
|   227 |         kernel_data.end     = __pa_symbol(_end - 1);
| --
| arch/arm64/kernel/hibernate.c:94:65: warning: array subscript -1 is outside array bounds of 'const void[]' [-Warray-bounds]
|    94 |         unsigned long nosave_end_pfn = sym_to_pfn(&__nosave_end - 1);

The last of those can't have the `- 1` pulled out, but we could stuff a
RELOC_HIDE() in there, as __pa_symbol() has internally.

Ideally we'd rework the section markers to not have this problem, either
rethinking the way we mark them as flexible arrays, or giving them accessors,
e.g.

	#define va_init_begin()	RELOC_HIDE((unsigned long)__init_begin)

... which'd be a pain, but at least it'd solve this generally.

> I think the easy fix would be to reword this line to
> 
>        kernel_code.end     = __pa_symbol(__init_begin) - 1;
> 

I agree that'd work for the __pa_symbol() cases.

For consistency it might be worth using RELOC_HIDE(), e.g.

	kernel_code.end     = __pa_symbol(RELOC_HIDE(__init_begin)) - 1);

... which IIUC should do the trick.

Thanks,
Mark.

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

* Re: gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
@ 2022-06-06  9:41     ` Mark Rutland
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Rutland @ 2022-06-06  9:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Naresh Kamboju, Linux ARM, open list, regressions, lkft-triage,
	Catalin Marinas, Will Deacon, Andrew Morton, John Donnelly,
	Huacai Chen, Bjorn Andersson, Andy Shevchenko, David Hildenbrand,
	Guilherme G. Piccoli, Zhen Lei, Anshuman Khandual, Kefeng Wang

On Fri, Jun 03, 2022 at 09:40:07AM +0200, Arnd Bergmann wrote:
> On Fri, Jun 3, 2022 at 4:03 AM Naresh Kamboju <naresh.kamboju@linaro.org> wrote:
> >     inlined from 'setup_arch' at arch/arm64/kernel/setup.c:350:2:
> > arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is
> > outside array bounds of 'char[]' [-Warray-bounds]
> >   225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);
> >
> 
> Is this the only warning of this type that you get for arm64?

There are a handful of those subscript warnings. Looking at v5.19-rc1
defconfig, using the kernel.org GCC 12.1.0 cross toolchain:

| [mark@lakrids:~/src/linux]% usekorg 12.1.0 make ARCH=arm64 CROSS_COMPILE=aarch64-linux- -j50 2>&1 | grep -A1 subscript
| arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
|   225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);
| --
| arch/arm64/kernel/setup.c:227:48: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
|   227 |         kernel_data.end     = __pa_symbol(_end - 1);
| --
| arch/arm64/kernel/hibernate.c:94:65: warning: array subscript -1 is outside array bounds of 'const void[]' [-Warray-bounds]
|    94 |         unsigned long nosave_end_pfn = sym_to_pfn(&__nosave_end - 1);

The last of those can't have the `- 1` pulled out, but we could stuff a
RELOC_HIDE() in there, as __pa_symbol() has internally.

Ideally we'd rework the section markers to not have this problem, either
rethinking the way we mark them as flexible arrays, or giving them accessors,
e.g.

	#define va_init_begin()	RELOC_HIDE((unsigned long)__init_begin)

... which'd be a pain, but at least it'd solve this generally.

> I think the easy fix would be to reword this line to
> 
>        kernel_code.end     = __pa_symbol(__init_begin) - 1;
> 

I agree that'd work for the __pa_symbol() cases.

For consistency it might be worth using RELOC_HIDE(), e.g.

	kernel_code.end     = __pa_symbol(RELOC_HIDE(__init_begin)) - 1);

... which IIUC should do the trick.

Thanks,
Mark.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
  2022-06-06  9:41     ` Mark Rutland
@ 2022-06-08  6:54       ` Arnd Bergmann
  -1 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2022-06-08  6:54 UTC (permalink / raw)
  To: Mark Rutland
  Cc: Arnd Bergmann, Naresh Kamboju, Linux ARM, open list, regressions,
	lkft-triage, Catalin Marinas, Will Deacon, Andrew Morton,
	John Donnelly, Huacai Chen, Bjorn Andersson, Andy Shevchenko,
	David Hildenbrand, Guilherme G. Piccoli, Zhen Lei,
	Anshuman Khandual, Kefeng Wang

On Mon, Jun 6, 2022 at 11:41 AM Mark Rutland <mark.rutland@arm.com> wrote:
> On Fri, Jun 03, 2022 at 09:40:07AM +0200, Arnd Bergmann wrote:
>
>         #define va_init_begin() RELOC_HIDE((unsigned long)__init_begin)
>
> ... which'd be a pain, but at least it'd solve this generally.
>
> > I think the easy fix would be to reword this line to
> >
> >        kernel_code.end     = __pa_symbol(__init_begin) - 1;
> >
>
> I agree that'd work for the __pa_symbol() cases.
>
> For consistency it might be worth using RELOC_HIDE(), e.g.
>
>         kernel_code.end     = __pa_symbol(RELOC_HIDE(__init_begin)) - 1);
>asm-gener
> ... which IIUC should do the trick.
>

I see we have similar logic on each architecture, and they probably
all have the same
issue now, so maybe we can just do a helper function in include/linux/ioport.h
(which has all the struct resource logic) that can be called like

resource_set_pa(&kernel_code, _stext, __init_begin);
resource_set_pa(&kernel_data, _sdata, _end);

      Arnd

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

* Re: gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]
@ 2022-06-08  6:54       ` Arnd Bergmann
  0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2022-06-08  6:54 UTC (permalink / raw)
  To: Mark Rutland
  Cc: Arnd Bergmann, Naresh Kamboju, Linux ARM, open list, regressions,
	lkft-triage, Catalin Marinas, Will Deacon, Andrew Morton,
	John Donnelly, Huacai Chen, Bjorn Andersson, Andy Shevchenko,
	David Hildenbrand, Guilherme G. Piccoli, Zhen Lei,
	Anshuman Khandual, Kefeng Wang

On Mon, Jun 6, 2022 at 11:41 AM Mark Rutland <mark.rutland@arm.com> wrote:
> On Fri, Jun 03, 2022 at 09:40:07AM +0200, Arnd Bergmann wrote:
>
>         #define va_init_begin() RELOC_HIDE((unsigned long)__init_begin)
>
> ... which'd be a pain, but at least it'd solve this generally.
>
> > I think the easy fix would be to reword this line to
> >
> >        kernel_code.end     = __pa_symbol(__init_begin) - 1;
> >
>
> I agree that'd work for the __pa_symbol() cases.
>
> For consistency it might be worth using RELOC_HIDE(), e.g.
>
>         kernel_code.end     = __pa_symbol(RELOC_HIDE(__init_begin)) - 1);
>asm-gener
> ... which IIUC should do the trick.
>

I see we have similar logic on each architecture, and they probably
all have the same
issue now, so maybe we can just do a helper function in include/linux/ioport.h
(which has all the struct resource logic) that can be called like

resource_set_pa(&kernel_code, _stext, __init_begin);
resource_set_pa(&kernel_data, _sdata, _end);

      Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-06-08  6:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03  2:03 gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds] Naresh Kamboju
2022-06-03  2:03 ` Naresh Kamboju
2022-06-03  7:40 ` Arnd Bergmann
2022-06-03  7:40   ` Arnd Bergmann
2022-06-06  9:01   ` Maxime Ripard
2022-06-06  9:01     ` Maxime Ripard
2022-06-06  9:41   ` Mark Rutland
2022-06-06  9:41     ` Mark Rutland
2022-06-08  6:54     ` Arnd Bergmann
2022-06-08  6:54       ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.