[PATCH v4 02/11] x86/irq: Define NMI source vectors
From: Jacob Pan
Date: Tue Jul 09 2024 - 10:34:19 EST
When NMI-source reporting is supported, each logical processor maintains
a 16-bit NMI-source bitmap. It is up to the system software to assign NMI
sources for their matching vector (bit position) in the bitmap.
Notice that NMI source vector is in a different namespace than the IDT
vectors. Though they share the same programming interface/field in the
NMI originator.
This initial allocation of the NMI sources are limited to local NMIs in
that there is no external device NMI usage yet.
Signed-off-by: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
---
arch/x86/include/asm/irq_vectors.h | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h
index 13aea8fc3d45..4f767c3940d6 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -105,6 +105,36 @@
#define NR_VECTORS 256
+/*
+ * NMI senders specify the NMI-source vector as an 8-bit integer in their
+ * vector field with NMI delivery mode. A local APIC receiving an NMI will
+ * set the corresponding bit in a 16-bit bitmask, which is accumulated until
+ * the NMI is delivered.
+ *
+ * When a sender didn't specify an NMI-source vector the source vector will
+ * be 0, which will result in bit 0 of the bitmask being set. For out of
+ * bounds vectors >= 16, bit 0 will also be set.
+ *
+ * When bit 0 is set, system software must invoke all registered NMI handlers
+ * as if NMI-source reporting feature is not enabled.
+ *
+ * Vector 2 is reserved for matching IDT NMI vector where it may be hardcoded
+ * by some external devices.
+ *
+ * The NMI-source vectors are sorted by descending priority with the exceptions
+ * of 0 and 2.
+ */
+#define NMI_SOURCE_VEC_UNKNOWN 0
+#define NMI_SOURCE_VEC_IPI_REBOOT 1 /* Crash reboot */
+#define NMI_SOURCE_VEC_IDT_NMI 2 /* Match IDT NMI vector 2 */
+#define NMI_SOURCE_VEC_IPI_SMP_STOP 3 /* Panic stop CPU */
+#define NMI_SOURCE_VEC_IPI_BT 4 /* CPU backtrace */
+#define NMI_SOURCE_VEC_PMI 5 /* PerfMon counters */
+#define NMI_SOURCE_VEC_IPI_KGDB 6 /* KGDB */
+#define NMI_SOURCE_VEC_IPI_MCE 7 /* MCE injection */
+#define NMI_SOURCE_VEC_IPI_TEST 8 /* For remote and local IPIs */
+#define NR_NMI_SOURCE_VECTORS 9
+
#ifdef CONFIG_X86_LOCAL_APIC
#define FIRST_SYSTEM_VECTOR POSTED_MSI_NOTIFICATION_VECTOR
#else
--
2.25.1