diff mbox series

[1/1] x86/cpu/topology: Don't limit CPUs to 1 for Xen PV guests due to disabled APIC

Message ID 20250405181650.22827-2-arkamar@atlas.cz (mailing list archive)
State New
Headers show
Series x86/topology: Fix regression limiting Xen PV DomU CPUs to 1 | expand

Commit Message

Petr Vaněk April 5, 2025, 6:16 p.m. UTC
Xen PV guests in DomU have APIC disabled by design, which causes
topology_apply_cmdline_limits_early() to limit the number of possible
CPUs to 1, regardless of the configured number of vCPUs.

This is a regression introduced in version 6.9 in commit 7c0edad3643f
("x86/cpu/topology: Rework possible CPU management") which added an
early check that limits CPUs if apic_is_disabled, without accounting for
the fact that Xen PV guests always disable APIC even when SMP is
supported.

This patch fixes the issue by skipping the apic_is_disabled check for
Xen PV guests, allowing them to boot with the full set of configured vCPUs.

Fixes: 7c0edad3643f ("x86/cpu/topology: Rework possible CPU management")
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Cc: xen-devel@lists.xenproject.org
Cc: stable@vger.kernel.org # 6.9+
Signed-off-by: Petr Vaněk <arkamar@atlas.cz>
---
 arch/x86/kernel/cpu/topology.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Thomas Gleixner April 6, 2025, 10:08 a.m. UTC | #1
On Sat, Apr 05 2025 at 20:16, Petr Vaněk wrote:

> Xen PV guests in DomU have APIC disabled by design, which causes
> topology_apply_cmdline_limits_early() to limit the number of possible
> CPUs to 1, regardless of the configured number of vCPUs.

PV guests have a APIC emulation and there is no code which actually
disables the APIC by design unconditionally. There is one way though,
which disables the APIC indirectly.

xen_arch_setup() disables ACPI, which in turn causes acpi_mps_check() to
return 1, which disables the APIC. This only happens when the kernel
configuration has:

     CONFIG_X86_MPPARSE=n
     CONFIG_ACPI=y

If you enable MPPARSE the problem goes away, no?

> +	/* 'maxcpus=0' 'nosmp' 'nolapic'
> +	 *
> +	 * The apic_is_disabled check is ignored for Xen PV domains because Xen
> +	 * disables ACPI in unprivileged PV DomU guests, which would otherwise limit
> +	 * CPUs to 1, even if multiple vCPUs were configured.

This is the wrong place as it invalidates the effect of 'nolapic' on the
kernel command line for XEN PV.

You actually explain in the comment that XEN disables ACPI, so why are
you slapping this xen check into this code instead of doing the obvious
and prevent acpi_mps_check() to cause havoc?

Thanks,

        tglx
Petr Vaněk April 7, 2025, 1:24 p.m. UTC | #2
On Sun, Apr 06, 2025 at 12:08:29PM +0200, Thomas Gleixner wrote:
> On Sat, Apr 05 2025 at 20:16, Petr Vaněk wrote:
> 
> > Xen PV guests in DomU have APIC disabled by design, which causes
> > topology_apply_cmdline_limits_early() to limit the number of possible
> > CPUs to 1, regardless of the configured number of vCPUs.
> 
> PV guests have a APIC emulation and there is no code which actually
> disables the APIC by design unconditionally. There is one way though,
> which disables the APIC indirectly.

It seems I have got a bit lost in APIC/ACPI abbreviations. Sorry.

> xen_arch_setup() disables ACPI, which in turn causes acpi_mps_check() to
> return 1, which disables the APIC. This only happens when the kernel
> configuration has:
> 
>      CONFIG_X86_MPPARSE=n
>      CONFIG_ACPI=y
> 
> If you enable MPPARSE the problem goes away, no?

Yes, it goes away.

> > +	/* 'maxcpus=0' 'nosmp' 'nolapic'
> > +	 *
> > +	 * The apic_is_disabled check is ignored for Xen PV domains because Xen
> > +	 * disables ACPI in unprivileged PV DomU guests, which would otherwise limit
> > +	 * CPUs to 1, even if multiple vCPUs were configured.
> 
> This is the wrong place as it invalidates the effect of 'nolapic' on the
> kernel command line for XEN PV.
> 
> You actually explain in the comment that XEN disables ACPI, so why are
> you slapping this xen check into this code instead of doing the obvious
> and prevent acpi_mps_check() to cause havoc?

Thank you for your explanation and suggestion. I will correct acpi_mps_check()
in following patch.

Thanks,
Petr
diff mbox series

Patch

diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
index 01456236a6dd..10aa7f471ec9 100644
--- a/arch/x86/kernel/cpu/topology.c
+++ b/arch/x86/kernel/cpu/topology.c
@@ -428,8 +428,13 @@  void __init topology_apply_cmdline_limits_early(void)
 {
 	unsigned int possible = nr_cpu_ids;
 
-	/* 'maxcpus=0' 'nosmp' 'nolapic' */
-	if (!setup_max_cpus || apic_is_disabled)
+	/* 'maxcpus=0' 'nosmp' 'nolapic'
+	 *
+	 * The apic_is_disabled check is ignored for Xen PV domains because Xen
+	 * disables ACPI in unprivileged PV DomU guests, which would otherwise limit
+	 * CPUs to 1, even if multiple vCPUs were configured.
+	 */
+	if (!setup_max_cpus || (!xen_pv_domain() && apic_is_disabled))
 		possible = 1;
 
 	/* 'possible_cpus=N' */