2022-09-11 08:49:51

by Mateusz Jończyk

[permalink] [raw]
Subject: [PATCH v2 02/10] x86/apic: fix panic message when x2APIC is not supported

The correct course of action is to enable x2APIC support in the kernel,
not to disable it in the BIOS (which may be impossible).
x2APIC has performance and functionality benefits, so it is best to use
it if it is available on the platform.

Signed-off-by: Mateusz Jończyk <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: [email protected]
Cc: "H. Peter Anvin" <[email protected]>
Cc: Johan Hovold <[email protected]>
Cc: "Maciej W. Rozycki" <[email protected]>
Cc: Yinghai Lu <[email protected]>
---
v2: add a newline at the end of the text

arch/x86/kernel/apic/apic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 6d303d1d276c..206a2693a27a 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1902,7 +1902,7 @@ static int __init validate_x2apic(void)
/*
* Checkme: Can we simply turn off x2apic here instead of panic?
*/
- panic("BIOS has enabled x2apic but kernel doesn't support x2apic, please disable x2apic in BIOS.\n");
+ panic("Kernel does not support x2APIC, please recompile with CONFIG_X86_X2APIC or disable x2APIC in BIOS.\n");
}
early_initcall(validate_x2apic);

--
2.25.1


Subject: RE: [PATCH v2 02/10] x86/apic: fix panic message when x2APIC is not supported



> diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
...
> @@ -1902,7 +1902,7 @@ static int __init validate_x2apic(void)
> /*
> * Checkme: Can we simply turn off x2apic here instead of panic?
> */
> - panic("BIOS has enabled x2apic but kernel doesn't support x2apic, please disable x2apic in BIOS.\n");
> + panic("Kernel does not support x2APIC, please recompile with CONFIG_X86_X2APIC or disable x2APIC in BIOS.\n");

With a defconfig build (no CONFIG_X86_X2APIC) on a system with x2apic,
I noticed this triggers before ever getting to that panic() call:

static void setup_local_APIC(void)
...
/*
* Double-check whether this APIC is really registered.
* This is meaningless in clustered apic mode, so we skip it.
*/
BUG_ON(!apic->apic_id_registered());

That was also reported in 2020:
https://lkml.org/lkml/2020/2/21/1501

The BUG print is:
[ 5.827523] APIC: Switch to symmetric I/O mode setup
[ 5.832519] ------------[ cut here ]------------
[ 5.837163] kernel BUG at arch/x86/kernel/apic/apic.c:1593!
[ 5.842767] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
[ 5.848009] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.0.0-rc1-14412-g34ab3d31f076 #1
[ 5.855954] Hardware name: HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 03/08/2022
[ 5.864508] RIP: 0010:setup_local_APIC+0x3aa/0x3c0
[ 5.869317] Code: 02 0f 85 ca fe ff ff 85 d2 7f 26 48 8b 05 be 4d 62 01 be 00 07 01 00 bf 50 03 00 00 48 8b 40 10 e8 ab 51 fb 00 e9 c9 fe ff ff <0f> 0b e8 df 5f cb 00 e9 45 7f c5 00 66 2e 0f 1f 84 00 00 00 00 00
[ 5.888156] RSP: 0000:ffffffffa6403e90 EFLAGS: 00010246
[ 5.893398] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ 5.900555] RDX: 0000000000000000 RSI: 00000000fffffeff RDI: 0000000000000020
[ 5.907712] RBP: ffffa2837ffea180 R08: 00000000ffffdfff R09: 00000000ffffdfff
[ 5.914870] R10: ffffffffa6455f20 R11: ffffffffa6455f20 R12: ffffa2837ffea1c9
[ 5.922027] R13: 0000000000000000 R14: ffffffffa6414120 R15: 000000009f1597b0
[ 5.929185] FS: 0000000000000000(0000) GS:ffffa252c0000000(0000) knlGS:0000000000000000
[ 5.937304] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 5.943067] CR2: ffffa2837fdff000 CR3: 00000028d320c001 CR4: 00000000000606f0
[ 5.950225] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 5.957385] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 5.964543] Call Trace:
[ 5.966994] <TASK>
[ 5.969097] ? _printk+0x63/0x7e
[ 5.972338] apic_intr_mode_init+0xde/0xfc
[ 5.976448] x86_late_time_init+0x1b/0x2f
[ 5.980471] start_kernel+0x5db/0x69b
[ 5.984143] secondary_startup_64_no_verify+0xe0/0xeb
[ 5.989213] </TASK>