Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1291729rwl; Fri, 24 Mar 2023 08:38:00 -0700 (PDT) X-Google-Smtp-Source: AKy350bE8GV3p7LRiLFgOvyoOy3cD//z1++AJvALr9qEYo5kuL9Dk00w4eyxf9Q8LB/qd3wO+cV2 X-Received: by 2002:a17:906:d1cf:b0:8b1:7aaa:4c25 with SMTP id bs15-20020a170906d1cf00b008b17aaa4c25mr3193398ejb.29.1679672280730; Fri, 24 Mar 2023 08:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679672280; cv=none; d=google.com; s=arc-20160816; b=ZCs1sxvohu16q8Oh3TpD1NSr+qrpBkoJJCv1vsHGpijBiUf4h/3UrWIw+Szfcp+x+g i0vo3lbBUA2hjB/oXrL0yKEYHLikEUWpzKc2jHVuqlwW7X5QzFlEataRe3FBVcK7j/kY QgwtEuUkEUcAlWs6GCe0XZ5dBTmUGW4i666BWcSDcMRWA80+0Sp9oqWX7BGzkxVSJz0R YgKTcW/KDVSrJnyzuzc4UJ4kyNgd7JyUUnVCyt0zKERrq0BOwtWHOWW4B39nhIm+Qgzh l7qh6RczarIg24AWEqrE4Yfk1kc0WS79r/ktcPwADNE9fBI2UrHCkh0Ov0E/eTL4HuZg yqcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=UagDg680n7nc1vx7pvNNkFlK8h6/0MoetxhHv4ixiy8=; b=uuQMtuNrQLjDcrhft/Va9uxdzuZB/YKeZUdZRabxx9bWbKujxwk/lO1JHokkaKy+eB 4c+L3i2oFptsL+l2AXmTWXPkJCMhj3fp5ehcQAh4dl5aAVzL5ybUt9Kd7cIragDljBb+ 6vuaS6z4b/2xehqc/Bh4NmitKm8W1xZ7bODxg+YVZaotqzkO5xovaUZIwqUgpDdcjeqE 4clZNsTE9YUmjPjFf65mLqC4eqMXnG4t3rdBFvvemU3oZ+/T9R8zKQRGB3L+pqq4z48s GG+epJRyf+Dx6oEIjbAsL/2a4vRi91w48+lFloeHUktBoy9w6VX7NjgtiIc3ywL3eN5L Tajw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s27-20020a170906355b00b0093083e8ec20si523249eja.56.2023.03.24.08.37.36; Fri, 24 Mar 2023 08:38:00 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232342AbjCXPXw (ORCPT + 99 others); Fri, 24 Mar 2023 11:23:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231795AbjCXPXu (ORCPT ); Fri, 24 Mar 2023 11:23:50 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C38D0619F; Fri, 24 Mar 2023 08:23:48 -0700 (PDT) Received: (Authenticated sender: alex@ghiti.fr) by mail.gandi.net (Postfix) with ESMTPSA id A71C1FF814; Fri, 24 Mar 2023 15:23:42 +0000 (UTC) Message-ID: Date: Fri, 24 Mar 2023 16:23:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v8 3/4] arm64: Make use of memblock_isolate_memory for the linear mapping Content-Language: en-US To: Will Deacon , 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 References: <20230316131711.1284451-1-alexghiti@rivosinc.com> <20230316131711.1284451-4-alexghiti@rivosinc.com> <20230324152112.GD27199@willie-the-truck> From: Alexandre Ghiti In-Reply-To: <20230324152112.GD27199@willie-the-truck> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.7 required=5.0 tests=NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Hi Will, On 3/24/23 16:21, Will Deacon wrote: > 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? Yes, the next version won't touch arm64 at all since actually, I'll remove this new api. Thanks for your time, Alex > > 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 >> > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv