linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
@ 2018-12-05 10:11 Borislav Petkov
  2018-12-05 12:44 ` Rafael J. Wysocki
  2018-12-05 13:49 ` Masami Hiramatsu
  0 siblings, 2 replies; 11+ messages in thread
From: Borislav Petkov @ 2018-12-05 10:11 UTC (permalink / raw)
  To: LKML
  Cc: Andrew Banman, Dimitri Sivanich, H. Peter Anvin, Ingo Molnar,
	Masami Hiramatsu, Mike Travis, Steven Rostedt (VMware),
	Thomas Gleixner, Yi Wang, linux-acpi

From: Borislav Petkov <bp@suse.de>

... 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 <rostedt@goodmis.org>.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Banman <andrew.banman@hpe.com>
Cc: Dimitri Sivanich <dimitri.sivanich@hpe.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mike Travis <mike.travis@hpe.com>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yi Wang <wang.yi59@zte.com.cn>
Cc: linux-acpi@vger.kernel.org
---
 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(-)

diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index ae13bc974416..ed8ec011a9fd 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -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);
diff --git a/arch/x86/include/asm/trace/exceptions.h b/arch/x86/include/asm/trace/exceptions.h
index 69615e387973..e0e6d7f21399 100644
--- a/arch/x86/include/asm/trace/exceptions.h
+++ b/arch/x86/include/asm/trace/exceptions.h
@@ -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 */
diff --git a/arch/x86/include/asm/trace/irq_vectors.h b/arch/x86/include/asm/trace/irq_vectors.h
index 0af81b590a0c..33b9d0f0aafe 100644
--- a/arch/x86/include/asm/trace/irq_vectors.h
+++ b/arch/x86/include/asm/trace/irq_vectors.h
@@ -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 */
diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h
index 5fcdf5687406..7d6f3f3fad78 100644
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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);
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 32b2b7a41ef5..b7bcdd781651 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -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>
diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
index e84c9eb4e5b4..0005c284a5c5 100644
--- a/arch/x86/kernel/apic/apic_flat_64.c
+++ b/arch/x86/kernel/apic/apic_flat_64.c
@@ -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;
 
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 652e7ffa9b9d..3173e07d3791 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -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>
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index 391f358ebb4c..a555da094157 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -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;
diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
index 72adf6c335dc..168543d077d7 100644
--- a/arch/x86/kernel/asm-offsets.c
+++ b/arch/x86/kernel/asm-offsets.c
@@ -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
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index eeea634bee0a..69f6bbb41be0 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -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>
diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index 7eba34df54c3..804c49493938 100644
--- a/arch/x86/kernel/cpu/aperfmperf.c
+++ b/arch/x86/kernel/cpu/aperfmperf.c
@@ -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"
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 500278f5308e..923e954a0075 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -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);
diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c
index dc1b9342e9c4..c4d1023fb0ab 100644
--- a/arch/x86/kernel/cpu/cacheinfo.c
+++ b/arch/x86/kernel/cpu/cacheinfo.c
@@ -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>
 
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
index 772c219b6889..389168fa6e24 100644
--- a/arch/x86/kernel/cpu/scattered.c
+++ b/arch/x86/kernel/cpu/scattered.c
@@ -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;
diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
index 71ca064e3794..8f6c784141d1 100644
--- a/arch/x86/kernel/cpu/topology.c
+++ b/arch/x86/kernel/cpu/topology.c
@@ -10,6 +10,8 @@
 #include <asm/pat.h>
 #include <asm/processor.h>
 
+#include "cpu.h"
+
 /* leaf 0xb SMT level */
 #define SMT_LEVEL	0
 
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 87a57b7642d3..cd3956fc8158 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -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;
 
diff --git a/arch/x86/kernel/kprobes/common.h b/arch/x86/kernel/kprobes/common.h
index 2b949f4fd4d8..f0fc628c4bb7 100644
--- a/arch/x86/kernel/kprobes/common.h
+++ b/arch/x86/kernel/kprobes/common.h
@@ -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);
diff --git a/arch/x86/kernel/sysfb_efi.c b/arch/x86/kernel/sysfb_efi.c
index 623965e86b65..fa51723571c8 100644
--- a/arch/x86/kernel/sysfb_efi.c
+++ b/arch/x86/kernel/sysfb_efi.c
@@ -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 {
diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
index 2e85f4dcf77b..496748ed266a 100644
--- a/arch/x86/kernel/tracepoint.c
+++ b/arch/x86/kernel/tracepoint.c
@@ -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);
 
diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h
index cf59e6210d27..4f34734e7f36 100644
--- a/include/acpi/cppc_acpi.h
+++ b/include/acpi/cppc_acpi.h
@@ -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*/
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index e909413e4e38..91d19d6a2892 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -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)
-- 
2.19.1


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

* Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
  2018-12-05 10:11 [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings Borislav Petkov
@ 2018-12-05 12:44 ` Rafael J. Wysocki
  2018-12-05 13:49 ` Masami Hiramatsu
  1 sibling, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2018-12-05 12:44 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Linux Kernel Mailing List, andrew.banman, dimitri.sivanich,
	H. Peter Anvin, Ingo Molnar, mhiramat, mike.travis,
	Steven Rostedt, Thomas Gleixner, wang.yi59,
	ACPI Devel Maling List

On Wed, Dec 5, 2018 at 11:11 AM Borislav Petkov <bp@alien8.de> wrote:
>
> From: Borislav Petkov <bp@suse.de>
>
> ... 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 <rostedt@goodmis.org>.
>
> Signed-off-by: Borislav Petkov <bp@suse.de>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

for the ACPI and cpufreq bits.

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

* Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
  2018-12-05 10:11 [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings Borislav Petkov
  2018-12-05 12:44 ` Rafael J. Wysocki
@ 2018-12-05 13:49 ` Masami Hiramatsu
  2018-12-05 14:24   ` Borislav Petkov
  1 sibling, 1 reply; 11+ messages in thread
From: Masami Hiramatsu @ 2018-12-05 13:49 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: LKML, Andrew Banman, Dimitri Sivanich, H. Peter Anvin,
	Ingo Molnar, Masami Hiramatsu, Mike Travis,
	Steven Rostedt (VMware),
	Thomas Gleixner, Yi Wang, linux-acpi

Hi Borislav,

On Wed,  5 Dec 2018 11:11:31 +0100
Borislav Petkov <bp@alien8.de> wrote:

> From: Borislav Petkov <bp@suse.de>
> 
> ... 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.

[...]
> diff --git a/arch/x86/kernel/kprobes/common.h b/arch/x86/kernel/kprobes/common.h
> index 2b949f4fd4d8..f0fc628c4bb7 100644
> --- a/arch/x86/kernel/kprobes/common.h
> +++ b/arch/x86/kernel/kprobes/common.h
> @@ -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.

>  #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);
[...]
> diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
> index e909413e4e38..91d19d6a2892 100644
> --- a/include/linux/kprobes.h
> +++ b/include/linux/kprobes.h
> @@ -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,

-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
  2018-12-05 13:49 ` Masami Hiramatsu
@ 2018-12-05 14:24   ` Borislav Petkov
  2018-12-05 16:25     ` Ingo Molnar
  2018-12-07 15:21     ` [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings Masami Hiramatsu
  0 siblings, 2 replies; 11+ messages in thread
From: Borislav Petkov @ 2018-12-05 14:24 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: LKML, Andrew Banman, Dimitri Sivanich, H. Peter Anvin,
	Ingo Molnar, Mike Travis, Steven Rostedt (VMware),
	Thomas Gleixner, Yi Wang, linux-acpi

On Wed, Dec 05, 2018 at 10:49:06PM +0900, Masami Hiramatsu wrote:
> I would like to put this prototype inside arch/x86/kernel/kprobes/core.c,
> since that is locally used.

Done.

> Should we declare prototypes for __weak functions? Anyway, we should remove
> __weak from the prototypes.

And done.

Thx.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

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

* Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
  2018-12-05 14:24   ` Borislav Petkov
@ 2018-12-05 16:25     ` Ingo Molnar
  2018-12-05 17:15       ` Borislav Petkov
  2018-12-08 11:31       ` [tip:x86/cleanups] x86/kprobes: Remove trampoline_handler() prototype tip-bot for Borislav Petkov
  2018-12-07 15:21     ` [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings Masami Hiramatsu
  1 sibling, 2 replies; 11+ messages in thread
From: Ingo Molnar @ 2018-12-05 16:25 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Masami Hiramatsu, LKML, Andrew Banman, Dimitri Sivanich,
	H. Peter Anvin, Ingo Molnar, Mike Travis, Steven Rostedt (VMware),
	Thomas Gleixner, Yi Wang, linux-acpi


* Borislav Petkov <bp@alien8.de> wrote:

> On Wed, Dec 05, 2018 at 10:49:06PM +0900, Masami Hiramatsu wrote:
> > 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:

Reviewed-by: Ingo Molnar <mingo@kernel.org>

Thanks,

	Ingo

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

* Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
  2018-12-05 16:25     ` Ingo Molnar
@ 2018-12-05 17:15       ` Borislav Petkov
  2018-12-07 14:42         ` Masami Hiramatsu
  2018-12-08 11:31       ` [tip:x86/cleanups] x86/kprobes: Remove trampoline_handler() prototype tip-bot for Borislav Petkov
  1 sibling, 1 reply; 11+ messages in thread
From: Borislav Petkov @ 2018-12-05 17:15 UTC (permalink / raw)
  To: Ingo Molnar, Masami Hiramatsu
  Cc: LKML, Andrew Banman, Dimitri Sivanich, H. Peter Anvin,
	Ingo Molnar, Mike Travis, Steven Rostedt (VMware),
	Thomas Gleixner, Yi Wang, linux-acpi

On Wed, Dec 05, 2018 at 05:25:26PM +0100, Ingo Molnar wrote:
> 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?

---
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 6480056d370f..308bf103cc73 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -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;

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

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

* Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
  2018-12-05 17:15       ` Borislav Petkov
@ 2018-12-07 14:42         ` Masami Hiramatsu
  2018-12-07 19:48           ` Borislav Petkov
  0 siblings, 1 reply; 11+ messages in thread
From: Masami Hiramatsu @ 2018-12-07 14:42 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Ingo Molnar, LKML, Andrew Banman, Dimitri Sivanich,
	H. Peter Anvin, Ingo Molnar, Mike Travis, Steven Rostedt (VMware),
	Thomas Gleixner, Yi Wang, linux-acpi

Hi,

On Wed, 5 Dec 2018 18:15:47 +0100
Borislav Petkov <bp@alien8.de> wrote:

> On Wed, Dec 05, 2018 at 05:25:26PM +0100, Ingo Molnar wrote:
> > 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?

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)

Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>

Thank you,

> 
> ---
> diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> index 6480056d370f..308bf103cc73 100644
> --- a/arch/x86/kernel/kprobes/core.c
> +++ b/arch/x86/kernel/kprobes/core.c
> @@ -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;
> 
> -- 
> Regards/Gruss,
>     Boris.
> 
> Good mailing practices for 400: avoid top-posting and trim the reply.


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
  2018-12-05 14:24   ` Borislav Petkov
  2018-12-05 16:25     ` Ingo Molnar
@ 2018-12-07 15:21     ` Masami Hiramatsu
  1 sibling, 0 replies; 11+ messages in thread
From: Masami Hiramatsu @ 2018-12-07 15:21 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: LKML, Andrew Banman, Dimitri Sivanich, H. Peter Anvin,
	Ingo Molnar, Mike Travis, Steven Rostedt (VMware),
	Thomas Gleixner, Yi Wang, linux-acpi

On Wed, 5 Dec 2018 15:24:48 +0100
Borislav Petkov <bp@alien8.de> wrote:

> On Wed, Dec 05, 2018 at 10:49:06PM +0900, Masami Hiramatsu wrote:
> > I would like to put this prototype inside arch/x86/kernel/kprobes/core.c,
> > since that is locally used.
> 
> Done.
> 
> > Should we declare prototypes for __weak functions? Anyway, we should remove
> > __weak from the prototypes.
> 
> And done.
> 
> Thx.

OK, I think it is good to me.

Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks,

> 
> -- 
> Regards/Gruss,
>     Boris.
> 
> Good mailing practices for 400: avoid top-posting and trim the reply.


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
  2018-12-07 14:42         ` Masami Hiramatsu
@ 2018-12-07 19:48           ` Borislav Petkov
  2018-12-08  5:56             ` Masami Hiramatsu
  0 siblings, 1 reply; 11+ messages in thread
From: Borislav Petkov @ 2018-12-07 19:48 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Ingo Molnar, LKML, Andrew Banman, Dimitri Sivanich,
	H. Peter Anvin, Ingo Molnar, Mike Travis, Steven Rostedt (VMware),
	Thomas Gleixner, Yi Wang, linux-acpi

On Fri, Dec 07, 2018 at 11:42:10PM +0900, Masami Hiramatsu wrote:
> 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...?

> Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
> 
> Thank you,
> 
> > 
> > ---
> > diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> > index 6480056d370f..308bf103cc73 100644
> > --- a/arch/x86/kernel/kprobes/core.c
> > +++ b/arch/x86/kernel/kprobes/core.c
> > @@ -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;
> > 
> > -- 
> > Regards/Gruss,
> >     Boris.
> > 
> > Good mailing practices for 400: avoid top-posting and trim the reply.
> 
> 
> -- 
> Masami Hiramatsu <mhiramat@kernel.org>

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

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

* Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
  2018-12-07 19:48           ` Borislav Petkov
@ 2018-12-08  5:56             ` Masami Hiramatsu
  0 siblings, 0 replies; 11+ messages in thread
From: Masami Hiramatsu @ 2018-12-08  5:56 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Ingo Molnar, LKML, Andrew Banman, Dimitri Sivanich,
	H. Peter Anvin, Ingo Molnar, Mike Travis, Steven Rostedt (VMware),
	Thomas Gleixner, Yi Wang, linux-acpi

On Fri, 7 Dec 2018 20:48:47 +0100
Borislav Petkov <bp@alien8.de> wrote:

> On Fri, Dec 07, 2018 at 11:42:10PM +0900, Masami Hiramatsu wrote:
> > 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...?

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!

> 
> > Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
> > 
> > Thank you,
> > 
> > > 
> > > ---
> > > diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> > > index 6480056d370f..308bf103cc73 100644
> > > --- a/arch/x86/kernel/kprobes/core.c
> > > +++ b/arch/x86/kernel/kprobes/core.c
> > > @@ -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;
> > > 
> > > -- 
> > > Regards/Gruss,
> > >     Boris.
> > > 
> > > Good mailing practices for 400: avoid top-posting and trim the reply.
> > 
> > 
> > -- 
> > Masami Hiramatsu <mhiramat@kernel.org>
> 
> -- 
> Regards/Gruss,
>     Boris.
> 
> Good mailing practices for 400: avoid top-posting and trim the reply.


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* [tip:x86/cleanups] x86/kprobes: Remove trampoline_handler() prototype
  2018-12-05 16:25     ` Ingo Molnar
  2018-12-05 17:15       ` Borislav Petkov
@ 2018-12-08 11:31       ` tip-bot for Borislav Petkov
  1 sibling, 0 replies; 11+ messages in thread
From: tip-bot for Borislav Petkov @ 2018-12-08 11:31 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: mingo, bp, hpa, linux-kernel, mhiramat, tglx

Commit-ID:  4b1bacab61aa252d15dde99cd0440a965bd863e5
Gitweb:     https://git.kernel.org/tip/4b1bacab61aa252d15dde99cd0440a965bd863e5
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Fri, 7 Dec 2018 20:38:09 +0100
Committer:  Borislav Petkov <bp@suse.de>
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.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://lkml.kernel.org/r/20181205162526.GB109259@gmail.com
---
 arch/x86/kernel/kprobes/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 6480056d370f..308bf103cc73 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -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;

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

end of thread, other threads:[~2018-12-08 11:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-05 10:11 [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings Borislav Petkov
2018-12-05 12:44 ` Rafael J. Wysocki
2018-12-05 13:49 ` Masami Hiramatsu
2018-12-05 14:24   ` Borislav Petkov
2018-12-05 16:25     ` Ingo Molnar
2018-12-05 17:15       ` Borislav Petkov
2018-12-07 14:42         ` Masami Hiramatsu
2018-12-07 19:48           ` Borislav Petkov
2018-12-08  5:56             ` Masami Hiramatsu
2018-12-08 11:31       ` [tip:x86/cleanups] x86/kprobes: Remove trampoline_handler() prototype tip-bot for Borislav Petkov
2018-12-07 15:21     ` [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).