[PATCH] x86/apic: retpoline mitigation for send_IPI

Pete Swain posted 1 patch 4 years, 4 months ago
arch/x86/include/asm/smp.h            | 8 ++++++--
arch/x86/kernel/apic/ipi.c            | 5 ++++-
arch/x86/kernel/apic/x2apic_cluster.c | 2 +-
3 files changed, 11 insertions(+), 4 deletions(-)
[PATCH] x86/apic: retpoline mitigation for send_IPI
Posted by Pete Swain 4 years, 4 months ago
adds INDIRECT_CALL wrappers to hot paths

Signed-off-by: Pete Swain <swine@google.com>
---
 arch/x86/include/asm/smp.h            | 8 ++++++--
 arch/x86/kernel/apic/ipi.c            | 5 ++++-
 arch/x86/kernel/apic/x2apic_cluster.c | 2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 81a0211a372d..1e239583b5a8 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -3,6 +3,7 @@
 #define _ASM_X86_SMP_H
 #ifndef __ASSEMBLY__
 #include <linux/cpumask.h>
+#include <linux/indirect_call_wrapper.h>
 #include <asm/percpu.h>
 
 #include <asm/thread_info.h>
@@ -114,9 +115,13 @@ static inline void smp_send_reschedule(int cpu)
 	smp_ops.smp_send_reschedule(cpu);
 }
 
+void native_send_call_func_single_ipi(int cpu);
+
 static inline void arch_send_call_function_single_ipi(int cpu)
 {
-	smp_ops.send_call_func_single_ipi(cpu);
+
+	INDIRECT_CALL_1(smp_ops.send_call_func_single_ipi,
+			native_send_call_func_single_ipi, cpu);
 }
 
 static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
@@ -144,7 +149,6 @@ void cond_wakeup_cpu0(void);
 
 void native_smp_send_reschedule(int cpu);
 void native_send_call_func_ipi(const struct cpumask *mask);
-void native_send_call_func_single_ipi(int cpu);
 void x86_idle_thread_init(unsigned int cpu, struct task_struct *idle);
 
 void smp_store_boot_cpu_info(void);
diff --git a/arch/x86/kernel/apic/ipi.c b/arch/x86/kernel/apic/ipi.c
index d1fb874fbe64..e376c6e433a6 100644
--- a/arch/x86/kernel/apic/ipi.c
+++ b/arch/x86/kernel/apic/ipi.c
@@ -71,9 +71,12 @@ void native_smp_send_reschedule(int cpu)
 	apic->send_IPI(cpu, RESCHEDULE_VECTOR);
 }
 
+INDIRECT_CALLABLE_DECLARE(void __weak x2apic_send_IPI(int cpu, int vector));
+
 void native_send_call_func_single_ipi(int cpu)
 {
-	apic->send_IPI(cpu, CALL_FUNCTION_SINGLE_VECTOR);
+	INDIRECT_CALL_1(apic->send_IPI, x2apic_send_IPI,
+			cpu, CALL_FUNCTION_SINGLE_VECTOR);
 }
 
 void native_send_call_func_ipi(const struct cpumask *mask)
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
index e696e22d0531..53ea00793ee0 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -31,7 +31,7 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 	return x2apic_enabled();
 }
 
-static void x2apic_send_IPI(int cpu, int vector)
+INDIRECT_CALLABLE_SCOPE void x2apic_send_IPI(int cpu, int vector)
 {
 	u32 dest = x86_cpu_to_logical_apicid[cpu];
 
-- 
2.35.1.473.g83b2b277ed-goog