Thread (24 messages) 24 messages, 5 authors, 2025-05-09

Re: [PATCH v5 6/9] x86/nmi: Prepare for the new NMI-source vector encoding

From: Peter Zijlstra <peterz@infradead.org>
Date: 2025-05-07 09:17:36
Also in: kvm, linux-edac, linux-perf-users, linux-pm, lkml

On Tue, May 06, 2025 at 06:21:42PM -0700, Sohil Mehta wrote:
+/*
+ * Prepare the delivery mode and vector for the ICR.
+ *
+ * NMI-source vectors have the NMI delivery mode encoded within them to
+ * differentiate them from the IDT vectors. IDT vector 0x2 (NMI_VECTOR)
+ * is treated as an NMI request but without any NMI-source information.
+ */
+static inline u16 __prepare_ICR_DM_vector(u16 dm_vector)
+{
+	u16 vector = dm_vector & APIC_VECTOR_MASK;
+	u16 dm = dm_vector & APIC_DM_MASK;
+
+	if (dm == APIC_DM_NMI) {
+		/*
+		 * Pre-FRED, the actual vector is ignored for NMIs, but
+		 * zero it if NMI-source reporting is not supported to
+		 * avoid breakage on misbehaving hardware or hypervisors.
+		 */
+		if (!cpu_feature_enabled(X86_FEATURE_NMI_SOURCE))
+			vector = 0;
+
+		return dm | vector;
+	}
+
+	if (vector == NMI_VECTOR)
+		return APIC_DM_NMI;
+	else
Please drop that else, that's pointless.
+		return APIC_DM_FIXED | vector;
+}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help