[tip: x86/urgent] x86/apic/msi: Fix MSI interrupt affinity configuration
From: tip-bot2 for WeitaoWang-oc
Date: Thu Nov 19 2026 - 23:43:17 EST
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 068d82afd070beb8ea32c8ee64d685af7d3f36e2
Gitweb: https://git.kernel.org/tip/068d82afd070beb8ea32c8ee64d685af7d3f36e2
Author: WeitaoWang-oc <WeitaoWang-oc@xxxxxxxxxxx>
AuthorDate: Sat, 17 Oct 2026 02:10:16 +08:00
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Thu, 19 Nov 2026 20:17:47 -08:00
x86/apic/msi: Fix MSI interrupt affinity configuration
The two step update sequence in msi_set_affinity() is required for MSI
interrupts which cannot be migrated atomically, i.e. devices which do not
provide MSI masking.
The MSI message update writes address and data registers separately, so such
a device can raise an interrupt in between, which results in a message built
from half updated state: a stray interrupt on a stale vector and a possibly
lost device interrupt.
The update sequence is selected by a per interrupt quirk flag, which is set
for interrupts which cannot use reservation mode. Reservation mode is only
enabled for maskable interrupts, i.e. devices which provide MSI-X or
mask support, so the quirk flag is the inverse of the reservation mode
bit.
The removal of the quirk flag replaced the flag check with a reservation mode
check, but dropped the negation of the removed condition:
- if (!irqd_msi_nomask_quirk(irqd) || ...)
+ if (!irqd_can_reserve(irqd) || ...)
As the quirk flag is the inverse of the reservation mode bit, the replacement
inverted the condition and selects the wrong update path for every interrupt:
non-maskable interrupts take the direct update path again, which reopens the
race, while maskable interrupts needlessly go through the two step update.
Restore the original condition so that the direct update path is selected when
reservation mode is enabled, which also matches the comment above the check:
direct update is possible when the MSI is maskable, which is the case when the
reservation mode bit is set.
[ bp: Massage commit message. ]
Fixes: b56ebe7c896d ("x86/apic/msi: Fix misconfigured non-maskable MSI quirk")
Signed-off-by: Weitao Wang <WeitaoWang-oc@xxxxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Reviewed-by: Koichiro Den <den@xxxxxxxxxxxxx>
Acked-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx # v6.1+
Link: https://patch.msgid.link/20261016181016.3850-1-WeitaoWang-oc@xxxxxxxxxxx
---
arch/x86/kernel/apic/msi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
index 66bc5d3..da5f44a 100644
--- a/arch/x86/kernel/apic/msi.c
+++ b/arch/x86/kernel/apic/msi.c
@@ -62,7 +62,7 @@ msi_set_affinity(struct irq_data *irqd, const struct cpumask *mask, bool force)
* - The interrupt is not yet started up
* - The new destination CPU is the same as the old destination CPU
*/
- if (!irqd_can_reserve(irqd) ||
+ if (irqd_can_reserve(irqd) ||
cfg->vector == old_cfg.vector ||
old_cfg.vector == MANAGED_IRQ_SHUTDOWN_VECTOR ||
!irqd_is_started(irqd) ||