* [PATCH v1 1/1] x86/reboot: KVM: Guard nmi_shootdown_cpus_on_restart() with ifdeffery
@ 2024-09-09 10:44 Andy Shevchenko
0 siblings, 0 replies; only message in thread
From: Andy Shevchenko @ 2024-09-09 10:44 UTC (permalink / raw)
To: Andy Shevchenko, linux-kernel, llvm
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
The nmi_shootdown_cpus_on_restart() in some cases may be not used.
This, in particular, prevents kernel builds with clang, `make W=1`
and CONFIG_WERROR=y:
arch/x86/kernel/reboot.c:957:20: error: unused function 'nmi_shootdown_cpus_on_restart' [-Werror,-Wunused-function]
957 | static inline void nmi_shootdown_cpus_on_restart(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by guarging the definitions with the respective KVM ifdeffery.
See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
inline functions for W=1 build").
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/kernel/reboot.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 0e0a4cf6b5eb..627fe86b4fcb 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -528,9 +528,9 @@ static inline void kb_wait(void)
}
}
+#if IS_ENABLED(CONFIG_KVM_INTEL) || IS_ENABLED(CONFIG_KVM_AMD)
static inline void nmi_shootdown_cpus_on_restart(void);
-#if IS_ENABLED(CONFIG_KVM_INTEL) || IS_ENABLED(CONFIG_KVM_AMD)
/* RCU-protected callback to disable virtualization prior to reboot. */
static cpu_emergency_virt_cb __rcu *cpu_emergency_virt_callback;
@@ -954,12 +954,6 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback)
*/
}
-static inline void nmi_shootdown_cpus_on_restart(void)
-{
- if (!crash_ipi_issued)
- nmi_shootdown_cpus(NULL);
-}
-
/*
* Check if the crash dumping IPI got issued and if so, call its callback
* directly. This function is used when we have already been in NMI handler.
@@ -987,9 +981,19 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback)
/* No other CPUs to shoot down */
}
-static inline void nmi_shootdown_cpus_on_restart(void) { }
-
void run_crash_ipi_callback(struct pt_regs *regs)
{
}
#endif
+
+#if IS_ENABLED(CONFIG_KVM_INTEL) || IS_ENABLED(CONFIG_KVM_AMD)
+#if defined(CONFIG_SMP)
+static inline void nmi_shootdown_cpus_on_restart(void)
+{
+ if (!crash_ipi_issued)
+ nmi_shootdown_cpus(NULL);
+}
+#else /* !CONFIG_SMP */
+static inline void nmi_shootdown_cpus_on_restart(void) { }
+#endif /* !CONFIG_SMP */
+#endif
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-09 10:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-09 10:44 [PATCH v1 1/1] x86/reboot: KVM: Guard nmi_shootdown_cpus_on_restart() with ifdeffery Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®