Commit cff9ab2b authored by Denys Vlasenko's avatar Denys Vlasenko Committed by Thomas Gleixner

x86/apic: Get rid of apic_version[] array

The array has a size of MAX_LOCAL_APIC, which can be as large as 32k, so it
can consume up to 128k.

The array has been there forever and was never used for anything useful
other than a version mismatch check which was introduced in 2009.

There is no reason to store the version in an array. The kernel is not
prepared to handle different APIC versions anyway, so the real important
part is to detect a version mismatch and warn about it, which can be done
with a single variable as well.

[ tglx: Massaged changelog ]
Signed-off-by: default avatarDenys Vlasenko <dvlasenk@redhat.com>
CC: Andy Lutomirski <luto@amacapital.net>
CC: Borislav Petkov <bp@alien8.de>
CC: Brian Gerst <brgerst@gmail.com>
CC: Mike Travis <travis@sgi.com>
Link: http://lkml.kernel.org/r/20160913181232.30815-1-dvlasenk@redhat.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent b0f48706
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <asm/x86_init.h> #include <asm/x86_init.h>
#include <asm/apicdef.h> #include <asm/apicdef.h>
extern int apic_version[];
extern int pic_mode; extern int pic_mode;
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
...@@ -40,6 +39,7 @@ extern int mp_bus_id_to_type[MAX_MP_BUSSES]; ...@@ -40,6 +39,7 @@ extern int mp_bus_id_to_type[MAX_MP_BUSSES];
extern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES); extern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
extern unsigned int boot_cpu_physical_apicid; extern unsigned int boot_cpu_physical_apicid;
extern u8 boot_cpu_apic_version;
extern unsigned long mp_lapic_addr; extern unsigned long mp_lapic_addr;
#ifdef CONFIG_X86_LOCAL_APIC #ifdef CONFIG_X86_LOCAL_APIC
......
...@@ -182,7 +182,7 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled) ...@@ -182,7 +182,7 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
} }
if (boot_cpu_physical_apicid != -1U) if (boot_cpu_physical_apicid != -1U)
ver = apic_version[boot_cpu_physical_apicid]; ver = boot_cpu_apic_version;
cpu = generic_processor_info(id, ver); cpu = generic_processor_info(id, ver);
if (cpu >= 0) if (cpu >= 0)
......
...@@ -64,6 +64,8 @@ unsigned disabled_cpus; ...@@ -64,6 +64,8 @@ unsigned disabled_cpus;
unsigned int boot_cpu_physical_apicid = -1U; unsigned int boot_cpu_physical_apicid = -1U;
EXPORT_SYMBOL_GPL(boot_cpu_physical_apicid); EXPORT_SYMBOL_GPL(boot_cpu_physical_apicid);
u8 boot_cpu_apic_version;
/* /*
* The highest APIC ID seen during enumeration. * The highest APIC ID seen during enumeration.
*/ */
...@@ -1812,8 +1814,7 @@ void __init init_apic_mappings(void) ...@@ -1812,8 +1814,7 @@ void __init init_apic_mappings(void)
* since smp_sanity_check is prepared for such a case * since smp_sanity_check is prepared for such a case
* and disable smp mode * and disable smp mode
*/ */
apic_version[new_apicid] = boot_cpu_apic_version = GET_APIC_VERSION(apic_read(APIC_LVR));
GET_APIC_VERSION(apic_read(APIC_LVR));
} }
} }
...@@ -1828,13 +1829,10 @@ void __init register_lapic_address(unsigned long address) ...@@ -1828,13 +1829,10 @@ void __init register_lapic_address(unsigned long address)
} }
if (boot_cpu_physical_apicid == -1U) { if (boot_cpu_physical_apicid == -1U) {
boot_cpu_physical_apicid = read_apic_id(); boot_cpu_physical_apicid = read_apic_id();
apic_version[boot_cpu_physical_apicid] = boot_cpu_apic_version = GET_APIC_VERSION(apic_read(APIC_LVR));
GET_APIC_VERSION(apic_read(APIC_LVR));
} }
} }
int apic_version[MAX_LOCAL_APIC];
/* /*
* Local APIC interrupts * Local APIC interrupts
*/ */
...@@ -2124,11 +2122,10 @@ int generic_processor_info(int apicid, int version) ...@@ -2124,11 +2122,10 @@ int generic_processor_info(int apicid, int version)
cpu, apicid); cpu, apicid);
version = 0x10; version = 0x10;
} }
apic_version[apicid] = version;
if (version != apic_version[boot_cpu_physical_apicid]) { if (version != boot_cpu_apic_version) {
pr_warning("BIOS bug: APIC version mismatch, boot CPU: %x, CPU %d: version %x\n", pr_warning("BIOS bug: APIC version mismatch, boot CPU: %x, CPU %d: version %x\n",
apic_version[boot_cpu_physical_apicid], cpu, version); boot_cpu_apic_version, cpu, version);
} }
physid_set(apicid, phys_cpu_present_map); physid_set(apicid, phys_cpu_present_map);
...@@ -2271,7 +2268,7 @@ int __init APIC_init_uniprocessor(void) ...@@ -2271,7 +2268,7 @@ int __init APIC_init_uniprocessor(void)
* Complain if the BIOS pretends there is one. * Complain if the BIOS pretends there is one.
*/ */
if (!boot_cpu_has(X86_FEATURE_APIC) && if (!boot_cpu_has(X86_FEATURE_APIC) &&
APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { APIC_INTEGRATED(boot_cpu_apic_version)) {
pr_err("BIOS bug, local APIC 0x%x not detected!...\n", pr_err("BIOS bug, local APIC 0x%x not detected!...\n",
boot_cpu_physical_apicid); boot_cpu_physical_apicid);
return -1; return -1;
......
...@@ -1593,7 +1593,7 @@ void __init setup_ioapic_ids_from_mpc(void) ...@@ -1593,7 +1593,7 @@ void __init setup_ioapic_ids_from_mpc(void)
* no meaning without the serial APIC bus. * no meaning without the serial APIC bus.
*/ */
if (!(boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) if (!(boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
|| APIC_XAPIC(apic_version[boot_cpu_physical_apicid])) || APIC_XAPIC(boot_cpu_apic_version))
return; return;
setup_ioapic_ids_from_mpc_nocheck(); setup_ioapic_ids_from_mpc_nocheck();
} }
...@@ -2423,7 +2423,7 @@ static int io_apic_get_unique_id(int ioapic, int apic_id) ...@@ -2423,7 +2423,7 @@ static int io_apic_get_unique_id(int ioapic, int apic_id)
static u8 io_apic_unique_id(int idx, u8 id) static u8 io_apic_unique_id(int idx, u8 id)
{ {
if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
!APIC_XAPIC(apic_version[boot_cpu_physical_apicid])) !APIC_XAPIC(boot_cpu_apic_version))
return io_apic_get_unique_id(idx, id); return io_apic_get_unique_id(idx, id);
else else
return id; return id;
......
...@@ -152,7 +152,7 @@ early_param("apic", parse_apic); ...@@ -152,7 +152,7 @@ early_param("apic", parse_apic);
void __init default_setup_apic_routing(void) void __init default_setup_apic_routing(void)
{ {
int version = apic_version[boot_cpu_physical_apicid]; int version = boot_cpu_apic_version;
if (num_possible_cpus() > 8) { if (num_possible_cpus() > 8) {
switch (boot_cpu_data.x86_vendor) { switch (boot_cpu_data.x86_vendor) {
......
...@@ -683,7 +683,7 @@ wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip) ...@@ -683,7 +683,7 @@ wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip)
* Give the other CPU some time to accept the IPI. * Give the other CPU some time to accept the IPI.
*/ */
udelay(200); udelay(200);
if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { if (APIC_INTEGRATED(boot_cpu_apic_version)) {
maxlvt = lapic_get_maxlvt(); maxlvt = lapic_get_maxlvt();
if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
apic_write(APIC_ESR, 0); apic_write(APIC_ESR, 0);
...@@ -710,7 +710,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) ...@@ -710,7 +710,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
/* /*
* Be paranoid about clearing APIC errors. * Be paranoid about clearing APIC errors.
*/ */
if (APIC_INTEGRATED(apic_version[phys_apicid])) { if (APIC_INTEGRATED(boot_cpu_apic_version)) {
if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
apic_write(APIC_ESR, 0); apic_write(APIC_ESR, 0);
apic_read(APIC_ESR); apic_read(APIC_ESR);
...@@ -749,7 +749,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) ...@@ -749,7 +749,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
* Determine this based on the APIC version. * Determine this based on the APIC version.
* If we don't have an integrated APIC, don't send the STARTUP IPIs. * If we don't have an integrated APIC, don't send the STARTUP IPIs.
*/ */
if (APIC_INTEGRATED(apic_version[phys_apicid])) if (APIC_INTEGRATED(boot_cpu_apic_version))
num_starts = 2; num_starts = 2;
else else
num_starts = 0; num_starts = 0;
...@@ -987,7 +987,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) ...@@ -987,7 +987,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
/* /*
* Be paranoid about clearing APIC errors. * Be paranoid about clearing APIC errors.
*/ */
if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { if (APIC_INTEGRATED(boot_cpu_apic_version)) {
apic_write(APIC_ESR, 0); apic_write(APIC_ESR, 0);
apic_read(APIC_ESR); apic_read(APIC_ESR);
} }
...@@ -1242,7 +1242,7 @@ static int __init smp_sanity_check(unsigned max_cpus) ...@@ -1242,7 +1242,7 @@ static int __init smp_sanity_check(unsigned max_cpus)
/* /*
* If we couldn't find a local APIC, then get out of here now! * If we couldn't find a local APIC, then get out of here now!
*/ */
if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) && if (APIC_INTEGRATED(boot_cpu_apic_version) &&
!boot_cpu_has(X86_FEATURE_APIC)) { !boot_cpu_has(X86_FEATURE_APIC)) {
if (!disable_apic) { if (!disable_apic) {
pr_err("BIOS bug, local APIC #%d not detected!...\n", pr_err("BIOS bug, local APIC #%d not detected!...\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment