2023-05-16 19:52:00

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 00/20] x86: address -Wmissing-prototype warnings

From: Arnd Bergmann <[email protected]>

This addresses all x86 specific prototype warnings. The majority of the
patches should be straightforward, either adding an #include statement
to get the right header, or ensuring that an unused global function is
left out of the build when the prototype is hidden.

The ones that are a bit awkward are those that just add a prototype to
shut up the warning, but the prototypes are never used for calling the
function because the only caller is in assembler code. I tried to come up
with other ways to shut up the compiler using the asmlinkage annotation,
but with no success.

All of the warnings have to be addressed in some form before the warning
can be enabled by default.

Arnd

Link: https://people.kernel.org/arnd/missing-prototype-warnings-in-the-kernel


Arnd Bergmann (20):
x86: move prepare_ftrace_return prototype to header
x86: ce4100: Mark local functions as 'static'
x86: apic: hide unused safe_smp_processor_id on UP
x86: avoid unneeded __div64_32 function definition
x86: head: add dummy prototype for mk_early_pgtbl_32
x86: math-emu: include asm/fpu/regset.h
x86: doublefault: avoid missing-prototype warnings
x86: highmem: include asm/numa.h for set_highmem_pages_init
x86: platform_quirks: include linux/pnp.h for arch_pnpbios_disabled
x86: xen: add missing prototypes
x86: entry: add do_SYSENTER_32() prototype
x86: qspinlock-paravirt: fix mising-prototype warnings
x86: hibernate: declare global functions in suspend.h
x86: fbdev: include asm/fb.h as needed
x86: mce: add copy_mc_fragile_handle_tail prototype
x86: vdso: include vdso/processor.h
x86: usercopy: include arch_wb_cache_pmem declaration
x86: ioremap: add early_memremap_pgprot_adjust prototype
x86: purgatory: include header for warn() declaration
x86: olpc: avoid missing-prototype warnings

arch/x86/boot/compressed/error.c | 2 +-
arch/x86/boot/compressed/error.h | 2 +-
arch/x86/entry/vdso/vgetcpu.c | 1 +
arch/x86/include/asm/div64.h | 2 ++
arch/x86/include/asm/doublefault.h | 4 ++++
arch/x86/include/asm/ftrace.h | 3 +++
arch/x86/include/asm/mce.h | 3 +++
arch/x86/include/asm/qspinlock_paravirt.h | 2 ++
arch/x86/include/asm/syscall.h | 6 ++++--
arch/x86/kernel/apic/ipi.c | 2 ++
arch/x86/kernel/doublefault_32.c | 1 +
arch/x86/kernel/ftrace.c | 3 ---
arch/x86/kernel/head32.c | 1 +
arch/x86/kernel/paravirt.c | 2 ++
arch/x86/kernel/platform-quirks.c | 1 +
arch/x86/lib/usercopy_64.c | 1 +
arch/x86/math-emu/fpu_entry.c | 1 +
arch/x86/mm/highmem_32.c | 1 +
arch/x86/pci/ce4100.c | 4 ++--
arch/x86/platform/olpc/olpc_dt.c | 2 +-
arch/x86/purgatory/purgatory.c | 1 +
arch/x86/video/fbdev.c | 1 +
arch/x86/xen/efi.c | 2 ++
arch/x86/xen/smp.h | 3 +++
arch/x86/xen/xen-ops.h | 14 ++++++++++++++
include/linux/io.h | 5 +++++
include/linux/olpc-ec.h | 2 ++
include/linux/suspend.h | 4 ++++
include/xen/xen.h | 3 +++
kernel/locking/qspinlock_paravirt.h | 20 ++++++++++----------
kernel/power/power.h | 5 -----
mm/internal.h | 6 ------
32 files changed, 79 insertions(+), 31 deletions(-)

--
2.39.2

Cc: Thomas Gleixner <[email protected]> (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),commit_signer:1/5=20%,authored:1/5=20%)
Cc: Ingo Molnar <[email protected]> (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT))
Cc: Borislav Petkov <[email protected]> (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),commit_signer:1/3=33%,commit_signer:1/5=20%,authored:1/5=20%,removed_lines:40/51=78%)
Cc: Dave Hansen <[email protected]> (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),commit_signer:1/5=20%)
Cc: [email protected] (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT))
Cc: "H. Peter Anvin" <[email protected]> (reviewer:X86 ARCHITECTURE (32-BIT AND 64-BIT))
Cc: Andy Lutomirski <[email protected]> (maintainer:X86 VDSO)
Cc: Steven Rostedt <[email protected]> (maintainer:FUNCTION HOOKS (FTRACE))
Cc: Masami Hiramatsu <[email protected]> (maintainer:FUNCTION HOOKS (FTRACE))
Cc: Mark Rutland <[email protected]> (reviewer:FUNCTION HOOKS (FTRACE))
Cc: Juergen Gross <[email protected]> (supporter:PARAVIRT_OPS INTERFACE,commit_signer:2/5=40%,authored:1/5=20%,added_lines:20/31=65%,removed_lines:27/35=77%)
Cc: "Srivatsa S. Bhat (VMware)" <[email protected]> (supporter:PARAVIRT_OPS INTERFACE)
Cc: Alexey Makhalov <[email protected]> (reviewer:PARAVIRT_OPS INTERFACE)
Cc: VMware PV-Drivers Reviewers <[email protected]> (reviewer:PARAVIRT_OPS INTERFACE)
Cc: Peter Zijlstra <[email protected]> (maintainer:X86 MM,commit_signer:4/5=80%,commit_signer:1/2=50%)
Cc: Darren Hart <[email protected]> (reviewer:X86 PLATFORM DRIVERS - ARCH)
Cc: Andy Shevchenko <[email protected]> (reviewer:X86 PLATFORM DRIVERS - ARCH)
Cc: Boris Ostrovsky <[email protected]> (reviewer:XEN HYPERVISOR X86)
Cc: "Rafael J. Wysocki" <[email protected]> (supporter:HIBERNATION (aka Software Suspend, aka swsusp))
Cc: [email protected] (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT))
Cc: [email protected] (open list:FUNCTION HOOKS (FTRACE))
Cc: [email protected] (open list:PARAVIRT_OPS INTERFACE)
Cc: [email protected] (open list:PCI SUBSYSTEM)
Cc: [email protected] (open list:X86 PLATFORM DRIVERS - ARCH)
Cc: [email protected] (moderated list:XEN HYPERVISOR X86)
Cc: [email protected] (open list:HIBERNATION (aka Software Suspend, aka swsusp))
Cc: [email protected] (open list:MEMORY MANAGEMENT)



2023-05-16 19:52:15

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 19/20] x86: purgatory: include header for warn() declaration

From: Arnd Bergmann <[email protected]>

The purgatory code has uses parts of the decompressor and provides
its own warn() function, but has to include the corresponding
header file to avoid a -Wmissing-prototypes warning.

It turns out that this the function prototype actually differs
from the declaration, so change it to get a constant pointer
in the declaration and the other definition as well.

Signed-off-by: Arnd Bergmann <[email protected]>
---
arch/x86/boot/compressed/error.c | 2 +-
arch/x86/boot/compressed/error.h | 2 +-
arch/x86/purgatory/purgatory.c | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/boot/compressed/error.c b/arch/x86/boot/compressed/error.c
index c881878e56d3..ce5ed7d8265e 100644
--- a/arch/x86/boot/compressed/error.c
+++ b/arch/x86/boot/compressed/error.c
@@ -7,7 +7,7 @@
#include "misc.h"
#include "error.h"

-void warn(char *m)
+void warn(const char *m)
{
error_putstr("\n\n");
error_putstr(m);
diff --git a/arch/x86/boot/compressed/error.h b/arch/x86/boot/compressed/error.h
index 1de5821184f1..87062dea9a20 100644
--- a/arch/x86/boot/compressed/error.h
+++ b/arch/x86/boot/compressed/error.h
@@ -4,7 +4,7 @@

#include <linux/compiler.h>

-void warn(char *m);
+void warn(const char *m);
void error(char *m) __noreturn;

#endif /* BOOT_COMPRESSED_ERROR_H */
diff --git a/arch/x86/purgatory/purgatory.c b/arch/x86/purgatory/purgatory.c
index 7558139920f8..aea47e793963 100644
--- a/arch/x86/purgatory/purgatory.c
+++ b/arch/x86/purgatory/purgatory.c
@@ -14,6 +14,7 @@
#include <crypto/sha2.h>
#include <asm/purgatory.h>

+#include "../boot/compressed/error.h"
#include "../boot/string.h"

u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE] __section(".kexec-purgatory");
--
2.39.2


2023-05-16 19:53:12

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 06/20] x86: math-emu: include asm/fpu/regset.h

From: Arnd Bergmann <[email protected]>

The fpregs_soft_set/fpregs_soft_get functions are declared in a
header that is not included in the file that defines them, causing
a W=1 warning:

/home/arnd/arm-soc/arch/x86/math-emu/fpu_entry.c:638:5: error: no previous prototype for 'fpregs_soft_set' [-Werror=missing-prototypes]
638 | int fpregs_soft_set(struct task_struct *target,
| ^~~~~~~~~~~~~~~
/home/arnd/arm-soc/arch/x86/math-emu/fpu_entry.c:690:5: error: no previous prototype for 'fpregs_soft_get' [-Werror=missing-prototypes]
690 | int fpregs_soft_get(struct task_struct *target,

Include the file here to avoid the warning.

Signed-off-by: Arnd Bergmann <[email protected]>
---
arch/x86/math-emu/fpu_entry.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/math-emu/fpu_entry.c b/arch/x86/math-emu/fpu_entry.c
index 7fe56c594aa6..91c52ead1226 100644
--- a/arch/x86/math-emu/fpu_entry.c
+++ b/arch/x86/math-emu/fpu_entry.c
@@ -32,6 +32,7 @@
#include <asm/traps.h>
#include <asm/user.h>
#include <asm/fpu/api.h>
+#include <asm/fpu/regset.h>

#include "fpu_system.h"
#include "fpu_emu.h"
--
2.39.2


2023-05-16 19:53:42

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 18/20] x86: ioremap: add early_memremap_pgprot_adjust prototype

From: Arnd Bergmann <[email protected]>

early_memremap_pgprot_adjust() is a __weak function with a local
prototype, but x86 has a custom implementation that does not
see the prototype, causing a W=1 warning:

arch/x86/mm/ioremap.c:785:17: error: no previous prototype for 'early_memremap_pgprot_adjust' [-Werror=missing-prototypes]

Move the declaration into the global linux/io.h header to avoid this.

Signed-off-by: Arnd Bergmann <[email protected]>
---
include/linux/io.h | 5 +++++
mm/internal.h | 6 ------
2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/linux/io.h b/include/linux/io.h
index 308f4f0cfb93..7304f2a69960 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -68,6 +68,11 @@ void *devm_memremap(struct device *dev, resource_size_t offset,
size_t size, unsigned long flags);
void devm_memunmap(struct device *dev, void *addr);

+/* architectures can override this */
+pgprot_t __init early_memremap_pgprot_adjust(resource_size_t phys_addr,
+ unsigned long size, pgprot_t prot);
+
+
#ifdef CONFIG_PCI
/*
* The PCI specifications (Rev 3.0, 3.2.5 "Transaction Ordering and
diff --git a/mm/internal.h b/mm/internal.h
index 68410c6d97ac..e6029d94bdb2 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -178,12 +178,6 @@ extern unsigned long highest_memmap_pfn;
*/
#define MAX_RECLAIM_RETRIES 16

-/*
- * in mm/early_ioremap.c
- */
-pgprot_t __init early_memremap_pgprot_adjust(resource_size_t phys_addr,
- unsigned long size, pgprot_t prot);
-
/*
* in mm/vmscan.c:
*/
--
2.39.2


2023-05-16 19:54:04

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 02/20] x86: ce4100: Mark local functions as 'static'

From: Arnd Bergmann <[email protected]>

Two functions in this file are global but have no prototype in
a header and are not called from elsewhere, so they should
be static:

arch/x86/pci/ce4100.c:86:6: error: no previous prototype for 'sata_revid_init' [-Werror=missing-prototypes]
arch/x86/pci/ce4100.c:175:5: error: no previous prototype for 'bridge_read' [-Werror=missing-prototypes]

Signed-off-by: Arnd Bergmann <[email protected]>
---
arch/x86/pci/ce4100.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/pci/ce4100.c b/arch/x86/pci/ce4100.c
index 584c25b588b4..87313701f069 100644
--- a/arch/x86/pci/ce4100.c
+++ b/arch/x86/pci/ce4100.c
@@ -83,7 +83,7 @@ static void ehci_reg_read(struct sim_dev_reg *reg, u32 *value)
*value |= 0x100;
}

-void sata_revid_init(struct sim_dev_reg *reg)
+static void sata_revid_init(struct sim_dev_reg *reg)
{
reg->sim_reg.value = 0x01060100;
reg->sim_reg.mask = 0;
@@ -172,7 +172,7 @@ static inline void extract_bytes(u32 *value, int reg, int len)
*value &= mask;
}

-int bridge_read(unsigned int devfn, int reg, int len, u32 *value)
+static int bridge_read(unsigned int devfn, int reg, int len, u32 *value)
{
u32 av_bridge_base, av_bridge_limit;
int retval = 0;
--
2.39.2


2023-05-18 17:33:44

by Dave Hansen

[permalink] [raw]
Subject: Re: [PATCH 00/20] x86: address -Wmissing-prototype warnings

On 5/16/23 12:35, Arnd Bergmann wrote:
> The ones that are a bit awkward are those that just add a prototype to
> shut up the warning, but the prototypes are never used for calling the
> function because the only caller is in assembler code. I tried to come up
> with other ways to shut up the compiler using the asmlinkage annotation,
> but with no success.

I went looking for the same thing. It's too bad gcc doesn't have an
__attribute__ for it.

2023-05-18 22:15:51

by Dave Hansen

[permalink] [raw]
Subject: Re: [PATCH 00/20] x86: address -Wmissing-prototype warnings

On 5/16/23 12:35, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> This addresses all x86 specific prototype warnings. The majority of the
> patches should be straightforward, either adding an #include statement
> to get the right header, or ensuring that an unused global function is
> left out of the build when the prototype is hidden.
>
> The ones that are a bit awkward are those that just add a prototype to
> shut up the warning, but the prototypes are never used for calling the
> function because the only caller is in assembler code. I tried to come up
> with other ways to shut up the compiler using the asmlinkage annotation,
> but with no success.
>
> All of the warnings have to be addressed in some form before the warning
> can be enabled by default.

I picked up the ones that were blatantly obvious, but left out 03, 04,
10, 12 and 19 for the moment.

BTW, I think the i386 allyesconfig is getting pretty lightly tested
these days. I think you and I hit the same mlx4 __bad_copy_from()
compile issue.

2023-05-19 10:09:30

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 00/20] x86: address -Wmissing-prototype warnings

On Fri, May 19, 2023 at 12:56 AM Dave Hansen <[email protected]> wrote:
> On 5/16/23 12:35, Arnd Bergmann wrote:

> I picked up the ones that were blatantly obvious, but left out 03, 04,
> 10, 12 and 19 for the moment.

Btw, there is series that went unnoticed

https://lore.kernel.org/all/[email protected]/

I dunno why.

--
With Best Regards,
Andy Shevchenko

2023-05-19 12:11:34

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 00/20] x86: address -Wmissing-prototype warnings

On Thu, May 18, 2023, at 23:56, Dave Hansen wrote:
> On 5/16/23 12:35, Arnd Bergmann wrote:
>>
>> All of the warnings have to be addressed in some form before the warning
>> can be enabled by default.
>
> I picked up the ones that were blatantly obvious, but left out 03, 04,
> 10, 12 and 19 for the moment.

Ok, thanks!

I've already sent a fixed version of patch 10, let me know if you
need anything else for the other ones.

> BTW, I think the i386 allyesconfig is getting pretty lightly tested
> these days. I think you and I hit the same mlx4 __bad_copy_from()
> compile issue.

I did all my testing on randconfig builds, so I probably caught a lot
of the more obscure corner cases, but it doesn't always hit everything
that is in allyesconfig/allmodconfig.

Arnd