lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d232e50f-01fc-ef2e-db29-3f790d960c0e@suse.com>
Date:   Mon, 31 Jul 2023 12:17:09 +0200
From:   Juergen Gross <jgross@...e.com>
To:     Thomas Gleixner <tglx@...utronix.de>,
        LKML <linux-kernel@...r.kernel.org>
Cc:     x86@...nel.org, Andrew Cooper <andrew.cooper3@...rix.com>,
        Tom Lendacky <thomas.lendacky@....com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Wei Liu <wei.liu@...nel.org>,
        Arjan van de Ven <arjan@...ux.intel.com>,
        Michael Kelley <mikelley@...rosoft.com>,
        Peter Keresztes Schmidt <peter@...esztesschmidt.de>,
        "Peter Zijlstra (Intel)" <peterz@...radead.org>
Subject: Re: [patch V2 16/58] x86/apic: Sanitize num_processors handling

On 24.07.23 15:34, Thomas Gleixner wrote:
> num_processors is 0 by default and only gets incremented when local APICs
> are registered.
> 
> Make init_apic_mappings(), which tries to enable the local APIC in the case
> that no SMP configuration was found set num_processors to 1.
> 
> This allows to remove yet another check for the local APIC and yet another
> place which registers the boot CPUs local APIC ID.
> 
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> Acked-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> ---
>   arch/x86/kernel/apic/apic.c |    9 ++++++---
>   arch/x86/kernel/smpboot.c   |   18 ------------------
>   2 files changed, 6 insertions(+), 21 deletions(-)
> 
> --- a/arch/x86/kernel/apic/apic.c
> +++ b/arch/x86/kernel/apic/apic.c
> @@ -2130,9 +2130,12 @@ void __init init_apic_mappings(void)
>   	if (x2apic_mode)
>   		return;
>   
> -	if (!smp_found_config && !detect_init_APIC()) {
> -		pr_info("APIC: disable apic facility\n");
> -		apic_disable();
> +	if (!smp_found_config) {
> +		if (!detect_init_APIC()) {
> +			pr_info("APIC: disable apic facility\n");
> +			apic_disable();
> +		}
> +		num_processors = 1;
>   	}
>   }
>   

This is introducing a regression for Xen PV guests: those have no ACPI
tables, so smp_found_config will be 0. OTOH num_processors has been set
already using hypervisor data, so setting num_processors to 1 here will
overwrite the previous setting.

Below diff on top is fixing the problem:

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 564d584c8b99..59c12b20c635 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2135,7 +2135,13 @@ void __init init_apic_mappings(void)
                         pr_info("APIC: disable apic facility\n");
                         apic_disable();
                 }
-               num_processors = 1;
+
+               /*
+                * Unprivileged Xen PV guests have smp_found_config = 0, but
+                * they have set num_processors already from hypervisor data.
+                */
+               if (!num_processors)
+                       num_processors = 1;
         }
  }


Juergen

Download attachment "OpenPGP_0xB0DE9DD628BF132F.asc" of type "application/pgp-keys" (3099 bytes)

Download attachment "OpenPGP_signature" of type "application/pgp-signature" (496 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ