From patchwork Fri Aug 19 04:11:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12948306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15436C25B0E for ; Fri, 19 Aug 2022 04:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xVkx+2rkNw/+86Fuuq8eH8JhjVTLA6X5agrNg9iW+aY=; b=NOzCSZJFXWTTG4 L0kRGz/daQpx6q7IW2MwUoqPVeXk/I+k87PKWLa9YPC2vEx4ENS/bTfLFV/o1BGzUePM0z3LE/dRA 2fUdyr+6ol4rJzCOUvqYOH3DZfBSbF54vx4wwu1aTiPCz3vJCCIlZ3T3MaydRKbIOlZ/QIqlaMSJ2 GQPRxzeqV60wE68hX0adqPQN+hGEVd3lDN5h0gA6JB7YVTJ6Mq8WMTpIAbTGHvs60XXKdSfzCeCfl 2yx+d6l+wrkTHU/U1DmACtpSTJ7nn8gQwVti0SQvIXZSW1EGFagsofKAMIPUSktM93NprCdJE448K RomM0a++deql8erqry5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOtO2-00HFUE-Jc; Fri, 19 Aug 2022 04:13:35 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOtN4-00HDiu-4p for linux-arm-kernel@lists.infradead.org; Fri, 19 Aug 2022 04:12:35 +0000 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 dfw.source.kernel.org (Postfix) with ESMTPS id AF01E6153F; Fri, 19 Aug 2022 04:12:33 +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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220818_211234_336102_774867C7 X-CRM114-Status: GOOD ( 18.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 }