[rfc -tip 2/2] x86, apic: Allow to send self NMI ipi

From: Cyrill Gorcunov
Date: Wed Oct 27 2010 - 16:08:59 EST


Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxxx>
CC: Don Zickus <dzickus@xxxxxxxxxx>
---
arch/x86/include/asm/ipi.h | 6 ++++++
arch/x86/kernel/apic/ipi.c | 5 ++++-
arch/x86/kernel/apic/probe_64.c | 5 ++++-
arch/x86/kernel/apic/x2apic_cluster.c | 5 ++++-
arch/x86/kernel/apic/x2apic_phys.c | 5 ++++-
arch/x86/kernel/apic/x2apic_uv_x.c | 5 ++++-
6 files changed, 26 insertions(+), 5 deletions(-)

Index: linux-2.6.git/arch/x86/include/asm/ipi.h
=====================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/ipi.h
+++ linux-2.6.git/arch/x86/include/asm/ipi.h
@@ -149,6 +149,12 @@ static inline void __default_local_send_
__default_send_IPI_shortcut(APIC_DEST_ALLINC, vector, apic->dest_logical);
}

+static inline void __default_send_IPI_self_nmi(void)
+{
+ const struct cpumask *cpumask = cpumask_of(smp_processor_id());
+ apic->send_IPI_mask(cpumask, NMI_VECTOR);
+}
+
#ifdef CONFIG_X86_32
extern void default_send_IPI_mask_logical(const struct cpumask *mask,
int vector);
Index: linux-2.6.git/arch/x86/kernel/apic/ipi.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/ipi.c
+++ linux-2.6.git/arch/x86/kernel/apic/ipi.c
@@ -134,7 +134,10 @@ void default_send_IPI_all(int vector)

void default_send_IPI_self(int vector)
{
- __default_send_IPI_shortcut(APIC_DEST_SELF, vector, apic->dest_logical);
+ if (unlikely(vector == NMI_VECTOR))
+ __default_send_IPI_self_nmi();
+ else
+ __default_send_IPI_shortcut(APIC_DEST_SELF, vector, apic->dest_logical);
}

/* must come after the send_IPI functions above for inlining */
Index: linux-2.6.git/arch/x86/kernel/apic/probe_64.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/probe_64.c
+++ linux-2.6.git/arch/x86/kernel/apic/probe_64.c
@@ -92,7 +92,10 @@ void __init default_setup_apic_routing(v

void apic_send_IPI_self(int vector)
{
- __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
+ if (unlikely(vector == NMI_VECTOR))
+ __default_send_IPI_self_nmi();
+ else
+ __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
}

int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
Index: linux-2.6.git/arch/x86/kernel/apic/x2apic_cluster.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/x2apic_cluster.c
+++ linux-2.6.git/arch/x86/kernel/apic/x2apic_cluster.c
@@ -174,7 +174,10 @@ static int x2apic_cluster_phys_pkg_id(in

static void x2apic_send_IPI_self(int vector)
{
- apic_write(APIC_SELF_IPI, vector);
+ if (unlikely(vector == NMI_VECTOR))
+ __default_send_IPI_self_nmi();
+ else
+ apic_write(APIC_SELF_IPI, vector);
}

static void init_x2apic_ldr(void)
Index: linux-2.6.git/arch/x86/kernel/apic/x2apic_phys.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/x2apic_phys.c
+++ linux-2.6.git/arch/x86/kernel/apic/x2apic_phys.c
@@ -166,7 +166,10 @@ static int x2apic_phys_pkg_id(int initia

static void x2apic_send_IPI_self(int vector)
{
- apic_write(APIC_SELF_IPI, vector);
+ if (unlikely(vector == NMI_VECTOR))
+ __default_send_IPI_self_nmi();
+ else
+ apic_write(APIC_SELF_IPI, vector);
}

static void init_x2apic_ldr(void)
Index: linux-2.6.git/arch/x86/kernel/apic/x2apic_uv_x.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/x2apic_uv_x.c
+++ linux-2.6.git/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -274,7 +274,10 @@ static int uv_phys_pkg_id(int initial_ap

static void uv_send_IPI_self(int vector)
{
- apic_write(APIC_SELF_IPI, vector);
+ if (unlikely(vector == NMI_VECTOR))
+ __default_send_IPI_self_nmi();
+ else
+ apic_write(APIC_SELF_IPI, vector);
}

struct apic __refdata apic_x2apic_uv_x = {

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/