Commit 8a4f202a authored by William Lee Irwin III's avatar William Lee Irwin III Committed by Linus Torvalds

[PATCH] apic: fix kicking of non-present cpus

The following patch repairs kicking of non-present cpus by making
cpu_present_to_apicid() bounds-check its argument.  It also corrects the
same issue on NUMA-Q by correctly passing the generated artificial APIC ID
instead of the raw value discovered in the MP table.

A miscellaneous compilefix for CONFIG_ACPI_BOOT is also included for
completeness.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1efe4998
...@@ -722,7 +722,7 @@ static int __init ioapic_pirq_setup(char *str) ...@@ -722,7 +722,7 @@ static int __init ioapic_pirq_setup(char *str)
__setup("pirq=", ioapic_pirq_setup); __setup("pirq=", ioapic_pirq_setup);
static int get_physical_broadcast(void) int get_physical_broadcast(void)
{ {
unsigned int lvr, version; unsigned int lvr, version;
lvr = apic_read(APIC_LVR); lvr = apic_read(APIC_LVR);
......
...@@ -107,7 +107,7 @@ static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __initdat ...@@ -107,7 +107,7 @@ static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __initdat
#ifdef CONFIG_X86_NUMAQ #ifdef CONFIG_X86_NUMAQ
static int MP_valid_apicid(int apicid, int version) static int MP_valid_apicid(int apicid, int version)
{ {
return hweight_long(i & 0xf) == 1 && (i >> 4) != 0xf; return hweight_long(apicid & 0xf) == 1 && (apicid >> 4) != 0xf;
} }
#else #else
static int MP_valid_apicid(int apicid, int version) static int MP_valid_apicid(int apicid, int version)
...@@ -207,7 +207,7 @@ void __init MP_processor_info (struct mpc_config_processor *m) ...@@ -207,7 +207,7 @@ void __init MP_processor_info (struct mpc_config_processor *m)
num_processors++; num_processors++;
ver = m->mpc_apicver; ver = m->mpc_apicver;
if (MP_valid_apicid(m->mpc_apicid, ver)) if (MP_valid_apicid(apicid, ver))
MP_mark_version_physids(ver); MP_mark_version_physids(ver);
else { else {
printk(KERN_WARNING "Processor #%d INVALID. (Max ID: %d).\n", printk(KERN_WARNING "Processor #%d INVALID. (Max ID: %d).\n",
...@@ -871,7 +871,7 @@ void __init mp_register_lapic ( ...@@ -871,7 +871,7 @@ void __init mp_register_lapic (
MP_processor_info(&processor); MP_processor_info(&processor);
} }
#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) #if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
#define MP_ISA_BUS 0 #define MP_ISA_BUS 0
#define MP_MAX_IOAPIC_PIN 127 #define MP_MAX_IOAPIC_PIN 127
...@@ -1143,5 +1143,5 @@ void __init mp_parse_prt (void) ...@@ -1143,5 +1143,5 @@ void __init mp_parse_prt (void)
} }
#endif /*CONFIG_ACPI_PCI*/ #endif /*CONFIG_ACPI_PCI*/
#endif /*CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER*/ #endif /*CONFIG_X86_IO_APIC && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)*/
#endif /*CONFIG_ACPI_BOOT*/ #endif /*CONFIG_ACPI_BOOT*/
...@@ -41,6 +41,8 @@ static __inline__ void apic_wait_icr_idle(void) ...@@ -41,6 +41,8 @@ static __inline__ void apic_wait_icr_idle(void)
do { } while ( apic_read( APIC_ICR ) & APIC_ICR_BUSY ); do { } while ( apic_read( APIC_ICR ) & APIC_ICR_BUSY );
} }
int get_physical_broadcast(void);
#ifdef CONFIG_X86_GOOD_APIC #ifdef CONFIG_X86_GOOD_APIC
# define FORCE_READ_AROUND_WRITE 0 # define FORCE_READ_AROUND_WRITE 0
# define apic_read_around(x) # define apic_read_around(x)
......
...@@ -79,7 +79,10 @@ static inline int cpu_to_logical_apicid(int cpu) ...@@ -79,7 +79,10 @@ static inline int cpu_to_logical_apicid(int cpu)
static inline int cpu_present_to_apicid(int mps_cpu) static inline int cpu_present_to_apicid(int mps_cpu)
{ {
return mps_cpu; if (mps_cpu < get_physical_broadcast())
return mps_cpu;
else
return BAD_APICID;
} }
static inline physid_mask_t apicid_to_cpu_present(int phys_apicid) static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
......
...@@ -60,7 +60,10 @@ static inline int cpu_to_logical_apicid(int cpu) ...@@ -60,7 +60,10 @@ static inline int cpu_to_logical_apicid(int cpu)
static inline int cpu_present_to_apicid(int mps_cpu) static inline int cpu_present_to_apicid(int mps_cpu)
{ {
return mps_cpu; if (mps_cpu < get_physical_broadcast())
return mps_cpu;
else
return BAD_APICID;
} }
static inline physid_mask_t apicid_to_cpu_present(int apicid) static inline physid_mask_t apicid_to_cpu_present(int apicid)
......
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