From patchwork Wed Aug 9 19:12:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 133464 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp3035113vqr; Wed, 9 Aug 2023 12:49:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiIHVRiW/6jsJFJjLvFBG6TYC5p8Uh8ne22/7WP+n8sTjYp+kLGB+ZQKenEJaRrs0M4OSV X-Received: by 2002:a05:6512:3a8b:b0:4fb:94fd:645f with SMTP id q11-20020a0565123a8b00b004fb94fd645fmr63120lfu.68.1691610562251; Wed, 09 Aug 2023 12:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691610562; cv=none; d=google.com; s=arc-20160816; b=q/Hg12WNfI6CkjBCQ0Y25WBQF8+VJtpXw0RqeYu/DcoLPqAhi2DEk1adRcpvnTPzmu n6Xwd+C8qIKtzQuGYH43UN/2u5CD5TusIOiwjh0rAKMupsqQs6UR7sN6TEQgUiMEHuDQ D7bp0DSME7Pd+xSqiSWQMn4zYKLggTzEKTJFtg1mfwKQa6pbT+GFr0kK5G3K4agfqarp QYITI5n5QdhTapscOyHVGX+IXZMgTDgF/Yrvm/h0gt+vx4q7bGaW4cpQpp/7CrBn7SGz 8M512fMK1w0Isg64Al75KsyUqNCoZvrzufEDYYnRttUeiNssU2/lnV8a88++8fHqL9TG YjsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=QsdkW04j1Bduy4ECESsEb9beUBdQScODA//fkTgFUCI=; fh=jBwjuriIPWA1lnCf5oMMiNAPpgGE0iGPmBzZMsd85oQ=; b=ChoyFI3Mn4ApciMr3xUG1lcq+tjZVPvCJclTGZrwQm2JgIg7QuRth/+2H/MxVVxeH1 S3811PFAjjxgJIWxT8E4aGYV4bDpifGL4TZPAga3vn19Y/ZmmLkLjxxCQ3yVwgKIXuYU i3skZQHqtw2T/88EKu2fTLCi6r1rJU2QMhbM0TIWlUW+JSrARs6eHvhTgkxu/CMZAscq DBqsYA4iyoTQeMGHlkdZROJx1v9ikyvBbmBxBU9oWfbT347XArEfj3VzpzOpuE2UGUvj WNi+JaFVezvOodnV0smimCN0jSkGH9TtZC1DqHPW4gZIiwDsf1Cz7pRQ/b86+Mf8SU91 cAkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DQGIqLgV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 m17-20020aa7c491000000b00521d0a2c5adsi9575126edq.379.2023.08.09.12.48.58; Wed, 09 Aug 2023 12:49:22 -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=DQGIqLgV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S232875AbjHITNY (ORCPT + 99 others); Wed, 9 Aug 2023 15:13:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231851AbjHITMl (ORCPT ); Wed, 9 Aug 2023 15:12:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2621A2D4F; Wed, 9 Aug 2023 12:12:29 -0700 (PDT) Date: Wed, 09 Aug 2023 19:12:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691608343; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QsdkW04j1Bduy4ECESsEb9beUBdQScODA//fkTgFUCI=; b=DQGIqLgVb9ZTYeIzA+O3KTCSf3+iwuj9RTFW9CIqml9cT2Dj4qs+MbygTPDV+Nz+6BUaIa iDGI2ROlzMR4xTUwd86wx61yoh2Y6Den7ipKr6/MepRm2VzSLtbGt/kROYyDYy5u3pFP0T rNIaR65PAofcL28ODCPmINJtZvPbISpxC9dcvPJrDT6JsZIIGaNcnDBm7MxqBX8+bhU7V6 GjYOx9tXbxvTd5s6nSdpfoC/3mKRFkqWrW+HyMuvSqpdQtVeN2c927NbP3sIIMg6ieubVH GZFyHGCaiFvBdHyi136hYARh+ifvhS0q/bcZOf4WDjCReWUtlweAQGCz1d7Nog== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691608343; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QsdkW04j1Bduy4ECESsEb9beUBdQScODA//fkTgFUCI=; b=J1sHgZORUtL5j5ArSBoVHoUM+6sqpkBe+wnS2VLeP0+S46Em1xbHlI+Nh08S46rfncG+Mp YIlJigk+oiSp5nAA== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/apic] x86/apic: Sanitize num_processors handling Cc: Thomas Gleixner , Dave Hansen , "Peter Zijlstra (Intel)" , Michael Kelley , Sohil Mehta , Juergen Gross , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169160834326.27769.10323770352453532680.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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,URIBL_BLOCKED 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: 1773773032897150617 X-GMAIL-MSGID: 1773782236732389079 The following commit has been merged into the x86/apic branch of tip: Commit-ID: e8122513ff9e92cdc514ad6cbb5c25d551ac3629 Gitweb: https://git.kernel.org/tip/e8122513ff9e92cdc514ad6cbb5c25d551ac3629 Author: Thomas Gleixner AuthorDate: Tue, 08 Aug 2023 15:03:50 -07:00 Committer: Dave Hansen CommitterDate: Wed, 09 Aug 2023 11:58:21 -07:00 x86/apic: Sanitize num_processors handling 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 Signed-off-by: Dave Hansen Acked-by: Peter Zijlstra (Intel) Tested-by: Michael Kelley Tested-by: Sohil Mehta Tested-by: Juergen Gross # Xen PV (dom0 and unpriv. guest) --- arch/x86/kernel/apic/apic.c | 9 ++++++--- arch/x86/kernel/smpboot.c | 18 ------------------ 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 84ff5b2..564d584 100644 --- 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; } } diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 5467c58..fc2173b 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1397,24 +1397,6 @@ __init void prefill_possible_map(void) { 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;