Skip to contentSkip to conversation

x86: remaining -Wmissing-prototype warning fixes

PATCH Applied Arnd Bergmann 3 participants 14 messages Aug 3, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover x86: remaining -Wmissing-prototype warning fixes

From: Arnd Bergmann <[email protected]>

This is almost the same as before, and should let us turn on -Wmissing-prototypes by default. I'm still unsure whether we need to do this per architecture as some other ones still produce a lot of warnings, or we just enabled it for everyone and let arch maintainers deal with it now that the major ones (x86, arm64, arm, powerpc, riscv, s390) are clean.

Changes compared to v2:
- add amd_check_microcode() patch to the series. I had sent that separately as this was a regression in 6.5-rc

- rework comment for __div64_32

- split paravirt patch into two patches and rewrite the native_pv_lock_init() one as requested by Boris

Arnd

Arnd Bergmann (7):
x86: Fix amd_check_microcode() declaration
x86: apic: hide unused safe_smp_processor_id on UP
x86: avoid unneeded __div64_32 function definition
x86: purgatory: include header for warn() declaration
x86: alternative: add __alt_reloc_selftest prototype
x86: paravirt: shut up unused native_pv_lock_init() function warning
x86: qspinlock-paravirt: fix mising-prototype warning

 arch/x86/boot/compressed/error.c          |  2 +-
 arch/x86/boot/compressed/error.h          |  2 +-
 arch/x86/include/asm/div64.h              |  6 ++++++
 arch/x86/include/asm/microcode_amd.h      |  3 +--
 arch/x86/include/asm/paravirt.h           |  7 +++++++
 arch/x86/include/asm/processor.h          |  2 ++
 arch/x86/include/asm/qspinlock.h          |  7 +------
 arch/x86/include/asm/qspinlock_paravirt.h |  2 ++
 arch/x86/kernel/alternative.c             |  1 +
 arch/x86/kernel/apic/ipi.c                |  2 ++
 arch/x86/kernel/paravirt.c                |  3 ++-
 arch/x86/purgatory/purgatory.c            |  1 +
 kernel/locking/qspinlock_paravirt.h       | 20 ++++++++++----------
 13 files changed, 37 insertions(+), 21 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH v3 1/7 x86: Fix amd_check_microcode() declaration

From: Arnd Bergmann <[email protected]>

The newly added amd_check_microcode() function has two conflicting definitions if CONFIG_CPU_SUP_AMD is enabled and CONFIG_MICROCODE_AMD is disabled. Since the header with the stub definition is not included in cpu/amd.c, this only causes a -Wmissing-prototype warning with W=1

arch/x86/kernel/cpu/amd.c:1289:6: error: no previous prototype for 'amd_check_microcode' [-Werror=missing-prototypes]

Adding the missing #include shows the other problem:

arch/x86/kernel/cpu/amd.c:1290:6: error: redefinition of 'amd_check_microcode' arch/x86/include/asm/microcode_amd.h:58:20: note: previous definition of 'amd_check_microcode' with type 'void(void)'

Move the declaration into a more appropriate header that is already included, with the #ifdef check changed to match the definition's.

Fixes 522b1d69219d8 ("x86/cpu/amd: Add a Zenbleed fix")
---
 arch/x86/include/asm/microcode_amd.h | 3 +--
 arch/x86/include/asm/processor.h     | 2 ++
 2 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/include/asm/microcode_amd.h +1 -2
index a9b3f9635727e..81d3294b2b5e2 100644
@@ -47,12 +47,11 @@ struct microcode_amd {
 extern void load_ucode_amd_early(unsigned int cpuid_1_eax);
 extern int __init save_microcode_in_initrd_amd(unsigned int family);
 void reload_ucode_amd(unsigned int cpu);
-extern void amd_check_microcode(void);
 #else
 static inline void load_ucode_amd_early(unsigned int cpuid_1_eax) {}
 static inline int __init
 save_microcode_in_initrd_amd(unsigned int family) { return -EINVAL; }
 static inline void reload_ucode_amd(unsigned int cpu) {}
-static inline void amd_check_microcode(void) {}
 #endif
+
 #endif /* _ASM_X86_MICROCODE_AMD_H */
arch/x86/include/asm/processor.h +2 -0
index d46300e94f853..36d52075fdade 100644
@@ -682,9 +682,11 @@ extern u16 get_llc_id(unsigned int cpu);
 #ifdef CONFIG_CPU_SUP_AMD
 extern u32 amd_get_nodes_per_socket(void);
 extern u32 amd_get_highest_perf(void);
+extern void amd_check_microcode(void);
 #else
 static inline u32 amd_get_nodes_per_socket(void)	{ return 0; }
 static inline u32 amd_get_highest_perf(void)		{ return 0; }
+static inline void amd_check_microcode(void)		{ }
 #endif
 
 extern unsigned long arch_align_stack(unsigned long sp);
Signature · 1 line
2.39.2
#2 lore raw

PATCH v3 2/7 x86: apic: hide unused safe_smp_processor_id on UP

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When CONFIG_SMP is disabled, the prototype for safe_smp_processor_id() is hidden, which causes a W=1 warning:

/home/arnd/arm-soc/arch/x86/kernel/apic/ipi.c:316:5: error: no previous prototype for 'safe_smp_processor_id' [-Werror=missing-prototypes]

Since there are no callers in this configuration, just hide the definition as well.

---
 arch/x86/kernel/apic/ipi.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/kernel/apic/ipi.c +2 -0
index 2a6509e8c840d..9bfd6e3973845 100644
@@ -301,6 +301,7 @@ void default_send_IPI_mask_logical(const struct cpumask *cpumask, int vector)
 	local_irq_restore(flags);
 }
 
+#ifdef CONFIG_SMP
 /* must come after the send_IPI functions above for inlining */
 static int convert_apicid_to_cpu(int apic_id)
 {
@@ -329,3 +330,4 @@ int safe_smp_processor_id(void)
 	return cpuid >= 0 ? cpuid : 0;
 }
 #endif
+#endif
Signature · 1 line
2.39.2
#3 lore raw

PATCH v3 3/7 x86: avoid unneeded __div64_32 function definition

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The __div64_32() function is provided for 32-bit architectures that don't have a custom do_div() implementation. x86_32 has one, and does not use the header file that declares the function prototype, so the definition causes a W=1 warning:

lib/math/div64.c:31:32: error: no previous prototype for '__div64_32' [-Werror=missing-prototypes]

Define an empty macro to prevent the function definition from getting built, which avoids the warning and saves a little .text space.

---
v3: improve code comment

---
 arch/x86/include/asm/div64.h | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/include/asm/div64.h +6 -0
index b8f1dc0761e4b..9931e4c7d73f3 100644
@@ -71,6 +71,12 @@ static inline u64 mul_u32_u32(u32 a, u32 b)
 }
 #define mul_u32_u32 mul_u32_u32
 
+/*
+ * __div64_32() is never called on x86, so prevent the
+ * generic definition from getting built.
+ */
+#define __div64_32
+
 #else
 # include <asm-generic/div64.h>
 
Signature · 1 line
2.39.2
merge bot Applied
#4 lore raw

[tip: x86/cleanups] x86/asm: Avoid unneeded __div64_32 function definition

The following commit has been merged into the x86/cleanups branch of tip:

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     65412c8d72741cc6e6b082b478b8957d7e7c0480
Gitweb:        https://git.kernel.org/tip/65412c8d72741cc6e6b082b478b8957d7e7c0480
Author:        Arnd Bergmann <[email protected]>
AuthorDate:    Thu, 03 Aug 2023 10:26:15 +02:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 03 Aug 2023 12:08:35 +02:00

x86/asm: Avoid unneeded __div64_32 function definition

The __div64_32() function is provided for 32-bit architectures that don't have a custom do_div() implementation. x86_32 has one, and does not use the header file that declares the function prototype, so the definition causes a W=1 warning:

lib/math/div64.c:31:32: error: no previous prototype for '__div64_32' [-Werror=missing-prototypes]

Define an empty macro to prevent the function definition from getting built, which avoids the warning and saves a little .text space.

---
 arch/x86/include/asm/div64.h | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/include/asm/div64.h +6 -0
index b8f1dc0..9931e4c 100644
@@ -71,6 +71,12 @@ static inline u64 mul_u32_u32(u32 a, u32 b)
 }
 #define mul_u32_u32 mul_u32_u32
 
+/*
+ * __div64_32() is never called on x86, so prevent the
+ * generic definition from getting built.
+ */
+#define __div64_32
+
 #else
 # include <asm-generic/div64.h>
 
#5 lore raw

PATCH v3 4/7 x86: purgatory: include header for warn() declaration

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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

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

---
 arch/x86/boot/compressed/error.c | 2 +-
 arch/x86/boot/compressed/error.h | 2 +-
 arch/x86/purgatory/purgatory.c   | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/boot/compressed/error.c +1 -1
index 5313c5cb2b802..19a8251de506a 100644
@@ -7,7 +7,7 @@
 #include "misc.h"
 #include "error.h"
 
-void warn(char *m)
+void warn(const char *m)
 {
 	error_putstr("\n\n");
 	error_putstr(m);
arch/x86/boot/compressed/error.h +1 -1
index 86fe33b937154..31f9e080d61a8 100644
@@ -4,7 +4,7 @@
 
 #include <linux/compiler.h>
 
-void warn(char *m);
+void warn(const char *m);
 void error(char *m) __noreturn;
 void panic(const char *fmt, ...) __noreturn __cold;
 
arch/x86/purgatory/purgatory.c +1 -0
index 7558139920f8c..aea47e7939637 100644
@@ -14,6 +14,7 @@
 #include <crypto/sha2.h>
 #include <asm/purgatory.h>
 
+#include "../boot/compressed/error.h"
 #include "../boot/string.h"
 
 u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE] __section(".kexec-purgatory");
Signature · 1 line
2.39.2
merge bot Applied
#6 lore raw

[tip: x86/cleanups] x86/purgatory: Include header for warn() declaration

The following commit has been merged into the x86/cleanups branch of tip:

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     6d33531bc0234332572ae612232d947f353a4450
Gitweb:        https://git.kernel.org/tip/6d33531bc0234332572ae612232d947f353a4450
Author:        Arnd Bergmann <[email protected]>
AuthorDate:    Thu, 03 Aug 2023 10:26:16 +02:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 03 Aug 2023 16:37:18 +02:00

x86/purgatory: Include header for warn() declaration

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

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

---
 arch/x86/boot/compressed/error.c | 2 +-
 arch/x86/boot/compressed/error.h | 2 +-
 arch/x86/purgatory/purgatory.c   | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/boot/compressed/error.c +1 -1
index 5313c5c..19a8251 100644
@@ -7,7 +7,7 @@
 #include "misc.h"
 #include "error.h"
 
-void warn(char *m)
+void warn(const char *m)
 {
 	error_putstr("\n\n");
 	error_putstr(m);
arch/x86/boot/compressed/error.h +1 -1
index 86fe33b..31f9e08 100644
@@ -4,7 +4,7 @@
 
 #include <linux/compiler.h>
 
-void warn(char *m);
+void warn(const char *m);
 void error(char *m) __noreturn;
 void panic(const char *fmt, ...) __noreturn __cold;
 
arch/x86/purgatory/purgatory.c +1 -0
index 7558139..aea47e7 100644
@@ -14,6 +14,7 @@
 #include <crypto/sha2.h>
 #include <asm/purgatory.h>
 
+#include "../boot/compressed/error.h"
 #include "../boot/string.h"
 
 u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE] __section(".kexec-purgatory");
#7 lore raw

PATCH v3 5/7 x86: alternative: add __alt_reloc_selftest prototype

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly introduced selftest function causes a warning when -Wmissing-prototypes is enabled:

arch/x86/kernel/alternative.c:1461:32: error: no previous prototype for '__alt_reloc_selftest' [-Werror=missing-prototypes]

Since it's only used locally, add the prototype directly in front of it.

Fixes 270a69c4485d ("x86/alternative: Support relocations in alternatives")
---
 arch/x86/kernel/alternative.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/alternative.c +1 -0
index 2dcf3a06af090..934c23f24a3f8 100644
@@ -1531,6 +1531,7 @@ static noinline void __init int3_selftest(void)
 
 static __initdata int __alt_reloc_selftest_addr;
 
+extern void __init __alt_reloc_selftest(void *arg);
 __visible noinline void __init __alt_reloc_selftest(void *arg)
 {
 	WARN_ON(arg != &__alt_reloc_selftest_addr);
Signature · 1 line
2.39.2
merge bot Applied
#8 lore raw

[tip: x86/cleanups] x86/alternative: Add a __alt_reloc_selftest() prototype

The following commit has been merged into the x86/cleanups branch of tip:

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     1a3e4b4da39bbf540a379e21869faa74bb19d16f
Gitweb:        https://git.kernel.org/tip/1a3e4b4da39bbf540a379e21869faa74bb19d16f
Author:        Arnd Bergmann <[email protected]>
AuthorDate:    Thu, 03 Aug 2023 10:26:17 +02:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 03 Aug 2023 16:40:50 +02:00

x86/alternative: Add a __alt_reloc_selftest() prototype

The newly introduced selftest function causes a warning when -Wmissing-prototypes is enabled:

arch/x86/kernel/alternative.c:1461:32: error: no previous prototype for '__alt_reloc_selftest' [-Werror=missing-prototypes]

Since it's only used locally, add the prototype directly in front of it.

Fixes 270a69c4485d ("x86/alternative: Support relocations in alternatives")
---
 arch/x86/kernel/alternative.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/alternative.c +1 -0
index 2dcf3a0..934c23f 100644
@@ -1531,6 +1531,7 @@ static noinline void __init int3_selftest(void)
 
 static __initdata int __alt_reloc_selftest_addr;
 
+extern void __init __alt_reloc_selftest(void *arg);
 __visible noinline void __init __alt_reloc_selftest(void *arg)
 {
 	WARN_ON(arg != &__alt_reloc_selftest_addr);
#9 lore raw

PATCH v3 6/7 x86: paravirt: shut up unused native_pv_lock_init() function warning

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The native_pv_lock_init function is only used in SMP configurations and declared in asm/qspinlock.h, which is not used in UP kernels, but the function is still defined for both, which causes a warning:

arch/x86/kernel/paravirt.c:76:13: error: no previous prototype for 'native_pv_lock_init' [-Werror=missing-prototypes]

Move the declaration to asm/paravirt.h so it is visible even with CONFIG_SMP but short-circuit the definition to turn it into an empty function.

---
v3: new patch to avoid adding another #ifdef to paravirt.c

---
 arch/x86/include/asm/paravirt.h  | 7 +++++++
 arch/x86/include/asm/qspinlock.h | 7 +------
 arch/x86/kernel/paravirt.c       | 3 ++-
 3 files changed, 10 insertions(+), 7 deletions(-)
arch/x86/include/asm/paravirt.h +7 -0
index b49778664d2be..6c8ff12140aea 100644
@@ -739,6 +739,7 @@ static __always_inline unsigned long arch_local_irq_save(void)
 	     ".popsection")
 
 extern void default_banner(void);
+void native_pv_lock_init(void) __init;
 
 #else  /* __ASSEMBLY__ */
 
@@ -778,6 +779,12 @@ extern void default_banner(void);
 #endif /* __ASSEMBLY__ */
 #else  /* CONFIG_PARAVIRT */
 # define default_banner x86_init_noop
+
+#ifndef __ASSEMBLY__
+static inline void native_pv_lock_init(void)
+{
+}
+#endif
 #endif /* !CONFIG_PARAVIRT */
 
 #ifndef __ASSEMBLY__
arch/x86/include/asm/qspinlock.h +1 -6
index d87451df480bd..cde8357bb226d 100644
@@ -74,8 +74,6 @@ static inline bool vcpu_is_preempted(long cpu)
  */
 DECLARE_STATIC_KEY_TRUE(virt_spin_lock_key);
 
-void native_pv_lock_init(void) __init;
-
 /*
  * Shortcut for the queued_spin_lock_slowpath() function that allows
  * virt to hijack it.
@@ -103,10 +101,7 @@ static inline bool virt_spin_lock(struct qspinlock *lock)
 
 	return true;
 }
-#else
-static inline void native_pv_lock_init(void)
-{
-}
+
 #endif /* CONFIG_PARAVIRT */
 
 #include <asm-generic/qspinlock.h>
arch/x86/kernel/paravirt.c +2 -1
index 89842bb7ec9cc..066fc19d2568e 100644
@@ -75,7 +75,8 @@ DEFINE_STATIC_KEY_TRUE(virt_spin_lock_key);
 
 void __init native_pv_lock_init(void)
 {
-	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
+	if (IS_ENABLED(CONFIG_PARAVIRT_SPINLOCKS) &&
+	    !boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		static_branch_disable(&virt_spin_lock_key);
 }
 
Signature · 1 line
2.39.2
merge bot Applied
#10 lore raw

[tip: x86/cleanups] x86/paravirt: Silence unused native_pv_lock_init() function warning

The following commit has been merged into the x86/cleanups branch of tip:

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     ce0a1b608bfc709cf366f020b520310a3b3272c3
Gitweb:        https://git.kernel.org/tip/ce0a1b608bfc709cf366f020b520310a3b3272c3
Author:        Arnd Bergmann <[email protected]>
AuthorDate:    Thu, 03 Aug 2023 10:26:18 +02:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 03 Aug 2023 16:50:19 +02:00

x86/paravirt: Silence unused native_pv_lock_init() function warning

The native_pv_lock_init() function is only used in SMP configurations and declared in asm/qspinlock.h which is not used in UP kernels, but the function is still defined for both, which causes a warning:

arch/x86/kernel/paravirt.c:76:13: error: no previous prototype for 'native_pv_lock_init' [-Werror=missing-prototypes]

Move the declaration to asm/paravirt.h so it is visible even with CONFIG_SMP but short-circuit the definition to turn it into an empty function.

---
 arch/x86/include/asm/paravirt.h  | 7 +++++++
 arch/x86/include/asm/qspinlock.h | 7 +------
 arch/x86/kernel/paravirt.c       | 3 ++-
 3 files changed, 10 insertions(+), 7 deletions(-)
arch/x86/include/asm/paravirt.h +7 -0
index b497786..6c8ff12 100644
@@ -739,6 +739,7 @@ static __always_inline unsigned long arch_local_irq_save(void)
 	     ".popsection")
 
 extern void default_banner(void);
+void native_pv_lock_init(void) __init;
 
 #else  /* __ASSEMBLY__ */
 
@@ -778,6 +779,12 @@ extern void default_banner(void);
 #endif /* __ASSEMBLY__ */
 #else  /* CONFIG_PARAVIRT */
 # define default_banner x86_init_noop
+
+#ifndef __ASSEMBLY__
+static inline void native_pv_lock_init(void)
+{
+}
+#endif
 #endif /* !CONFIG_PARAVIRT */
 
 #ifndef __ASSEMBLY__
arch/x86/include/asm/qspinlock.h +1 -6
index d87451d..cde8357 100644
@@ -74,8 +74,6 @@ static inline bool vcpu_is_preempted(long cpu)
  */
 DECLARE_STATIC_KEY_TRUE(virt_spin_lock_key);
 
-void native_pv_lock_init(void) __init;
-
 /*
  * Shortcut for the queued_spin_lock_slowpath() function that allows
  * virt to hijack it.
@@ -103,10 +101,7 @@ static inline bool virt_spin_lock(struct qspinlock *lock)
 
 	return true;
 }
-#else
-static inline void native_pv_lock_init(void)
-{
-}
+
 #endif /* CONFIG_PARAVIRT */
 
 #include <asm-generic/qspinlock.h>
arch/x86/kernel/paravirt.c +2 -1
index ac10b46..32e94a3 100644
@@ -75,7 +75,8 @@ DEFINE_STATIC_KEY_TRUE(virt_spin_lock_key);
 
 void __init native_pv_lock_init(void)
 {
-	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
+	if (IS_ENABLED(CONFIG_PARAVIRT_SPINLOCKS) &&
+	    !boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		static_branch_disable(&virt_spin_lock_key);
 }
 
#11 lore raw

PATCH v3 7/7 x86: qspinlock-paravirt: fix mising-prototype warning

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

__pv_queued_spin_unlock_slowpath is defined in a header file as a global function, and designed to be called from an inline asm, but there is no prototype visible in the definition:

kernel/locking/qspinlock_paravirt.h:493:1: error: no previous prototype for '__pv_queued_spin_unlock_slowpath' [-Werror=missing-prototypes]

Add this to the x86 header that contains the inline asm calling it, and ensure this gets included before the definition, rather than after it.

---
v3: split out native_pv_lock_init() changes into a separate patch, keeping only __pv_queued_spin_unlock_slowpath here

---
 arch/x86/include/asm/qspinlock_paravirt.h |  2 ++
 kernel/locking/qspinlock_paravirt.h       | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)
arch/x86/include/asm/qspinlock_paravirt.h +2 -0
index 42b17cf10b10e..85b6e3609cb92 100644
@@ -4,6 +4,8 @@
 
 #include <asm/ibt.h>
 
+void __lockfunc __pv_queued_spin_unlock_slowpath(struct qspinlock *lock, u8 locked);
+
 /*
  * For x86-64, PV_CALLEE_SAVE_REGS_THUNK() saves and restores 8 64-bit
  * registers. For i386, however, only 1 32-bit register needs to be saved
kernel/locking/qspinlock_paravirt.h +10 -10
index 6afc249ce697d..6a0184e9c2348 100644
@@ -485,6 +485,16 @@ pv_wait_head_or_lock(struct qspinlock *lock, struct mcs_spinlock *node)
 	return (u32)(atomic_read(&lock->val) | _Q_LOCKED_VAL);
 }
 
+/*
+ * Include the architecture specific callee-save thunk of the
+ * __pv_queued_spin_unlock(). This thunk is put together with
+ * __pv_queued_spin_unlock() to make the callee-save thunk and the real unlock
+ * function close to each other sharing consecutive instruction cachelines.
+ * Alternatively, architecture specific version of __pv_queued_spin_unlock()
+ * can be defined.
+ */
+#include <asm/qspinlock_paravirt.h>
+
 /*
  * PV versions of the unlock fastpath and slowpath functions to be used
  * instead of queued_spin_unlock().
@@ -533,16 +543,6 @@ __pv_queued_spin_unlock_slowpath(struct qspinlock *lock, u8 locked)
 	pv_kick(node->cpu);
 }
 
-/*
- * Include the architecture specific callee-save thunk of the
- * __pv_queued_spin_unlock(). This thunk is put together with
- * __pv_queued_spin_unlock() to make the callee-save thunk and the real unlock
- * function close to each other sharing consecutive instruction cachelines.
- * Alternatively, architecture specific version of __pv_queued_spin_unlock()
- * can be defined.
- */
-#include <asm/qspinlock_paravirt.h>
-
 #ifndef __pv_queued_spin_unlock
 __visible __lockfunc void __pv_queued_spin_unlock(struct qspinlock *lock)
 {
Signature · 1 line
2.39.2
merge bot Applied
#12 lore raw

[tip: x86/cleanups] x86/qspinlock-paravirt: Fix missing-prototype warning

The following commit has been merged into the x86/cleanups branch of tip:

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     8874a414f8f706daf1de467cbf2550988ebec09d
Gitweb:        https://git.kernel.org/tip/8874a414f8f706daf1de467cbf2550988ebec09d
Author:        Arnd Bergmann <[email protected]>
AuthorDate:    Thu, 03 Aug 2023 10:26:19 +02:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 03 Aug 2023 17:15:05 +02:00

x86/qspinlock-paravirt: Fix missing-prototype warning

__pv_queued_spin_unlock_slowpath() is defined in a header file as a global function, and designed to be called from inline asm, but there is no prototype visible in the definition:

  kernel/locking/qspinlock_paravirt.h:493:1: error: no previous \
    prototype for '__pv_queued_spin_unlock_slowpath' [-Werror=missing-prototypes]

Add this to the x86 header that contains the inline asm calling it, and ensure this gets included before the definition, rather than after it.

---
 arch/x86/include/asm/qspinlock_paravirt.h |  2 ++
 kernel/locking/qspinlock_paravirt.h       | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)
arch/x86/include/asm/qspinlock_paravirt.h +2 -0
index 42b17cf..85b6e36 100644
@@ -4,6 +4,8 @@
 
 #include <asm/ibt.h>
 
+void __lockfunc __pv_queued_spin_unlock_slowpath(struct qspinlock *lock, u8 locked);
+
 /*
  * For x86-64, PV_CALLEE_SAVE_REGS_THUNK() saves and restores 8 64-bit
  * registers. For i386, however, only 1 32-bit register needs to be saved
kernel/locking/qspinlock_paravirt.h +10 -10
index 6afc249..6a0184e 100644
@@ -486,6 +486,16 @@ gotlock:
 }
 
 /*
+ * Include the architecture specific callee-save thunk of the
+ * __pv_queued_spin_unlock(). This thunk is put together with
+ * __pv_queued_spin_unlock() to make the callee-save thunk and the real unlock
+ * function close to each other sharing consecutive instruction cachelines.
+ * Alternatively, architecture specific version of __pv_queued_spin_unlock()
+ * can be defined.
+ */
+#include <asm/qspinlock_paravirt.h>
+
+/*
  * PV versions of the unlock fastpath and slowpath functions to be used
  * instead of queued_spin_unlock().
  */
@@ -533,16 +543,6 @@ __pv_queued_spin_unlock_slowpath(struct qspinlock *lock, u8 locked)
 	pv_kick(node->cpu);
 }
 
-/*
- * Include the architecture specific callee-save thunk of the
- * __pv_queued_spin_unlock(). This thunk is put together with
- * __pv_queued_spin_unlock() to make the callee-save thunk and the real unlock
- * function close to each other sharing consecutive instruction cachelines.
- * Alternatively, architecture specific version of __pv_queued_spin_unlock()
- * can be defined.
- */
-#include <asm/qspinlock_paravirt.h>
-
 #ifndef __pv_queued_spin_unlock
 __visible __lockfunc void __pv_queued_spin_unlock(struct qspinlock *lock)
 {
maintainer
#13 lore raw
In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

This is almost the same as before, and should let us turn on -Wmissing-prototypes by default. I'm still unsure whether we need to do this per architecture as some other ones still produce a lot of warnings, or we just enabled it for everyone and let arch maintainers deal with it now that the major

Yeah, might wanna ask them first.

I definitely want this finally enabled so that we can finally put this one to rest.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette