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 6E99FC6FD1D for ; Thu, 23 Mar 2023 12:16:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C98396B0075; Thu, 23 Mar 2023 08:16:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C48946B0078; Thu, 23 Mar 2023 08:16:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B103B6B007B; Thu, 23 Mar 2023 08:16:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A2C7D6B0075 for ; Thu, 23 Mar 2023 08:16:33 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7C5E0802B8 for ; Thu, 23 Mar 2023 12:16:33 +0000 (UTC) X-FDA: 80600061066.26.D16D714 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf12.hostedemail.com (Postfix) with ESMTP id AC3A94001D for ; Thu, 23 Mar 2023 12:16:31 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TDgklDt8; spf=pass (imf12.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679573791; a=rsa-sha256; cv=none; b=DAD4FH5wn2YUjQVUPZous7JK3FAHzlsUZbi7KkHxDxzF5xFzwFzJEa10iXN2D86UPSKobC L+waU1lflx+McYPd5L1tPdKpHT6Kkv2qzwmtDlp6MCijuZvTp7ICDY87we0xcYID/QH2jJ 1o3GB+e30tExDNJpGI2U7fgL/MkNHYw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TDgklDt8; spf=pass (imf12.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679573791; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eBfdOEBdKdyls7HEALAvsjrUvY9D8Xw/O/OUGsBbOYw=; b=xXn0Yzu23vGQWHKgGY95O9MyeiCJJU4RfFogGtZYDqOT9uiHZeIpe88r+Y9e7FDzT4W/Ob D20K1vULwCpQH9GwlqpR+09HnD004Xki/hCvX/Tj4Jws+DPGp/W3x5+v/EqLLjCGUka2Xx CuUVZbzuyWdmAQf+kO+NsUHoCZuPcKc= 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 ECDF2B820D4; Thu, 23 Mar 2023 12:16:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A110FC433D2; Thu, 23 Mar 2023 12:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679573788; bh=8YTL8vaeuBpq0vMMQ/pbSHbLP5F5De7OWHvSO64jqWA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TDgklDt8UIydy52o7p+cvl9EhYSRXBlx8yDr0RpdwchOpAWt6GwNdHG/NBGCmELJV Uql/fyfzD0OL9HkOe/Ms1uxy6JSV5qRIFuevWhqnixbnOo43OLrxQ5N95RM1eq3K9j 5+Ku2OpjWJxdiAkdfmdbx3w1fpTxA5j4wVZXbpkZX1/cXch1PeVuxJJjQQ6dV+76Y0 zjDfQ7yiArDoR6s/YPeV/52Gbes/HR4ZXY5pO+ID4bBnkvaG+QmC/XzexzI1XSOrqV M6TX9FtCCqI/IlT4JR8TeV9DkaQRsifWQ92K/J06fytFjYUkmp/nxzywNO1E6RT9t8 GjueaLrm8T/GQ== Date: Thu, 23 Mar 2023 14:16:12 +0200 From: Mike Rapoport To: Alexandre Ghiti 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 Subject: Re: [PATCH v8 2/4] mm: Introduce memblock_isolate_memory Message-ID: References: <20230316131711.1284451-1-alexghiti@rivosinc.com> <20230316131711.1284451-3-alexghiti@rivosinc.com> <67ba29ff-b03d-2d24-a844-7ae25ddca447@ghiti.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <67ba29ff-b03d-2d24-a844-7ae25ddca447@ghiti.fr> X-Rspam-User: X-Rspamd-Queue-Id: AC3A94001D X-Rspamd-Server: rspam01 X-Stat-Signature: 4sgqzxt861i45t43aod377fnsaph6q8m X-HE-Tag: 1679573791-143389 X-HE-Meta: U2FsdGVkX1/QPx6423GmiyK7ostQd4QASGf59Sdi9je+IMAINiV+sQc7xIUoFYrxNKI8C/ngcWG0JC55AlWlbYY9b5no1oQHU3gujw7+vFBBfFwPreEFbe/b/KShBxQKBPFP4yZQ6250Xyn/HdQRBw7QTxm7srMHeqKBAADiv9hvZ5JZipKLTTSh7+nr3elmrwroPDI3+jnjH2lnakq95sOCzJ8W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Ap9xvqmz7jcj5OSVR5 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: 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? > > > > 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 > > > > > -- Sincerely yours, Mike.