From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50597606A32C for ; Thu, 3 Dec 2026 00:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ShW876pp Received: by kanga.kvack.org (Postfix) id 756736B05B1; Wed, 2 Dec 2026 19:28:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 707D06B05B2; Wed, 2 Dec 2026 19:28:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F5EF6B05B3; Wed, 2 Dec 2026 19:28:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4064E6B05B1 for ; Wed, 2 Dec 2026 19:28:02 -0500 (EST) Received: from smtpin17.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A92851602C7 for ; Thu, 3 Dec 2026 00:28:01 +0000 (UTC) X-FDA: 85500784362.17.816E1DE Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf03.hostedemail.com (Postfix) with ESMTP id 06ADD2000C for ; Thu, 3 Dec 2026 00:27:59 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ShW876pp; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796257680; b=HNzyuQ9eg4S8mYqJbvL2MFzu9NMqa1fFHkIXavDyvezwQUKV1cRjzzuFhULwzwnod17d8O EmCxZ5urel5rmecWDvyEts+s5Wp3U5Gsm4ZmxNM+eXzxCeOtYLh2lST3Fsk4OLsg6fyp9w b9cAOkht8MKbUwGgg3HuUB88KCfURG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796257680; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fkj+Nnk9apMOwKoq4jrWMIRPWthE2Aou2uSkaVSASpI=; b=uO23AWV8StYg6jMxCGLu1XkTxqFLdCZ8jWv719TlSE7qtsjJmpcRjZAwEbyKTSuCrzo0Mz WgOmCEwZLjbVH/kWHr39+Oh/gVmEQu0EqggiH4BJAVmhDBQkuy3YnY+QiILUyWEpkRvgDF kQbDOB1UxAfq3jQRhqb8J/i/xYOT3fM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ShW876pp; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 066794061C; Thu, 3 Dec 2026 00:27:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A75371F00896; Thu, 3 Dec 2026 00:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796257678; bh=fkj+Nnk9apMOwKoq4jrWMIRPWthE2Aou2uSkaVSASpI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ShW876ppZqjxcuyTc6swRpJ57vzpP0T+N2rjog/OgNSKPYZbZB5ZjwW6nYGrqYo+E nWLRKa0RqgZe2408qLnUTa1dEySQtrRbNe+e2AoECGJlGoGClz6PFYdAzYwj4mfLll GqkN9V6PSO3pt/IzR7PUh6W6oPGI0X3yHC2VKs42O+joJ5uGKbFA+i6LyvsLPE/Mv1 rqbSsF1CIl+MJEZnVg7g4CSE0PVw70yJ6hphTP3v4dybODUBaaDskyKA7CtNCkflkv OyAwAVc88dui/NoDlcLtUt+2MxRUN50EtSqo4UrEbJpd1CUfGlD6H3zwdH8k1M5GMV nxQVAljZHr1uw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH 05/11] mm/extmem: add architecture-neutral external memory subsystem Reply-To: sashiko-reviews@lists.linux.dev To: "Suseendran Bhaskaran" , "Andrew Morton" , "Mike Rapoport" , "Dan Williams" , "David Hildenbrand" Cc: "Alexander Graf" , "Alison Schofield" , "Andy Lutomirski" , "Borislav Petkov" , "Catalin Marinas" , "Changyuan Lyu" , "Dave Hansen" , "Dave Jiang" , "David Rientjes" , "Frank van der Linden" , "H. Peter Anvin" , "Ingo Molnar" , "Ira Weiny" , "Jonathan Corbet" , "Liam R. Howlett" , "Mark Rutland" , "Michal Hocko" , "Oscar Salvador" , "Pasha Tatashin" , "Peter Zijlstra" , "Pratyush Yadav" , "Randy Dunlap" , "Shuah Khan" , "Thomas Gleixner" , "Vishal Verma" , "Vlastimil Babka" , "Will Deacon" , kexec@lists.infradead.org, linux-cxl@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org In-Reply-To: <20261202001946.1226273-6-suseendranb@google.com> References: <20261202001946.1226273-1-suseendranb@google.com> <20261202001946.1226273-6-suseendranb@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 00:27:57 +0000 X-Rspamd-Queue-Id: 06ADD2000C X-Rspam-User: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Rspamd-Server: rspam03 X-Stat-Signature: ibim69cwpukfedatdnqwb3zonei34u4g X-HE-Tag: 1796257679-288074 X-HE-Meta: U2FsdGVkX19Md/rd0dxc25kCiPWvQ/wfj7tNTklqv0sSRJjh9WkHVlRs2U3FigUlHZrOZMAfBztO7nW1A+wFeAlOGxoatoNyouVz5zvw+6mWR28b8eoRTbJfdmHbrEm+990Cq22+OeLbE2MFxha7NA5mZ/gIZJbeC63IdrZUeHv92UMEbJ4QoKXVYkdzrUaMZG6dw2ryuhlWhQ6rqiD59LQo932qdSSiuoJYho4peNKbe9hDlujBDTN1BswI7slqdokLmGVasntPmjMqvIMdynCO8U0jAhf8jiXaL+Pels5r5vVEMt2frJid/3YfD3G3QkaXnnrUcJ/pJK/m8T+5oaFf5OxC6t2PgihMO3WlvsrgNo4A8ZpPdraw6ddn/enGA7runog1hNnjZc1v9ocQBqkgrzNvfXGjHSn+nde0Fy8PXtM2Ns1g5AvIVLcv7R5NDKtnEhF4IuaWsYp78u9KZe/cR4BZiofrt2ffZaUNwm3YMZoH1UXCm6vMPlD2OwPFTqA6AtHPvED4oyvTsBhXDSEbZ/714f5M+VDSbsmd7Z47Qb6Ot1tW1BomlV4QyrgRtsthAwiTgaogrfu/AFm0gdNGXpccg5CY2IqCVpg/1fJiUvv2Mb8UJVlUg0S1xDObygobZdQu6qCvrc5HcCwJhinTq5OFvH91rCAh5Of3veui4JaI3MbR1mcv7dtwjbDawKeAFp4ZsXtC1tDNX0KLGXCTfFOK/hhVa2LVu7OG1QRL4V9EfvifVICByNY8KM4TcI05uDXPHkAlxbVIs+belSRCNYkXzbaUVwxfp13ygaJYxoghUIxRbhKVGzES76Z8Rb7znGS7klx84ADx/+vo+v7uc82SX8rdVodWt5orqIuzlbIyQftuG512OirIaCAUUoso97dI5zpXfRWh6PCnORsnkSuo9Er/OGQxvRKuN8wn1Dlblgxyiy9tzbLFTgY63B8r2YAcuRAJ+GuqCPG 68lq+3f6 vo2DvHbdFKdGzlw0LGMfeJL1ftGzpCa5qETP1hjiDpCvoip5pmcPQh6ORrRGjNL90ztq2Da9YvAAQpvcekEYa6aUYgt+z04uq7aTC45atVKxvO01Yf/OyZWC5gZxNPUx0FDLxPnnBGH14yadwRlIJQU26UL/xmePU8Ao72l+jGntkOCndFJwol0uGTH6Oxl+WbwcWplTVlBUzgYty2VZwbQwPI3+x0aWt1zaoh+3u7sxqh0C8UJ95qTPDTB3+s81k6DORPbTHxvIvVWC2upiD+GVsktAGS46Rzfk9YToFpoRjvWaAZOdx1Ad2gLqCTAPyRgEM3ut4Qb90fOhpra0oPoGskvLwaXLjmSVJ8hoGPavly5zPQkNGz2Qx2P4D9XlDIvlraqFRBTSpDSNqXwPSbouqta4ZcRfjVMSfV0h2EdhaoUag8qb519xer8pf85GGItzNhDtEVuvKfnTakoqTEmNKdC+X7vqc7GQrakxxWy2ur5mprpRUdt4lVoNGv8IwUjGgyYsX3ad0yI3b2N0xQ6ZaZBgAwfEe71rhMGApki9cvfnAr/x+8gKPDvsnE03Tihcovl3ptNaLncLdwSlJNPHCFjkwH1jm/ubmKqQmDU/Qd4CM9z5FGZn2S59b+W6TTSXP0/pbKPFURLUaOauwx+bwI4DaM5gcy1j/t8iOowIdomwOlTKWRtL0F25Uw78rzgEfGAvpfAeuCTZ7foPbYWmShPKt8ui59lUc1Fkz8WfzV15mEfttD72c0wvR8dVO24E/1Gydvb4IQGNseLjh4eXC3gvBvznOhUHj9jJ4eeyo6T41Qj8P+Bcl943OrJPjzWTu Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] mm/extmem: premature memblock_phys_free() before memblock_remove() - [Medium] mm/extmem: unreleased System RAM iomem resource on unmap failure -- commit 832cde3acb6d693441f2a529f057ca782a706be9 Author: Suseendran Bhaskaran mm/extmem: add architecture-neutral external memory subsystem This commit adds CONFIG_EXTMEM and the extmem=3D early boot parameter to carve NUMA-aware physical memory regions out of memblock, unmap them from the direct map, and register them as "extmem" platform devices. > diff --git a/mm/extmem.c b/mm/extmem.c > new file mode 100644 > index 0000000000000..e5be9fcb6bbd6 > --- /dev/null > +++ b/mm/extmem.c [ ... ] > +static void __init extmem_carve_node(int nid, const struct extmem_rule *= rule) > +{ [ ... ] > + nr =3D memblock_reserve_contig_multi(rule->size, rule->align, rule->ali= gn, > + high_min, nid, flags, cands, > + max_ranges); > + if (nr < 0) { > + pr_err("failed to carve on %s above %pa (%pe)\n", > + scope, &high_min, ERR_PTR(nr)); > + return; > + } > + if (!nr) { > + pr_info("%s has no carvable memory above %pa\n", > + scope, &high_min); > + return; > + } > + > + for (k =3D 0; k < nr; k++) { > + memblock_phys_free(cands[k].base, cands[k].size); > + extmem_regions[extmem_nr_regions + k] =3D (struct extmem_region) { > + .base =3D cands[k].base, > + .size =3D cands[k].size, > + .align =3D rule->align, > + .nid =3D cands[k].nid, > + }; > + } > + > + if (extmem_commit_regions(nr, "carved")) > + pr_err("failed to remove carved range on %s\n", scope); > +} > + > +void __init extmem_init(void) > +{ > + unsigned long orig_end_pfn, new_end_pfn; > + unsigned int i, j; > + int nid; > + > + if (!extmem_nr_rules) > + return; > + > + orig_end_pfn =3D PFN_DOWN(memblock_end_of_DRAM()); > + memblock_set_bottom_up(false); [Severity: Medium] Can memblock_double_array() allocate the new memblock.memory.regions array inside a carved range? extmem_init() restores top-down allocation before the carving loop, and extmem_carve_node() frees all cands[] from memblock.reserved before extmem_commit_regions() calls memblock_remove(). If memblock_remove() -> memblock_isolate_range() triggers memblock_double_array(&memblock.memory, ...), the new array is allocated top-down from the highest unreserved address in memblock.memory, which is inside the unreserved cands[] range being removed (or at the top of a node to be carved by a subsequent rule). That range will then be removed from memblock.memory and unmapped from the direct map by extmem_unmap_regions(), causing a page fault or memory corruption when memblock.memory.regions is accessed. Keeping each candidate reserved in memblock.reserved until after memblock_remove() succeeds and deferring memblock_set_bottom_up(false) until the rule loop finishes would avoid this. [ ... ] > +void __init extmem_unmap_regions(void) > +{ > + unsigned int i, dst =3D 0; > + > + for (i =3D 0; i < extmem_nr_regions; i++) { > + struct extmem_region *reg =3D &extmem_regions[i]; > + phys_addr_t end =3D reg->base + reg->size - 1; > + int err; > + > + err =3D arch_boot_carveout_unmap(reg->base, reg->size); > + if (err) { > + pr_err("failed to unmap [%pa-%pa]: %pe\n", > + ®->base, &end, ERR_PTR(err)); > + continue; > + } > + > + extmem_regions[dst++] =3D *reg; > + } > + extmem_nr_regions =3D dst; > +} [Severity: Medium] If arch_boot_carveout_unmap() fails, does dropping reg from extmem_regions[] leave its range registered as System RAM in iomem_resource? release_mem_region_adjustable() is only called later in extmem_publish_regions() for entries that remain in extmem_regions[]. A region that fails to unmap was already removed from memblock.memory before sparse_init() and has no struct pages, so leaving it as System RAM in iomem_resource on x86_64 allows walk_system_ram_range() consumers to dereference unmapped struct page pointers. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202001946.1226= 273-1-suseendranb@google.com?part=3D5