x86/kernel: Fix more -Wmissing-prototypes warnings
Subsystems (7)
Borislav Petkov
maintainerPATCH 1/1 x86/kernel: Fix more -Wmissing-prototypes warnings
From: Borislav Petkov <[email protected]>
... with the goal of eventually enabling -Wmissing-prototypes by default. At least on x86.
Make functions static where possible, otherwise add prototypes or make them visible through includes.
asm/trace/ changes courtesy of Steven Rostedt <[email protected]>.
--- arch/x86/include/asm/setup.h | 3 +++ arch/x86/include/asm/trace/exceptions.h | 1 + arch/x86/include/asm/trace/irq_vectors.h | 1 + arch/x86/include/asm/traps.h | 5 +++++ arch/x86/kernel/apic/apic.c | 1 + arch/x86/kernel/apic/apic_flat_64.c | 7 ++++--- arch/x86/kernel/apic/vector.c | 1 + arch/x86/kernel/apic/x2apic_uv_x.c | 4 ++-- arch/x86/kernel/asm-offsets.c | 3 ++- arch/x86/kernel/cpu/amd.c | 1 + arch/x86/kernel/cpu/aperfmperf.c | 1 + arch/x86/kernel/cpu/bugs.c | 2 ++ arch/x86/kernel/cpu/cacheinfo.c | 1 + arch/x86/kernel/cpu/scattered.c | 3 ++- arch/x86/kernel/cpu/topology.c | 2 ++ arch/x86/kernel/fpu/xstate.c | 2 +- arch/x86/kernel/kprobes/common.h | 2 ++ arch/x86/kernel/sysfb_efi.c | 3 +++ arch/x86/kernel/tracepoint.c | 1 + include/acpi/cppc_acpi.h | 3 +++ include/linux/kprobes.h | 3 +++ 21 files changed, 42 insertions(+), 8 deletions(-)
arch/x86/include/asm/setup.h +3 -0
@@ -46,6 +46,9 @@ extern unsigned long saved_video_mode;extern void reserve_standard_io_resources (void );extern void i386_reserve_resources (void ); +extern unsigned long __startup_64 (unsigned long physaddr,struct boot_params *bp); +extern unsigned long __startup_secondary_64 (void ); +extern int early_make_pgtable (unsigned long address);#ifdef CONFIG_X86_INTEL_MID extern void x86_intel_mid_early_setup (void );
arch/x86/include/asm/trace/exceptions.h +1 -0
@@ -45,6 +45,7 @@ DEFINE_PAGE_FAULT_EVENT(page_fault_user);DEFINE_PAGE_FAULT_EVENT (page_fault_kernel);#undef TRACE_INCLUDE_PATH +#undef TRACE_INCLUDE_FILE#define TRACE_INCLUDE_PATH .#define TRACE_INCLUDE_FILE exceptions#endif /* _TRACE_PAGE_FAULT_H */
arch/x86/include/asm/trace/irq_vectors.h +1 -0
@@ -389,6 +389,7 @@ TRACE_EVENT(vector_free_moved,#endif /* CONFIG_X86_LOCAL_APIC */ #undef TRACE_INCLUDE_PATH +#undef TRACE_INCLUDE_FILE#define TRACE_INCLUDE_PATH .#define TRACE_INCLUDE_FILE irq_vectors#endif /* _TRACE_IRQ_VECTORS_H */
arch/x86/include/asm/traps.h +5 -0
@@ -113,6 +113,11 @@ asmlinkage void smp_threshold_interrupt(struct pt_regs *regs); asmlinkage void smp_deferred_error_interrupt(struct pt_regs *regs);#endif +void smp_apic_timer_interrupt (struct pt_regs *regs); +void smp_spurious_interrupt (struct pt_regs *regs); +void smp_error_interrupt (struct pt_regs *regs); +asmlinkage void smp_irq_move_cleanup_interrupt(void); +extern void ist_enter (struct pt_regs *regs);extern void ist_exit (struct pt_regs *regs);extern void ist_begin_non_atomic (struct pt_regs *regs);
arch/x86/kernel/apic/apic.c +1 -0
@@ -44,6 +44,7 @@#include <asm/mpspec.h> #include <asm/i8259.h> #include <asm/proto.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/io_apic.h> #include <asm/desc.h>
arch/x86/kernel/apic/apic_flat_64.c +4 -3
@@ -8,6 +8,7 @@* Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and * James Cleverdon. */ +#include <linux/acpi.h> #include <linux/errno.h> #include <linux/threads.h> #include <linux/cpumask.h>
@@ -16,13 +17,13 @@#include <linux/ctype.h> #include <linux/hardirq.h> #include <linux/export.h> +#include <asm/smp.h> -#include <asm/apic.h> #include <asm/ipi.h> +#include <asm/apic.h> +#include <asm/apic_flat_64.h> #include <asm/jailhouse_para.h> -#include <linux/acpi.h> -static struct apic apic_physflat;static struct apic apic_flat;
arch/x86/kernel/apic/vector.c +1 -0
@@ -18,6 +18,7 @@#include <linux/slab.h> #include <asm/irqdomain.h> #include <asm/hw_irq.h> +#include <asm/traps.h> #include <asm/apic.h> #include <asm/i8259.h> #include <asm/desc.h>
arch/x86/kernel/apic/x2apic_uv_x.c +2 -2
@@ -1079,7 +1079,7 @@ late_initcall(uv_init_heartbeat);#endif /* !CONFIG_HOTPLUG_CPU */ /* Direct Legacy VGA I/O traffic to designated IOH */ -int uv_set_vga_state (struct pci_dev *pdev,bool decode,unsigned int command_bits,u32 flags) +static int uv_set_vga_state (struct pci_dev *pdev,bool decode,unsigned int command_bits,u32 flags) {int domain, bus, rc;
@@ -1148,7 +1148,7 @@ static void get_mn(struct mn *mnp) mnp->m_shift = mnp->m_val ?64 - mnp->m_val :0 ; } -void __init uv_init_hub_info (struct uv_hub_info_s *hi) +static void __init uv_init_hub_info (struct uv_hub_info_s *hi) {union uvh_node_id_u node_id;struct mn mn;
arch/x86/kernel/asm-offsets.c +2 -1
@@ -29,7 +29,8 @@# include "asm-offsets_64.c" #endif -void common (void ) { +static void __used common (void ) +{BLANK ();OFFSET (TASK_threadsp, task_struct, thread.sp);#ifdef CONFIG_STACKPROTECTOR
arch/x86/kernel/cpu/amd.c +1 -0
@@ -15,6 +15,7 @@#include <asm/smp.h> #include <asm/pci-direct.h> #include <asm/delay.h> +#include <asm/debugreg.h> #ifdef CONFIG_X86_64 # include <asm/mmconfig.h>
arch/x86/kernel/cpu/aperfmperf.c +1 -0
@@ -12,6 +12,7 @@#include <linux/ktime.h> #include <linux/math64.h> #include <linux/percpu.h> +#include <linux/cpufreq.h> #include <linux/smp.h> #include "cpu.h"
arch/x86/kernel/cpu/bugs.c +2 -0
@@ -32,6 +32,8 @@#include <asm/e820/api.h> #include <asm/hypervisor.h> +#include "cpu.h" +static void __init spectre_v2_select_mitigation (void );static void __init ssb_select_mitigation (void );static void __init l1tf_select_mitigation (void );
arch/x86/kernel/cpu/cacheinfo.c +1 -0
@@ -17,6 +17,7 @@#include <linux/pci.h> #include <asm/cpufeature.h> +#include <asm/cacheinfo.h> #include <asm/amd_nb.h> #include <asm/smp.h>
arch/x86/kernel/cpu/scattered.c +2 -1
@@ -5,9 +5,10 @@#include <linux/cpu.h> #include <asm/pat.h> +#include <asm/apic.h> #include <asm/processor.h> -#include <asm/apic.h> +#include "cpu.h" struct cpuid_bit {u16 feature;
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
arch/x86/kernel/fpu/xstate.c +1 -1
@@ -811,7 +811,7 @@ void fpu__resume_cpu(void)* * Note: does not work for compacted buffers. */ -void *__raw_xsave_addr (struct xregs_state *xsave,int xstate_feature_mask) +static void *__raw_xsave_addr (struct xregs_state *xsave,int xstate_feature_mask) {int feature_nr =fls64 (xstate_feature_mask) -1 ;
arch/x86/kernel/kprobes/common.h +2 -0
@@ -91,6 +91,8 @@ extern int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn);extern void synthesize_reljump (void *dest,void *from,void *to);extern void synthesize_relcall (void *dest,void *from,void *to); +extern void *trampoline_handler (struct pt_regs *regs); +#ifdef CONFIG_OPTPROBES extern int setup_detour_execution (struct kprobe *p,struct pt_regs *regs,int reenter);extern unsigned long __recover_optprobed_insn (kprobe_opcode_t *buf,unsigned long addr);
arch/x86/kernel/sysfb_efi.c +3 -0
@@ -19,12 +19,15 @@#include <linux/dmi.h> #include <linux/err.h> +#include <linux/efi.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/mm.h> #include <linux/pci.h> #include <linux/screen_info.h> #include <video/vga.h> + +#include <asm/efi.h> #include <asm/sysfb.h> enum {
arch/x86/kernel/tracepoint.c +1 -0
@@ -11,6 +11,7 @@#include <asm/hw_irq.h> #include <asm/desc.h> #include <asm/trace/exceptions.h> +#include <asm/trace/irq_vectors.h> DEFINE_STATIC_KEY_FALSE (trace_pagefault_key);
include/acpi/cppc_acpi.h +3 -0
@@ -142,5 +142,8 @@ extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);extern int cppc_get_perf_caps (int cpu,struct cppc_perf_caps *caps);extern int acpi_get_psd_map (struct cppc_cpudata **);extern unsigned int cppc_get_transition_latency (int cpu); +extern bool cpc_ffh_supported (void ); +extern int cpc_read_ffh (int cpunum,struct cpc_reg *reg,u64 *val); +extern int cpc_write_ffh (int cpunum,struct cpc_reg *reg,u64 val);#endif /* _CPPC_ACPI_H*/
include/linux/kprobes.h +3 -0
@@ -379,6 +379,9 @@ int enable_kprobe(struct kprobe *kp);void dump_kprobe (struct kprobe *kp); +void __weak *alloc_insn_page (void ); +void __weak free_insn_page (void *page); +#else /* !CONFIG_KPROBES: */ static inline int kprobes_built_in (void )
Signature · 1 line
2.19.1
Quoted 6 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
... with the goal of eventually enabling -Wmissing-prototypes by default. At least on x86.
Quoted 6 lines
Make functions static where possible, otherwise add prototypes or make them visible through includes.
asm/trace/ changes courtesy of Steven Rostedt <[email protected]>.
Signed-off-by Borislav Petkov <[email protected]>
for the ACPI and cpufreq bits.
Masami Hiramatsu
maintainerHi Borislav,
Quoted 7 lines · On Wed, 5 Dec 2018 11:11:31 +0100 Borislav Petkov <[email protected]> wrote:
From: Borislav Petkov <[email protected]>
... with the goal of eventually enabling -Wmissing-prototypes by default. At least on x86.
Make functions static where possible, otherwise add prototypes or make them visible through includes.
OK, and I have some comments for kprobe's parts.
[...]
arch/x86/kernel/kprobes/common.h extern int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn); · line 95
Quoted 10 lines
arch/x86/kernel/kprobes/common.h +2
-0@@ -91,6 +91,8 @@ extern int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn);extern void synthesize_reljump (void *dest,void *from,void *to);extern void synthesize_relcall (void *dest,void *from,void *to); +extern void *trampoline_handler (struct pt_regs *regs); +
I would like to put this prototype inside arch/x86/kernel/kprobes/core.c, since that is locally used.
Quoted 3 lines
arch/x86/kernel/kprobes/common.h +0
-0#ifdef CONFIG_OPTPROBES extern int setup_detour_execution (struct kprobe *p,struct pt_regs *regs,int reenter);extern unsigned long __recover_optprobed_insn (kprobe_opcode_t *buf,unsigned long addr);
[...]
include/linux/kprobes.h int enable_kprobe(struct kprobe *kp); · line 383
Quoted 10 lines
include/linux/kprobes.h +2
-0@@ -379,6 +379,9 @@ int enable_kprobe(struct kprobe *kp);void dump_kprobe (struct kprobe *kp); +void __weak *alloc_insn_page (void ); +void __weak free_insn_page (void *page);
Should we declare prototypes for __weak functions? Anyway, we should remove __weak from the prototypes.
Thank you,
Signature · 1 line
Masami Hiramatsu <[email protected]>
Borislav Petkov
maintainerQuoted 2 lines · Masami Hiramatsu
I would like to put this prototype inside
arch/x86/kernel/kprobes/core.c, since that is locally used.
Done.
Quoted 2 lines
Should we declare prototypes for
__weakfunctions? Anyway, we should remove__weakfrom the prototypes.
And done.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Ingo Molnar
Reviewed-byQuoted 5 lines · Borislav Petkov
Quoted 2 lines · Masami Hiramatsu
I would like to put this prototype inside
arch/x86/kernel/kprobes/core.c, since that is locally used.Done.
Also, preferably the prototype should be eliminated via proper ordering of functions from lower level to higher levels.
On the rest:
Thanks,
Ingo
Borislav Petkov
maintainerQuoted 2 lines · Ingo Molnar
Also, preferably the prototype should be eliminated via proper ordering of functions from lower level to higher levels.
Well, that trampoline_handler() is special as we call it from inline asm and I see Masami has marked it __visible etc.
So doing this below still builds and the trampoline_handler doesn't get discarded but maybe there's a reason for it not being static.
Masami?
---
arch/x86/kernel/kprobes/core.c +1 -3
@@ -66,8 +66,6 @@#include "common.h" -void *trampoline_handler (struct pt_regs *regs); - DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
@@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);/* * Called from kretprobe_trampoline */ -__visible __used void *trampoline_handler(struct pt_regs *regs) +static __used void *trampoline_handler (struct pt_regs *regs) {struct kretprobe_instance *ri =NULL ;struct hlist_head *head, empty_rp;
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Hi,
Quoted 11 lines · On Wed, 5 Dec 2018 18:15:47 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 2 lines · Ingo Molnar
Also, preferably the prototype should be eliminated via proper ordering of functions from lower level to higher levels.
Well, that
trampoline_handler()is special as we call it from inline asm and I see Masami has marked it__visibleetc.So doing this below still builds and the
trampoline_handlerdoesn't get discarded but maybe there's a reason for it not being static.Masami?
Hmm, I just thought that the symbol only referred from inline asm should be visible. But if it is OK for any version of supported gcc and clang, I'm good to remove it. :-) (IOW, I just concerned about older gcc)
Thank you,
Quoted 30 lines
---
arch/x86/kernel/kprobes/core.c +1
-3@@ -66,8 +66,6 @@#include "common.h" -void *trampoline_handler (struct pt_regs *regs); - DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);@@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);/* * Called from kretprobe_trampoline */ -__visible __used void *trampoline_handler(struct pt_regs *regs) +static __used void *trampoline_handler (struct pt_regs *regs) {struct kretprobe_instance *ri =NULL ;struct hlist_head *head, empty_rp;Signature · 5 lines
-- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.
Signature · 1 line
Masami Hiramatsu <[email protected]>
Borislav Petkov
maintainerQuoted 3 lines · Masami Hiramatsu
Hmm, I just thought that the symbol only referred from inline asm should be visible. But if it is OK for any version of supported gcc and clang, I'm good to remove it. :-) (IOW, I just concerned about older gcc)
I just tried two gcc versions: 8.2 and 4.8.5. Both asms looks good:
ffffffff81044690 <kretprobe_trampoline>:
...
ffffffff810446ab: 41 57 push %r15 ffffffff810446ad: 48 89 e7 mov %rsp,%rdi ffffffff810446b0: e8 db 01 00 00 callq ffffffff81044890 <trampoline_handler>
there's the CALL...
ffffffff810446b5: 48 89 84 24 98 00 00 mov %rax,0x98(%rsp) ffffffff810446bc: 00
... and the handler is at the expected address.
ffffffff81044890 <trampoline_handler>:
ffffffff81044890: e8 ab c9 7b 00 callq ffffffff81801240 <__fentry__> ffffffff81044895: 41 57 push %r15 ffffffff81044897: 41 56 push %r14 ffffffff81044899: 41 55 push %r13 ffffffff8104489b: 49 89 fd mov %rdi,%r13
Dunno, if you feel like there might be some trouble with some compilers, I can keep the hunk below as a separate patch and revert it when it explodes somewhere...?
Quoted 38 lines
Reviewed-by Masami Hiramatsu <[email protected]>Thank you,
Quoted 30 lines
---
arch/x86/kernel/kprobes/core.c +1
-3@@ -66,8 +66,6 @@#include "common.h" -void *trampoline_handler (struct pt_regs *regs); - DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);@@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);/* * Called from kretprobe_trampoline */ -__visible __used void *trampoline_handler(struct pt_regs *regs) +static __used void *trampoline_handler (struct pt_regs *regs) {struct kretprobe_instance *ri =NULL ;struct hlist_head *head, empty_rp;Signature · 5 lines
-- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.Signature · 1 line
Masami Hiramatsu <[email protected]>
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Masami Hiramatsu
maintainerQuoted 29 lines · On Fri, 7 Dec 2018 20:48:47 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 3 lines · Masami Hiramatsu
Hmm, I just thought that the symbol only referred from inline asm should be visible. But if it is OK for any version of supported gcc and clang, I'm good to remove it. :-) (IOW, I just concerned about older gcc)
I just tried two gcc versions: 8.2 and 4.8.5. Both asms looks good:
ffffffff81044690<kretprobe_trampoline>:
...ffffffff810446ab: 41 57 push %r15 ffffffff810446ad: 48 89 e7 mov %rsp,%rdi ffffffff810446b0: e8 db 01 00 00 callq ffffffff81044890 <trampoline_handler>there's the CALL...
ffffffff810446b5: 48 89 84 24 98 00 00 mov %rax,0x98(%rsp) ffffffff810446bc: 00... and the handler is at the expected address.
ffffffff81044890<trampoline_handler>:ffffffff81044890: e8 ab c9 7b 00 callq ffffffff81801240 <__fentry__> ffffffff81044895: 41 57 push %r15 ffffffff81044897: 41 56 push %r14 ffffffff81044899: 41 55 push %r13 ffffffff8104489b: 49 89 fd mov %rdi,%r13
Quoted 3 lines
Dunno, if you feel like there might be some trouble with some compilers, I can keep the hunk below as a separate patch and revert it when it explodes somewhere...?
OK, then please remove it. :-) Even if any problem occurs, which must be build error, so we can revert it in that case.
Thank you!
Quoted 45 lines
Quoted 39 lines
Reviewed-by Masami Hiramatsu <[email protected]>Thank you,
Quoted 30 lines
---
arch/x86/kernel/kprobes/core.c +1
-3@@ -66,8 +66,6 @@#include "common.h" -void *trampoline_handler (struct pt_regs *regs); - DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);@@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);/* * Called from kretprobe_trampoline */ -__visible __used void *trampoline_handler(struct pt_regs *regs) +static __used void *trampoline_handler (struct pt_regs *regs) {struct kretprobe_instance *ri =NULL ;struct hlist_head *head, empty_rp;Signature · 5 lines
-- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.Signature · 1 line
Masami Hiramatsu <[email protected]>Signature · 4 lines
Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.
Signature · 1 line
Masami Hiramatsu <[email protected]>
tip-bot for Borislav Petkov
merge bot[tip:x86/cleanups] x86/kprobes: Remove trampoline_handler() prototype
In reply to Ingo Molnarx86/kprobes: Remove trampoline_handler() prototype
Commit-ID: 4b1bacab61aa252d15dde99cd0440a965bd863e5 Gitweb: https://git.kernel.org/tip/4b1bacab61aa252d15dde99cd0440a965bd863e5 Author: Borislav Petkov <[email protected]> AuthorDate: Fri, 7 Dec 2018 20:38:09 +0100 Committer: Borislav Petkov <[email protected]> CommitDate: Sat, 8 Dec 2018 12:25:12 +0100
x86/kprobes: Remove trampoline_handler() prototype
... and make it static. It is called only by the kretprobe_trampoline() from asm.
It was marked __visible so that it is visible outside of the current compilation unit but that is not needed as it is used only in this compilation unit.
--- arch/x86/kernel/kprobes/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kernel/kprobes/core.c +1 -3
@@ -66,8 +66,6 @@#include "common.h" -void *trampoline_handler (struct pt_regs *regs); - DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
@@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);/* * Called from kretprobe_trampoline */ -__visible __used void *trampoline_handler(struct pt_regs *regs) +static __used void *trampoline_handler (struct pt_regs *regs) {struct kretprobe_instance *ri =NULL ;struct hlist_head *head, empty_rp;
Quoted 4 lines · On Wed, 5 Dec 2018 15:24:48 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 2 lines · Masami Hiramatsu
I would like to put this prototype inside
arch/x86/kernel/kprobes/core.c, since that is locally used.
Quoted 8 lines
Done.
Quoted 2 lines
Should we declare prototypes for
__weakfunctions? Anyway, we should remove__weakfrom the prototypes.And done.
Thx.
OK, I think it is good to me.
Thanks,
Quoted 6 lines
Signature · 5 lines
-- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.
Signature · 1 line
Masami Hiramatsu <[email protected]>