Skip to content

Commit b981513

Browse files
Jiang Liurafaeljw
Jiang Liu
authored andcommitted
ACPI / scan: bail out early if failed to parse APIC ID for CPU
Enhance ACPI CPU hotplug driver to print clear error message and bail out early if BIOS returns wrong value in ACPI MADT table or _MAT method. Otherwise it will add the CPU device even if failed to get APIC ID and fails any operations against sysfs interface: /sys/devices/system/cpu/cpux/online Signed-off-by: Jiang Liu <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent d6e0a2d commit b981513

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

drivers/acpi/acpi_processor.c

+14-10
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
212212
union acpi_object object = { 0 };
213213
struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
214214
struct acpi_processor *pr = acpi_driver_data(device);
215-
int cpu_index, device_declaration = 0;
215+
int apic_id, cpu_index, device_declaration = 0;
216216
acpi_status status = AE_OK;
217217
static int cpu0_initialized;
218218
unsigned long long value;
@@ -258,18 +258,21 @@ static int acpi_processor_get_info(struct acpi_device *device)
258258
device_declaration = 1;
259259
pr->acpi_id = value;
260260
}
261-
pr->apic_id = acpi_get_apicid(pr->handle, device_declaration,
262-
pr->acpi_id);
263-
cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
264261

265-
/* Handle UP system running SMP kernel, with no LAPIC in MADT */
266-
if (!cpu0_initialized && (cpu_index == -1) &&
267-
(num_online_cpus() == 1)) {
268-
cpu_index = 0;
262+
apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);
263+
if (apic_id < 0) {
264+
acpi_handle_err(pr->handle, "failed to get CPU APIC ID.\n");
265+
return -ENODEV;
269266
}
267+
pr->apic_id = apic_id;
270268

271-
cpu0_initialized = 1;
272-
269+
cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
270+
if (!cpu0_initialized) {
271+
cpu0_initialized = 1;
272+
/* Handle UP system running SMP kernel, with no LAPIC in MADT */
273+
if ((cpu_index == -1) && (num_online_cpus() == 1))
274+
cpu_index = 0;
275+
}
273276
pr->id = cpu_index;
274277

275278
/*
@@ -282,6 +285,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
282285
if (ret)
283286
return ret;
284287
}
288+
285289
/*
286290
* On some boxes several processors use the same processor bus id.
287291
* But they are located in different scope. For example:

0 commit comments

Comments
 (0)