The patches are for the problem which is in below link.
https://lkml.org/lkml/2016/10/4/39
Dou Liyang (2):
x86/acpi: Fix the local APIC id validation in case of 0xff
x86/acpi: Fix error handling steps in parsing the lapic/x2apic entry
arch/x86/kernel/acpi/boot.c | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
--
2.5.5
Originally, in acpi_parse_x2apic(), when the apic_id is invalid and
enabled is false, the acpi_register_lapic() also can be executed.
This does not make sense.
Optimize the decision logic to avoid performing meaningless operations
if the apic_id is invalid.
Signed-off-by: Dou Liyang <[email protected]>
---
arch/x86/kernel/acpi/boot.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index d642c95..343e752 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -203,17 +203,20 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
apic_id = processor->local_apic_id;
enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
#ifdef CONFIG_X86_X2APIC
+ if (!apic->apic_id_valid(apic_id)) {
+ if (enabled)
+ printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
+ return -EINVAL;
+ }
+
/*
- * We need to register disabled CPU as well to permit
- * counting disabled CPUs. This allows us to size
- * cpus_possible_map more accurately, to permit
- * to not preallocating memory for all NR_CPUS
- * when we use CPU hotplug.
- */
- if (!apic->apic_id_valid(apic_id) && enabled)
- printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
- else
- acpi_register_lapic(apic_id, processor->uid, enabled);
+ * We need to register disabled CPU as well to permit
+ * counting disabled CPUs. This allows us to size
+ * cpus_possible_map more accurately, to permit
+ * to not preallocating memory for all NR_CPUS
+ * when we use CPU hotplug.
+ */
+ acpi_register_lapic(apic_id, processor->uid, enabled);
#else
printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
#endif
@@ -225,6 +228,7 @@ static int __init
acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
{
struct acpi_madt_local_apic *processor = NULL;
+ u8 enabled;
processor = (struct acpi_madt_local_apic *)header;
@@ -233,9 +237,14 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
acpi_table_print_madt_entry(header);
+ enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
+
/* the 0xff is an invalid local APIC id */
- if (processor->id == 0xff)
+ if (processor->id == 0xff) {
+ if (enabled)
+ printk(KERN_WARNING PREFIX "lapic entry ignored\n");
return -EINVAL;
+ }
/*
* We need to register disabled CPU as well to permit
@@ -246,7 +255,7 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
*/
acpi_register_lapic(processor->id, /* APIC ID */
processor->processor_id, /* ACPI ID */
- processor->lapic_flags & ACPI_MADT_ENABLED);
+ enabled);
return 0;
}
--
2.5.5
In MADT, the 0xff is an invalid local APIC id.
When the kernel uses both the local APIC id and x2apic id, it may
affect x2apic.
Only add validation when the kernel parse the local APIC ids.
Reported-by: Yinghai Lu <[email protected]>
Signed-off-by: Dou Liyang <[email protected]>
---
arch/x86/kernel/acpi/boot.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 32a7d70..d642c95 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -233,6 +233,10 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
acpi_table_print_madt_entry(header);
+ /* the 0xff is an invalid local APIC id */
+ if (processor->id == 0xff)
+ return -EINVAL;
+
/*
* We need to register disabled CPU as well to permit
* counting disabled CPUs. This allows us to size
--
2.5.5