Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1184744rwb; Thu, 18 Aug 2022 21:40:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR67jFH51BWhi6N3Il5Qsn2L0b2NDL3OwMkjkWnc/wL9qCUVhWinJ+t7RAI9VxpKENlIGc9U X-Received: by 2002:a17:907:a40f:b0:730:c4ce:631c with SMTP id sg15-20020a170907a40f00b00730c4ce631cmr3617695ejc.362.1660884025297; Thu, 18 Aug 2022 21:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660884025; cv=none; d=google.com; s=arc-20160816; b=CA6zHRsCY43iGp06wt6lJiszQYePc3Nqudwi2vqET/eWRY3YpXo19lE2hZ0oq0ICnA /jq9t6j44kiRPVzosDI3hPs9K8iXQHTfjht2atJ0uPM0UU+bWE9s1hB7iZQsm7iuSSFY 7r3E1kfuDPRSOfbvxp+tHvp1XIlT6k5faO4fEpEUT6Ge5ZscTSgBcd/TMDwG0ESmX7Ej Z13tkhUbvtQSvFSohfBncbIp0JaUuWpSyHXLXMHQ5D5O8C3Tb6d3GPutnSKTCZiu+N6t mNG1reuPdvBF+/Dsy738FWolCo5nFIG6j/XN7wwRvKCUHOr/bRUneD9m1yL5MFdRRUZN b8tQ== 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 :dkim-signature; bh=ENv6NMYpPjYuQUQjnvjBQP5A6MhNUqa49pAnq4pN6mw=; b=lmP8aINWxbk5Td0CgIskoNG1D8gYlAT4U0m/5EWsbxmUoBd3Mt9hRrmJ1Gmdhlfc+f Hrbw+QMiSbK4pTqCngYCK0LqnSOiXsD9UIOhvySiy6+WEJCx6ediRQWhR7v5qWtPH3hv g3LpVqIKyGGCuT1aAf2ruAd3SAF3FD5lVKDAonVCwJhReOHWzagZGqCcTvWiRmcjfzjM 3NwCEnzocpcxDfOj86qlagmleg34MNcHHozFX2jzpAZTDs09kumoft3aBb9LbHWe+nGZ yvElhsc0Eace2X6ZJIJmiSmCbjFLG92CrLuslh8Di9ow8xBsXf0ahhGmwiZ22f12co22 xITQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dZb0HOnl; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i30-20020a0564020f1e00b004464a7ae588si121268eda.411.2022.08.18.21.39.59; Thu, 18 Aug 2022 21:40:25 -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=@kernel.org header.s=k20201202 header.b=dZb0HOnl; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238548AbiHSEMn (ORCPT + 99 others); Fri, 19 Aug 2022 00:12:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346021AbiHSEMg (ORCPT ); Fri, 19 Aug 2022 00:12:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A49C2D4BEE for ; Thu, 18 Aug 2022 21:12:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5EB46B825AA for ; Fri, 19 Aug 2022 04:12:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8142AC43140; Fri, 19 Aug 2022 04:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660882353; bh=xA88Ovos9H3DHR/HPlEe0AwH/mYo7aEjxL8NAKpwIOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dZb0HOnlL2Y22Acis6FSAF9KAcZ8A1LfVc5yWntVp0HlvxGO+KFsurLTJob9b+hQh PkfQ8LIifmzwzPin/wpr8baDOHLVGMK9hlbneLnyAg4Vhw+WTENfeCYHnsmxUFfadT /cx8xnmqRSVv/+OVb+4vOf/9n9Cg+KXY/kiu+eBy4vzbXYQcqBckcpqJYtcv8h1t/w qyDkiaBA+aAJjJK7hdkJcNfRp9/x8rfE3dnSkkyV//lEzdUx1c1+C9r06rmuX1dbKN T0Bkc9f7cE2HpKpkJ8/WyTDrSRuU4Ib/DgFQIkZHrw8dPEISYIzaKYU0+Y9UlLXG/k RCeyHxW12/8Cg== From: Mike Rapoport To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Guanghui Feng , Mark Rutland , Mike Rapoport , Mike Rapoport , Will Deacon , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 5/5] arm64/mmu: simplify logic around crash kernel mapping in map_mem() Date: Fri, 19 Aug 2022 07:11:56 +0300 Message-Id: <20220819041156.873873-6-rppt@kernel.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220819041156.873873-1-rppt@kernel.org> References: <20220819041156.873873-1-rppt@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Mike Rapoport The check for crashkernel command line parameter and presence of CONFIG_ZONE_DMA[32] in mmu::map_mem() are not necessary because crashk_res.end would be set by the time map_mem() runs only if reserve_crashkernel() was called from arm64_memblock_init() and only if there was proper crashkernel parameter in the command line. Leave only check that crashk_res.end is non-zero to decide whether crash kernel memory should be mapped with base pages. Signed-off-by: Mike Rapoport --- arch/arm64/mm/mmu.c | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 83f2f18f7f34..fa23cfa6b772 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -502,21 +502,6 @@ void __init mark_linear_text_alias_ro(void) PAGE_KERNEL_RO); } -static bool crash_mem_map __initdata; - -static int __init enable_crash_mem_map(char *arg) -{ - /* - * Proper parameter parsing is done by reserve_crashkernel(). We only - * need to know if the linear map has to avoid block mappings so that - * the crashkernel reservations can be unmapped later. - */ - crash_mem_map = true; - - return 0; -} -early_param("crashkernel", enable_crash_mem_map); - static void __init map_mem(pgd_t *pgdp) { static const u64 direct_map_end = _PAGE_END(VA_BITS_MIN); @@ -547,11 +532,9 @@ static void __init map_mem(pgd_t *pgdp) memblock_mark_nomap(kernel_start, kernel_end - kernel_start); #ifdef CONFIG_KEXEC_CORE - if (crash_mem_map && !have_zone_dma()) { - if (crashk_res.end) - memblock_mark_nomap(crashk_res.start, - resource_size(&crashk_res)); - } + if (crashk_res.end) + memblock_mark_nomap(crashk_res.start, + resource_size(&crashk_res)); #endif /* map all the memory banks */ @@ -582,20 +565,17 @@ static void __init map_mem(pgd_t *pgdp) memblock_clear_nomap(kernel_start, kernel_end - kernel_start); /* - * Use page-level mappings here so that we can shrink the region - * in page granularity and put back unused memory to buddy system - * through /sys/kernel/kexec_crash_size interface. + * Use page-level mappings here so that we can protect crash kernel + * memory to allow post-mortem analysis when things go awry. */ #ifdef CONFIG_KEXEC_CORE - if (crash_mem_map && !have_zone_dma()) { - if (crashk_res.end) { - __map_memblock(pgdp, crashk_res.start, - crashk_res.end + 1, - PAGE_KERNEL, - NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS); - memblock_clear_nomap(crashk_res.start, - resource_size(&crashk_res)); - } + if (crashk_res.end) { + __map_memblock(pgdp, crashk_res.start, + crashk_res.end + 1, + PAGE_KERNEL, + NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS); + memblock_clear_nomap(crashk_res.start, + resource_size(&crashk_res)); } #endif } -- 2.35.3