From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4276FC433DB for ; Wed, 13 Jan 2021 01:44:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EDD4E22B37 for ; Wed, 13 Jan 2021 01:44:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDD4E22B37 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FDjWeei8Xk3bPnnmgNJnoICkWSuyspive3ctegAPqOw=; b=3A1qpAK6cEtBWl/l5vYWB2IK8M mOa8TzxAOCA7bp+etZc0rhZ3OBuF7Ru5eUugcpACBja6HxNaCJgJlCAk2uvkyDz2eHSfYlF1e7kRm xT67Y0poHRubxTMQKg3bFiTPIZ6nereihY1ZVbViJefw1qYhCI69rr62KHYVYeZWjUZ+c5K/6myUG c1NdtJ+WYpBbysyd47Dif/JBt6IHPLdi1AI6PrR22RyG9uh/yWfHQsslAVNPzYbadD6RAIPENkaVD w2vjsHMYpBoqNt0dOjGymjIkA3rXqYfmXO9WHS2vMPiizQQiQqQM5k/FdnrIhGq0xvP4P23+JWwOb WwTKOUvg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzVAT-0006pX-QF; Wed, 13 Jan 2021 01:41:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzVAP-0006o3-JK for linux-arm-kernel@lists.infradead.org; Wed, 13 Jan 2021 01:41:46 +0000 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 F3B881063; Tue, 12 Jan 2021 17:41:41 -0800 (PST) Received: from entos-ampere-02.shanghai.arm.com (entos-ampere-02.shanghai.arm.com [10.169.214.110]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 193653F70D; Tue, 12 Jan 2021 17:41:35 -0800 (PST) From: Jia He To: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/2] arm64/cpuinfo: Move init_cpu_features() ahead of setup.c::early_fixmap_init() Date: Wed, 13 Jan 2021 09:40:46 +0800 Message-Id: <20210113014047.14371-2-justin.he@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210113014047.14371-1-justin.he@arm.com> References: <20210113014047.14371-1-justin.he@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210112_204145_767346_7B61404B X-CRM114-Status: GOOD ( 14.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Kefeng Wang , Jia He , Suzuki K Poulose , Ard Biesheuvel , Marc Zyngier , Anshuman Khandual , Richard Henderson , "Gustavo A. R. Silva" , Steven Price , Mark Brown , Cristian Marussi , Gavin Shan , Andrew Morton , Dave Martin , Mike Rapoport MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move init_cpu_features() ahead of setup_arch()->early_fixmap_init(), which is the preparation work for checking the condition to assign arm64_use_ng_mappings as cpus_have_const_cap(ARM64_UNMAP_KERNEL_AT_EL0). Besides, jump_label_init() is also moved ahead because cpus_have_const_cap() depends on static key enable api. Percpu helpers should be avoided in cpuinfo_store_boot_cpu() before percpu init at main.c::setup_per_cpu_areas() Signed-off-by: Jia He --- arch/arm64/include/asm/cpu.h | 1 + arch/arm64/kernel/cpuinfo.c | 13 ++++++++++--- arch/arm64/kernel/setup.c | 14 +++++++++----- arch/arm64/kernel/smp.c | 3 +-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/cpu.h b/arch/arm64/include/asm/cpu.h index 7faae6ff3ab4..59f36f5e3c04 100644 --- a/arch/arm64/include/asm/cpu.h +++ b/arch/arm64/include/asm/cpu.h @@ -63,6 +63,7 @@ DECLARE_PER_CPU(struct cpuinfo_arm64, cpu_data); void cpuinfo_store_cpu(void); void __init cpuinfo_store_boot_cpu(void); +void __init save_boot_cpuinfo_data(void); void __init init_cpu_features(struct cpuinfo_arm64 *info); void update_cpu_features(int cpu, struct cpuinfo_arm64 *info, diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 77605aec25fe..f8de5b8bae20 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -413,9 +413,16 @@ void cpuinfo_store_cpu(void) void __init cpuinfo_store_boot_cpu(void) { - struct cpuinfo_arm64 *info = &per_cpu(cpu_data, 0); - __cpuinfo_store_cpu(info); + __cpuinfo_store_cpu(&boot_cpu_data); - boot_cpu_data = *info; init_cpu_features(&boot_cpu_data); } + +void __init save_boot_cpuinfo_data(void) +{ + struct cpuinfo_arm64 *info; + + set_my_cpu_offset(per_cpu_offset(smp_processor_id())); + info = &per_cpu(cpu_data, 0); + *info = boot_cpu_data; +} diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 1a57a76e1cc2..e078ab068f3b 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -297,16 +297,20 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p) */ arm64_use_ng_mappings = kaslr_requires_kpti(); - early_fixmap_init(); - early_ioremap_init(); - - setup_machine_fdt(__fdt_pointer); - /* * Initialise the static keys early as they may be enabled by the * cpufeature code and early parameters. */ jump_label_init(); + + /* Init the cpu feature codes for boot cpu */ + cpuinfo_store_boot_cpu(); + + early_fixmap_init(); + early_ioremap_init(); + + setup_machine_fdt(__fdt_pointer); + parse_early_param(); /* diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 2499b895efea..3df1f5b1da0b 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -449,8 +449,7 @@ void __init smp_cpus_done(unsigned int max_cpus) void __init smp_prepare_boot_cpu(void) { - set_my_cpu_offset(per_cpu_offset(smp_processor_id())); - cpuinfo_store_boot_cpu(); + save_boot_cpuinfo_data(); /* * We now know enough about the boot CPU to apply the -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel