2023-10-30 22:16:32

by kernel test robot

[permalink] [raw]
Subject: arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func'

Hi Steven,

FYI, the error/warning still remains.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 14ab6d425e80674b6a0145f05719b11e82e64824
commit: 17b251a290ba84a0c2c5c82df9596cb2e7207ca6 ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
date: 2 years ago
config: sh-allnoconfig (https://download.01.org/0day-ci/archive/20231031/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231031/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

arch/sh/boot/compressed/misc.c:109:6: warning: no previous prototype for '__stack_chk_fail' [-Wmissing-prototypes]
109 | void __stack_chk_fail(void)
| ^~~~~~~~~~~~~~~~
arch/sh/boot/compressed/misc.c:115:6: warning: no previous prototype for 'ftrace_stub' [-Wmissing-prototypes]
115 | void ftrace_stub(void)
| ^~~~~~~~~~~
>> arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func' [-Wmissing-prototypes]
118 | void arch_ftrace_ops_list_func(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
arch/sh/boot/compressed/misc.c:128:6: warning: no previous prototype for 'decompress_kernel' [-Wmissing-prototypes]
128 | void decompress_kernel(void)
| ^~~~~~~~~~~~~~~~~


vim +/arch_ftrace_ops_list_func +118 arch/sh/boot/compressed/misc.c

113
114 /* Needed because vmlinux.lds.h references this */
115 void ftrace_stub(void)
116 {
117 }
> 118 void arch_ftrace_ops_list_func(void)
119 {
120 }
121

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


2023-10-30 22:37:40

by Steven Rostedt

[permalink] [raw]
Subject: Re: arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func'

On Tue, 31 Oct 2023 06:15:04 +0800
kernel test robot <[email protected]> wrote:

> Hi Steven,
>
> FYI, the error/warning still remains.
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 14ab6d425e80674b6a0145f05719b11e82e64824
> commit: 17b251a290ba84a0c2c5c82df9596cb2e7207ca6 ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
> date: 2 years ago
> config: sh-allnoconfig (https://download.01.org/0day-ci/archive/20231031/[email protected]/config)
> compiler: sh4-linux-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231031/[email protected]/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <[email protected]>
> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>
> All warnings (new ones prefixed by >>):
>
> arch/sh/boot/compressed/misc.c:109:6: warning: no previous prototype for '__stack_chk_fail' [-Wmissing-prototypes]
> 109 | void __stack_chk_fail(void)
> | ^~~~~~~~~~~~~~~~
> arch/sh/boot/compressed/misc.c:115:6: warning: no previous prototype for 'ftrace_stub' [-Wmissing-prototypes]
> 115 | void ftrace_stub(void)
> | ^~~~~~~~~~~
> >> arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func' [-Wmissing-prototypes]
> 118 | void arch_ftrace_ops_list_func(void)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~

As the comment states, this is needed only because the linker script
vmlinux.lds.h references them, and it will not build without it.

If someone really cares, they could simply add a header to quiet these
warnings, but seriously, these functions are just stubs to allow the sh
boot portion use the vmlinux.lds.h linker script. These stubs are only for
satisfying linker references and are not used. I'm not going to be the one
to bother "fixing" it.

-- Steve


> arch/sh/boot/compressed/misc.c:128:6: warning: no previous prototype for 'decompress_kernel' [-Wmissing-prototypes]
> 128 | void decompress_kernel(void)
> | ^~~~~~~~~~~~~~~~~
>
>
> vim +/arch_ftrace_ops_list_func +118 arch/sh/boot/compressed/misc.c
>
> 113
> 114 /* Needed because vmlinux.lds.h references this */
> 115 void ftrace_stub(void)
> 116 {
> 117 }
> > 118 void arch_ftrace_ops_list_func(void)
> 119 {
> 120 }
> 121
>

2023-10-31 01:44:25

by Yujie Liu

[permalink] [raw]
Subject: Re: arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func'

On Mon, Oct 30, 2023 at 06:37:22PM -0400, Steven Rostedt wrote:
> On Tue, 31 Oct 2023 06:15:04 +0800
> kernel test robot <[email protected]> wrote:
>
> > Hi Steven,
> >
> > FYI, the error/warning still remains.
> >
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: 14ab6d425e80674b6a0145f05719b11e82e64824
> > commit: 17b251a290ba84a0c2c5c82df9596cb2e7207ca6 ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
> > date: 2 years ago
> > config: sh-allnoconfig (https://download.01.org/0day-ci/archive/20231031/[email protected]/config)
> > compiler: sh4-linux-gcc (GCC) 13.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231031/[email protected]/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <[email protected]>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> >
> > All warnings (new ones prefixed by >>):
> >
> > arch/sh/boot/compressed/misc.c:109:6: warning: no previous prototype for '__stack_chk_fail' [-Wmissing-prototypes]
> > 109 | void __stack_chk_fail(void)
> > | ^~~~~~~~~~~~~~~~
> > arch/sh/boot/compressed/misc.c:115:6: warning: no previous prototype for 'ftrace_stub' [-Wmissing-prototypes]
> > 115 | void ftrace_stub(void)
> > | ^~~~~~~~~~~
> > >> arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func' [-Wmissing-prototypes]
> > 118 | void arch_ftrace_ops_list_func(void)
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~
>
> As the comment states, this is needed only because the linker script
> vmlinux.lds.h references them, and it will not build without it.
>
> If someone really cares, they could simply add a header to quiet these
> warnings, but seriously, these functions are just stubs to allow the sh
> boot portion use the vmlinux.lds.h linker script. These stubs are only for
> satisfying linker references and are not used. I'm not going to be the one
> to bother "fixing" it.

Thanks a lot for the details. We've configured the bot to ignore this on
the reported commit.

Best Regards,
Yujie

>
> -- Steve
>
>
> > arch/sh/boot/compressed/misc.c:128:6: warning: no previous prototype for 'decompress_kernel' [-Wmissing-prototypes]
> > 128 | void decompress_kernel(void)
> > | ^~~~~~~~~~~~~~~~~
> >
> >
> > vim +/arch_ftrace_ops_list_func +118 arch/sh/boot/compressed/misc.c
> >
> > 113
> > 114 /* Needed because vmlinux.lds.h references this */
> > 115 void ftrace_stub(void)
> > 116 {
> > 117 }
> > > 118 void arch_ftrace_ops_list_func(void)
> > 119 {
> > 120 }
> > 121
> >
>
>

Subject: Re: arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func'

Hi Steven!

On Mon, 2023-10-30 at 18:37 -0400, Steven Rostedt wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: 14ab6d425e80674b6a0145f05719b11e82e64824
> > commit: 17b251a290ba84a0c2c5c82df9596cb2e7207ca6 ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
> > date: 2 years ago
> > config: sh-allnoconfig (https://download.01.org/0day-ci/archive/20231031/[email protected]/config)
> > compiler: sh4-linux-gcc (GCC) 13.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231031/[email protected]/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > > Reported-by: kernel test robot <[email protected]>
> > > Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> >
> > All warnings (new ones prefixed by >>):
> >
> > arch/sh/boot/compressed/misc.c:109:6: warning: no previous prototype for '__stack_chk_fail' [-Wmissing-prototypes]
> > 109 | void __stack_chk_fail(void)
> > | ^~~~~~~~~~~~~~~~
> > arch/sh/boot/compressed/misc.c:115:6: warning: no previous prototype for 'ftrace_stub' [-Wmissing-prototypes]
> > 115 | void ftrace_stub(void)
> > | ^~~~~~~~~~~
> > > > arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func' [-Wmissing-prototypes]
> > 118 | void arch_ftrace_ops_list_func(void)
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~
>
> As the comment states, this is needed only because the linker script
> vmlinux.lds.h references them, and it will not build without it.
>
> If someone really cares, they could simply add a header to quiet these
> warnings, but seriously, these functions are just stubs to allow the sh
> boot portion use the vmlinux.lds.h linker script. These stubs are only for
> satisfying linker references and are not used. I'm not going to be the one
> to bother "fixing" it.

I have to admit that I don't fully understand what the problem is.

Is this just a cosmetic issue? I would be willing to fix it in any case.

Adrian

--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

2023-11-02 20:28:57

by Steven Rostedt

[permalink] [raw]
Subject: Re: arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func'

On Thu, 02 Nov 2023 21:05:29 +0100
John Paul Adrian Glaubitz <[email protected]> wrote:

> > > All warnings (new ones prefixed by >>):
> > >
> > > arch/sh/boot/compressed/misc.c:109:6: warning: no previous prototype for '__stack_chk_fail' [-Wmissing-prototypes]
> > > 109 | void __stack_chk_fail(void)
> > > | ^~~~~~~~~~~~~~~~
> > > arch/sh/boot/compressed/misc.c:115:6: warning: no previous prototype for 'ftrace_stub' [-Wmissing-prototypes]
> > > 115 | void ftrace_stub(void)
> > > | ^~~~~~~~~~~
> > > > > arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func' [-Wmissing-prototypes]
> > > 118 | void arch_ftrace_ops_list_func(void)
> > > | ^~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > As the comment states, this is needed only because the linker script
> > vmlinux.lds.h references them, and it will not build without it.
> >
> > If someone really cares, they could simply add a header to quiet these
> > warnings, but seriously, these functions are just stubs to allow the sh
> > boot portion use the vmlinux.lds.h linker script. These stubs are only for
> > satisfying linker references and are not used. I'm not going to be the one
> > to bother "fixing" it.
>
> I have to admit that I don't fully understand what the problem is.
>
> Is this just a cosmetic issue? I would be willing to fix it in any case.

I'm not sure it really needs to be fixed. But I won't complain if you do.

Anyway, the issue is that arch/sh/boot/compressed/misc.c is not part of the
kernel. It's the code that decompresses the vmlinuz (or whatever sh calls
it). That is, the build will build the kernel (vmlinux) then compress it
and add a program to decompress it (vmlinuz). At least this is what is done
on x86, and I'm assuming it's the same for sh.

The vmlinuz is stored on disk, the boot loader loads it into memory and
executes it. The vmlinuz has the code to decompress the attached vmlinux
into memory and jump to that when its done.

Thus, you have two executables. The kernel and this wrapper program that
decompresses the kernel at start up (and is freed right afterward). This
wrapper code exists in arch/sh/boot (and in arch/x86/boot for x86).

As this code needs to be built just like the kernel, it uses the same
linker script as the kernel (vmlinux.lds.h), which has some references to
vmlinux code. Those include (from the warnings in this "bug"):

arch/sh/boot/compressed/misc.c:115:6: warning: no previous prototype for 'ftrace_stub' [-Wmissing-prototypes]
115 | void ftrace_stub(void)
| ^~~~~~~~~~~
>> arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func' [-Wmissing-prototypes]
118 | void arch_ftrace_ops_list_func(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~

Which are referenced by include/asm-generic/vmlinux.lds.h, and if you do
not include them, then linking will fail as these will be undefined
references.

Note, that bug also has:

arch/sh/boot/compressed/misc.c:109:6: warning: no previous prototype for '__stack_chk_fail' [-Wmissing-prototypes]
109 | void __stack_chk_fail(void)
| ^~~~~~~~~~~~~~~~

Which has a reference added by the compiler for stack protection options.

arch/sh/boot/compressed/misc.c:128:6: warning: no previous prototype for 'decompress_kernel' [-Wmissing-prototypes]
128 | void decompress_kernel(void)

Which is called by arch/sh/boot/compressed/head_*.S, which is assembly.

None of these really need prototypes, as there's nothing that would use the
prototypes. The two ftrace function stubs do not even add parameters to
match the vmlinux prototype, because they are never called. The other two
functions are either for gcc internal usage or called from assembly, both
which do not care about seeing a prototype either.

If you want to quiet gcc, you can add in arch/sh/boot/compressed, a header
file called "stubs.h" that just has:

#ifndef _STUBS_H
#define _STUBS_H

/* Quiet gcc complaining about these prototypes */

void __stack_chk_fail(void);
void decompress_kernel(void);
void ftrace_stub(void);
void arch_ftrace_ops_list_func(void);

#endif

and include that header.

-- Steve

Subject: Re: arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func'

Hi Steven!

On Thu, 2023-11-02 at 16:28 -0400, Steven Rostedt wrote:
>
> I'm not sure it really needs to be fixed. But I won't complain if you do.
>
> Anyway, the issue is that arch/sh/boot/compressed/misc.c is not part of the
> kernel. It's the code that decompresses the vmlinuz (or whatever sh calls
> it). That is, the build will build the kernel (vmlinux) then compress it
> and add a program to decompress it (vmlinuz). At least this is what is done
> on x86, and I'm assuming it's the same for sh.
>
> The vmlinuz is stored on disk, the boot loader loads it into memory and
> executes it. The vmlinuz has the code to decompress the attached vmlinux
> into memory and jump to that when its done.
>
> Thus, you have two executables. The kernel and this wrapper program that
> decompresses the kernel at start up (and is freed right afterward). This
> wrapper code exists in arch/sh/boot (and in arch/x86/boot for x86).
>
> As this code needs to be built just like the kernel, it uses the same
> linker script as the kernel (vmlinux.lds.h), which has some references to
> vmlinux code. Those include (from the warnings in this "bug"):
>
> arch/sh/boot/compressed/misc.c:115:6: warning: no previous prototype for 'ftrace_stub' [-Wmissing-prototypes]
> 115 | void ftrace_stub(void)
> | ^~~~~~~~~~~
> > > arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for 'arch_ftrace_ops_list_func' [-Wmissing-prototypes]
> 118 | void arch_ftrace_ops_list_func(void)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~
>
> Which are referenced by include/asm-generic/vmlinux.lds.h, and if you do
> not include them, then linking will fail as these will be undefined
> references.
>
> Note, that bug also has:
>
> arch/sh/boot/compressed/misc.c:109:6: warning: no previous prototype for '__stack_chk_fail' [-Wmissing-prototypes]
> 109 | void __stack_chk_fail(void)
> | ^~~~~~~~~~~~~~~~
>
> Which has a reference added by the compiler for stack protection options.
>
> arch/sh/boot/compressed/misc.c:128:6: warning: no previous prototype for 'decompress_kernel' [-Wmissing-prototypes]
> 128 | void decompress_kernel(void)
>
> Which is called by arch/sh/boot/compressed/head_*.S, which is assembly.
>
> None of these really need prototypes, as there's nothing that would use the
> prototypes. The two ftrace function stubs do not even add parameters to
> match the vmlinux prototype, because they are never called. The other two
> functions are either for gcc internal usage or called from assembly, both
> which do not care about seeing a prototype either.
>
> If you want to quiet gcc, you can add in arch/sh/boot/compressed, a header
> file called "stubs.h" that just has:
>
> #ifndef _STUBS_H
> #define _STUBS_H
>
> /* Quiet gcc complaining about these prototypes */
>
> void __stack_chk_fail(void);
> void decompress_kernel(void);
> void ftrace_stub(void);
> void arch_ftrace_ops_list_func(void);
>
> #endif
>
> and include that header.

Thank you for the very detailed explanation. I will look into fixing this for v6.7.

Adrian

--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913