From patchwork Mon Jul 17 23:14:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121650 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1399704vqt; Mon, 17 Jul 2023 16:18:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlH+fc9Y6FQCD/VgubM0g/XT7blgnRx71tgZ7S6GCOiHnxQ6jIwiHPlKQsDqH0GIPo/QC/HV X-Received: by 2002:a17:906:5a45:b0:977:95f4:5cca with SMTP id my5-20020a1709065a4500b0097795f45ccamr11723796ejc.54.1689635919185; Mon, 17 Jul 2023 16:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689635919; cv=none; d=google.com; s=arc-20160816; b=pyanLVvI5XdBrwOSIQLTAX1pL8mzLRfTUHBPVxowNfYsrG/YappmIRoEOF7eWjKgJz JJSZp34kfIeH1LkEWET+z3J/qgUtHtKlJMaj4050gfOMSPI1W0fW6ikbTubWyQbmOgIv Z2ANdqouVJVI53d22okbyggxAvISczyTj/EynvGSOIZOmpcEK4x46Ta3y7JQkPBTspRA Eo5MA4Uz4nPNOxIbay/wh3zvqt9G6a/x3GBefH8qMEGE/gOzuLFgHPvVKTty2wlenGnS 9hR61Zvn8rcLulCvLoJzmIsTUqJny8csZ1qq6CViRKHOF23G6mlpa803ggTffbNtIswy 8BWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=rxQN3La4uHdTmHXWvnEPxqt3sCLh4RNMZmN6BFMgny4=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=Kbncsb1cYjTHrBQrXWBFHc1mWdtISJ/STtnqETwjP25UUp0MLZIaOYmAIrJQBGyPSA ccxNF1vDcF7cwq7d2GNKUDQKgJwS22SQgEVw58S51+jV1z8WvHZq9DeWkt8On08iAMJt RbfhsOpSza4eRcOj7KfiQJ8bnpsVNWVl5j2DBX0GdFM9vyWUmYQHeapU2/JUgXQ0NXC9 JHFO78utf1aXOZpfXX05cyzjWdDcV1LERXT/Jvpv2Wit3SgsD6byNIv5ZBO8zF9VPgcn DwCGFhQZjtHaektAeNYi87sI8YUXyGRhzfD6AZeuf9MI+5u8CXOgF1Qnhm5kzRLOYbWK n8HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NcyMzc1S; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v23-20020a1709067d9700b00992f1b3ce88si306771ejo.590.2023.07.17.16.18.16; Mon, 17 Jul 2023 16:18:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NcyMzc1S; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbjGQXPs (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229724AbjGQXPk (ORCPT ); Mon, 17 Jul 2023 19:15:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2301A1BCF for ; Mon, 17 Jul 2023 16:15:01 -0700 (PDT) Message-ID: <20230717223224.030628920@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635699; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=rxQN3La4uHdTmHXWvnEPxqt3sCLh4RNMZmN6BFMgny4=; b=NcyMzc1SpuMYk05jsCRG2BlucobaDGGxjcwIrVbflUWp+DfMWiCjUrOP+3T+SHBItpDnJz JQr/UwH+IrAWFgJHt+49ROFOgVq7XMwdrqWa3LoPyQNrsokPM2L/hm6rOLOxye6alIHXNu d+in5MQswN9Xf2J5maeJBeEjIlAiNDVaybk/8iFq9y+Pl7tX9B26CTM/jkG2tCTAzAxfex 1gAqexir7pwpa8+ntX2jez7qrxyTZQjDNTsyGVvwhm3gQvaaOYMA5Q7jUuQ249K0aqwulA VuQ0imijJyYSAG6hb74CJdYn7kMHxSPWQEFrohzQ+t675BzWo6RSomjFTM4RHg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635699; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=rxQN3La4uHdTmHXWvnEPxqt3sCLh4RNMZmN6BFMgny4=; b=B6sKhRrWrOBnzZ3M5Uk7oINAy9QWuQJLDHj4bnToS+GnxoWP+NoHkWASgNtcqo603IhS08 YD51KKO/6iFbZLCw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 16/58] x86/apic: Sanitize num_processors handling References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:59 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711673664473580 X-GMAIL-MSGID: 1771711673664473580 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 --- 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; } } --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1389,24 +1389,6 @@ early_param("possible_cpus", _setup_poss { int i, possible; - /* No processor was found in mptable or ACPI MADT */ - if (!num_processors) { - if (boot_cpu_has(X86_FEATURE_APIC)) { - int apicid = boot_cpu_physical_apicid; - int cpu = read_apic_id(); - - pr_warn("Boot CPU (id %d) not listed by BIOS\n", cpu); - - /* Make sure boot cpu is enumerated */ - if (apic->cpu_present_to_apicid(0) == BAD_APICID && - apic->apic_id_valid(apicid)) - generic_processor_info(apicid); - } - - if (!num_processors) - num_processors = 1; - } - i = setup_max_cpus ?: 1; if (setup_possible_cpus == -1) { possible = num_processors;