Skip to content

Commit 162927f

Browse files
KAGA-KOKOheftig
authored andcommitted
x86/apic: Remove logical destination mode for 64-bit
Logical destination mode of the local APIC is used for systems with up to 8 CPUs. It has an advantage over physical destination mode as it allows to target multiple CPUs at once with IPIs. That advantage was definitely worth it when systems with up to 8 CPUs were state of the art for servers and workstations, but that's history. Aside of that there are systems which fail to work with logical destination mode as the ACPI/DMI quirks show and there are AMD Zen1 systems out there which fail when interrupt remapping is enabled. The latter can be cured by firmware updates, but not all OEMs distribute the required changes. Physical destination mode is guaranteed to work because it is the only way to get a CPU up and running via the INIT/INIT/STARTUP sequence. As the number of CPUs keeps increasing, logical destination mode becomes a less used code path so there is no real good reason to keep it around. Therefore remove logical destination mode support for 64-bit and default to physical destination mode. Signed-off-by: Thomas Gleixner <[email protected]> Cherry-picked-for: https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/issues/64
1 parent 9c89311 commit 162927f

File tree

2 files changed

+7
-120
lines changed

2 files changed

+7
-120
lines changed

arch/x86/include/asm/apic.h

-8
Original file line numberDiff line numberDiff line change
@@ -345,20 +345,12 @@ extern struct apic *apic;
345345
* APIC drivers are probed based on how they are listed in the .apicdrivers
346346
* section. So the order is important and enforced by the ordering
347347
* of different apic driver files in the Makefile.
348-
*
349-
* For the files having two apic drivers, we use apic_drivers()
350-
* to enforce the order with in them.
351348
*/
352349
#define apic_driver(sym) \
353350
static const struct apic *__apicdrivers_##sym __used \
354351
__aligned(sizeof(struct apic *)) \
355352
__section(".apicdrivers") = { &sym }
356353

357-
#define apic_drivers(sym1, sym2) \
358-
static struct apic *__apicdrivers_##sym1##sym2[2] __used \
359-
__aligned(sizeof(struct apic *)) \
360-
__section(".apicdrivers") = { &sym1, &sym2 }
361-
362354
extern struct apic *__apicdrivers[], *__apicdrivers_end[];
363355

364356
/*

arch/x86/kernel/apic/apic_flat_64.c

+7-112
Original file line numberDiff line numberDiff line change
@@ -8,129 +8,25 @@
88
* Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
99
* James Cleverdon.
1010
*/
11-
#include <linux/cpumask.h>
1211
#include <linux/export.h>
13-
#include <linux/acpi.h>
1412

15-
#include <asm/jailhouse_para.h>
1613
#include <asm/apic.h>
1714

1815
#include "local.h"
1916

20-
static struct apic apic_physflat;
21-
static struct apic apic_flat;
22-
23-
struct apic *apic __ro_after_init = &apic_flat;
24-
EXPORT_SYMBOL_GPL(apic);
25-
26-
static int flat_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
27-
{
28-
return 1;
29-
}
30-
31-
static void _flat_send_IPI_mask(unsigned long mask, int vector)
32-
{
33-
unsigned long flags;
34-
35-
local_irq_save(flags);
36-
__default_send_IPI_dest_field(mask, vector, APIC_DEST_LOGICAL);
37-
local_irq_restore(flags);
38-
}
39-
40-
static void flat_send_IPI_mask(const struct cpumask *cpumask, int vector)
41-
{
42-
unsigned long mask = cpumask_bits(cpumask)[0];
43-
44-
_flat_send_IPI_mask(mask, vector);
45-
}
46-
47-
static void
48-
flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)
49-
{
50-
unsigned long mask = cpumask_bits(cpumask)[0];
51-
int cpu = smp_processor_id();
52-
53-
if (cpu < BITS_PER_LONG)
54-
__clear_bit(cpu, &mask);
55-
56-
_flat_send_IPI_mask(mask, vector);
57-
}
58-
59-
static u32 flat_get_apic_id(u32 x)
17+
static u32 physflat_get_apic_id(u32 x)
6018
{
6119
return (x >> 24) & 0xFF;
6220
}
6321

64-
static int flat_probe(void)
22+
static int physflat_probe(void)
6523
{
6624
return 1;
6725
}
6826

69-
static struct apic apic_flat __ro_after_init = {
70-
.name = "flat",
71-
.probe = flat_probe,
72-
.acpi_madt_oem_check = flat_acpi_madt_oem_check,
73-
74-
.dest_mode_logical = true,
75-
76-
.disable_esr = 0,
77-
78-
.init_apic_ldr = default_init_apic_ldr,
79-
.cpu_present_to_apicid = default_cpu_present_to_apicid,
80-
81-
.max_apic_id = 0xFE,
82-
.get_apic_id = flat_get_apic_id,
83-
84-
.calc_dest_apicid = apic_flat_calc_apicid,
85-
86-
.send_IPI = default_send_IPI_single,
87-
.send_IPI_mask = flat_send_IPI_mask,
88-
.send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself,
89-
.send_IPI_allbutself = default_send_IPI_allbutself,
90-
.send_IPI_all = default_send_IPI_all,
91-
.send_IPI_self = default_send_IPI_self,
92-
.nmi_to_offline_cpu = true,
93-
94-
.read = native_apic_mem_read,
95-
.write = native_apic_mem_write,
96-
.eoi = native_apic_mem_eoi,
97-
.icr_read = native_apic_icr_read,
98-
.icr_write = native_apic_icr_write,
99-
.wait_icr_idle = apic_mem_wait_icr_idle,
100-
.safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout,
101-
};
102-
103-
/*
104-
* Physflat mode is used when there are more than 8 CPUs on a system.
105-
* We cannot use logical delivery in this case because the mask
106-
* overflows, so use physical mode.
107-
*/
10827
static int physflat_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
10928
{
110-
#ifdef CONFIG_ACPI
111-
/*
112-
* Quirk: some x86_64 machines can only use physical APIC mode
113-
* regardless of how many processors are present (x86_64 ES7000
114-
* is an example).
115-
*/
116-
if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
117-
(acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL)) {
118-
printk(KERN_DEBUG "system APIC only can use physical flat");
119-
return 1;
120-
}
121-
122-
if (!strncmp(oem_id, "IBM", 3) && !strncmp(oem_table_id, "EXA", 3)) {
123-
printk(KERN_DEBUG "IBM Summit detected, will use apic physical");
124-
return 1;
125-
}
126-
#endif
127-
128-
return 0;
129-
}
130-
131-
static int physflat_probe(void)
132-
{
133-
return apic == &apic_physflat || num_possible_cpus() > 8 || jailhouse_paravirt();
29+
return 1;
13430
}
13531

13632
static struct apic apic_physflat __ro_after_init = {
@@ -146,7 +42,7 @@ static struct apic apic_physflat __ro_after_init = {
14642
.cpu_present_to_apicid = default_cpu_present_to_apicid,
14743

14844
.max_apic_id = 0xFE,
149-
.get_apic_id = flat_get_apic_id,
45+
.get_apic_id = physflat_get_apic_id,
15046

15147
.calc_dest_apicid = apic_default_calc_apicid,
15248

@@ -166,8 +62,7 @@ static struct apic apic_physflat __ro_after_init = {
16662
.wait_icr_idle = apic_mem_wait_icr_idle,
16763
.safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout,
16864
};
65+
apic_driver(apic_physflat);
16966

170-
/*
171-
* We need to check for physflat first, so this order is important.
172-
*/
173-
apic_drivers(apic_physflat, apic_flat);
67+
struct apic *apic __ro_after_init = &apic_physflat;
68+
EXPORT_SYMBOL_GPL(apic);

0 commit comments

Comments
 (0)