From patchwork Fri Feb 3 13:50:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 52503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp850364wrn; Fri, 3 Feb 2023 05:56:31 -0800 (PST) X-Google-Smtp-Source: AK7set8HfVIvY4WKvvmamzjnUpjc6Mjz2oNp05rwJ9FOBO0wJwzO5O0YRbEf496WgzOrYP2DGLdu X-Received: by 2002:a05:6402:f1c:b0:4a2:4485:2930 with SMTP id i28-20020a0564020f1c00b004a244852930mr11263328eda.14.1675432590982; Fri, 03 Feb 2023 05:56:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675432590; cv=none; d=google.com; s=arc-20160816; b=mZfu/Bo2GBUhzXdyrd31BB+OABwXJNJxT7++Eg1Iwm224+/nUzjcHJzJAddBkmANNc gCtVDuoGYzfzx3kD/WLBB0dlgmBjWN0Tx9QwBnbuc07rm9camcljHCcmkgtYqh6GV8sR DNeDyAKJe+hdveNAr5TlRDGes7U7WOiClLdobO/s5nDkLfNOoODMLS83d9lPkbaup+od 94WXd+UkgO4lMKYvR/kmxl70lZnEU7lE7HRnHPhTmMCRRQfal64cAiK5hqKC8JT3mi07 9+Nh7PGtGkkTe36ctIZw98hsjiPLk3SW69DzpamXT4LJmPNrXajzLy5K2JR8AuBh2Od5 Uo1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0y/Erix8qdxhD33p5i3cpi8dfzlzsEsUb59e5yJFOLo=; b=ztPUL4fIU1AOmNIWUkLfPvQI4vDOxbxQ2vZx1Fr+1uWaur0iqCp3uLncgrTaKeOQoe cYxdV7nQBtPj2Byg7dKH2fw19jra8r1X5IVEo4c3dRw4UQy0YcgUsDkxLCj1S4ysT52U y+R9GLbA9dh+a2mBt+KRWPxXUwkm7S0UT6JBbchRC2PkMu/Dc+eAUok8eU9t9gyccnG/ PgVTfjCYjE71DnvvxJA6X7d4igjBpWkvGL8q/npOD/beViq3F6ne1JrYdZ3x+Jfav7hr w19BpAZBHF5/P4c+26hW8zfok78n2fATFpNzHqAeYgCHctzLdLduckqfO/V5nvHMmVRw qqTA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id er18-20020a056402449200b0046a0331778dsi2910856edb.118.2023.02.03.05.56.06; Fri, 03 Feb 2023 05:56:30 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232409AbjBCNzI (ORCPT + 99 others); Fri, 3 Feb 2023 08:55:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233120AbjBCNyp (ORCPT ); Fri, 3 Feb 2023 08:54:45 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F35682B090; Fri, 3 Feb 2023 05:53:11 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CFE5E1596; Fri, 3 Feb 2023 05:53:25 -0800 (PST) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.177]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0EB193F71E; Fri, 3 Feb 2023 05:52:39 -0800 (PST) From: James Morse To: linux-pm@vger.kernel.org, loongarch@lists.linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Mark Rutland , Sudeep Holla , Borislav Petkov , H Peter Anvin , Dave Hansen , Ingo Molnar , Will Deacon , Catalin Marinas , Huacai Chen , James Morse , Suzuki K Poulose , Oliver Upton , Len Brown , Rafael Wysocki , WANG Xuerui , Salil Mehta , Russell King , Jean-Philippe Brucker Subject: [RFC PATCH 12/32] ACPI: processor: Register CPUs that are online, but not described in the DSDT Date: Fri, 3 Feb 2023 13:50:23 +0000 Message-Id: <20230203135043.409192-13-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230203135043.409192-1-james.morse@arm.com> References: <20230203135043.409192-1-james.morse@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756818404754192319?= X-GMAIL-MSGID: =?utf-8?q?1756818404754192319?= ACPI has two descriptions of CPUs, on in the MADT/APIC table, the other in the DSDT. Both are required. (ACPI 6.5's 8.4 "Declaring Processors" says "Each processor in the system must be declared in the ACPI namespace"). Having two descriptions allows firmware authors to get this wrong. If CPUs are described in the MADT/APIC, they will be brought online early during boot. Once the register_cpu() calls are moved to ACPI, they will be based on the ACPI description of the CPUs. When CPUs are missing from the ACPI description, they will end up online, but not registered. Add a helper that runs after acpi_init() has completed to register CPUs that are online, but weren't found in the DSDT. Any CPU that is registered by this code triggers a firmware-bug warning and kernel taint. Qemu TCG only describes the first CPU in the DSDT, unless cpu-hotplug is configured. Signed-off-by: James Morse --- drivers/acpi/acpi_processor.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 52668fa22c51..967837b60453 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -694,6 +694,25 @@ void __init acpi_processor_init(void) acpi_scan_add_handler(&processor_container_handler); } +static int acpi_processor_register_missing_cpus(void) +{ + int cpu; + + if (acpi_disabled) + return 0; + + for_each_online_cpu(cpu) { + if (!get_cpu_device(cpu)) { + pr_err_once(FW_BUG "CPU %u has no ACPI namespace description!\n", cpu); + add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); + arch_register_cpu(cpu); + } + } + + return 0; +} +subsys_initcall_sync(acpi_processor_register_missing_cpus); + #ifdef CONFIG_ACPI_PROCESSOR_CSTATE /** * acpi_processor_claim_cst_control - Request _CST control from the platform.