From mboxrd@z Thu Jan 1 00:00:00 1970 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 0E1E1C6FD1C for ; Thu, 23 Mar 2023 12:31:33 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fs0B4wG30FpdF/QKHu8P0lLyFoTjn7jte7TeiQLfGXA=; b=O1bWppSiCpV4Sb g1kkv35dr7+YQHYKokC0qGyHnViwlejjt8U2MpSuwtCunHDoCGKISM0XFGBgQMwNhUxqNoISSwKnX tkeLu4bWHS+3zcJhHS1YsKeuI24fxGmsT2koWmZ61AWeIyZCk+CMvZfp3SfC7TLBGaugUbdMmu+IA wgVuL2k+EXV87yeeLRlT05XRuWYPu8FhP0SM1hlBco4CjwioBApzZ3I+Nzb4YkrIKUKZchljT4e65 +MIgTHxQGPXvA/kC3y4VtiGmH28H4Ti8cWOwRavtpV7pM8vDx5gEywSQLeEn5wz0AGd1NBxAK8SMu q38OpIQM6hTjgctY/Low==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pfK5W-001up2-1D; Thu, 23 Mar 2023 12:30:38 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pfK5S-001uo1-2f; Thu, 23 Mar 2023 12:30:37 +0000 Received: (Authenticated sender: alex@ghiti.fr) by mail.gandi.net (Postfix) with ESMTPSA id D14AB40003; Thu, 23 Mar 2023 12:30:25 +0000 (UTC) Message-ID: <5e3dec6d-c3a1-1fdb-7c5a-e9b81cfde2b5@ghiti.fr> Date: Thu, 23 Mar 2023 13:30:25 +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 2/4] mm: Introduce memblock_isolate_memory Content-Language: en-US To: Mike Rapoport Cc: Alexandre Ghiti , Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , Rob Herring , Frank Rowand , 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-3-alexghiti@rivosinc.com> <67ba29ff-b03d-2d24-a844-7ae25ddca447@ghiti.fr> From: Alexandre Ghiti In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230323_053035_153643_49889BF7 X-CRM114-Status: GOOD ( 19.54 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 3/23/23 13:16, Mike Rapoport wrote: > On Thu, Mar 23, 2023 at 12:52:36PM +0100, Alexandre Ghiti wrote: >> On 3/20/23 18:44, Mike Rapoport wrote: >>> On Mon, Mar 20, 2023 at 11:54:14AM +0100, Alexandre Ghiti wrote: >>>> Hi Mike, >>>> >>>> On 3/16/23 21:12, Mike Rapoport wrote: >>>>> Hi Alexandre, >>>>> >>>>> On Thu, Mar 16, 2023 at 02:17:09PM +0100, Alexandre Ghiti wrote: >>>>>> This function allows to split a region in memblock.memory and will be >>>>>> useful when setting up the linear mapping with STRICT_KERNEL_RWX: it >>>>>> allows to isolate the kernel text/rodata and then avoid to map those >>>>>> regions with a PUD/P4D/PGD. >>>>> Sorry I've missed it last time. The changelog is fine in the context of >>>> No worries :) >>>> >>>> >>>>> this series, but if you look at it as a part of memblock changelog it >>>>> doesn't provide enough background on why memblock_isolate_memory() is >>>>> useful. >>>>> >>>>> Can you please add more context so it would be self explanatory? >>>> What about: "memblock.memory contains the list of memory regions and a >>>> memory region can cover memory that will be mapped with different >>>> permissions. So to ease the mapping process, allow to isolate those regions >>>> by introducing a new function called memblock_isolate_memory. This will be >>>> used in arch specific code to isolate the kernel text/rodata regions when >>>> STRICT_KERNEL_RWX is enabled so that we avoid mapping them with PUD/P4D/PGD >>>> mappings." >>> With this change >>> >>> ... STRICT_KERNEL_RWX is enabled so that they can be mapped with base pages. >> >> Actually they will get mapped with PMD mappings :) I'll just append: "or PMD >> mapping" to your sentence above if that's ok with you. > Didn't read the rest of the patches :) > > .. STRICT_KERNEL_RWX is enabled so that they can be mapped with differently > than the rest of the memory. > > Does it cover the usescases? Yes, fine with me! Thanks again > >>> Acked-by: Mike Rapoport (IBM) >> >> Thanks for your review, >> >> Alex >> >> >>>> Thanks, >>>> >>>> Alex >>>> >>>> >>>>>> Signed-off-by: Alexandre Ghiti >>>>>> Reviewed-by: Anup Patel >>>>>> Tested-by: Anup Patel >>>>>> --- >>>>>> include/linux/memblock.h | 1 + >>>>>> mm/memblock.c | 20 ++++++++++++++++++++ >>>>>> 2 files changed, 21 insertions(+) >>>>>> >>>>>> diff --git a/include/linux/memblock.h b/include/linux/memblock.h >>>>>> index 50ad19662a32..2f7ef97c0da7 100644 >>>>>> --- a/include/linux/memblock.h >>>>>> +++ b/include/linux/memblock.h >>>>>> @@ -125,6 +125,7 @@ int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size); >>>>>> int memblock_mark_mirror(phys_addr_t base, phys_addr_t size); >>>>>> int memblock_mark_nomap(phys_addr_t base, phys_addr_t size); >>>>>> int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); >>>>>> +int memblock_isolate_memory(phys_addr_t base, phys_addr_t size); >>>>>> void memblock_free_all(void); >>>>>> void memblock_free(void *ptr, size_t size); >>>>>> diff --git a/mm/memblock.c b/mm/memblock.c >>>>>> index 25fd0626a9e7..e8c651a37012 100644 >>>>>> --- a/mm/memblock.c >>>>>> +++ b/mm/memblock.c >>>>>> @@ -805,6 +805,26 @@ static int __init_memblock memblock_isolate_range(struct memblock_type *type, >>>>>> return 0; >>>>>> } >>>>>> +/** >>>>>> + * memblock_isolate_memory - isolate given range in memblock.memory >>>>>> + * @base: base of range to isolate >>>>>> + * @size: size of range to isolate >>>>>> + * >>>>>> + * Isolates the given range in memblock.memory so that it does not share any >>>>>> + * region with other ranges. >>>>>> + * >>>>>> + * Return: >>>>>> + * 0 on success, -errno on failure. >>>>>> + */ >>>>>> + >>>>>> +int __init_memblock memblock_isolate_memory(phys_addr_t base, phys_addr_t size) >>>>>> +{ >>>>>> + int start_rgn, end_rgn; >>>>>> + >>>>>> + return memblock_isolate_range(&memblock.memory, base, size, >>>>>> + &start_rgn, &end_rgn); >>>>>> +} >>>>>> + >>>>>> static int __init_memblock memblock_remove_range(struct memblock_type *type, >>>>>> phys_addr_t base, phys_addr_t size) >>>>>> { >>>>>> -- >>>>>> 2.37.2 >>>>>> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel