Skip to content

Commit ce0a1b6

Browse files
arndbbp3tk0v
authored andcommitted
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]
1 parent 1a3e4b4 commit ce0a1b6

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

arch/x86/include/asm/paravirt.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ static __always_inline unsigned long arch_local_irq_save(void)
739739
".popsection")
740740

741741
extern void default_banner(void);
742+
void native_pv_lock_init(void) __init;
742743

743744
#else /* __ASSEMBLY__ */
744745

@@ -778,6 +779,12 @@ extern void default_banner(void);
778779
#endif /* __ASSEMBLY__ */
779780
#else /* CONFIG_PARAVIRT */
780781
# define default_banner x86_init_noop
782+
783+
#ifndef __ASSEMBLY__
784+
static inline void native_pv_lock_init(void)
785+
{
786+
}
787+
#endif
781788
#endif /* !CONFIG_PARAVIRT */
782789

783790
#ifndef __ASSEMBLY__

arch/x86/include/asm/qspinlock.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ static inline bool vcpu_is_preempted(long cpu)
7474
*/
7575
DECLARE_STATIC_KEY_TRUE(virt_spin_lock_key);
7676

77-
void native_pv_lock_init(void) __init;
78-
7977
/*
8078
* Shortcut for the queued_spin_lock_slowpath() function that allows
8179
* virt to hijack it.
@@ -103,10 +101,7 @@ static inline bool virt_spin_lock(struct qspinlock *lock)
103101

104102
return true;
105103
}
106-
#else
107-
static inline void native_pv_lock_init(void)
108-
{
109-
}
104+
110105
#endif /* CONFIG_PARAVIRT */
111106

112107
#include <asm-generic/qspinlock.h>

arch/x86/kernel/paravirt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ DEFINE_STATIC_KEY_TRUE(virt_spin_lock_key);
7575

7676
void __init native_pv_lock_init(void)
7777
{
78-
if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
78+
if (IS_ENABLED(CONFIG_PARAVIRT_SPINLOCKS) &&
79+
!boot_cpu_has(X86_FEATURE_HYPERVISOR))
7980
static_branch_disable(&virt_spin_lock_key);
8081
}
8182

0 commit comments

Comments
 (0)