2023-08-03 09:01:29

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH v3 0/7] 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(-)

--
2.39.2



2023-08-03 09:52:57

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH v3 3/7] x86: avoid unneeded __div64_32 function definition

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.

Signed-off-by: Arnd Bergmann <[email protected]>
---
v3: improve code comment
---
arch/x86/include/asm/div64.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
index b8f1dc0761e4b..9931e4c7d73f3 100644
--- a/arch/x86/include/asm/div64.h
+++ b/arch/x86/include/asm/div64.h
@@ -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>

--
2.39.2


2023-08-03 09:55:39

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH v3 6/7] x86: paravirt: shut up unused native_pv_lock_init() function warning

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.

Signed-off-by: Arnd Bergmann <[email protected]>
---
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(-)

diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index b49778664d2be..6c8ff12140aea 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -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__
diff --git a/arch/x86/include/asm/qspinlock.h b/arch/x86/include/asm/qspinlock.h
index d87451df480bd..cde8357bb226d 100644
--- a/arch/x86/include/asm/qspinlock.h
+++ b/arch/x86/include/asm/qspinlock.h
@@ -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>
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 89842bb7ec9cc..066fc19d2568e 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -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);
}

--
2.39.2


2023-08-03 13:49:25

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH v3 0/7] x86: remaining -Wmissing-prototype warning fixes

On Thu, Aug 03, 2023 at 10:26:12AM +0200, Arnd Bergmann wrote:
> 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.

--
Regards/Gruss,
Boris.

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

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

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.

Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Borislav Petkov (AMD) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
arch/x86/include/asm/div64.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
index b8f1dc0..9931e4c 100644
--- a/arch/x86/include/asm/div64.h
+++ b/arch/x86/include/asm/div64.h
@@ -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>


Subject: [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:

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.

Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Borislav Petkov (AMD) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
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(-)

diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index b497786..6c8ff12 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -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__
diff --git a/arch/x86/include/asm/qspinlock.h b/arch/x86/include/asm/qspinlock.h
index d87451d..cde8357 100644
--- a/arch/x86/include/asm/qspinlock.h
+++ b/arch/x86/include/asm/qspinlock.h
@@ -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>
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index ac10b46..32e94a3 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -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);
}