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 D4A4FC76195 for ; Mon, 20 Mar 2023 17:44:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 662626B0074; Mon, 20 Mar 2023 13:44:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 612406B0078; Mon, 20 Mar 2023 13:44:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D9AA6B007B; Mon, 20 Mar 2023 13:44:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 39CBF6B0074 for ; Mon, 20 Mar 2023 13:44:20 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D0F4316095B for ; Mon, 20 Mar 2023 17:44:19 +0000 (UTC) X-FDA: 80590000638.09.F1B937A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 9349C140021 for ; Mon, 20 Mar 2023 17:44:16 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XC3RVwkx; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 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=1679334256; a=rsa-sha256; cv=none; b=GOmUJIy6iM8zs+rCAGpVh+qNM1DqXPcb+FAPOD0nbZj+zkL4GQYVyRspdEhOuSPfYsYf5J DomHW4pWWY8mpU2BngARAZA5MWIShzh7iZxArfhy8nTxXwmtY0wRZamYWxRudCZgc+eHsV hFhAc9oE55b6JS/du/om/P1SOE+BHpI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XC3RVwkx; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 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=1679334256; 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=noL7nQyVb1IAbPvMtgUR8wxVfG8fbO3wATHbo1KkM7g=; b=D7BKaHz+lPPVZNm8ZF5CizXUwvOsRvw+0mL0PZtmuMe1PHtfaSx8SqRomuQr7F6YkuaRrh vKv1PtFE/ckdcuuXT+EH7AZ22qpMfEfErEpp9hDUxgXpbpEJXgVPUcGTJ+wyYMy8LcU148 +Kwd3L4C+D1I2WMxftpSv2uj94bw2zU= 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 dfw.source.kernel.org (Postfix) with ESMTPS id 8401E61758; Mon, 20 Mar 2023 17:44:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88782C433EF; Mon, 20 Mar 2023 17:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679334254; bh=6DWJt0rrEq7W4EzAc8pwNUO8xNmHBtl5KZ70f953RzI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XC3RVwkxvdJkDzjF8FSRbgTX/PSUM+XlKBbymCh2x+kc97dcQZWohPbBKWgd5cP8d 0O9+YU98jipjen13c3LbUtk7ozKRRORHvXfQ3zr45yf5uliOOnO15/bd9hSGL7C3wo pVi/b5a/yTO6WqOLVDJ/layBzld0e64d4C8gC57eXEkYV9cuf4/dLwDBrlSH4ULJ5c kj40KbM5m2dk4osuXVGTIu/4yJ/4yyudUKPf/TuExxSxyM8APjQd+D/LvtRw4IqXeF 6Xt0J6kq2oHZ2IsV+SmV3PS268168Cru1T55WfD6r51OsVIVTCVmh21/u2ao3HHrWv dvYLbYktXlmjA== Date: Mon, 20 Mar 2023 19:44:00 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: 9349C140021 X-Rspamd-Server: rspam01 X-Stat-Signature: 9cz6o93k7ra5h8hdyfsimxbxpxy3wf7d X-HE-Tag: 1679334256-612144 X-HE-Meta: U2FsdGVkX1+Ev2eoBhvxOfPjUvJocMoOnQNnVgYAW9w96AK1489jxeC3prW0ATZO29dXYAoBNJoKRkeEuE2l3LQHoSXrDJ0Cu6YNAj57Cq2Zxis632x6Wor99EUlVYCyreM0NWWCtYFYlOIbmY/Km2hlfYYW0jB5Wd4b0rgMWdO5jAIRpalq4eK2tQQ54z1yl/r/Ps2UVr1gypceBIsbbBBLpv2SDl6lj1oy6EF8Y64Quq4GaN8g9nxTf8k7vLx6hLOK3CEtKuB6RMvPmNAQ3ZrfdQhej0TAm5po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c1YcvhR+zvo6SY40oRGFmlmcEVtz55brVjBLVXZIaVqC+C4OJpXWin4YPFaytduE/cqoR0EOCYu0WBe4wVpPBGgNQdZLT5U+C+sHyqs7R3WKHv+50CKmm+ZLBrVwwHC1PnN4u5GteA2nuEDP9iZT3r12u+N7GjxUWaFJhoQr7yv5ju7tv2DGs5857ZOBAAzTisQn01D1avD5xX8UX+e9Jw8wHtIqHrA+Xm9pDQ4nmnalHHeKKk= 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 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. Acked-by: Mike Rapoport (IBM) > 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.