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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ACB8C7618A for ; Mon, 20 Mar 2023 10:54:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C81B6B007B; Mon, 20 Mar 2023 06:54:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 077E26B007D; Mon, 20 Mar 2023 06:54:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5AEE6B007E; Mon, 20 Mar 2023 06:54:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D37C76B007B for ; Mon, 20 Mar 2023 06:54:25 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 996DB1409CD for ; Mon, 20 Mar 2023 10:54:25 +0000 (UTC) X-FDA: 80588967690.30.BE6FC17 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by imf20.hostedemail.com (Postfix) with ESMTP id 8D3031C0006 for ; Mon, 20 Mar 2023 10:54:23 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=none; spf=none (imf20.hostedemail.com: domain of alex@ghiti.fr has no SPF policy when checking 217.70.183.200) smtp.mailfrom=alex@ghiti.fr ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679309664; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DcmBSbD+KuC41nmurL33jXU8LA+OTSLRI2kvlQmBgzA=; b=GLEWNBNoIv65n0ZKO/RZdVFv7P6gUp4I6I4WYlk+iQGKqE2ylm1BAtajB5DHaxc3gedlWp 2DvLhLTstqayR5PflmLsWdMXrq3X/4hnUGBsdz3QGV6qq2m2G3c+b0jNKIdGHLFLF/hp/t SCuj7ExlB5GSx2q4Ur0loNK+uo4JzaE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=none; spf=none (imf20.hostedemail.com: domain of alex@ghiti.fr has no SPF policy when checking 217.70.183.200) smtp.mailfrom=alex@ghiti.fr ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679309664; a=rsa-sha256; cv=none; b=Jc1YDXSzEFI8dpxRNhVAxAX+Yzq8h00huVnUjgfjGb6ypAW+Jh8ICSAR7Vr1N9boqVKc5u 8+7ATa6NBFrSpuPCFFlnhCHyEymHtPBVVMlfuEW7HqprRB4jUQ/xZ2dxcGSmdULLHmoH/2 cwBw0WXO4r4Q7RRhtXv6LM0XKfj9i24= Received: (Authenticated sender: alex@ghiti.fr) by mail.gandi.net (Postfix) with ESMTPSA id 2F98D20003; Mon, 20 Mar 2023 10:54:14 +0000 (UTC) Message-ID: Date: Mon, 20 Mar 2023 11:54:14 +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 , Alexandre Ghiti Cc: 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> From: Alexandre Ghiti In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 8D3031C0006 X-Stat-Signature: iy3kaaasiai1ftn1x7yfpeh717xjf8rf X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1679309663-974560 X-HE-Meta: U2FsdGVkX19sQ6143jQ4UUQZ6vQrHjLgfEkwpB/ULihiK6hpKxMKUcL2Vc/rOIJf3DOh2isCxn9MbxNvx26u0RjRePceaz60lIX9Vej7eorkMgbwJ88DIzXBny5iKM6Bp7uEQ1Knri+dVwT48/uSinCqetVBiC4VdHhI17QzS9XX16KfvbkiZfITsav7tCZ7AVFwsneKS+R57MBbxYis9deoCCXKah9srq7tOZVTBW+ERm1SgtzJh2XgCigx3gXkAp1gFoROuiK6zyTauVQbVoB/bAqXaqHVM7cIc+P9qnRGuXZ+2dMdHvNe1dsW9fDzev2gPplB09Ks367kmS0IAniIKb3Dac+AqE+ppE+V6t79m6ziWhNi10AzfTo1niEj1lErvJIIyaT0kvS7oGSGsGtHbSzfNuH5LXVngCHLZvnygEqun0aB1rTEH3CX7xzyoI7wY5M5vlhOZIYA8SwhwnnFEsW2os10ZbcMl4TkonqtdVXkXzNrbXgRlPNI43j0zc3tH19TItnBRg8gQrrUnQuausVroJ2eVPlmF0NkTPb7FfF3V+3c9ngqV57m8eyc/eCtpA64YzKjRkLl1oFv7BBNjUHI9qFsmmjaduT9VfxvK31JtbpBy+QeJdWWZQdGovfjJGYLU/1XKPonksMirXlCtFDtDuQIIZlhEpOm7KJjvYjtoLL9Zzas8+d9+M9VBEWkIrUbNGjbXgL0vtxcj7KWAvPxi3vx3R7vuN75OUgRwwf1EJWDch9OULrZh9i1M5MmdqpcuYXYoC4lJC0l3wqk4oO2T6X9cjTnLnZP65Gf7vSxuLOVN1+0Flcs9J2zrkHATeQjZEjw2yXG+DF3iFJy/YhwOH5+OQnE7vo6Aag+qrk0PfpE/gWbtJSvru22dHqg6F7olJNVtKXL+G27lW2DE5HxFpSBFzbQAiBTOHFjtcq3f3cqkKz3VO/5TQ7kcnHsszdlaYVjQ3Q4U1g 609bhjDa 4ptKVQjkswb+Rr2D3p4cG2NstIAo7eBzL9YRRkYEmITNZG92PEEPHe1i3ecimAKKvCfh7r8VajeqEf900tSUNoMQUvIY1o0K0QwHAU9huYSZ6Hswx4JD0ur9Z+8fPVr8SZF3OxKisZ+pSK/KHeSTiakVUpRu0757UFABQWUFcdKITD1j5u+BJYtW3u1hNIswE4Vq1mWI3Yy0C9ED/3m3K9p4/i5b9K63HkNDtiXWPUjvVEAtYLCDUEusiBLhtsUQ225G16b9bbWArsybWPyV2ge69ZWam81bsFqUW6MRRkR24UD7mQScRN+uE9w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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." 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 >>