x86/cpu: fix prototype warning
PATCH v2 1/1 x86/cpu: fix prototype warning
This patch fix the following build warnings which because of missing include file:
arch/x86/kernel/cpu/cacheinfo.c:647:6: warning: no previous prototype for ‘cacheinfo_amd_init_llc_id’ [-Wmissing-prototypes] arch/x86/kernel/cpu/cacheinfo.c:686:6: warning: no previous prototype for ‘cacheinfo_hygon_init_llc_id’ [-Wmissing-prototypes] arch/x86/kernel/cpu/scattered.c:37:6: warning: no previous prototype for ‘init_scattered_cpuid_features’ [-Wmissing-prototypes] arch/x86/kernel/cpu/scattered.c:60:5: warning: no previous prototype for ‘get_scattered_cpuid_leaf’ [-Wmissing-prototypes] arch/x86/kernel/cpu/topology.c:25:5: warning: no previous prototype for ‘detect_extended_topology_early’ [-Wmissing-prototypes] arch/x86/kernel/cpu/topology.c:57:5: warning: no previous prototype for ‘detect_extended_topology’ [-Wmissing-prototypes]
---
v2: merge the series into a single patch
--- arch/x86/kernel/cpu/cacheinfo.c | 1 + arch/x86/kernel/cpu/scattered.c | 2 ++ arch/x86/kernel/cpu/topology.c | 2 ++ 3 files changed, 5 insertions(+)
arch/x86/kernel/cpu/cacheinfo.c +1 -0
@@ -19,6 +19,7 @@#include <asm/cpufeature.h> #include <asm/amd_nb.h> #include <asm/smp.h> +#include <asm/cacheinfo.h> #include "cpu.h"
arch/x86/kernel/cpu/scattered.c +2 -0
@@ -9,6 +9,8 @@#include <asm/apic.h> +#include "cpu.h" +struct cpuid_bit {u16 feature;u8 reg;
arch/x86/kernel/cpu/topology.c +2 -0
@@ -10,6 +10,8 @@#include <asm/pat.h> #include <asm/processor.h> +#include "cpu.h" +/* leaf 0xb SMT level */ #define SMT_LEVEL 0
Signature · 1 line
1.8.3.1
Borislav Petkov
maintainerQuoted 7 lines · Yi Wang
This patch fix the following build warnings which because of missing include file:
arch/x86/kernel/cpu/cacheinfo.c:647:6: warning: no previous prototype for ‘cacheinfo_amd_init_llc_id’ [-Wmissing-prototypes]arch/x86/kernel/cpu/cacheinfo.c:686:6: warning: no previous prototype for ‘cacheinfo_hygon_init_llc_id’ [-Wmissing-prototypes]arch/x86/kernel/cpu/scattered.c:37:6: warning: no previous prototype for ‘init_scattered_cpuid_features’ [-Wmissing-prototypes]arch/x86/kernel/cpu/scattered.c:60:5: warning: no previous prototype for ‘get_scattered_cpuid_leaf’ [-Wmissing-prototypes]
That function is gone in:
https://git.kernel.org/tip/43500e6f294d175602606c77bfb0d8cd4ea88b4f
You probably should run your test against tip/master.
Also, you should say in your commit message that this is an extra warning - -Wmissing-prototypes - which is not enabled by default but a W=1 one.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Borislav Petkov
maintainerQuoted 11 lines · Borislav Petkov
Quoted 7 lines · Yi Wang
This patch fix the following build warnings which because of missing include file:
arch/x86/kernel/cpu/cacheinfo.c:647:6: warning: no previous prototype for ‘cacheinfo_amd_init_llc_id’ [-Wmissing-prototypes]arch/x86/kernel/cpu/cacheinfo.c:686:6: warning: no previous prototype for ‘cacheinfo_hygon_init_llc_id’ [-Wmissing-prototypes]arch/x86/kernel/cpu/scattered.c:37:6: warning: no previous prototype for ‘init_scattered_cpuid_features’ [-Wmissing-prototypes]arch/x86/kernel/cpu/scattered.c:60:5: warning: no previous prototype for ‘get_scattered_cpuid_leaf’ [-Wmissing-prototypes]That function is gone in:
Quoted 7 lines
https://git.kernel.org/tip/43500e6f294d175602606c77bfb0d8cd4ea88b4f
You probably should run your test against tip/master.
Also, you should say in your commit message that this is an extra warning - -Wmissing-prototypes - which is not enabled by default but a W=1 one.
And frankly, I don't see why we should be fixing all those. So what if a global function does't have a previous prototype declaration?!
Micha, is there anything "useful" that warning bitches about or should we disable it?
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Borislav,
Quoted 2 lines · Borislav Petkov
And frankly, I don't see why we should be fixing all those. So what if a global function does't have a previous prototype declaration?!
Global function declarations must have a prototype definition, really.
Otherwise you can change the function signature and all callers which use the old unchanged prototype are hosed.
Thanks,
tglx
Borislav Petkov
maintainerQuoted 4 lines · Thomas Gleixner
Global function declarations must have a prototype definition, really.
Otherwise you can change the function signature and all callers which use the old unchanged prototype are hosed.
Ok, should we then enable this warning by default?
It is an extra warning now, behind W=1.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.From: Thomas Gleixner
Quoted 9 lines
Sent: 08 November 2018 15:36
Quoted 2 lines · Borislav Petkov
And frankly, I don't see why we should be fixing all those. So what if a global function does't have a previous prototype declaration?!
Global function declarations must have a prototype definition, really.
Otherwise you can change the function signature and all callers which use the old unchanged prototype are hosed.
I bet there are at least double-figures of real bugs out there.
The next on the list should be -Wwriteable-strings. Usually just needs a few 'const' sprinkled.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
tip-bot for Borislav Petkov
merge bot[tip:ras/core] x86/mce: Fix -Wmissing-prototypes warnings
In reply to Thomas Gleixnerx86/mce: Fix -Wmissing-prototypes warnings
Commit-ID: d813dfb28641306f66cf1e2c3586f39ab4f84b27 Gitweb: https://git.kernel.org/tip/d813dfb28641306f66cf1e2c3586f39ab4f84b27 Author: Borislav Petkov <[email protected]> AuthorDate: Fri, 9 Nov 2018 23:13:13 +0100 Committer: Borislav Petkov <[email protected]> CommitDate: Sat, 10 Nov 2018 11:19:16 +0100
x86/mce: Fix -Wmissing-prototypes warnings
Add the proper includes and make smca_get_name() static.
Fix an actual bug too which the warning triggered:
arch/x86/kernel/cpu/mcheck/therm_throt.c:395:39: error: conflicting \
types for ‘smp_thermal_interrupt’
asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r)
^~~~~~~~~~~~~~~~~~~~~
In file included from arch/x86/kernel/cpu/mcheck/therm_throt.c:29:
./arch/x86/include/asm/traps.h:107:17: note: previous declaration of \
‘smp_thermal_interrupt’ was here
asmlinkage void smp_thermal_interrupt(void);
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 3 ++- arch/x86/kernel/cpu/mcheck/therm_throt.c | 3 ++- arch/x86/kernel/cpu/mcheck/threshold.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +2 -1
@@ -23,6 +23,7 @@#include <linux/string.h> #include <asm/amd_nb.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -99,7 +100,7 @@ static u32 smca_bank_addrs[MAX_NR_BANKS][NR_BLOCKS] __ro_after_init = [0 ... MAX_NR_BANKS - 1] = { [0 ... NR_BLOCKS - 1] = -1 } }; -const char *smca_get_name (enum smca_bank_types t) +static const char *smca_get_name (enum smca_bank_types t) {if (t >=N_SMCA_BANK_TYPES )return NULL ;
arch/x86/kernel/cpu/mcheck/therm_throt.c +2 -1
@@ -25,6 +25,7 @@#include <linux/cpu.h> #include <asm/processor.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -390,7 +391,7 @@ static void unexpected_thermal_interrupt(void)static void (*smp_thermal_vector)(void ) = unexpected_thermal_interrupt; -asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r) +asmlinkage __visible void __irq_entry smp_thermal_interrupt(void) {entering_irq ();trace_thermal_apic_entry (THERMAL_APIC_VECTOR );
arch/x86/kernel/cpu/mcheck/threshold.c +1 -0
@@ -6,6 +6,7 @@#include <linux/kernel.h> #include <asm/irq_vectors.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/trace/irq_vectors.h>
Re: [tip:ras/core] x86/mce: Fix -Wmissing-prototypes warnings
On Sat, Nov 10, 2018 at 02:51:56AM -0800, tip-bot for Borislav Petkov wrote:
...
Quoted 13 lines
arch/x86/kernel/cpu/mcheck/therm_throt.c +1
-0@@ -25,6 +25,7 @@#include <linux/cpu.h> #include <asm/processor.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
arch/x86/kernel/cpu/mcheck/therm_throt.c static void unexpected_thermal_interrupt(void) · line 394
Quoted 5 lines
arch/x86/kernel/cpu/mcheck/therm_throt.c +1
-1@@ -390,7 +391,7 @@ static void unexpected_thermal_interrupt(void)static void (*smp_thermal_vector)(void ) = unexpected_thermal_interrupt; -asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r) +asmlinkage __visible void __irq_entry smp_thermal_interrupt(void)
And looking at this more, *this* is actually the wrong fix. Goes to show how important that warning is...
Anyway, all those interrupt handlers run with struct pt_regs * in %rdi, see the apic interrupt asm glue:
.macro apicinterrupt3 num sym do_sym
ENTRY(\sym)
UNWIND_HINT_IRET_REGS
pushq $~(\num).Lcommon_\sym:
call interrupt_entry
UNWIND_HINT_REGS indirect=1
call \do_sym /* rdi points to pt_regs */
^^^^^^^^^^
so the real fix should be this.
Even if the argument doesn't get used, its prototype should specify it as interrupt_entry() does all that preparation and puts a pt_regs ptr on stack.
---
From: Borislav Petkov <[email protected]>
Date: Fri, 9 Nov 2018 23:13:13 +0100
Subject: [PATCH] x86/mce: Fix -Wmissing-prototypes warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add the proper includes and make smca_get_name() static.
Fix an actual bug too which the warning triggered:
arch/x86/kernel/cpu/mcheck/therm_throt.c:395:39: error: conflicting \
types for ‘smp_thermal_interrupt’
asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r)
^~~~~~~~~~~~~~~~~~~~~
In file included from arch/x86/kernel/cpu/mcheck/therm_throt.c:29:
./arch/x86/include/asm/traps.h:107:17: note: previous declaration of \
‘smp_thermal_interrupt’ was here
asmlinkage void smp_thermal_interrupt(void);
--- arch/x86/include/asm/traps.h | 6 +++--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 5 +++-- arch/x86/kernel/cpu/mcheck/therm_throt.c | 1 + arch/x86/kernel/cpu/mcheck/threshold.c | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-)
arch/x86/include/asm/traps.h +3 -3
@@ -104,9 +104,9 @@ extern int panic_on_unrecovered_nmi;void math_emulate (struct math_emu_info *);#ifndef CONFIG_X86_32 -asmlinkage void smp_thermal_interrupt(void); -asmlinkage void smp_threshold_interrupt(void); -asmlinkage void smp_deferred_error_interrupt(void); +asmlinkage void smp_thermal_interrupt(struct pt_regs *); +asmlinkage void smp_threshold_interrupt(struct pt_regs *); +asmlinkage void smp_deferred_error_interrupt(struct pt_regs *);#endif extern void ist_enter (struct pt_regs *regs);
arch/x86/kernel/cpu/mcheck/mce_amd.c +3 -2
@@ -23,6 +23,7 @@#include <linux/string.h> #include <asm/amd_nb.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -99,7 +100,7 @@ static u32 smca_bank_addrs[MAX_NR_BANKS][NR_BLOCKS] __ro_after_init = [0 ... MAX_NR_BANKS - 1] = { [0 ... NR_BLOCKS - 1] = -1 } }; -const char *smca_get_name (enum smca_bank_types t) +static const char *smca_get_name (enum smca_bank_types t) {if (t >=N_SMCA_BANK_TYPES )return NULL ;
@@ -825,7 +826,7 @@ static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc)mce_log (&m); } -asmlinkage __visible void __irq_entry smp_deferred_error_interrupt(void) +asmlinkage __visible void __irq_entry smp_deferred_error_interrupt(struct pt_regs *r) {entering_irq ();trace_deferred_error_apic_entry (DEFERRED_ERROR_VECTOR );
arch/x86/kernel/cpu/mcheck/therm_throt.c +1 -0
@@ -25,6 +25,7 @@#include <linux/cpu.h> #include <asm/processor.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
arch/x86/kernel/cpu/mcheck/threshold.c +2 -1
@@ -6,6 +6,7 @@#include <linux/kernel.h> #include <asm/irq_vectors.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/trace/irq_vectors.h>
@@ -18,7 +19,7 @@ static void default_threshold_interrupt(void)void (*mce_threshold_vector)(void ) = default_threshold_interrupt; -asmlinkage __visible void __irq_entry smp_threshold_interrupt(void) +asmlinkage __visible void __irq_entry smp_threshold_interrupt(struct pt_regs *r) {entering_irq ();trace_threshold_apic_entry (THRESHOLD_APIC_VECTOR );
Signature · 7 lines
2.19.1
--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)Re: [tip:ras/core] x86/mce: Fix -Wmissing-prototypes warnings
Quoted 29 lines · Borislav Petkov
Fix an actual bug too which the warning triggered:
arch/x86/kernel/cpu/mcheck/therm_throt.c:395:39: error: conflicting \ types for ‘smp_thermal_interrupt’ asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r) ^~~~~~~~~~~~~~~~~~~~~In file included from
arch/x86/kernel/cpu/mcheck/therm_throt.c:29:
./arch/x86/include/asm/traps.h:107:17: note: previous declaration of \
‘smp_thermal_interrupt’ was here
asmlinkage voidsmp_thermal_interrupt(void);Signed-off-by Borislav Petkov <[email protected]>Cc Yi Wang <[email protected]>Cc Michael Matz <[email protected]>--- arch/x86/include/asm/traps.h | 6 +++--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 5 +++-- arch/x86/kernel/cpu/mcheck/therm_throt.c | 1 + arch/x86/kernel/cpu/mcheck/threshold.c | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-)arch/x86/include/asm/traps.h +0
-0
arch/x86/include/asm/traps.h extern int panic_on_unrecovered_nmi; · line 109
Quoted 9 lines
arch/x86/include/asm/traps.h +3
-3@@ -104,9 +104,9 @@ extern int panic_on_unrecovered_nmi;void math_emulate (struct math_emu_info *);#ifndef CONFIG_X86_32 -asmlinkage void smp_thermal_interrupt(void); -asmlinkage void smp_threshold_interrupt(void); -asmlinkage void smp_deferred_error_interrupt(void); +asmlinkage void smp_thermal_interrupt(struct pt_regs *); +asmlinkage void smp_threshold_interrupt(struct pt_regs *); +asmlinkage void smp_deferred_error_interrupt(struct pt_regs *);
Nit: please use full declarations in prototypes, i.e. 'struct pt_regs *regs' or so. Much of traps.h does this wrong so I guess this should be a separate cleanup patch.
arch/x86/include/asm/traps.h extern int panic_on_unrecovered_nmi; · line 112
Quoted 3 lines
arch/x86/include/asm/traps.h +2
-0+asmlinkage __visible void __irq_entry smp_deferred_error_interrupt(struct pt_regs *r) +asmlinkage __visible void __irq_entry smp_threshold_interrupt(struct pt_regs *r)
Please use the canonical name, i.e. 'regs'.
Thanks,
Ingo
Re: [tip:ras/core] x86/mce: Fix -Wmissing-prototypes warnings
Quoted 2 lines · Ingo Molnar
Nit: please use full declarations in prototypes, i.e. 'struct
pt_regs*regs' or so.
Done.
I'll test them some more and add them to tip:ras/core.
Quoted 2 lines
Much of
traps.hdoes this wrong so I guess this should be a separate cleanup patch.
See below.
Btw, do you remember why do_page_fault()'s error_code is "unsigned long" vs all the others which are only "long" type?
Because the error code pushed by the hardware is only a couple of (least significant) bits. 5 to be exact + there's bit 15 which is new for SGX. But all that should still fit in a long.
Hmmm?
---
arch/x86/include/asm/traps.h +22 -22
@@ -61,34 +61,34 @@ asmlinkage void xen_machine_check(void); asmlinkage void xen_simd_coprocessor_error(void);#endif -dotraplinkage void do_divide_error(struct pt_regs *, long); -dotraplinkage void do_debug(struct pt_regs *, long); -dotraplinkage void do_nmi(struct pt_regs *, long); -dotraplinkage void do_int3(struct pt_regs *, long); -dotraplinkage void do_overflow(struct pt_regs *, long); -dotraplinkage void do_bounds(struct pt_regs *, long); -dotraplinkage void do_invalid_op(struct pt_regs *, long); -dotraplinkage void do_device_not_available(struct pt_regs *, long); -dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *, long); -dotraplinkage void do_invalid_TSS(struct pt_regs *, long); -dotraplinkage void do_segment_not_present(struct pt_regs *, long); -dotraplinkage void do_stack_segment(struct pt_regs *, long); +dotraplinkage void do_divide_error(struct pt_regs *regs, long error_code); +dotraplinkage void do_debug(struct pt_regs *regs, long error_code); +dotraplinkage void do_nmi(struct pt_regs *regs, long error_code); +dotraplinkage void do_int3(struct pt_regs *regs, long error_code); +dotraplinkage void do_overflow(struct pt_regs *regs, long error_code); +dotraplinkage void do_bounds(struct pt_regs *regs, long error_code); +dotraplinkage void do_invalid_op(struct pt_regs *regs, long error_code); +dotraplinkage void do_device_not_available(struct pt_regs *regs, long error_code); +dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *regs, long error_code); +dotraplinkage void do_invalid_TSS(struct pt_regs *regs, long error_code); +dotraplinkage void do_segment_not_present(struct pt_regs *regs, long error_code); +dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_64 -dotraplinkage void do_double_fault(struct pt_regs *, long); +dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code);#endif -dotraplinkage void do_general_protection(struct pt_regs *, long); -dotraplinkage void do_page_fault(struct pt_regs *, unsigned long); -dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *, long); -dotraplinkage void do_coprocessor_error(struct pt_regs *, long); -dotraplinkage void do_alignment_check(struct pt_regs *, long); +dotraplinkage void do_general_protection(struct pt_regs *regs, long error_code); +dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code); +dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code); +dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code); +dotraplinkage void do_alignment_check(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_MCE -dotraplinkage void do_machine_check(struct pt_regs *, long); +dotraplinkage void do_machine_check(struct pt_regs *regs, long error_code);#endif -dotraplinkage void do_simd_coprocessor_error(struct pt_regs *, long); +dotraplinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_32 -dotraplinkage void do_iret_error(struct pt_regs *, long); +dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code);#endif -dotraplinkage void do_mce(struct pt_regs *, long); +dotraplinkage void do_mce(struct pt_regs *regs, long error_code);static inline int get_si_code (unsigned long condition) {
Signature · 4 lines
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)tip-bot for Borislav Petkov
merge bot[tip:x86/cleanups] x86/traps: Complete prototype declarations
In reply to Borislav Petkovx86/traps: Complete prototype declarations
Commit-ID: 95715a3f0e4f0abc4749c6a4fdf2c08c3ff18450 Gitweb: https://git.kernel.org/tip/95715a3f0e4f0abc4749c6a4fdf2c08c3ff18450 Author: Borislav Petkov <[email protected]> AuthorDate: Mon, 12 Nov 2018 13:20:36 +0100 Committer: Borislav Petkov <[email protected]> CommitDate: Tue, 13 Nov 2018 15:16:50 +0100
x86/traps: Complete prototype declarations
... with proper variable names.
No functional changes.
--- arch/x86/include/asm/traps.h | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
arch/x86/include/asm/traps.h +22 -22
@@ -61,34 +61,34 @@ asmlinkage void xen_machine_check(void); asmlinkage void xen_simd_coprocessor_error(void);#endif -dotraplinkage void do_divide_error(struct pt_regs *, long); -dotraplinkage void do_debug(struct pt_regs *, long); -dotraplinkage void do_nmi(struct pt_regs *, long); -dotraplinkage void do_int3(struct pt_regs *, long); -dotraplinkage void do_overflow(struct pt_regs *, long); -dotraplinkage void do_bounds(struct pt_regs *, long); -dotraplinkage void do_invalid_op(struct pt_regs *, long); -dotraplinkage void do_device_not_available(struct pt_regs *, long); -dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *, long); -dotraplinkage void do_invalid_TSS(struct pt_regs *, long); -dotraplinkage void do_segment_not_present(struct pt_regs *, long); -dotraplinkage void do_stack_segment(struct pt_regs *, long); +dotraplinkage void do_divide_error(struct pt_regs *regs, long error_code); +dotraplinkage void do_debug(struct pt_regs *regs, long error_code); +dotraplinkage void do_nmi(struct pt_regs *regs, long error_code); +dotraplinkage void do_int3(struct pt_regs *regs, long error_code); +dotraplinkage void do_overflow(struct pt_regs *regs, long error_code); +dotraplinkage void do_bounds(struct pt_regs *regs, long error_code); +dotraplinkage void do_invalid_op(struct pt_regs *regs, long error_code); +dotraplinkage void do_device_not_available(struct pt_regs *regs, long error_code); +dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *regs, long error_code); +dotraplinkage void do_invalid_TSS(struct pt_regs *regs, long error_code); +dotraplinkage void do_segment_not_present(struct pt_regs *regs, long error_code); +dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_64 -dotraplinkage void do_double_fault(struct pt_regs *, long); +dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code);#endif -dotraplinkage void do_general_protection(struct pt_regs *, long); -dotraplinkage void do_page_fault(struct pt_regs *, unsigned long); -dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *, long); -dotraplinkage void do_coprocessor_error(struct pt_regs *, long); -dotraplinkage void do_alignment_check(struct pt_regs *, long); +dotraplinkage void do_general_protection(struct pt_regs *regs, long error_code); +dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code); +dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code); +dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code); +dotraplinkage void do_alignment_check(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_MCE -dotraplinkage void do_machine_check(struct pt_regs *, long); +dotraplinkage void do_machine_check(struct pt_regs *regs, long error_code);#endif -dotraplinkage void do_simd_coprocessor_error(struct pt_regs *, long); +dotraplinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_32 -dotraplinkage void do_iret_error(struct pt_regs *, long); +dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code);#endif -dotraplinkage void do_mce(struct pt_regs *, long); +dotraplinkage void do_mce(struct pt_regs *regs, long error_code);static inline int get_si_code (unsigned long condition) {
tip-bot for Borislav Petkov
merge bot[tip:x86/cleanups] x86/traps: Complete prototype declarations
In reply to Borislav Petkovx86/traps: Complete prototype declarations
Commit-ID: 8e1599fcac2efda8b7d433ef69d2492f0b351e3f Gitweb: https://git.kernel.org/tip/8e1599fcac2efda8b7d433ef69d2492f0b351e3f Author: Borislav Petkov <[email protected]> AuthorDate: Mon, 12 Nov 2018 13:20:36 +0100 Committer: Borislav Petkov <[email protected]> CommitDate: Wed, 14 Nov 2018 13:46:29 +0100
x86/traps: Complete prototype declarations
... with proper variable names.
No functional changes.
--- arch/x86/include/asm/traps.h | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
arch/x86/include/asm/traps.h +22 -22
@@ -61,34 +61,34 @@ asmlinkage void xen_machine_check(void); asmlinkage void xen_simd_coprocessor_error(void);#endif -dotraplinkage void do_divide_error(struct pt_regs *, long); -dotraplinkage void do_debug(struct pt_regs *, long); -dotraplinkage void do_nmi(struct pt_regs *, long); -dotraplinkage void do_int3(struct pt_regs *, long); -dotraplinkage void do_overflow(struct pt_regs *, long); -dotraplinkage void do_bounds(struct pt_regs *, long); -dotraplinkage void do_invalid_op(struct pt_regs *, long); -dotraplinkage void do_device_not_available(struct pt_regs *, long); -dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *, long); -dotraplinkage void do_invalid_TSS(struct pt_regs *, long); -dotraplinkage void do_segment_not_present(struct pt_regs *, long); -dotraplinkage void do_stack_segment(struct pt_regs *, long); +dotraplinkage void do_divide_error(struct pt_regs *regs, long error_code); +dotraplinkage void do_debug(struct pt_regs *regs, long error_code); +dotraplinkage void do_nmi(struct pt_regs *regs, long error_code); +dotraplinkage void do_int3(struct pt_regs *regs, long error_code); +dotraplinkage void do_overflow(struct pt_regs *regs, long error_code); +dotraplinkage void do_bounds(struct pt_regs *regs, long error_code); +dotraplinkage void do_invalid_op(struct pt_regs *regs, long error_code); +dotraplinkage void do_device_not_available(struct pt_regs *regs, long error_code); +dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *regs, long error_code); +dotraplinkage void do_invalid_TSS(struct pt_regs *regs, long error_code); +dotraplinkage void do_segment_not_present(struct pt_regs *regs, long error_code); +dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_64 -dotraplinkage void do_double_fault(struct pt_regs *, long); +dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code);#endif -dotraplinkage void do_general_protection(struct pt_regs *, long); -dotraplinkage void do_page_fault(struct pt_regs *, unsigned long); -dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *, long); -dotraplinkage void do_coprocessor_error(struct pt_regs *, long); -dotraplinkage void do_alignment_check(struct pt_regs *, long); +dotraplinkage void do_general_protection(struct pt_regs *regs, long error_code); +dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code); +dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code); +dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code); +dotraplinkage void do_alignment_check(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_MCE -dotraplinkage void do_machine_check(struct pt_regs *, long); +dotraplinkage void do_machine_check(struct pt_regs *regs, long error_code);#endif -dotraplinkage void do_simd_coprocessor_error(struct pt_regs *, long); +dotraplinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_32 -dotraplinkage void do_iret_error(struct pt_regs *, long); +dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code);#endif -dotraplinkage void do_mce(struct pt_regs *, long); +dotraplinkage void do_mce(struct pt_regs *regs, long error_code);static inline int get_si_code (unsigned long condition) {
tip-bot for Borislav Petkov
merge bot[tip:x86/cleanups] x86/mce: Fix -Wmissing-prototypes warnings
In reply to Thomas Gleixnerx86/mce: Fix -Wmissing-prototypes warnings
Commit-ID: 83a204daa40315a38204493f60768910c8604e9c Gitweb: https://git.kernel.org/tip/83a204daa40315a38204493f60768910c8604e9c Author: Borislav Petkov <[email protected]> AuthorDate: Fri, 9 Nov 2018 23:13:13 +0100 Committer: Borislav Petkov <[email protected]> CommitDate: Tue, 13 Nov 2018 14:55:08 +0100
x86/mce: Fix -Wmissing-prototypes warnings
Add the proper includes and make smca_get_name() static.
Fix an actual bug too which the warning triggered:
arch/x86/kernel/cpu/mcheck/therm_throt.c:395:39: error: conflicting \
types for ‘smp_thermal_interrupt’
asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r)
^~~~~~~~~~~~~~~~~~~~~
In file included from arch/x86/kernel/cpu/mcheck/therm_throt.c:29:
./arch/x86/include/asm/traps.h:107:17: note: previous declaration of \
‘smp_thermal_interrupt’ was here
asmlinkage void smp_thermal_interrupt(void);
--- arch/x86/include/asm/traps.h | 6 +++--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 5 +++-- arch/x86/kernel/cpu/mcheck/therm_throt.c | 1 + arch/x86/kernel/cpu/mcheck/threshold.c | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-)
arch/x86/include/asm/traps.h +3 -3
@@ -104,9 +104,9 @@ extern int panic_on_unrecovered_nmi;void math_emulate (struct math_emu_info *);#ifndef CONFIG_X86_32 -asmlinkage void smp_thermal_interrupt(void); -asmlinkage void smp_threshold_interrupt(void); -asmlinkage void smp_deferred_error_interrupt(void); +asmlinkage void smp_thermal_interrupt(struct pt_regs *regs); +asmlinkage void smp_threshold_interrupt(struct pt_regs *regs); +asmlinkage void smp_deferred_error_interrupt(struct pt_regs *regs);#endif extern void ist_enter (struct pt_regs *regs);
arch/x86/kernel/cpu/mcheck/mce_amd.c +3 -2
@@ -23,6 +23,7 @@#include <linux/string.h> #include <asm/amd_nb.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -99,7 +100,7 @@ static u32 smca_bank_addrs[MAX_NR_BANKS][NR_BLOCKS] __ro_after_init = [0 ... MAX_NR_BANKS - 1] = { [0 ... NR_BLOCKS - 1] = -1 } }; -const char *smca_get_name (enum smca_bank_types t) +static const char *smca_get_name (enum smca_bank_types t) {if (t >=N_SMCA_BANK_TYPES )return NULL ;
@@ -825,7 +826,7 @@ static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc)mce_log (&m); } -asmlinkage __visible void __irq_entry smp_deferred_error_interrupt(void) +asmlinkage __visible void __irq_entry smp_deferred_error_interrupt(struct pt_regs *regs) {entering_irq ();trace_deferred_error_apic_entry (DEFERRED_ERROR_VECTOR );
arch/x86/kernel/cpu/mcheck/therm_throt.c +1 -0
@@ -25,6 +25,7 @@#include <linux/cpu.h> #include <asm/processor.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
arch/x86/kernel/cpu/mcheck/threshold.c +2 -1
@@ -6,6 +6,7 @@#include <linux/kernel.h> #include <asm/irq_vectors.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/trace/irq_vectors.h>
@@ -18,7 +19,7 @@ static void default_threshold_interrupt(void)void (*mce_threshold_vector)(void ) = default_threshold_interrupt; -asmlinkage __visible void __irq_entry smp_threshold_interrupt(void) +asmlinkage __visible void __irq_entry smp_threshold_interrupt(struct pt_regs *regs) {entering_irq ();trace_threshold_apic_entry (THRESHOLD_APIC_VECTOR );
tip-bot for Borislav Petkov
merge bot[tip:x86/cleanups] x86/mce: Fix -Wmissing-prototypes warnings
In reply to Thomas Gleixnerx86/mce: Fix -Wmissing-prototypes warnings
Commit-ID: 68b5e4326e4b8ac9080835005d8254fed0fb3c56 Gitweb: https://git.kernel.org/tip/68b5e4326e4b8ac9080835005d8254fed0fb3c56 Author: Borislav Petkov <[email protected]> AuthorDate: Fri, 9 Nov 2018 23:13:13 +0100 Committer: Borislav Petkov <[email protected]> CommitDate: Wed, 14 Nov 2018 13:46:26 +0100
x86/mce: Fix -Wmissing-prototypes warnings
Add the proper includes and make smca_get_name() static.
Fix an actual bug too which the warning triggered:
arch/x86/kernel/cpu/mcheck/therm_throt.c:395:39: error: conflicting \
types for ‘smp_thermal_interrupt’
asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r)
^~~~~~~~~~~~~~~~~~~~~
In file included from arch/x86/kernel/cpu/mcheck/therm_throt.c:29:
./arch/x86/include/asm/traps.h:107:17: note: previous declaration of \
‘smp_thermal_interrupt’ was here
asmlinkage void smp_thermal_interrupt(void);
--- arch/x86/include/asm/traps.h | 6 +++--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 5 +++-- arch/x86/kernel/cpu/mcheck/therm_throt.c | 3 ++- arch/x86/kernel/cpu/mcheck/threshold.c | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-)
arch/x86/include/asm/traps.h +3 -3
@@ -104,9 +104,9 @@ extern int panic_on_unrecovered_nmi;void math_emulate (struct math_emu_info *);#ifndef CONFIG_X86_32 -asmlinkage void smp_thermal_interrupt(void); -asmlinkage void smp_threshold_interrupt(void); -asmlinkage void smp_deferred_error_interrupt(void); +asmlinkage void smp_thermal_interrupt(struct pt_regs *regs); +asmlinkage void smp_threshold_interrupt(struct pt_regs *regs); +asmlinkage void smp_deferred_error_interrupt(struct pt_regs *regs);#endif extern void ist_enter (struct pt_regs *regs);
arch/x86/kernel/cpu/mcheck/mce_amd.c +3 -2
@@ -23,6 +23,7 @@#include <linux/string.h> #include <asm/amd_nb.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -99,7 +100,7 @@ static u32 smca_bank_addrs[MAX_NR_BANKS][NR_BLOCKS] __ro_after_init = [0 ... MAX_NR_BANKS - 1] = { [0 ... NR_BLOCKS - 1] = -1 } }; -const char *smca_get_name (enum smca_bank_types t) +static const char *smca_get_name (enum smca_bank_types t) {if (t >=N_SMCA_BANK_TYPES )return NULL ;
@@ -825,7 +826,7 @@ static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc)mce_log (&m); } -asmlinkage __visible void __irq_entry smp_deferred_error_interrupt(void) +asmlinkage __visible void __irq_entry smp_deferred_error_interrupt(struct pt_regs *regs) {entering_irq ();trace_deferred_error_apic_entry (DEFERRED_ERROR_VECTOR );
arch/x86/kernel/cpu/mcheck/therm_throt.c +2 -1
@@ -25,6 +25,7 @@#include <linux/cpu.h> #include <asm/processor.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -390,7 +391,7 @@ static void unexpected_thermal_interrupt(void)static void (*smp_thermal_vector)(void ) = unexpected_thermal_interrupt; -asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r) +asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *regs) {entering_irq ();trace_thermal_apic_entry (THERMAL_APIC_VECTOR );
arch/x86/kernel/cpu/mcheck/threshold.c +2 -1
@@ -6,6 +6,7 @@#include <linux/kernel.h> #include <asm/irq_vectors.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/trace/irq_vectors.h>
@@ -18,7 +19,7 @@ static void default_threshold_interrupt(void)void (*mce_threshold_vector)(void ) = default_threshold_interrupt; -asmlinkage __visible void __irq_entry smp_threshold_interrupt(void) +asmlinkage __visible void __irq_entry smp_threshold_interrupt(struct pt_regs *regs) {entering_irq ();trace_threshold_apic_entry (THRESHOLD_APIC_VECTOR );
Hi,
Quoted 5 lines · Borislav Petkov
And frankly, I don't see why we should be fixing all those. So what if a global function does't have a previous prototype declaration?!
Micha, is there anything "useful" that warning bitches about or should we disable it?
What tglx said. If you don't intend such functions to be called from other units make them static, if you do intend them to be callable declare the properly.
[There's also one subtle issue with argument promotions. prototypeless functions are called as if they are declared "int name()" that is default argument promotions take place (float->double, {char,short}->int), which won't happen with prototypes, and argument type conversions won't take place (as no parameter types are known). This might lead to different values between calling a prototyped and a prototype-less function arriving at the function even though the call expression looked the same]
Ciao,
Michael.
Borislav Petkov
maintainerQuoted 4 lines · Michael Matz
What tglx said. If you don't intend such functions to be called from other units make them static, if you do intend them to be callable declare the properly.
Quoted 8 lines
[There's also one subtle issue with argument promotions. prototypeless functions are called as if they are declared "int
name()" that is default argument promotions take place (float->double, {char,short}->int), which won't happen with prototypes, and argument type conversions won't take place (as no parameter types are known). This might lead to different values between calling a prototyped and a prototype-less function arriving at the function even though the call expression looked the same]
Eww, that's yucky.
Ok, so we should enalbe this warning by default then. And doing that in the main Makefile gives ~1400 warnings on an allmodconfig build.
Yi Wang, I guess you have a long road in front of you. :-)
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.A message that is not in the archive (sent off-list or not yet received): [email protected]
Borislav Petkov
maintainerQuoted 2 lines · On Fri, Nov 09, 2018 at 08:43:12AM +0800, [email protected] wrote:
Yeah, so that is. However, I suppose we should not enable this by default before we fix ALL of these warning,
Yeah, the build is really noisy now.
Quoted 1 line
which is really a hard work. :)
Yeah, I wonder if adding this to a kernel janitors TODO list or somesuch would help speeding up the process.
Maybe Greg knows.
Greg, the question is whether we can get people to help out with
-Wmissing-prototypes
fixes around the tree. Currently, there are ~1400 warnings and we want to have 0 and then add that option to the main Makefile.
It is very easy to do: you simply build the kernel with W=1, choose one -Wmissing-prototypes warning and fix it by adding a function prototype or declaring the function static.
It should be a pretty easy for newbies to get involved...
Quoted 2 lines
Aha, I will try my best to to work on this, and as you said, that's a long road to go, so maybe I would only work on modules which I am familiar with. ;-)
Sounds good.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 17 lines · Borislav Petkov
Quoted 2 lines · On Fri, Nov 09, 2018 at 08:43:12AM +0800, [email protected] wrote:
Yeah, so that is. However, I suppose we should not enable this by default before we fix ALL of these warning,
Yeah, the build is really noisy now.
Quoted 1 line
which is really a hard work. :)
Yeah, I wonder if adding this to a kernel janitors TODO list or somesuch would help speeding up the process.
Maybe Greg knows.
Greg, the question is whether we can get people to help out with
-Wmissing-prototypes
Quoted 8 lines
fixes around the tree. Currently, there are ~1400 warnings and we want to have 0 and then add that option to the main
Makefile.It is very easy to do: you simply build the kernel with W=1, choose one -Wmissing-prototypes warning and fix it by adding a function prototype or declaring the function static.
It should be a pretty easy for newbies to get involved...
Sure, sounds like a good task. Post it to the driverdevel mailing list and see if people are interested.
thanks,
greg k-h
Borislav Petkov
maintainerQuoted 2 lines · Greg KH
Sure, sounds like a good task. Post it to the driverdevel mailing list and see if people are interested.
By "driverdevel" do you mean this guy, per chance:
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
?
Also, I guess I should send to [email protected] too, no?
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 7 lines · Borislav Petkov
Quoted 2 lines · Greg KH
Sure, sounds like a good task. Post it to the driverdevel mailing list and see if people are interested.
By "driverdevel" do you mean this guy, per chance:
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Yes.
Quoted 1 line
Also, I guess I should send to [email protected] too, no?
I don't know if that list is still alive, but it could not hurt :)
Borislav Petkov
maintainerQuoted 3 lines · Michael Matz
What tglx said. If you don't intend such functions to be called from other units make them static, if you do intend them to be callable declare the properly.
Well, I'll be damned!
That just caught two bugs, the smp_thermal_interrupt() is *exactly* what the warning is supposed to catch - functions with changed prototype!
---
From: Borislav Petkov <[email protected]>
Date: Fri, 9 Nov 2018 23:13:13 +0100
Subject: [PATCH] x86/mce: Fix -Wmissing-prototypes warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add the proper includes and make smca_get_name() static.
Fix an actual bug too which the warning triggered:
arch/x86/kernel/cpu/mcheck/therm_throt.c:395:39: error: conflicting \
types for ‘smp_thermal_interrupt’
asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r)
^~~~~~~~~~~~~~~~~~~~~
In file included from arch/x86/kernel/cpu/mcheck/therm_throt.c:29:
./arch/x86/include/asm/traps.h:107:17: note: previous declaration of \
‘smp_thermal_interrupt’ was here
asmlinkage void smp_thermal_interrupt(void);
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 3 ++- arch/x86/kernel/cpu/mcheck/therm_throt.c | 3 ++- arch/x86/kernel/cpu/mcheck/threshold.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +2 -1
@@ -23,6 +23,7 @@#include <linux/string.h> #include <asm/amd_nb.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -99,7 +100,7 @@ static u32 smca_bank_addrs[MAX_NR_BANKS][NR_BLOCKS] __ro_after_init = [0 ... MAX_NR_BANKS - 1] = { [0 ... NR_BLOCKS - 1] = -1 } }; -const char *smca_get_name (enum smca_bank_types t) +static const char *smca_get_name (enum smca_bank_types t) {if (t >=N_SMCA_BANK_TYPES )return NULL ;
arch/x86/kernel/cpu/mcheck/therm_throt.c +2 -1
@@ -26,6 +26,7 @@#include <linux/cpu.h> #include <asm/processor.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -391,7 +392,7 @@ static void unexpected_thermal_interrupt(void)static void (*smp_thermal_vector)(void ) = unexpected_thermal_interrupt; -asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r) +asmlinkage __visible void __irq_entry smp_thermal_interrupt(void) {entering_irq ();trace_thermal_apic_entry (THERMAL_APIC_VECTOR );
arch/x86/kernel/cpu/mcheck/threshold.c +1 -0
@@ -6,6 +6,7 @@#include <linux/kernel.h> #include <asm/irq_vectors.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/mce.h> #include <asm/trace/irq_vectors.h>
Signature · 7 lines
2.19.1
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.