x86/acpi/boot: Do not register processors that cannot be onlined for x2apic
Subsystems (3)
PATCH v2 1/1 x86/acpi/boot: Do not register processors that cannot be onlined for x2apic
Section 5.2.12.12 Processor Local x2APIC Structure in the ACPI v6.5 spec mandates that both "enabled" and "online capable" Local APIC Flags should be used to determine if the processor is usable or not.
However, Linux doesn't use the "online capable" flag for x2APIC to determine if the processor is usable. As a result, cpu_possible_mask has incorrect value and results in more memory getting allocated for per_cpu variables than it is going to be used.
Make sure Linux parses both "enabled" and "online capable" flags for x2APIC to correctly determine if the processor is usable.
---
Changes from v1:
1) Changed the ACPI spec version to 6.5 in the commit log
2) Changed the Fixes tag to point to commit aa06e20f1be6
3) Added "Reported-by: Leo Duran <[email protected]>"
arch/x86/kernel/acpi/boot.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
arch/x86/kernel/acpi/boot.c +16 -3
@@ -188,6 +188,17 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)return cpu; } +static bool __init acpi_is_processor_usable (u32 lapic_flags) +{ +if (lapic_flags &ACPI_MADT_ENABLED ) +return true; + +if (acpi_support_online_capable && (lapic_flags &ACPI_MADT_ONLINE_CAPABLE )) +return true; + +return false; +} +static int __init acpi_parse_x2apic (union acpi_subtable_headers *header,const unsigned long end) {
@@ -212,6 +223,10 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)if (apic_id ==0xffffffff )return 0 ; +/* don't register processors that cannot be onlined */ +if (!acpi_is_processor_usable (processor->lapic_flags)) +return 0 ; +/* * We need to register disabled CPU as well to permit * counting disabled CPUs. This allows us to size
@@ -250,9 +265,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)return 0 ;/* don't register processors that can not be onlined */ -if (acpi_support_online_capable && - !(processor->lapic_flags &ACPI_MADT_ENABLED ) && - !(processor->lapic_flags &ACPI_MADT_ONLINE_CAPABLE )) +if (!acpi_is_processor_usable (processor->lapic_flags))return 0 ;/*
Signature · 1 line
2.34.1
Quoted 10 lines · Kishon Vijay Abraham I
Section 5.2.12.12 Processor Local x2APIC Structure in the ACPI v6.5 spec mandates that both "enabled" and "online capable" Local APIC Flags should be used to determine if the processor is usable or not.
However, Linux doesn't use the "online capable" flag for x2APIC to determine if the processor is usable. As a result,
cpu_possible_maskhas incorrect value and results in more memory getting allocated forper_cpuvariables than it is going to be used.
Quoted 7 lines
Make sure Linux parses both "enabled" and "online capable" flags for x2APIC to correctly determine if the processor is usable.
Fixes aa06e20f1be6 ("x86/ACPI: Don't add CPUs that are not online capable")Reviewed-by Borislav Petkov (AMD) <[email protected]>Reported-by Leo Duran <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>
Quoted 55 lines
---
Changes from v1:
1) Changed the ACPI spec version to 6.5 in the commit log
2) Changed the Fixes tag to point to commitaa06e20f1be6
3) Added "Reported-by: Leo Duran <[email protected]>"arch/x86/kernel/acpi/boot.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)arch/x86/kernel/acpi/boot.c +16
-4@@ -188,6 +188,17 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)return cpu; } +static bool __init acpi_is_processor_usable (u32 lapic_flags) +{ +if (lapic_flags &ACPI_MADT_ENABLED ) +return true; + +if (acpi_support_online_capable && (lapic_flags &ACPI_MADT_ONLINE_CAPABLE )) +return true; + +return false; +} +static int __init acpi_parse_x2apic (union acpi_subtable_headers *header,const unsigned long end) {@@ -212,6 +223,10 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)if (apic_id ==0xffffffff )return 0 ; +/* don't register processors that cannot be onlined */ +if (!acpi_is_processor_usable (processor->lapic_flags)) +return 0 ; +/* * We need to register disabled CPU as well to permit * counting disabled CPUs. This allows us to size @@ -250,9 +265,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)return 0 ;/* don't register processors that can not be onlined */ -if (acpi_support_online_capable && - !(processor->lapic_flags &ACPI_MADT_ENABLED ) && - !(processor->lapic_flags &ACPI_MADT_ONLINE_CAPABLE )) +if (!acpi_is_processor_usable (processor->lapic_flags))return 0 ;/* -- 2.34.1
Borislav Petkov
maintainerQuoted 14 lines · Rafael J. Wysocki
Quoted 13 lines · Kishon Vijay Abraham I
Section 5.2.12.12 Processor Local x2APIC Structure in the ACPI v6.5 spec mandates that both "enabled" and "online capable" Local APIC Flags should be used to determine if the processor is usable or not.
However, Linux doesn't use the "online capable" flag for x2APIC to determine if the processor is usable. As a result,
cpu_possible_maskhas incorrect value and results in more memory getting allocated forper_cpuvariables than it is going to be used.Make sure Linux parses both "enabled" and "online capable" flags for x2APIC to correctly determine if the processor is usable.
Quoted 6 lines
Quoted 4 lines
Fixes aa06e20f1be6 ("x86/ACPI: Don't add CPUs that are not online capable")Reviewed-by Borislav Petkov (AMD) <[email protected]>Reported-by Leo Duran <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>
Are you saying, I should take it through tip?
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRafael J. Wysocki
maintainerQuoted 16 lines · Borislav Petkov
Quoted 14 lines · Rafael J. Wysocki
Quoted 13 lines · Kishon Vijay Abraham I
Section 5.2.12.12 Processor Local x2APIC Structure in the ACPI v6.5 spec mandates that both "enabled" and "online capable" Local APIC Flags should be used to determine if the processor is usable or not.
However, Linux doesn't use the "online capable" flag for x2APIC to determine if the processor is usable. As a result,
cpu_possible_maskhas incorrect value and results in more memory getting allocated forper_cpuvariables than it is going to be used.Make sure Linux parses both "enabled" and "online capable" flags for x2APIC to correctly determine if the processor is usable.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Fixes aa06e20f1be6 ("x86/ACPI: Don't add CPUs that are not online capable")Reviewed-by Borislav Petkov (AMD) <[email protected]>Reported-by Leo Duran <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>Are you saying, I should take it through tip?
Works for me either way.
Just please let me know if I need to take care of it. :-)
Borislav Petkov
maintainerQuoted 1 line · Rafael J. Wysocki
Just please let me know if I need to take care of it. :-)
You don't. :-)
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteZhang, Rui
Reviewed-byQuoted 18 lines · Rafael J. Wysocki
Quoted 16 lines · Kishon Vijay Abraham I
Section 5.2.12.12 Processor Local x2APIC Structure in the ACPI v6.5 spec mandates that both "enabled" and "online capable" Local APIC Flags
should be used to determine if the processor is usable or not.However, Linux doesn't use the "online capable" flag for x2APIC to determine if the processor is usable. As a result,
cpu_possible_maskhas
incorrect value and results in more memory getting allocated forper_cpu
variables than it is going to be used.Make sure Linux parses both "enabled" and "online capable" flags for
x2APIC to correctly determine if the processor is usable.
Quoted 8 lines
Quoted 5 lines
Fixes aa06e20f1be6 ("x86/ACPI: Don't add CPUs that are not onlinecapable")
Reviewed-by Borislav Petkov (AMD) <[email protected]>Reported-by Leo Duran <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>
thanks,
rui
Quoted 61 lines
Quoted 61 lines
---
Changes from v1:
1) Changed the ACPI spec version to 6.5 in the commit log
2) Changed the Fixes tag to point to commitaa06e20f1be6
3) Added "Reported-by: Leo Duran <[email protected]>"arch/x86/kernel/acpi/boot.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)arch/x86/kernel/acpi/boot.c +11
-0@@ -188,6 +188,17 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)return cpu; } +static bool __init acpi_is_processor_usable (u32 lapic_flags) +{ +if (lapic_flags &ACPI_MADT_ENABLED ) +return true; + +if (acpi_support_online_capable && (lapic_flags &ACPI_MADT_ONLINE_CAPABLE )) +return true; + +return false; +} + static int __initacpi_parse_x2apic(union
acpi_subtable_headers*header, const
unsigned long end)
{arch/x86/kernel/acpi/boot.c +4
-0@@ -212,6 +223,10 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)if (apic_id ==0xffffffff )return 0 ; +/* don't register processors that cannot be onlined */ +if (!acpi_is_processor_usable (processor->lapic_flags)) +return 0 ; +/* * We need to register disabled CPU as well to permit * counting disabled CPUs. This allows us to size
arch/x86/kernel/acpi/boot.c +1
-3@@ -250,9 +265,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)return 0 ;/* don't register processors that can not be onlined */ -if (acpi_support_online_capable && - !(processor->lapic_flags &ACPI_MADT_ENABLED ) && - !(processor->lapic_flags &ACPI_MADT_ONLINE_CAPABLE )) +if (!acpi_is_processor_usable (processor->lapic_flags))return 0 ;/*--
2.34.1
[tip: x86/boot] x86/acpi/boot: Do not register processors that cannot be onlined for x2APIC
In reply to Kishon Vijay Abraham IThe following commit has been merged into the x86/boot branch of tip:
The following commit has been merged into the x86/boot branch of tip:
Commit-ID: e2869bd7af608c343988429ceb1c2fe99644a01f Gitweb: https://git.kernel.org/tip/e2869bd7af608c343988429ceb1c2fe99644a01f Author: Kishon Vijay Abraham I <[email protected]> AuthorDate: Thu, 05 Jan 2023 04:10:59 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 10 Jan 2023 19:21:07 +01:00
x86/acpi/boot: Do not register processors that cannot be onlined for x2APIC
Section 5.2.12.12 Processor Local x2APIC Structure in the ACPI v6.5 spec mandates that both "enabled" and "online capable" Local APIC Flags should be used to determine if the processor is usable or not.
However, Linux doesn't use the "online capable" flag for x2APIC to determine if the processor is usable. As a result, cpu_possible_mask has incorrect value and results in more memory getting allocated for per_cpu variables than it is going to be used.
Make sure Linux parses both "enabled" and "online capable" flags for x2APIC to correctly determine if the processor is usable.
--- arch/x86/kernel/acpi/boot.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
arch/x86/kernel/acpi/boot.c +16 -3
@@ -188,6 +188,17 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)return cpu; } +static bool __init acpi_is_processor_usable (u32 lapic_flags) +{ +if (lapic_flags &ACPI_MADT_ENABLED ) +return true; + +if (acpi_support_online_capable && (lapic_flags &ACPI_MADT_ONLINE_CAPABLE )) +return true; + +return false; +} +static int __init acpi_parse_x2apic (union acpi_subtable_headers *header,const unsigned long end) {
@@ -212,6 +223,10 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)if (apic_id ==0xffffffff )return 0 ; +/* don't register processors that cannot be onlined */ +if (!acpi_is_processor_usable (processor->lapic_flags)) +return 0 ; +/* * We need to register disabled CPU as well to permit * counting disabled CPUs. This allows us to size
@@ -250,9 +265,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)return 0 ;/* don't register processors that can not be onlined */ -if (acpi_support_online_capable && - !(processor->lapic_flags &ACPI_MADT_ENABLED ) && - !(processor->lapic_flags &ACPI_MADT_ONLINE_CAPABLE )) +if (!acpi_is_processor_usable (processor->lapic_flags))return 0 ;/*
Le 05/01/2023 à 05:10, Kishon Vijay Abraham I a écrit :
Quoted 9 lines
Section 5.2.12.12 Processor Local x2APIC Structure in the ACPI v6.5 spec mandates that both "enabled" and "online capable" Local APIC Flags should be used to determine if the processor is usable or not.
However, Linux doesn't use the "online capable" flag for x2APIC to determine if the processor is usable. As a result,
cpu_possible_maskhas incorrect value and results in more memory getting allocated forper_cpuvariables than it is going to be used.
Quoted 7 lines
Make sure Linux parses both "enabled" and "online capable" flags for x2APIC to correctly determine if the processor is usable.
Fixes aa06e20f1be6 ("x86/ACPI: Don't add CPUs that are not online capable")Reviewed-by Borislav Petkov (AMD) <[email protected]>Reported-by Leo Duran <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>
Hello everyone,
My system worked fine with kernel 6.1.15, but stopped booting after upgrading to 6.1.20 and resulted in a kernel panic:
---
[ 0.117782] Kernel panic — not syncing: timer doesn’t work through Interrupt-remapped IO-APIC [ 0.117848] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.1.0-7-and64 #1 Debian 6.1.20-1 [ 0.117913] Hardware name: Gigabyte Technology Co., Ltd. ABS50M-Gaming 3/AB350M-Gaming 3-CF, BIOS F50d 07/02/2020 [ 0.117982] Call Trace: [ 0.118634] <TASK> [ 0.118685] dump_stack_lvl+0x44/0x5c [ 0.118143] panic+0x118/0x2ed [ 0.118198] panic_if_irq_remap.cold+0x5/0x5 [ 0.118256] setup_I0_APIC+0x3db/0x64b [ 0.118313] ? _raw_spin_unlock_irqrestore+0x23/0x40 [ 0.118372] ? clear_IO_APIC_pin+0x169/0x240 [ 0.118429] apic_intr_node_init+0x101/0x106 [ 0.118485] x86_late_time_init+0x20/0x34 [ 0.118542] start_kerne1+0x667/0x727 [ 0.118598] secondary_startup_64_no_verify+0xe5/0xeb [ 0.118658] </TASK> [ 0.118711] ---[ end Kernel panic - not syncing: timer doesn’t work through Interrupt-remapped IO-APIC J---
---
I tried an update of the BIOS up to F51h without any effect.
I sent a bug report to Debian Bug Tracking System. In reply Bjørn Mork identified ce7d894bed1a539a8d6cff42f6f78f9db0c9c26b from the linux-6.1.y branch as the likely culprit.
After building a 6.1.20 kernel with just that commit reverted, my system boots normally again.
I reported that all tohttps://bugs.debian.org/1033732 and were asked to report the issue 'upstream' (which is what that mail is).
Hope it will help!
Best regards.
-- Guy Durrieu
Borislav Petkov
maintainerQuoted 2 lines · Guy Durrieu
My system worked fine with kernel 6.1.15, but stopped booting after upgrading to 6.1.20 and resulted in a kernel panic:
Does this fix it:
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=x86/urgent
Thx.
Signature · 1 line
Sent from a small device: formatting sucks and brevity is inevitable.
Le 02/04/2023 à 12:57, Borislav Petkov a écrit :
Quoted 9 lines · Guy Durrieu
Quoted 2 lines
My system worked fine with kernel 6.1.15, but stopped booting after upgrading to 6.1.20 and resulted in a kernel panic:
Does this fix it:
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=x86/urgent
Thx.
Yes it does.
Regards.
-- Guy Durrieu
Borislav Petkov
maintainerQuoted 1 line · Guy Durrieu
Yes it does.
Thanks for testing.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: Bug#1033732: [PATCH v2] x86/acpi/boot: Do not register processors that cannot be onlined for x2apic
In reply to Guy DurrieuHi
Quoted 49 lines · Guy Durrieu
Le 05/01/2023 à 05:10, Kishon Vijay Abraham I a écrit :
Quoted 9 lines
Section 5.2.12.12 Processor Local x2APIC Structure in the ACPI v6.5 spec mandates that both "enabled" and "online capable" Local APIC Flags should be used to determine if the processor is usable or not.
However, Linux doesn't use the "online capable" flag for x2APIC to determine if the processor is usable. As a result,
cpu_possible_maskhas incorrect value and results in more memory getting allocated forper_cpuvariables than it is going to be used.Quoted 7 lines
Make sure Linux parses both "enabled" and "online capable" flags for x2APIC to correctly determine if the processor is usable.
Fixes aa06e20f1be6 ("x86/ACPI: Don't add CPUs that are not online capable")Reviewed-by Borislav Petkov (AMD) <[email protected]>Reported-by Leo Duran <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>Hello everyone,
My system worked fine with kernel 6.1.15, but stopped booting after upgrading to 6.1.20 and resulted in a kernel panic:
---
[ 0.117782] Kernel panic — not syncing: timer doesn’t work through Interrupt-remapped IO-APIC [ 0.117848] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.1.0-7-and64 #1 Debian 6.1.20-1 [ 0.117913] Hardware name: Gigabyte Technology Co., Ltd. ABS50M-Gaming 3/AB350M-Gaming 3-CF, BIOS F50d 07/02/2020 [ 0.117982] Call Trace: [ 0.118634] <TASK> [ 0.118685] dump_stack_lvl+0x44/0x5c [ 0.118143] panic+0x118/0x2ed [ 0.118198] panic_if_irq_remap.cold+0x5/0x5 [ 0.118256] setup_I0_APIC+0x3db/0x64b [ 0.118313] ? _raw_spin_unlock_irqrestore+0x23/0x40 [ 0.118372] ? clear_IO_APIC_pin+0x169/0x240 [ 0.118429] apic_intr_node_init+0x101/0x106 [ 0.118485] x86_late_time_init+0x20/0x34 [ 0.118542] start_kerne1+0x667/0x727 [ 0.118598] secondary_startup_64_no_verify+0xe5/0xeb [ 0.118658] </TASK> [ 0.118711] ---[ end Kernel panic - not syncing: timer doesn’t work through Interrupt-remapped IO-APIC J------
I tried an update of the BIOS up to F51h without any effect.I sent a bug report to Debian Bug Tracking System. In reply Bjørn Mork identified
ce7d894bed1a539a8d6cff42f6f78f9db0c9c26bfrom the linux-6.1.y branch as the likely culprit.
Quoted 7 lines
After building a 6.1.20 kernel with just that commit reverted, my system boots normally again.
I reported that all tohttps://bugs.debian.org/1033732 and were asked to report the issue 'upstream' (which is what that mail is).
Hope it will help!
Best regards.
Trying to make as well the regression tracker bot aware of the issue (but dropping all CCs to not spam them with duplicate information):
#regzbot ^introduced e2869bd7af60
#regzbot title: Regression from "x86/acpi/boot: Do not register processors that cannot be onlined for x2APIC" #regzbot link https://lore.kernel.org/lkml/[email protected]/
#regzbot link https://bugs.debian.org/1033732
#regzbot fixed-by: fed8d8773b8e
Regards,
Salvatore