Skip to contentSkip to conversation

x86/smpboot/64: System will not boot on v6.5, v6.7-rc4

REGRESSION In review Borislav Petkov 5 participants 11 messages Dec 10, 2023 – Mar 12, 2024 7 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CA+2tU59853R49EaU_tyvOZuOTDdcU0RshGyydccp9R1NX9bEeQ@mail.gmail.com

Borislav Petkov

author maintainer
#1 lore raw
Quoted 7 lines · Chris Lindee

My Dell-EMC PowerEdge T340 server worked with v6.4.15, but it will not start with v6.5.x - it won't even display dmesg events during boot. I reproduced the issue on v6.7-rc4 and bisected the first problematic commit to:

0c7ffa32dbd6 x86/smpboot/64: Implement arch_cpuhp_init_parallel_bringup() and enable it

I presume booting with "cpuhp.parallel=0" on the kernel cmdline fixes it?

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

A message that is not in the archive (sent off-list or not yet received): CA+2tU585yW2z37NtYqjVe+ZMw+oU_vbS4X=Q=sAxME8GrPFDpg@mail.gmail.com

#3 lore raw

Chris!

Quoted 2 lines · Chris Lindee

My system hardware remains available for testing. What further information do you need?

Can you please provide dmesg output from 6.7-rc4 with "cpuhp.parallel=0" on the command line?

Thanks,

tglx

A message that is not in the archive (sent off-list or not yet received): CA+2tU5_TzDQO2U8SGDYhsVPR8iYh8Q8vTqv9+HUc7LN3cV=2Sg@mail.gmail.com

#5 lore raw
Quoted 7 lines · Chris Lindee
Quoted 2 lines · Thomas Gleixner

Can you please provide dmesg output from 6.7-rc4 with "cpuhp.parallel=0" on the command line?

Oops, I already upgraded to 6.7-rc5
<https://koji.fedoraproject.org/koji/buildinfo?buildID=2332379>; let me know if you would prefer I downgrade.

Nah. That's fine.

Quoted 1 line
[    0.002775] x2apic: enabled by BIOS, switching to x2apic ops

So BIOS has x2apic enabled, but ...

Quoted 4 lines
[    0.136888] smp: Bringing up secondary CPUs ...
[    0.136888] smpboot: x86: Booting SMP configuration:
[    0.136888] .... node  #0, CPUs:      #1
[    0.013471] x2apic enabled

this is really strange as it means that the APs do not come up with X2APIC enabled. Oh well. BIOS creativity is unlimited...

Quoted 2 lines
[    0.137980]  #2 #3
[    0.139937] smp: Brought up 1 node, 4 CPUs

Though that does not really explain why the parallel bringup goes south as that is not really different from what the serialized bringup is doing in terms of kicking the APs into life.

Can you try and add "ignore_loglevel earlyprintk=ttyS0,115200n8" to the kernel command line and capture dmesg on the serial port when booting with the parallel hotplug enabled?

Thanks,

tglx

#6 lore raw
Quoted 8 lines · Thomas Gleixner

On Tue, Dec 12 2023 at 13:11, Chris Lindee wrote:
Though that does not really explain why the parallel bringup goes south as that is not really different from what the serialized bringup is doing in terms of kicking the APs into life.

Can you try and add "ignore_loglevel earlyprintk=ttyS0,115200n8" to the kernel command line and capture dmesg on the serial port when booting with the parallel hotplug enabled?

Don't bother it wont tell us much and I decoded the issue already. Will send a patch tomorrow.

A message that is not in the archive (sent off-list or not yet received): CA+2tU5-RoR8qCGRdsMH0wo5n8v4fV8A_H5yT+mZadsF7E+QkWg@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CA+2tU5-18YQSpFzgUKyeZdJXe0Rs0GxtYY2s5QjznzTucJKCiQ@mail.gmail.com

#9 lore raw
Quoted 7 lines · Chris Lindee
Quoted 4 lines · Chris Lindee

The following are the processor options made available by the BIOS, with the currently selected value. If there are any interesting combinations that you'd like tested, I can try a handful of them.

Quoted 5 lines
Quoted 2 lines

x2APIC Mode: Enabled (requires Virtualization Technology to enable)

I disabled x2APIC and the system would boot, both without "cpuhp.parallel" and with "cpuhp.parallel=1" on the command line.

I would have expected that.

With the completely untested patch below it should also boot in X2APIC mode even with the broken AP configuration in the BIOS.

Thanks,

tglx
---

arch/x86/kernel/head_64.S +16 -0
@@ -255,6 +255,22 @@ SYM_INNER_LABEL(secondary_startup_64_no_
 	testl	$X2APIC_ENABLE, %eax
 	jnz	.Lread_apicid_msr
 
+#ifdef CONFIG_X86_X2APIC
+	/*
+	 * If system is in X2APIC mode then MMIO base mignt not be
+	 * mapped causing the MMIO read below to fault. Faults can't
+	 * be handled at that point.
+	 */
+	cmpl	$0, x2apic_mode(%rip)
+	jz	.Lread_apicid_mmio
+
+	/* Force the AP into X2APIC mode. */
+	orl	$X2APIC_ENABLE, %eax
+	wrmsr
+	jmp	.Lread_apicid_msr
+#endif
+
+.Lread_apicid_mmio:
 	/* Read the APIC ID from the fix-mapped MMIO space. */
 	movq	apic_mmio_base(%rip), %rcx
 	addq	$APIC_ID, %rcx

A message that is not in the archive (sent off-list or not yet received): CA+2tU596G+auWJ2MzYFJ3bv=Y4zP2NSrdtak7SdF9SH6Ht_dzg@mail.gmail.com

#11 lore raw

PATCH 1/1 x86/smpboot/64: Handle X2APIC BIOS inconsistency gracefully

Chris reported that a Dell PowerEdge T340 system stopped to boot when upgrading to a kernel which contains the parallel hotplug changes. Disabling parallel hotplug on the kernel command line makes it boot again.

It turns out that the Dell BIOS has x2APIC enabled and the boot CPU comes up in X2APIC mode, but the APs come up inconsistently in xAPIC mode.

Parallel hotplug requires that the upcoming CPU reads out its APIC ID from the local APIC in order to map it to the Linux CPU number.

In this particular case the readout on the APs uses the MMIO mapped registers because the BIOS failed to enable x2APIC mode. That readout results in a pagefault because the kernel does not have the APIC MMIO space mapped when X2APIC mode was enabled by the BIOS on the boot CPU and the kernel switched to X2APIC mode early. That page fault can't be handled on the upcoming CPU that early and results in a silent boot failure.

If parallel hotplug is disabled the system boots because in that case the APIC ID read is not required as the Linux CPU number is provided to the AP in the smpboot control word. When the kernel uses x2APIC mode then the APs are switched to x2APIC mode too slightly later in the bringup process, but there is no reason to do it that late.

Cure the BIOS bogosity by checking in the parallel bootup path whether the kernel uses x2APIC mode and if so switching over the APs to x2APIC mode before the APIC ID readout.

Fixes 0c7ffa32dbd6 "x86/smpboot/64: Implement arch_cpuhp_init_parallel_bringup() and enable it"
---
 arch/x86/kernel/head_64.S |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/x86/kernel/head_64.S +16 -0
@@ -268,6 +268,22 @@ SYM_INNER_LABEL(secondary_startup_64_no_
 	testl	$X2APIC_ENABLE, %eax
 	jnz	.Lread_apicid_msr
 
+#ifdef CONFIG_X86_X2APIC
+	/*
+	 * If system is in X2APIC mode then MMIO base mignt not be
+	 * mapped causing the MMIO read below to fault. Faults can't
+	 * be handled at that point.
+	 */
+	cmpl	$0, x2apic_mode(%rip)
+	jz	.Lread_apicid_mmio
+
+	/* Force the AP into X2APIC mode. */
+	orl	$X2APIC_ENABLE, %eax
+	wrmsr
+	jmp	.Lread_apicid_msr
+#endif
+
+.Lread_apicid_mmio:
 	/* Read the APIC ID from the fix-mapped MMIO space. */
 	movq	apic_mmio_base(%rip), %rcx
 	addq	$APIC_ID, %rcx
Reviewed-by on v1 1/1
#12 lore raw

Re: [PATCH] x86/smpboot/64: Handle X2APIC BIOS inconsistency gracefully

Quoted 27 lines · Thomas Gleixner

Chris reported that a Dell PowerEdge T340 system stopped to boot when upgrading to a kernel which contains the parallel hotplug changes. Disabling parallel hotplug on the kernel command line makes it boot again.

It turns out that the Dell BIOS has x2APIC enabled and the boot CPU comes up in X2APIC mode, but the APs come up inconsistently in xAPIC mode.

Parallel hotplug requires that the upcoming CPU reads out its APIC ID from the local APIC in order to map it to the Linux CPU number.

In this particular case the readout on the APs uses the MMIO mapped registers because the BIOS failed to enable x2APIC mode. That readout results in a pagefault because the kernel does not have the APIC MMIO space mapped when X2APIC mode was enabled by the BIOS on the boot CPU and the kernel switched to X2APIC mode early. That page fault can't be handled on the upcoming CPU that early and results in a silent boot failure.

If parallel hotplug is disabled the system boots because in that case the APIC ID read is not required as the Linux CPU number is provided to the AP in the smpboot control word. When the kernel uses x2APIC mode then the APs are switched to x2APIC mode too slightly later in the bringup process, but there is no reason to do it that late.

Cure the BIOS bogosity by checking in the parallel bootup path whether the kernel uses x2APIC mode and if so switching over the APs to x2APIC mode before the APIC ID readout.

Quoted 8 lines
Fixes 0c7ffa32dbd6 "x86/smpboot/64: Implement arch_cpuhp_init_parallel_bringup() and enable it"
---
 arch/x86/kernel/head_64.S |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

A message that is not in the archive (sent off-list or not yet received): CA+2tU5_hD-atkp9UcCJnL6TMneSOBxL87=ppvrQ1ugUn_0-7NA@mail.gmail.com

author maintainer
#14 lore raw

Re: [PATCH] x86/smpboot/64: Handle X2APIC BIOS inconsistency gracefully

Quoted 1 line · Chris Lindee

I think there is a typo in the code comment: s/mignt/might/

Fixed, thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#15 lore raw
In reply to Borislav Petkov

[TLDR: I'm adding this report to the list of tracked Linux kernel regressions; the text you find below is based on a few templates paragraphs you might have encountered already in similar form. See link in footer if these mails annoy you.]

Quoted 11 lines · Borislav Petkov
Quoted 7 lines · Chris Lindee

My Dell-EMC PowerEdge T340 server worked with v6.4.15, but it will not start with v6.5.x - it won't even display dmesg events during boot. I reproduced the issue on v6.7-rc4 and bisected the first problematic commit to:

0c7ffa32dbd6 x86/smpboot/64: Implement arch_cpuhp_init_parallel_bringup() and enable it

I presume booting with "cpuhp.parallel=0" on the kernel cmdline fixes it?

To be sure the issue doesn't fall through the cracks unnoticed, I'm adding it to regzbot, the Linux kernel regression tracking bot:

#regzbot ^introduced 0c7ffa32dbd6
#regzbot title x86: system stopped booting with v6.5 #regzbot ignore-activity

This isn't a regression? This issue or a fix for it are already discussed somewhere else? It was fixed already? You want to clarify when the regression started to happen? Or point out I got the title or something else totally wrong? Then just reply and tell me -- ideally while also telling regzbot about it, as explained by the page listed in the footer of this mail.

Developers: When fixing the issue, remember to add 'Link:' tags pointing to the report (the parent of this mail). See page linked in footer for details.

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) --
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
That page also explains what to do if mails like this annoy you.

#16 lore raw
In reply to Borislav Petkov
Quoted 6 lines · Borislav Petkov
Quoted 5 lines · Chris Lindee

My Dell-EMC PowerEdge T340 server worked with v6.4.15, but it will not start with v6.5.x - it won't even display dmesg events during boot. I reproduced the issue on v6.7-rc4 and bisected the first problematic commit to:

Quoted 6 lines
Quoted 2 lines

0c7ffa32dbd6 x86/smpboot/64: Implement arch_cpuhp_init_parallel_bringup() and enable it

I presume booting with "cpuhp.parallel=0" on the kernel cmdline fixes it?

#regzbot fix: 69a7386c1ec2

#17 lore raw
Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Borislav Petkov
Quoted 5 lines · Chris Lindee

My Dell-EMC PowerEdge T340 server worked with v6.4.15, but it will not start with v6.5.x - it won't even display dmesg events during boot. I reproduced the issue on v6.7-rc4 and bisected the first problematic commit to:

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

0c7ffa32dbd6 x86/smpboot/64: Implement arch_cpuhp_init_parallel_bringup() and enable it

I presume booting with "cpuhp.parallel=0" on the kernel cmdline fixes it?

#regzbot fix: 69a7386c1ec2

Many thx, I had missed that. Sadly regzbot was unable to handle this, as there was no blank line before the regzbot command. I wonder if I should drop that requirement...

#regzbot fix: 69a7386c1ec2

Ciao, Thorsten