Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp389930rdf; Tue, 21 Nov 2023 05:44:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHX7+vlN3s/yEDBbkEFBgWv0GvPpIrBByAvmvIN1B7i9W/DR1O0gcdCEOhS3eoFGQ4+/Bbn X-Received: by 2002:a05:6a20:e110:b0:186:46f3:7c10 with SMTP id kr16-20020a056a20e11000b0018646f37c10mr9875667pzb.51.1700574292780; Tue, 21 Nov 2023 05:44:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700574292; cv=none; d=google.com; s=arc-20160816; b=MvB1xsQCBwarr2iSU/WhAfmtKYSFHyA5eO0h5vDzi8w7M4IN19vh3YpvVf0KVPy9rj q+WkHDD0eh+77dw/FSCXeAqUo8+cdVPFqmY17Sd0efn0+lV55okv9V1TT76t0LRsOJ4k 9MVHwssjMtrJYWe9OOZGruU5dBzmOE1pnhjru97p0sYBjjYyqyY4EZXVorbu7F6T1QYi UFzTSxF2YMeu57F5qRfR1J81hSVaq1aYeKJZst6lpor+XIh6FvzAs9HlBV7SI+pmJYlF EwxPhB2eBZSdJ2iPDRurhZ7v8/bvYqZcWnPwRJ5yfFggsgdRLXTQmiwqyRUCNljmqsF/ FgCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:sender:message-id:content-transfer-encoding :content-disposition:mime-version:subject:cc:to:from:references :in-reply-to:dkim-signature; bh=IPSQ290E8DPF5FLSe+aRGb8AySZwOAxe+Qbv5W0+qQc=; fh=pBRrH9R0jn/tw414lsKbebjvUFyOrcd69gD7eKz3EjE=; b=rZJGN6IHxuRwYCCpV441sIhO3l2KLT4C+TcGM5RJSKKnTEVuaJlllbub08enz/oQBz vEoYzsWpNK+0T+5InsxvpDyIoKN15ZJgnXuAx+LlLXljtXVPR2thuHrZX1k2sudbiDOD G0TCn9Czfj0EhIJaGav5EnflUQM556AM3PEyaWpE7V0zG3RDHJ3eGUotqm3ehWXoDnjr e5iMs7oAuGKiXbvn5RwHaei7Be9BXV5dBN6NgrXmY2yW4odEh5elrJOZb4pRc0ZvzZEA 3j4uQFoUWyq8vK0EbeBYtmP/4tbsAevLhTk+P2nMZffPD9cqG+AN/8qd2+gKdZkBK6mo +R+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=jrLhUefG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id f189-20020a6251c6000000b006b618af5cd5si3169957pfb.300.2023.11.21.05.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 05:44:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=jrLhUefG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7F4DB80BB52D; Tue, 21 Nov 2023 05:44:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234340AbjKUNoZ (ORCPT + 99 others); Tue, 21 Nov 2023 08:44:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233844AbjKUNoV (ORCPT ); Tue, 21 Nov 2023 08:44:21 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F9DED75; Tue, 21 Nov 2023 05:44:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=IPSQ290E8DPF5FLSe+aRGb8AySZwOAxe+Qbv5W0+qQc=; b=jrLhUefGLk5f1PUHRc9HCT+s/S +wW1S09TAissMwnXitFWK/CuI7r5adngvPI/jZLJVr+4kfplr3BNwLqaiOwHJ27LuuDqEl9cCbJl4 mmotbGrSMp2dHExGSotlIWKkebYzsDYEG3l5LuqzwnxOOMwKx8rB8o2/6eWTA7o95LcLX97EE0LoP uel1PYd3KgBKpEcSMguCb+XzuWlfP09P7s9JVpJzj+3CY7ePOnozJpoiq3iNTla0bakA7IsSp+HUH i7rz61w+2GP8377PwsePQpuoxd16ji8a7AGAuf5GdiOqMph9l7NkqpextIvhoU2GqGqMw0m8KYBsw 4jd+0f9g==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:51922 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1r5R2k-00076J-0R; Tue, 21 Nov 2023 13:43:58 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1r5R2m-00Csyb-2S; Tue, 21 Nov 2023 13:44:00 +0000 In-Reply-To: References: From: Russell King (Oracle) To: linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kvmarm@lists.linux.dev, x86@kernel.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH 02/21] x86: intel_epb: Don't rely on link order MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Tue, 21 Nov 2023 13:44:00 +0000 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 05:44:44 -0800 (PST) From: James Morse intel_epb_init() is called as a subsys_initcall() to register cpuhp callbacks. The callbacks make use of get_cpu_device() which will return NULL unless register_cpu() has been called. register_cpu() is called from topology_init(), which is also a subsys_initcall(). This is fragile. Moving the register_cpu() to a different subsys_initcall() leads to a NULL dereference during boot. Make intel_epb_init() a late_initcall(), user-space can't provide a policy before this point anyway. Signed-off-by: James Morse Reviewed-by: Gavin Shan Signed-off-by: Russell King (Oracle) --- subsys_initcall_sync() would be an option, but moving the register_cpu() calls into ACPI also means adding a safety net for CPUs that are online but not described properly by firmware. This lives in subsys_initcall_sync(). --- arch/x86/kernel/cpu/intel_epb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/intel_epb.c b/arch/x86/kernel/cpu/intel_epb.c index e4c3ba91321c..f18d35fe27a9 100644 --- a/arch/x86/kernel/cpu/intel_epb.c +++ b/arch/x86/kernel/cpu/intel_epb.c @@ -237,4 +237,4 @@ static __init int intel_epb_init(void) cpuhp_remove_state(CPUHP_AP_X86_INTEL_EPB_ONLINE); return ret; } -subsys_initcall(intel_epb_init); +late_initcall(intel_epb_init); -- 2.30.2