Skip to content

Commit a31e58e

Browse files
committed
x86/apic: Switch all APICs to Fixed delivery mode
Some of the APIC incarnations are operating in lowest priority delivery mode. This worked as long as the vector management code allocated the same vector on all possible CPUs for each interrupt. Lowest priority delivery mode does not necessarily respect the affinity setting and may redirect to some other online CPU. This was documented somewhere in the old code and the conversion to single target delivery missed to update the delivery mode of the affected APIC drivers which results in spurious interrupts on some of the affected CPU/Chipset combinations. Switch the APIC drivers over to Fixed delivery mode and remove all leftovers of lowest priority delivery mode. Switching to Fixed delivery mode is not a problem on these CPUs because the kernel already uses Fixed delivery mode for IPIs. The reason for this is that th SDM explicitely forbids lowest prio mode for IPIs. The reason is obvious: If the irq routing does not honor destination targets in lowest prio mode then an IPI targeted at CPU1 might end up on CPU0, which would be a fatal problem in many cases. As a consequence of this change, the apic::irq_delivery_mode field is now pointless, but this needs to be cleaned up in a separate patch. Fixes: fdba46f ("x86/apic: Get rid of multi CPU affinity") Reported-by: vcaputo@pengaru.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: vcaputo@pengaru.com Cc: Pavel Machek <pavel@ucw.cz> Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1712281140440.1688@nanos
1 parent 64e05d1 commit a31e58e

File tree

6 files changed

+8
-16
lines changed

6 files changed

+8
-16
lines changed

arch/x86/kernel/apic/apic_flat_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static struct apic apic_flat __ro_after_init = {
151151
.apic_id_valid = default_apic_id_valid,
152152
.apic_id_registered = flat_apic_id_registered,
153153

154-
.irq_delivery_mode = dest_LowestPrio,
154+
.irq_delivery_mode = dest_Fixed,
155155
.irq_dest_mode = 1, /* logical */
156156

157157
.disable_esr = 0,

arch/x86/kernel/apic/apic_noop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct apic apic_noop __ro_after_init = {
110110
.apic_id_valid = default_apic_id_valid,
111111
.apic_id_registered = noop_apic_id_registered,
112112

113-
.irq_delivery_mode = dest_LowestPrio,
113+
.irq_delivery_mode = dest_Fixed,
114114
/* logical delivery broadcast to all CPUs: */
115115
.irq_dest_mode = 1,
116116

arch/x86/kernel/apic/msi.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,13 @@ static void irq_msi_compose_msg(struct irq_data *data, struct msi_msg *msg)
3939
((apic->irq_dest_mode == 0) ?
4040
MSI_ADDR_DEST_MODE_PHYSICAL :
4141
MSI_ADDR_DEST_MODE_LOGICAL) |
42-
((apic->irq_delivery_mode != dest_LowestPrio) ?
43-
MSI_ADDR_REDIRECTION_CPU :
44-
MSI_ADDR_REDIRECTION_LOWPRI) |
42+
MSI_ADDR_REDIRECTION_CPU |
4543
MSI_ADDR_DEST_ID(cfg->dest_apicid);
4644

4745
msg->data =
4846
MSI_DATA_TRIGGER_EDGE |
4947
MSI_DATA_LEVEL_ASSERT |
50-
((apic->irq_delivery_mode != dest_LowestPrio) ?
51-
MSI_DATA_DELIVERY_FIXED :
52-
MSI_DATA_DELIVERY_LOWPRI) |
48+
MSI_DATA_DELIVERY_FIXED |
5349
MSI_DATA_VECTOR(cfg->vector);
5450
}
5551

arch/x86/kernel/apic/probe_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static struct apic apic_default __ro_after_init = {
105105
.apic_id_valid = default_apic_id_valid,
106106
.apic_id_registered = default_apic_id_registered,
107107

108-
.irq_delivery_mode = dest_LowestPrio,
108+
.irq_delivery_mode = dest_Fixed,
109109
/* logical delivery broadcast to all CPUs: */
110110
.irq_dest_mode = 1,
111111

arch/x86/kernel/apic/x2apic_cluster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static struct apic apic_x2apic_cluster __ro_after_init = {
184184
.apic_id_valid = x2apic_apic_id_valid,
185185
.apic_id_registered = x2apic_apic_id_registered,
186186

187-
.irq_delivery_mode = dest_LowestPrio,
187+
.irq_delivery_mode = dest_Fixed,
188188
.irq_dest_mode = 1, /* logical */
189189

190190
.disable_esr = 0,

drivers/pci/host/pci-hyperv.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -985,9 +985,7 @@ static u32 hv_compose_msi_req_v1(
985985
int_pkt->wslot.slot = slot;
986986
int_pkt->int_desc.vector = vector;
987987
int_pkt->int_desc.vector_count = 1;
988-
int_pkt->int_desc.delivery_mode =
989-
(apic->irq_delivery_mode == dest_LowestPrio) ?
990-
dest_LowestPrio : dest_Fixed;
988+
int_pkt->int_desc.delivery_mode = dest_Fixed;
991989

992990
/*
993991
* Create MSI w/ dummy vCPU set, overwritten by subsequent retarget in
@@ -1008,9 +1006,7 @@ static u32 hv_compose_msi_req_v2(
10081006
int_pkt->wslot.slot = slot;
10091007
int_pkt->int_desc.vector = vector;
10101008
int_pkt->int_desc.vector_count = 1;
1011-
int_pkt->int_desc.delivery_mode =
1012-
(apic->irq_delivery_mode == dest_LowestPrio) ?
1013-
dest_LowestPrio : dest_Fixed;
1009+
int_pkt->int_desc.delivery_mode = dest_Fixed;
10141010

10151011
/*
10161012
* Create MSI w/ dummy vCPU set targeting just one vCPU, overwritten

0 commit comments

Comments
 (0)