The commit 1f60230cdc63 ("x86/smp: Use static_call for
arch_send_call_function_ipi()") changed to use a static call for
arch_send_call_function_ipi(), which causes two problems:

First, the KVM guest also changes 'smp_ops.send_call_func_ipi' when the
PV sched yield feature is available. However, the missing
static_call_update() breaks the PV sched yield feature.

Additionally, xen_smp_init() is called before static_call_init() during
the booting of the XENPV guest, which triggers a warning in
__static_call_update().

To simplify, move the static call update for 'smp_ops' into
smp_prepare_boot_cpu() to address these two problems together.

Fixes: 1f60230cdc63 ("x86/smp: Use static_call for 
arch_send_call_function_ipi()")
Signed-off-by: Hou Wenlong <[email protected]>
---
I'm not sure if the XEN part is okay or not. I think there should be no
IPI before smp_prepare_boot_cpu(), and even if there is, it's okay for
the KVM guest to use the native version before smp_prepare_boot_cpu().
---
 arch/x86/kernel/smpboot.c | 1 +
 arch/x86/xen/smp_hvm.c    | 1 -
 arch/x86/xen/smp_pv.c     | 1 -
 3 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 5cd6950ab672..84b8a4163ddb 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1088,6 +1088,7 @@ void __init smp_prepare_cpus_common(void)
 
 void __init smp_prepare_boot_cpu(void)
 {
+       x86_smp_ops_static_call_update();
        smp_ops.smp_prepare_boot_cpu();
 }
 
diff --git a/arch/x86/xen/smp_hvm.c b/arch/x86/xen/smp_hvm.c
index 5ea0f53e4ea3..485c1d8804f7 100644
--- a/arch/x86/xen/smp_hvm.c
+++ b/arch/x86/xen/smp_hvm.c
@@ -85,5 +85,4 @@ void __init xen_hvm_smp_init(void)
        smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
        smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
        smp_ops.send_call_func_single_ipi = 
xen_smp_send_call_function_single_ipi;
-       x86_smp_ops_static_call_update();
 }
diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
index 72a334b32c32..c40f326f0c3a 100644
--- a/arch/x86/xen/smp_pv.c
+++ b/arch/x86/xen/smp_pv.c
@@ -441,7 +441,6 @@ static const struct smp_ops xen_smp_ops __initconst = {
 void __init xen_smp_init(void)
 {
        smp_ops = xen_smp_ops;
-       x86_smp_ops_static_call_update();
 
        /* Avoid searching for BIOS MP tables */
        x86_init.mpparse.find_mptable           = x86_init_noop;
-- 
2.31.1


Reply via email to