Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1272310rwl; Fri, 24 Mar 2023 08:22:41 -0700 (PDT) X-Google-Smtp-Source: AKy350ZL948ZvTXa2iWqmsI6ZTPhqyzyqm04n/qMu58lviCNQxKXGz4IwuoPjfaueeu1KIlVbX7o X-Received: by 2002:a05:6402:50a:b0:4ab:d1f4:4b88 with SMTP id m10-20020a056402050a00b004abd1f44b88mr3364241edv.41.1679671360950; Fri, 24 Mar 2023 08:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679671360; cv=none; d=google.com; s=arc-20160816; b=I4Zo9kY9RqBNc2romFBQbUmyhHJKPlDIV9mKTosUNC5iDXaUt5hAqRweSva4GHh7Zi 10WUqk6eJkIEVOTwN4RGMlD9bn1KTd/64xUODYktF4mkV94Gs+NnEWLvgp8vobM53CXr j1zQOEsQ+bvo9Q+JLYC3AhWu2bTH/ZvtlFL6vjg1F/9g5cHC9xqZv4rObtrRY6Jae2fq gCN44i5mtSc3RGSfCNrMyeMNsXBTB7Dzgr79b5DaCmgvZa8MF5mILk010OUmqKUGOdza z8pbrtKy/5ktMERze8k5uP7cqMRjzWohK95Wk/eF3bjhkhln1GITxVgqiSMgUkGcsa0y dnag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=oisnA9cYnE1zu4OFEZZshctqP8rmeG6KLx22az7DwXU=; b=iFfjyYoTqBts2rUZQi623w1UyEooJCOjAGZlToC/TRaY0JGNcjlvVa0OsttfuTb0Jr tZXNDKNJw9IbQXbGRtRT7y0j2CujoH8Lec6u2WtxGsNjMTKzsCMAGkDPXPBShiVO5LHC NON7FgVCUkWw0MRqJz8zX8dwFMx9kvNsbihalKr5+BZH9x041TKmYqG9+en9I40TdlUQ KKpG9bBj5Ds3EBQ5ePEW8FT3AcTl7j9CQcpn+bglw2KKAhHpO5OTKdD082KJqXLaQtlL NZ23P7JgXFsSc72BlCv2GPdGsVe/TgYTa1/wxQg3u0BJJfan9/OXjUeYL/UPoZwBzTB+ JjoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fYn5+NeZ; 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 m22-20020a50ef16000000b00501df8f316bsi9374600eds.308.2023.03.24.08.22.16; Fri, 24 Mar 2023 08:22:40 -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=fYn5+NeZ; 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 S232277AbjCXPVY (ORCPT + 99 others); Fri, 24 Mar 2023 11:21:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232058AbjCXPVX (ORCPT ); Fri, 24 Mar 2023 11:21:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FDF2132EC; Fri, 24 Mar 2023 08:21:22 -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 BD2FAB82498; Fri, 24 Mar 2023 15:21:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4A70C433A8; Fri, 24 Mar 2023 15:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679671279; bh=02GM7K6r27KRYha6EteRpwwTUBbmpkVxG9OyijKlG3g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fYn5+NeZtpXWi3nVp/4LLy8DH0H0ymzl9ykR3HGhR56lH3c2NdLc7Vq9e+nz6yGLM th3lEHNjAcHCBgVNwpsDAEfKQW4MaCEZmWtunHGlBnrfdjyrj6dtyckAVr4AytNWP5 YoHlcyh9EHZLpMUfNtTxyT/IdQV32XFdbRz500HJrCQ7B2f3DEU8EIcFjArKBTNnl5 ITOUHbY65mucoIZhCnBong68mCzbzpAFuGBESgTkskfci1G2VXWa9Q9j1pHIxiB916 XgrZ1tXUn9nCbsGi93+pKgYS81I77gF95DX3iMV+WeX4Qo/HnMj3ISRhs917M91OiX +DMCYejfbkXNw== Date: Fri, 24 Mar 2023 15:21:13 +0000 From: Will Deacon To: Alexandre Ghiti Cc: Catalin Marinas , Paul Walmsley , Palmer Dabbelt , Albert Ou , Rob Herring , Frank Rowand , Mike Rapoport , Andrew Morton , Anup Patel , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v8 3/4] arm64: Make use of memblock_isolate_memory for the linear mapping Message-ID: <20230324152112.GD27199@willie-the-truck> References: <20230316131711.1284451-1-alexghiti@rivosinc.com> <20230316131711.1284451-4-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230316131711.1284451-4-alexghiti@rivosinc.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 On Thu, Mar 16, 2023 at 02:17:10PM +0100, Alexandre Ghiti wrote: > In order to isolate the kernel text mapping and the crash kernel > region, we used some sort of hack to isolate thoses ranges which consisted > in marking them as not mappable with memblock_mark_nomap. > > Simply use the newly introduced memblock_isolate_memory function which does > exactly the same but does not uselessly mark the region as not mappable. But that's not what this patch does -- it's also adding special-case code for kexec and, honestly, I'm struggling to see why this is improving anything. Can we leave the code like it is, or is there something else going on? Will > Signed-off-by: Alexandre Ghiti > --- > arch/arm64/mm/mmu.c | 25 ++++++++++++++++--------- > 1 file changed, 16 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 6f9d8898a025..387c2a065a09 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -548,19 +548,18 @@ static void __init map_mem(pgd_t *pgdp) > > /* > * Take care not to create a writable alias for the > - * read-only text and rodata sections of the kernel image. > - * So temporarily mark them as NOMAP to skip mappings in > - * the following for-loop > + * read-only text and rodata sections of the kernel image so isolate > + * those regions and map them after the for loop. > */ > - memblock_mark_nomap(kernel_start, kernel_end - kernel_start); > + memblock_isolate_memory(kernel_start, kernel_end - kernel_start); > > #ifdef CONFIG_KEXEC_CORE > if (crash_mem_map) { > if (defer_reserve_crashkernel()) > flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; > else if (crashk_res.end) > - memblock_mark_nomap(crashk_res.start, > - resource_size(&crashk_res)); > + memblock_isolate_memory(crashk_res.start, > + resource_size(&crashk_res)); > } > #endif > > @@ -568,6 +567,17 @@ static void __init map_mem(pgd_t *pgdp) > for_each_mem_range(i, &start, &end) { > if (start >= end) > break; > + > + if (start == kernel_start) > + continue; > + > +#ifdef CONFIG_KEXEC_CORE > + if (start == crashk_res.start && > + crash_mem_map && !defer_reserve_crashkernel() && > + crashk_res.end) > + continue; > +#endif > + > /* > * The linear map must allow allocation tags reading/writing > * if MTE is present. Otherwise, it has the same attributes as > @@ -589,7 +599,6 @@ static void __init map_mem(pgd_t *pgdp) > */ > __map_memblock(pgdp, kernel_start, kernel_end, > PAGE_KERNEL, NO_CONT_MAPPINGS); > - memblock_clear_nomap(kernel_start, kernel_end - kernel_start); > > /* > * Use page-level mappings here so that we can shrink the region > @@ -603,8 +612,6 @@ static void __init map_mem(pgd_t *pgdp) > crashk_res.end + 1, > PAGE_KERNEL, > NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS); > - memblock_clear_nomap(crashk_res.start, > - resource_size(&crashk_res)); > } > } > #endif > -- > 2.37.2 >