Skip to contentSkip to conversation

powerpc/sparse: make some things static

PATCH Applied Daniel Axtens 3 participants 12 messages May 18, 2016 – Aug 14, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 powerpc/sparse: make some things static

This is just a smattering of things picked up by sparse that should be made static.

---
 arch/powerpc/kernel/crash.c                     | 2 +-
 arch/powerpc/kernel/sysfs.c                     | 2 +-
 arch/powerpc/platforms/powernv/idle.c           | 2 +-
 arch/powerpc/platforms/pseries/pseries_energy.c | 8 ++++----
 4 files changed, 7 insertions(+), 7 deletions(-)
arch/powerpc/kernel/crash.c +1 -1
index 2bb252c01f07..c47a1bf36403 100644
@@ -65,7 +65,7 @@ static int handle_fault(struct pt_regs *regs)
 #ifdef CONFIG_SMP
 
 static atomic_t cpus_in_crash;
-void crash_ipi_callback(struct pt_regs *regs)
+static void crash_ipi_callback(struct pt_regs *regs)
 {
 	static cpumask_t cpus_state_saved = CPU_MASK_NONE;
 
arch/powerpc/kernel/sysfs.c +1 -1
index 692873bff334..c4f1d1f7bae0 100644
@@ -35,7 +35,7 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
 #ifdef CONFIG_PPC64
 
 /* Time in microseconds we delay before sleeping in the idle loop */
-DEFINE_PER_CPU(long, smt_snooze_delay) = { 100 };
+static DEFINE_PER_CPU(long, smt_snooze_delay) = { 100 };
 
 static ssize_t store_smt_snooze_delay(struct device *dev,
 				      struct device_attribute *attr,
arch/powerpc/platforms/powernv/idle.c +1 -1
index fcc8b6861b63..92a8020f3502 100644
@@ -29,7 +29,7 @@
 
 static u32 supported_cpuidle_states;
 
-int pnv_save_sprs_for_winkle(void)
+static int pnv_save_sprs_for_winkle(void)
 {
 	int cpu;
 	int rc;
arch/powerpc/platforms/pseries/pseries_energy.c +4 -4
index 92767791f93b..164a13d3998a 100644
@@ -208,19 +208,19 @@ static ssize_t percpu_deactivate_hint_show(struct device *dev,
  *	Per-cpu value of the hint
  */
 
-struct device_attribute attr_cpu_activate_hint_list =
+static struct device_attribute attr_cpu_activate_hint_list =
 		__ATTR(pseries_activate_hint_list, 0444,
 		cpu_activate_hint_list_show, NULL);
 
-struct device_attribute attr_cpu_deactivate_hint_list =
+static struct device_attribute attr_cpu_deactivate_hint_list =
 		__ATTR(pseries_deactivate_hint_list, 0444,
 		cpu_deactivate_hint_list_show, NULL);
 
-struct device_attribute attr_percpu_activate_hint =
+static struct device_attribute attr_percpu_activate_hint =
 		__ATTR(pseries_activate_hint, 0444,
 		percpu_activate_hint_show, NULL);
 
-struct device_attribute attr_percpu_deactivate_hint =
+static struct device_attribute attr_percpu_deactivate_hint =
 		__ATTR(pseries_deactivate_hint, 0444,
 		percpu_deactivate_hint_show, NULL);
 
Signature · 1 line
2.5.0
#1 lore raw

PATCH 2/4 powerpc: Introduce asm-prototypes.h

Sparse picked up a number of functions that are implemented in C and then only referred to in asm code.

This introduces asm-prototypes.h, which provides a place for prototypes of these functions.

This silences some sparse warnings.

---
 arch/powerpc/include/asm/asm-prototypes.h         | 79 +++++++++++++++++++++++
 arch/powerpc/kernel/machine_kexec_64.c            |  1 +
 arch/powerpc/kernel/smp.c                         |  1 +
 arch/powerpc/kernel/traps.c                       |  1 +
 arch/powerpc/lib/vmx-helper.c                     |  1 +
 arch/powerpc/platforms/powernv/opal-tracepoints.c |  1 +
 arch/powerpc/platforms/pseries/lpar.c             |  1 +
 7 files changed, 85 insertions(+)
 create mode 100644 arch/powerpc/include/asm/asm-prototypes.h
arch/powerpc/include/asm/asm-prototypes.h new file +79 -0
new file mode 100644
index 000000000000..6ee0a9d80bbc
@@ -0,0 +1,79 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Copyright IBM Corp. 2016
+ *
+ * Authors: Daniel Axtens <[email protected]>
+ */
+
+/*
+ * This file is for prototypes of C functions that are only called
+ * from asm, and any associated variables.
+ */
+
+#include <linux/threads.h>
+#include <linux/kprobes.h>
+
+/* SMP */
+extern struct thread_info *current_set[NR_CPUS];
+extern struct thread_info *secondary_ti;
+void start_secondary(void *unused);
+
+/* kexec */
+struct paca_struct;
+struct kimage;
+extern struct paca_struct kexec_paca;
+void kexec_copy_flush(struct kimage *image);
+
+/* pSeries hcall tracing */
+extern struct static_key hcall_tracepoint_key;
+void __trace_hcall_entry(unsigned long opcode, unsigned long *args);
+void __trace_hcall_exit(long opcode, unsigned long retval,
+			unsigned long *retbuf);
+/* OPAL tracing */
+#ifdef HAVE_JUMP_LABEL
+extern struct static_key opal_tracepoint_key;
+#endif
+
+void __trace_opal_entry(unsigned long opcode, unsigned long *args);
+void __trace_opal_exit(long opcode, unsigned long retval);
+
+/* VMX copying */
+int enter_vmx_usercopy(void);
+int exit_vmx_usercopy(void);
+int enter_vmx_copy(void);
+void * exit_vmx_copy(void *dest);
+
+/* Traps */
+long machine_check_early(struct pt_regs *regs);
+long hmi_exception_realmode(struct pt_regs *regs);
+void SMIException(struct pt_regs *regs);
+void handle_hmi_exception(struct pt_regs *regs);
+void instruction_breakpoint_exception(struct pt_regs *regs);
+void RunModeException(struct pt_regs *regs);
+void __kprobes single_step_exception(struct pt_regs *regs);
+void __kprobes program_check_exception(struct pt_regs *regs);
+void alignment_exception(struct pt_regs *regs);
+void StackOverflow(struct pt_regs *regs);
+void nonrecoverable_exception(struct pt_regs *regs);
+void kernel_fp_unavailable_exception(struct pt_regs *regs);
+void altivec_unavailable_exception(struct pt_regs *regs);
+void vsx_unavailable_exception(struct pt_regs *regs);
+void fp_unavailable_tm(struct pt_regs *regs);
+void altivec_unavailable_tm(struct pt_regs *regs);
+void vsx_unavailable_tm(struct pt_regs *regs);
+void facility_unavailable_exception(struct pt_regs *regs);
+void TAUException(struct pt_regs *regs);
+void altivec_assist_exception(struct pt_regs *regs);
+void unrecoverable_exception(struct pt_regs *regs);
+void kernel_bad_stack(struct pt_regs *regs);
+void system_reset_exception(struct pt_regs *regs);
+void machine_check_exception(struct pt_regs *regs);
+void __kprobes emulation_assist_interrupt(struct pt_regs *regs);
arch/powerpc/kernel/machine_kexec_64.c +1 -0
index b8c202d63ecb..50bf55135ef8 100644
@@ -29,6 +29,7 @@
 #include <asm/prom.h>
 #include <asm/smp.h>
 #include <asm/hw_breakpoint.h>
+#include <asm/asm-prototypes.h>
 
 #ifdef CONFIG_PPC_BOOK3E
 int default_machine_kexec_prepare(struct kimage *image)
arch/powerpc/kernel/smp.c +1 -0
index 55c924b65f71..f1adc3c4f4ca 100644
@@ -53,6 +53,7 @@
 #include <asm/vdso.h>
 #include <asm/debug.h>
 #include <asm/kexec.h>
+#include <asm/asm-prototypes.h>
 
 #ifdef DEBUG
 #include <asm/udbg.h>
arch/powerpc/kernel/traps.c +1 -0
index 9229ba63c370..11d15e7270e0 100644
@@ -60,6 +60,7 @@
 #include <asm/switch_to.h>
 #include <asm/tm.h>
 #include <asm/debug.h>
+#include <asm/asm-prototypes.h>
 #include <sysdev/fsl_pci.h>
 
 #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
arch/powerpc/lib/vmx-helper.c +1 -0
index b27e030fc9f8..bf925cdcaca9 100644
@@ -21,6 +21,7 @@
 #include <linux/uaccess.h>
 #include <linux/hardirq.h>
 #include <asm/switch_to.h>
+#include <asm/asm-prototypes.h>
 
 int enter_vmx_usercopy(void)
 {
arch/powerpc/platforms/powernv/opal-tracepoints.c +1 -0
index e11273b2386d..1e496b780efd 100644
@@ -1,6 +1,7 @@
 #include <linux/percpu.h>
 #include <linux/jump_label.h>
 #include <asm/trace.h>
+#include <asm/asm-prototypes.h>
 
 #ifdef HAVE_JUMP_LABEL
 struct static_key opal_tracepoint_key = STATIC_KEY_INIT;
arch/powerpc/platforms/pseries/lpar.c +1 -0
index 7f6100d91b4b..03ff9867a610 100644
@@ -45,6 +45,7 @@
 #include <asm/plpar_wrappers.h>
 #include <asm/kexec.h>
 #include <asm/fadump.h>
+#include <asm/asm-prototypes.h>
 
 #include "pseries.h"
 
Signature · 1 line
2.5.0
#8 lore raw

PATCH 3/4 powerpc/sparse: Include headers containing prototypes

In reply to Daniel Axtens

Sometimes headers that provide prototypes for functions are accidentally omitted from the files that define the functions.

Fix a couple of times that occurs.

---
 arch/powerpc/kernel/smp.c              | 1 +
 arch/powerpc/platforms/pseries/power.c | 2 ++
 2 files changed, 3 insertions(+)
arch/powerpc/kernel/smp.c +1 -0
index f1adc3c4f4ca..1b55c7864291 100644
@@ -31,6 +31,7 @@
 #include <linux/cpu.h>
 #include <linux/notifier.h>
 #include <linux/topology.h>
+#include <linux/profile.h>
 
 #include <asm/ptrace.h>
 #include <linux/atomic.h>
arch/powerpc/platforms/pseries/power.c +2 -0
index c26eadde434c..a4a0b57d1d81 100644
@@ -27,6 +27,8 @@
 #include <linux/init.h>
 #include <asm/machdep.h>
 
+#include "pseries.h"
+
 unsigned long rtas_poweron_auto; /* default and normal state is 0 */
 
 static ssize_t auto_poweron_show(struct kobject *kobj,
Signature · 1 line
2.5.0
#10 lore raw

PATCH 4/4 powerpc/sparse: Use LE definition of REG_BYTE

In reply to Daniel Axtens

Sparse complains that it doesn't know what REG_BYTE is:

arch/powerpc/kernel/align.c:313:29: error: undefined identifier 'REG_BYTE' arch/powerpc/kernel/align.c:320:37: error: undefined identifier 'REG_BYTE' arch/powerpc/kernel/align.c:328:29: error: cast from unknown type arch/powerpc/kernel/align.c:328:29: error: cast from unknown type

REG_BYTE is defined differently based on whether we're compiling for LE, BE32 or BE64. Sparse apparently doesn't provide __BIG_ENDIAN__ or __LITTLE_ENDIAN__, so add an explicit __CHECKER__ to the LE definition.

The choice of LE is arbitrary.

---
 arch/powerpc/kernel/align.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/align.c +1 -1
index 8e7cb8e2b21a..43f745f2cea9 100644
@@ -230,7 +230,7 @@ static int emulate_dcbz(struct pt_regs *regs, unsigned char __user *addr)
 #endif
 #endif
 
-#ifdef __LITTLE_ENDIAN__
+#if defined(__LITTLE_ENDIAN__) || defined(__CHECKER__)
 #define REG_BYTE(rp, i)		(*(((u8 *)((rp) + ((i)>>2)) + ((i)&3))))
 #endif
 
Signature · 1 line
2.5.0
reviewer Applied
#2 lore raw

Re: [2/4] powerpc: Introduce asm-prototypes.h

In reply to Daniel Axtens
Quoted 9 lines · Daniel Axtens

Sparse picked up a number of functions that are implemented in C and then only referred to in asm code.

This introduces asm-prototypes.h, which provides a place for prototypes of these functions.

This silences some sparse warnings.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/42f5b4cacd783faf05e3ff8bf8

cheers

#3 lore raw

Re: [PATCH 2/4] powerpc: Introduce asm-prototypes.h

In reply to Daniel Axtens

Le 18/05/2016 à 03:16, Daniel Axtens a écrit :

Quoted 5 lines

Sparse picked up a number of functions that are implemented in C and then only referred to in asm code.

This introduces asm-prototypes.h, which provides a place for prototypes of these functions.

It looks like this is a mis-use of asm-prototypes.h

On other architectures, asm-prototypes.h is there to allow MODVERSION to sent versions for exported assembly functions (I checked history of that file in x86 and arm64).

It looks like you have used it on the other way round, you have declared in it C functions used by ASM functions, whereas it is supposed to be dedicated to declaring exported ASM functions used by C functions.

Any plan to fix that ?

Christophe

Quoted 173 lines

This silences some sparse warnings.

---
  arch/powerpc/include/asm/asm-prototypes.h         | 79 +++++++++++++++++++++++
  arch/powerpc/kernel/machine_kexec_64.c            |  1 +
  arch/powerpc/kernel/smp.c                         |  1 +
  arch/powerpc/kernel/traps.c                       |  1 +
  arch/powerpc/lib/vmx-helper.c                     |  1 +
  arch/powerpc/platforms/powernv/opal-tracepoints.c |  1 +
  arch/powerpc/platforms/pseries/lpar.c             |  1 +
  7 files changed, 85 insertions(+)

create mode 100644 arch/powerpc/include/asm/asm-prototypes.h

arch/powerpc/include/asm/asm-prototypes.h new file +79 -0
new file mode 100644
index 000000000000..6ee0a9d80bbc
@@ -0,0 +1,79 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Copyright IBM Corp. 2016
+ *
+ * Authors: Daniel Axtens <[email protected]>
+ */
+
+/*
+ * This file is for prototypes of C functions that are only called
+ * from asm, and any associated variables.
+ */
+
+#include <linux/threads.h>
+#include <linux/kprobes.h>
+
+/* SMP */
+extern struct thread_info *current_set[NR_CPUS];
+extern struct thread_info *secondary_ti;
+void start_secondary(void *unused);
+
+/* kexec */
+struct paca_struct;
+struct kimage;
+extern struct paca_struct kexec_paca;
+void kexec_copy_flush(struct kimage *image);
+
+/* pSeries hcall tracing */
+extern struct static_key hcall_tracepoint_key;
+void __trace_hcall_entry(unsigned long opcode, unsigned long *args);
+void __trace_hcall_exit(long opcode, unsigned long retval,
+			unsigned long *retbuf);
+/* OPAL tracing */
+#ifdef HAVE_JUMP_LABEL
+extern struct static_key opal_tracepoint_key;
+#endif
+
+void __trace_opal_entry(unsigned long opcode, unsigned long *args);
+void __trace_opal_exit(long opcode, unsigned long retval);
+
+/* VMX copying */
+int enter_vmx_usercopy(void);
+int exit_vmx_usercopy(void);
+int enter_vmx_copy(void);
+void * exit_vmx_copy(void *dest);
+
+/* Traps */
+long machine_check_early(struct pt_regs *regs);
+long hmi_exception_realmode(struct pt_regs *regs);
+void SMIException(struct pt_regs *regs);
+void handle_hmi_exception(struct pt_regs *regs);
+void instruction_breakpoint_exception(struct pt_regs *regs);
+void RunModeException(struct pt_regs *regs);
+void __kprobes single_step_exception(struct pt_regs *regs);
+void __kprobes program_check_exception(struct pt_regs *regs);
+void alignment_exception(struct pt_regs *regs);
+void StackOverflow(struct pt_regs *regs);
+void nonrecoverable_exception(struct pt_regs *regs);
+void kernel_fp_unavailable_exception(struct pt_regs *regs);
+void altivec_unavailable_exception(struct pt_regs *regs);
+void vsx_unavailable_exception(struct pt_regs *regs);
+void fp_unavailable_tm(struct pt_regs *regs);
+void altivec_unavailable_tm(struct pt_regs *regs);
+void vsx_unavailable_tm(struct pt_regs *regs);
+void facility_unavailable_exception(struct pt_regs *regs);
+void TAUException(struct pt_regs *regs);
+void altivec_assist_exception(struct pt_regs *regs);
+void unrecoverable_exception(struct pt_regs *regs);
+void kernel_bad_stack(struct pt_regs *regs);
+void system_reset_exception(struct pt_regs *regs);
+void machine_check_exception(struct pt_regs *regs);
+void __kprobes emulation_assist_interrupt(struct pt_regs *regs);
arch/powerpc/kernel/machine_kexec_64.c +1 -0
index b8c202d63ecb..50bf55135ef8 100644
@@ -29,6 +29,7 @@
  #include <asm/prom.h>
  #include <asm/smp.h>
  #include <asm/hw_breakpoint.h>
+#include <asm/asm-prototypes.h>
 
  #ifdef CONFIG_PPC_BOOK3E
  int default_machine_kexec_prepare(struct kimage *image)
arch/powerpc/kernel/smp.c +1 -0
index 55c924b65f71..f1adc3c4f4ca 100644
@@ -53,6 +53,7 @@
  #include <asm/vdso.h>
  #include <asm/debug.h>
  #include <asm/kexec.h>
+#include <asm/asm-prototypes.h>
 
  #ifdef DEBUG
  #include <asm/udbg.h>
arch/powerpc/kernel/traps.c +1 -0
index 9229ba63c370..11d15e7270e0 100644
@@ -60,6 +60,7 @@
  #include <asm/switch_to.h>
  #include <asm/tm.h>
  #include <asm/debug.h>
+#include <asm/asm-prototypes.h>
  #include <sysdev/fsl_pci.h>
 
  #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
arch/powerpc/lib/vmx-helper.c +1 -0
index b27e030fc9f8..bf925cdcaca9 100644
@@ -21,6 +21,7 @@
  #include <linux/uaccess.h>
  #include <linux/hardirq.h>
  #include <asm/switch_to.h>
+#include <asm/asm-prototypes.h>
 
  int enter_vmx_usercopy(void)
  {
arch/powerpc/platforms/powernv/opal-tracepoints.c +1 -0
index e11273b2386d..1e496b780efd 100644
@@ -1,6 +1,7 @@
  #include <linux/percpu.h>
  #include <linux/jump_label.h>
  #include <asm/trace.h>
+#include <asm/asm-prototypes.h>
 
  #ifdef HAVE_JUMP_LABEL
  struct static_key opal_tracepoint_key = STATIC_KEY_INIT;
arch/powerpc/platforms/pseries/lpar.c +1 -0
index 7f6100d91b4b..03ff9867a610 100644
@@ -45,6 +45,7 @@
  #include <asm/plpar_wrappers.h>
  #include <asm/kexec.h>
  #include <asm/fadump.h>
+#include <asm/asm-prototypes.h>
 
  #include "pseries.h"
 
#4 lore raw

Re: [PATCH 2/4] powerpc: Introduce asm-prototypes.h

Quoted 4 lines · Christophe Leroy

Le 18/05/2016 à 03:16, Daniel Axtens a écrit :

Quoted 3 lines

Sparse picked up a number of functions that are implemented in C and then only referred to in asm code.

Quoted 8 lines
Quoted 2 lines

This introduces asm-prototypes.h, which provides a place for prototypes of these functions.

It looks like this is a mis-use of asm-prototypes.h

On other architectures, asm-prototypes.h is there to allow MODVERSION to sent versions for exported assembly functions (I checked history of that file in x86 and arm64).

Hmm, I was young(er) and (more) inexperienced 4 years ago and wouldn't have thought to check x86 and arm64.

Quoted 5 lines

It looks like you have used it on the other way round, you have declared in it C functions used by ASM functions, whereas it is supposed to be dedicated to declaring exported ASM functions used by C functions.

Any plan to fix that ?

What should we call it?

Kind regards,
Daniel

Quoted 176 lines

Christophe

Quoted 173 lines

This silences some sparse warnings.

---
  arch/powerpc/include/asm/asm-prototypes.h         | 79 +++++++++++++++++++++++
  arch/powerpc/kernel/machine_kexec_64.c            |  1 +
  arch/powerpc/kernel/smp.c                         |  1 +
  arch/powerpc/kernel/traps.c                       |  1 +
  arch/powerpc/lib/vmx-helper.c                     |  1 +
  arch/powerpc/platforms/powernv/opal-tracepoints.c |  1 +
  arch/powerpc/platforms/pseries/lpar.c             |  1 +
  7 files changed, 85 insertions(+)

create mode 100644 arch/powerpc/include/asm/asm-prototypes.h

arch/powerpc/include/asm/asm-prototypes.h new file +79 -0
new file mode 100644
index 000000000000..6ee0a9d80bbc
@@ -0,0 +1,79 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Copyright IBM Corp. 2016
+ *
+ * Authors: Daniel Axtens <[email protected]>
+ */
+
+/*
+ * This file is for prototypes of C functions that are only called
+ * from asm, and any associated variables.
+ */
+
+#include <linux/threads.h>
+#include <linux/kprobes.h>
+
+/* SMP */
+extern struct thread_info *current_set[NR_CPUS];
+extern struct thread_info *secondary_ti;
+void start_secondary(void *unused);
+
+/* kexec */
+struct paca_struct;
+struct kimage;
+extern struct paca_struct kexec_paca;
+void kexec_copy_flush(struct kimage *image);
+
+/* pSeries hcall tracing */
+extern struct static_key hcall_tracepoint_key;
+void __trace_hcall_entry(unsigned long opcode, unsigned long *args);
+void __trace_hcall_exit(long opcode, unsigned long retval,
+			unsigned long *retbuf);
+/* OPAL tracing */
+#ifdef HAVE_JUMP_LABEL
+extern struct static_key opal_tracepoint_key;
+#endif
+
+void __trace_opal_entry(unsigned long opcode, unsigned long *args);
+void __trace_opal_exit(long opcode, unsigned long retval);
+
+/* VMX copying */
+int enter_vmx_usercopy(void);
+int exit_vmx_usercopy(void);
+int enter_vmx_copy(void);
+void * exit_vmx_copy(void *dest);
+
+/* Traps */
+long machine_check_early(struct pt_regs *regs);
+long hmi_exception_realmode(struct pt_regs *regs);
+void SMIException(struct pt_regs *regs);
+void handle_hmi_exception(struct pt_regs *regs);
+void instruction_breakpoint_exception(struct pt_regs *regs);
+void RunModeException(struct pt_regs *regs);
+void __kprobes single_step_exception(struct pt_regs *regs);
+void __kprobes program_check_exception(struct pt_regs *regs);
+void alignment_exception(struct pt_regs *regs);
+void StackOverflow(struct pt_regs *regs);
+void nonrecoverable_exception(struct pt_regs *regs);
+void kernel_fp_unavailable_exception(struct pt_regs *regs);
+void altivec_unavailable_exception(struct pt_regs *regs);
+void vsx_unavailable_exception(struct pt_regs *regs);
+void fp_unavailable_tm(struct pt_regs *regs);
+void altivec_unavailable_tm(struct pt_regs *regs);
+void vsx_unavailable_tm(struct pt_regs *regs);
+void facility_unavailable_exception(struct pt_regs *regs);
+void TAUException(struct pt_regs *regs);
+void altivec_assist_exception(struct pt_regs *regs);
+void unrecoverable_exception(struct pt_regs *regs);
+void kernel_bad_stack(struct pt_regs *regs);
+void system_reset_exception(struct pt_regs *regs);
+void machine_check_exception(struct pt_regs *regs);
+void __kprobes emulation_assist_interrupt(struct pt_regs *regs);
arch/powerpc/kernel/machine_kexec_64.c +1 -0
index b8c202d63ecb..50bf55135ef8 100644
@@ -29,6 +29,7 @@
  #include <asm/prom.h>
  #include <asm/smp.h>
  #include <asm/hw_breakpoint.h>
+#include <asm/asm-prototypes.h>
 
  #ifdef CONFIG_PPC_BOOK3E
  int default_machine_kexec_prepare(struct kimage *image)
arch/powerpc/kernel/smp.c +1 -0
index 55c924b65f71..f1adc3c4f4ca 100644
@@ -53,6 +53,7 @@
  #include <asm/vdso.h>
  #include <asm/debug.h>
  #include <asm/kexec.h>
+#include <asm/asm-prototypes.h>
 
  #ifdef DEBUG
  #include <asm/udbg.h>
arch/powerpc/kernel/traps.c +1 -0
index 9229ba63c370..11d15e7270e0 100644
@@ -60,6 +60,7 @@
  #include <asm/switch_to.h>
  #include <asm/tm.h>
  #include <asm/debug.h>
+#include <asm/asm-prototypes.h>
  #include <sysdev/fsl_pci.h>
 
  #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
arch/powerpc/lib/vmx-helper.c +1 -0
index b27e030fc9f8..bf925cdcaca9 100644
@@ -21,6 +21,7 @@
  #include <linux/uaccess.h>
  #include <linux/hardirq.h>
  #include <asm/switch_to.h>
+#include <asm/asm-prototypes.h>
 
  int enter_vmx_usercopy(void)
  {
arch/powerpc/platforms/powernv/opal-tracepoints.c +1 -0
index e11273b2386d..1e496b780efd 100644
@@ -1,6 +1,7 @@
  #include <linux/percpu.h>
  #include <linux/jump_label.h>
  #include <asm/trace.h>
+#include <asm/asm-prototypes.h>
 
  #ifdef HAVE_JUMP_LABEL
  struct static_key opal_tracepoint_key = STATIC_KEY_INIT;
arch/powerpc/platforms/pseries/lpar.c +1 -0
index 7f6100d91b4b..03ff9867a610 100644
@@ -45,6 +45,7 @@
  #include <asm/plpar_wrappers.h>
  #include <asm/kexec.h>
  #include <asm/fadump.h>
+#include <asm/asm-prototypes.h>
 
  #include "pseries.h"
 
#5 lore raw

Re: [PATCH 2/4] powerpc: Introduce asm-prototypes.h

Quoted 18 lines · Daniel Axtens
Quoted 4 lines · Christophe Leroy

Le 18/05/2016 à 03:16, Daniel Axtens a écrit :

Quoted 3 lines

Sparse picked up a number of functions that are implemented in C and then only referred to in asm code.

Quoted 8 lines
Quoted 2 lines

This introduces asm-prototypes.h, which provides a place for prototypes of these functions.

It looks like this is a mis-use of asm-prototypes.h

On other architectures, asm-prototypes.h is there to allow MODVERSION to sent versions for exported assembly functions (I checked history of that file in x86 and arm64).

Hmm, I was young(er) and (more) inexperienced 4 years ago and wouldn't have thought to check x86 and arm64.

Quoted 7 lines
Quoted 5 lines

It looks like you have used it on the other way round, you have declared in it C functions used by ASM functions, whereas it is supposed to be dedicated to declaring exported ASM functions used by C functions.

Any plan to fix that ?

What should we call it?

I don't know but that's for sure more complex than just a rename.

Because after you created the file, people have started using it for what it is, see for instance following commits:
- 9e5f68842276 ("powerpc: Fix missing CRCs, add more asm-prototypes.h declarations") or commit
- 99ad503287da ("powerpc: Add a prototype for mcount() so it can be versioned")
- 43a8888f0a70 ("powerpc: Fix missing CRCs, add more asm-prototypes.h declarations")

But for instance, for function kexec_copy_flush(), I'd have included it is asm/kexec.c For function __trace_opal_entry() and __trace_opal_exit(), I would have added them in asm/opal.h Etc ...

Christophe

Quoted 179 lines

Kind regards,
Daniel

Quoted 176 lines

Christophe

Quoted 173 lines

This silences some sparse warnings.

---
   arch/powerpc/include/asm/asm-prototypes.h         | 79 +++++++++++++++++++++++
   arch/powerpc/kernel/machine_kexec_64.c            |  1 +
   arch/powerpc/kernel/smp.c                         |  1 +
   arch/powerpc/kernel/traps.c                       |  1 +
   arch/powerpc/lib/vmx-helper.c                     |  1 +
   arch/powerpc/platforms/powernv/opal-tracepoints.c |  1 +
   arch/powerpc/platforms/pseries/lpar.c             |  1 +
   7 files changed, 85 insertions(+)

create mode 100644 arch/powerpc/include/asm/asm-prototypes.h

arch/powerpc/include/asm/asm-prototypes.h new file +79 -0
new file mode 100644
index 000000000000..6ee0a9d80bbc
@@ -0,0 +1,79 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Copyright IBM Corp. 2016
+ *
+ * Authors: Daniel Axtens <[email protected]>
+ */
+
+/*
+ * This file is for prototypes of C functions that are only called
+ * from asm, and any associated variables.
+ */
+
+#include <linux/threads.h>
+#include <linux/kprobes.h>
+
+/* SMP */
+extern struct thread_info *current_set[NR_CPUS];
+extern struct thread_info *secondary_ti;
+void start_secondary(void *unused);
+
+/* kexec */
+struct paca_struct;
+struct kimage;
+extern struct paca_struct kexec_paca;
+void kexec_copy_flush(struct kimage *image);
+
+/* pSeries hcall tracing */
+extern struct static_key hcall_tracepoint_key;
+void __trace_hcall_entry(unsigned long opcode, unsigned long *args);
+void __trace_hcall_exit(long opcode, unsigned long retval,
+			unsigned long *retbuf);
+/* OPAL tracing */
+#ifdef HAVE_JUMP_LABEL
+extern struct static_key opal_tracepoint_key;
+#endif
+
+void __trace_opal_entry(unsigned long opcode, unsigned long *args);
+void __trace_opal_exit(long opcode, unsigned long retval);
+
+/* VMX copying */
+int enter_vmx_usercopy(void);
+int exit_vmx_usercopy(void);
+int enter_vmx_copy(void);
+void * exit_vmx_copy(void *dest);
+
+/* Traps */
+long machine_check_early(struct pt_regs *regs);
+long hmi_exception_realmode(struct pt_regs *regs);
+void SMIException(struct pt_regs *regs);
+void handle_hmi_exception(struct pt_regs *regs);
+void instruction_breakpoint_exception(struct pt_regs *regs);
+void RunModeException(struct pt_regs *regs);
+void __kprobes single_step_exception(struct pt_regs *regs);
+void __kprobes program_check_exception(struct pt_regs *regs);
+void alignment_exception(struct pt_regs *regs);
+void StackOverflow(struct pt_regs *regs);
+void nonrecoverable_exception(struct pt_regs *regs);
+void kernel_fp_unavailable_exception(struct pt_regs *regs);
+void altivec_unavailable_exception(struct pt_regs *regs);
+void vsx_unavailable_exception(struct pt_regs *regs);
+void fp_unavailable_tm(struct pt_regs *regs);
+void altivec_unavailable_tm(struct pt_regs *regs);
+void vsx_unavailable_tm(struct pt_regs *regs);
+void facility_unavailable_exception(struct pt_regs *regs);
+void TAUException(struct pt_regs *regs);
+void altivec_assist_exception(struct pt_regs *regs);
+void unrecoverable_exception(struct pt_regs *regs);
+void kernel_bad_stack(struct pt_regs *regs);
+void system_reset_exception(struct pt_regs *regs);
+void machine_check_exception(struct pt_regs *regs);
+void __kprobes emulation_assist_interrupt(struct pt_regs *regs);
arch/powerpc/kernel/machine_kexec_64.c +1 -0
index b8c202d63ecb..50bf55135ef8 100644
@@ -29,6 +29,7 @@
   #include <asm/prom.h>
   #include <asm/smp.h>
   #include <asm/hw_breakpoint.h>
+#include <asm/asm-prototypes.h>
 
   #ifdef CONFIG_PPC_BOOK3E
   int default_machine_kexec_prepare(struct kimage *image)
arch/powerpc/kernel/smp.c +1 -0
index 55c924b65f71..f1adc3c4f4ca 100644
@@ -53,6 +53,7 @@
   #include <asm/vdso.h>
   #include <asm/debug.h>
   #include <asm/kexec.h>
+#include <asm/asm-prototypes.h>
 
   #ifdef DEBUG
   #include <asm/udbg.h>
arch/powerpc/kernel/traps.c +1 -0
index 9229ba63c370..11d15e7270e0 100644
@@ -60,6 +60,7 @@
   #include <asm/switch_to.h>
   #include <asm/tm.h>
   #include <asm/debug.h>
+#include <asm/asm-prototypes.h>
   #include <sysdev/fsl_pci.h>
 
   #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
arch/powerpc/lib/vmx-helper.c +1 -0
index b27e030fc9f8..bf925cdcaca9 100644
@@ -21,6 +21,7 @@
   #include <linux/uaccess.h>
   #include <linux/hardirq.h>
   #include <asm/switch_to.h>
+#include <asm/asm-prototypes.h>
 
   int enter_vmx_usercopy(void)
   {
arch/powerpc/platforms/powernv/opal-tracepoints.c +1 -0
index e11273b2386d..1e496b780efd 100644
@@ -1,6 +1,7 @@
   #include <linux/percpu.h>
   #include <linux/jump_label.h>
   #include <asm/trace.h>
+#include <asm/asm-prototypes.h>
 
   #ifdef HAVE_JUMP_LABEL
   struct static_key opal_tracepoint_key = STATIC_KEY_INIT;
arch/powerpc/platforms/pseries/lpar.c +1 -0
index 7f6100d91b4b..03ff9867a610 100644
@@ -45,6 +45,7 @@
   #include <asm/plpar_wrappers.h>
   #include <asm/kexec.h>
   #include <asm/fadump.h>
+#include <asm/asm-prototypes.h>
 
   #include "pseries.h"
 
#6 lore raw

Re: [PATCH 2/4] powerpc: Introduce asm-prototypes.h

In reply to Christophe Leroy
Quoted 4 lines · Christophe Leroy

Le 18/05/2016 à 03:16, Daniel Axtens a écrit :

Quoted 3 lines

Sparse picked up a number of functions that are implemented in C and then only referred to in asm code.

Quoted 8 lines
Quoted 2 lines

This introduces asm-prototypes.h, which provides a place for prototypes of these functions.

It looks like this is a mis-use of asm-prototypes.h

On other architectures, asm-prototypes.h is there to allow MODVERSION to sent versions for exported assembly functions (I checked history of that file in x86 and arm64).

Look closer :)

42f5b4cacd78 ("powerpc: Introduce asm-prototypes.h") (Jun 2016) 334bb7738764 ("x86/kbuild: enable modversions for symbols exported from asm") (Dec 2016) c3296a1391cb ("arm64: add <asm/asm-prototypes.h>") (Dec 2018)

Quoted 3 lines

It looks like you have used it on the other way round, you have declared in it C functions used by ASM functions, whereas it is supposed to be dedicated to declaring exported ASM functions used by C functions.

But yes, it's since been co-opted for the modversions stuff.

I guess the contents should be split out into appropriate headers depending on what the prototypes are for.

chers

#7 lore raw

Re: [PATCH 2/4] powerpc: Introduce asm-prototypes.h

Quoted 14 lines · Michael Ellerman
Quoted 4 lines · Christophe Leroy

Le 18/05/2016 à 03:16, Daniel Axtens a écrit :

Quoted 3 lines

Sparse picked up a number of functions that are implemented in C and then only referred to in asm code.

Quoted 8 lines
Quoted 2 lines

This introduces asm-prototypes.h, which provides a place for prototypes of these functions.

It looks like this is a mis-use of asm-prototypes.h

On other architectures, asm-prototypes.h is there to allow MODVERSION to sent versions for exported assembly functions (I checked history of that file in x86 and arm64).

Quoted 5 lines

Look closer :)

42f5b4cacd78 ("powerpc: Introduce asm-prototypes.h") (Jun 2016) 334bb7738764 ("x86/kbuild: enable modversions for symbols exported from asm") (Dec 2016) c3296a1391cb ("arm64: add <asm/asm-prototypes.h>") (Dec 2018)

Aren't you all sitting at the same place in the middle of Pacific Ocean, far far away from Paris ? :)

Looking closer I see: mdr: (Ok, that's Nov 2016 but ...)

commit 4efca4ed05cbdfd13ec3e8cb623fb77d6e4ab187

Author: Nicholas Piggin <[email protected]>
Date:   Tue Nov 1 12:46:19 2016 +1100

kbuild: modversions for EXPORT_SYMBOL() for asm

Allow architectures to create asm/asm-prototypes.h file that provides C prototypes for exported asm functions, which enables proper CRC versions to be generated for them.

Quoted 10 lines
Quoted 4 lines

It looks like you have used it on the other way round, you have declared in it C functions used by ASM functions, whereas it is supposed to be dedicated to declaring exported ASM functions used by C functions.

But yes, it's since been co-opted for the modversions stuff.

I guess the contents should be split out into appropriate headers depending on what the prototypes are for.

Christophe