lkml.org 
[lkml]   [2022]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH] x86/apic: retpoline mitigation for send_IPI
From
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
\
 
 \ /
  Last update: 2022-02-19 00:26    [W:0.231 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site