aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2016-06-30 11:56:36 -0400
committerDavid Vrabel <david.vrabel@citrix.com>2016-07-25 08:30:53 -0400
commit3e9e57fad3d8530aa30787f861c710f598ddc4e7 (patch)
treef437f258cbf0b76537d5e51f37a9f45381d4bf0a
parentde2f5537b397249e91cafcbed4de64a24818542e (diff)
x86/acpi: store ACPI ids from MADT for future usage
Currently we don't save ACPI ids (unlike LAPIC ids which go to x86_cpu_to_apicid) from MADT and we may need this information later. Particularly, ACPI ids is the only existent way for a PVHVM Xen guest to figure out Xen's idea of its vCPUs ids before these CPUs boot and in some cases these ids diverge from Linux's cpu ids. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
-rw-r--r--arch/x86/include/asm/cpu.h1
-rw-r--r--arch/x86/include/asm/smp.h2
-rw-r--r--arch/x86/kernel/acpi/boot.c16
-rw-r--r--arch/x86/kernel/apic/apic.c2
-rw-r--r--arch/x86/kernel/setup_percpu.c3
5 files changed, 20 insertions, 4 deletions
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index 678637ad7476..a7fb9ddab16a 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -16,6 +16,7 @@ extern void prefill_possible_map(void);
16static inline void prefill_possible_map(void) {} 16static inline void prefill_possible_map(void) {}
17 17
18#define cpu_physical_id(cpu) boot_cpu_physical_apicid 18#define cpu_physical_id(cpu) boot_cpu_physical_apicid
19#define cpu_acpi_id(cpu) 0
19#define safe_smp_processor_id() 0 20#define safe_smp_processor_id() 0
20#define stack_smp_processor_id() 0 21#define stack_smp_processor_id() 0
21 22
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 66b057306f40..c47b42b0d283 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -33,6 +33,7 @@ static inline struct cpumask *cpu_llc_shared_mask(int cpu)
33} 33}
34 34
35DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid); 35DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid);
36DECLARE_EARLY_PER_CPU_READ_MOSTLY(u32, x86_cpu_to_acpiid);
36DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid); 37DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid);
37#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) 38#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
38DECLARE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid); 39DECLARE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid);
@@ -147,6 +148,7 @@ void x86_idle_thread_init(unsigned int cpu, struct task_struct *idle);
147void smp_store_boot_cpu_info(void); 148void smp_store_boot_cpu_info(void);
148void smp_store_cpu_info(int id); 149void smp_store_cpu_info(int id);
149#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) 150#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
151#define cpu_acpi_id(cpu) per_cpu(x86_cpu_to_acpiid, cpu)
150 152
151#else /* !CONFIG_SMP */ 153#else /* !CONFIG_SMP */
152#define wbinvd_on_cpu(cpu) wbinvd() 154#define wbinvd_on_cpu(cpu) wbinvd()
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 9414f84584e4..6738e5c82cca 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -161,13 +161,15 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
161/** 161/**
162 * acpi_register_lapic - register a local apic and generates a logic cpu number 162 * acpi_register_lapic - register a local apic and generates a logic cpu number
163 * @id: local apic id to register 163 * @id: local apic id to register
164 * @acpiid: ACPI id to register
164 * @enabled: this cpu is enabled or not 165 * @enabled: this cpu is enabled or not
165 * 166 *
166 * Returns the logic cpu number which maps to the local apic 167 * Returns the logic cpu number which maps to the local apic
167 */ 168 */
168static int acpi_register_lapic(int id, u8 enabled) 169static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
169{ 170{
170 unsigned int ver = 0; 171 unsigned int ver = 0;
172 int cpu;
171 173
172 if (id >= MAX_LOCAL_APIC) { 174 if (id >= MAX_LOCAL_APIC) {
173 printk(KERN_INFO PREFIX "skipped apicid that is too big\n"); 175 printk(KERN_INFO PREFIX "skipped apicid that is too big\n");
@@ -182,7 +184,11 @@ static int acpi_register_lapic(int id, u8 enabled)
182 if (boot_cpu_physical_apicid != -1U) 184 if (boot_cpu_physical_apicid != -1U)
183 ver = apic_version[boot_cpu_physical_apicid]; 185 ver = apic_version[boot_cpu_physical_apicid];
184 186
185 return generic_processor_info(id, ver); 187 cpu = generic_processor_info(id, ver);
188 if (cpu >= 0)
189 early_per_cpu(x86_cpu_to_acpiid, cpu) = acpiid;
190
191 return cpu;
186} 192}
187 193
188static int __init 194static int __init
@@ -212,7 +218,7 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
212 if (!apic->apic_id_valid(apic_id) && enabled) 218 if (!apic->apic_id_valid(apic_id) && enabled)
213 printk(KERN_WARNING PREFIX "x2apic entry ignored\n"); 219 printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
214 else 220 else
215 acpi_register_lapic(apic_id, enabled); 221 acpi_register_lapic(apic_id, processor->uid, enabled);
216#else 222#else
217 printk(KERN_WARNING PREFIX "x2apic entry ignored\n"); 223 printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
218#endif 224#endif
@@ -240,6 +246,7 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
240 * when we use CPU hotplug. 246 * when we use CPU hotplug.
241 */ 247 */
242 acpi_register_lapic(processor->id, /* APIC ID */ 248 acpi_register_lapic(processor->id, /* APIC ID */
249 processor->processor_id, /* ACPI ID */
243 processor->lapic_flags & ACPI_MADT_ENABLED); 250 processor->lapic_flags & ACPI_MADT_ENABLED);
244 251
245 return 0; 252 return 0;
@@ -258,6 +265,7 @@ acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
258 acpi_table_print_madt_entry(header); 265 acpi_table_print_madt_entry(header);
259 266
260 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */ 267 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
268 processor->processor_id, /* ACPI ID */
261 processor->lapic_flags & ACPI_MADT_ENABLED); 269 processor->lapic_flags & ACPI_MADT_ENABLED);
262 270
263 return 0; 271 return 0;
@@ -714,7 +722,7 @@ int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
714{ 722{
715 int cpu; 723 int cpu;
716 724
717 cpu = acpi_register_lapic(physid, ACPI_MADT_ENABLED); 725 cpu = acpi_register_lapic(physid, U32_MAX, ACPI_MADT_ENABLED);
718 if (cpu < 0) { 726 if (cpu < 0) {
719 pr_info(PREFIX "Unable to map lapic to logical cpu number\n"); 727 pr_info(PREFIX "Unable to map lapic to logical cpu number\n");
720 return cpu; 728 return cpu;
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 60078a67d7e3..db2326fd6cfa 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -92,8 +92,10 @@ static int apic_extnmi = APIC_EXTNMI_BSP;
92 */ 92 */
93DEFINE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid, BAD_APICID); 93DEFINE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid, BAD_APICID);
94DEFINE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid, BAD_APICID); 94DEFINE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid, BAD_APICID);
95DEFINE_EARLY_PER_CPU_READ_MOSTLY(u32, x86_cpu_to_acpiid, U32_MAX);
95EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_apicid); 96EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_apicid);
96EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid); 97EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid);
98EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_acpiid);
97 99
98#ifdef CONFIG_X86_32 100#ifdef CONFIG_X86_32
99 101
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index e4fcb87ba7a6..7a40e068302d 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -236,6 +236,8 @@ void __init setup_per_cpu_areas(void)
236 early_per_cpu_map(x86_cpu_to_apicid, cpu); 236 early_per_cpu_map(x86_cpu_to_apicid, cpu);
237 per_cpu(x86_bios_cpu_apicid, cpu) = 237 per_cpu(x86_bios_cpu_apicid, cpu) =
238 early_per_cpu_map(x86_bios_cpu_apicid, cpu); 238 early_per_cpu_map(x86_bios_cpu_apicid, cpu);
239 per_cpu(x86_cpu_to_acpiid, cpu) =
240 early_per_cpu_map(x86_cpu_to_acpiid, cpu);
239#endif 241#endif
240#ifdef CONFIG_X86_32 242#ifdef CONFIG_X86_32
241 per_cpu(x86_cpu_to_logical_apicid, cpu) = 243 per_cpu(x86_cpu_to_logical_apicid, cpu) =
@@ -271,6 +273,7 @@ void __init setup_per_cpu_areas(void)
271#ifdef CONFIG_X86_LOCAL_APIC 273#ifdef CONFIG_X86_LOCAL_APIC
272 early_per_cpu_ptr(x86_cpu_to_apicid) = NULL; 274 early_per_cpu_ptr(x86_cpu_to_apicid) = NULL;
273 early_per_cpu_ptr(x86_bios_cpu_apicid) = NULL; 275 early_per_cpu_ptr(x86_bios_cpu_apicid) = NULL;
276 early_per_cpu_ptr(x86_cpu_to_acpiid) = NULL;
274#endif 277#endif
275#ifdef CONFIG_X86_32 278#ifdef CONFIG_X86_32
276 early_per_cpu_ptr(x86_cpu_to_logical_apicid) = NULL; 279 early_per_cpu_ptr(x86_cpu_to_logical_apicid) = NULL;