From patchwork Wed Jan 13 01:40:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 12015557 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=ham 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 45D62C433E6 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 02A2423122 for ; Wed, 13 Jan 2021 01:44:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 02A2423122 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=NMeYvK3hQl1SyscuxVhkGdy5BzYWKY/9kaVoqfrA4S4=; b=kWUVdyfqOMAb8Z48TyKEcQ4yJx su3RDLq95JKXi37xI4T4Nf2TJA/qt8mLY6AKd75TACje6ngi/53ebSDRA78UNZsDTjiLDvEJz2RB8 d+LsHk4VhTmfpmZTxT2RuItnCHeayPlJC/X2J78nE1ba8UM9tWQgjDmnucxfzadxdDEZSihogGmSu B/JzXICx+hop+/upFxpNhRgVtDkwgJe+Irn07R7VgP1kHz3eHoq/JTDZX5JMM15Ws7SUSp35+alWC laJ2VLIOPL6PjSL2WdW10Nb0IRzwMuq58LI8IToC3+1lc795hlpfnZ//oA8Cnanle9fkMOk7+VPhj AeaxZ90A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzVAX-0006qh-KG; Wed, 13 Jan 2021 01:41:53 +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 1kzVAU-0006pu-D2 for linux-arm-kernel@lists.infradead.org; Wed, 13 Jan 2021 01:41:51 +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 6C914106F; Tue, 12 Jan 2021 17:41:48 -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 857DD3F70D; Tue, 12 Jan 2021 17:41:42 -0800 (PST) From: Jia He To: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/2] arm64: kpti: Update arm64_use_ng_mappings before pagetable mapping Date: Wed, 13 Jan 2021 09:40:47 +0800 Message-Id: <20210113014047.14371-3-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_204150_548240_5F98ACF4 X-CRM114-Status: GOOD ( 13.18 ) 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is a 10s stall in idmap_kpti_install_ng_mappings when kernel boots on a Ampere EMAG server. Commit f992b4dfd58b ("arm64: kpti: Add ->enable callback to remap swapper using nG mappings") updates the nG bit runtime if kpti is required. But things get worse if rodata=full in map_mem(). NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS is required when creating pagetable mapping. Hence all ptes are fully mapped in this case. On a Ampere EMAG server with 256G memory(pagesize=4k), it causes the 10s stall. After previous commit moving init_cpu_features(), we can use cpu_have_const_cap earlier than before. Hence we can avoid this stall by updating arm64_use_ng_mappings. Signed-off-by: Jia He --- arch/arm64/kernel/setup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index e078ab068f3b..51098ceb7159 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -306,6 +306,10 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p) /* Init the cpu feature codes for boot cpu */ cpuinfo_store_boot_cpu(); + /* ARM64_UNMAP_KERNEL_AT_EL0 cap can be updated in cpuinfo_store_boot_cpu() */ + if (!arm64_use_ng_mappings) + arm64_use_ng_mappings = cpus_have_const_cap(ARM64_UNMAP_KERNEL_AT_EL0); + early_fixmap_init(); early_ioremap_init();