From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796145788; b=WKqr7xOiM4ItRNgmbJhtmMBcGxdwYuBFhMr0lf18dGGNN6gVsfSg5XnPJIfw542FFIJ8 0kkmzsAWKGtd5JfuL2GnayGA45aQuE0cg3iirnYRu2ouSNS7aU5XkCX25STsrBorl4lUT AmlNPAbqG3hMP5Hx05vEr6Zy13QlBgj6YLAhf46L7hUyPx4dLv4m4/8TSCg/lGRVp59HU Cb5gh4pofh6+3MxZgitiOcc7+j15oalXlhd9bHSjJpKQ2fnyqc0+m4/ekpHX3l+nzsjNZ E9TX8BXEwF6LDdiseoQuv20uL8vrjF4kwzlALRUnks+2eYPfO7IlC6QCZ8Fgdd7gAZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796145788; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ZP23kDJm11MbH4p8vQCtXlbDDmjSYdc43iaIapJZv68=; b=01KKezUBjC4X6sr/Rbtonzm0ZubdiTflIpAZJOiEJc75y72NVkdLGakX3EyNz/EJT5Hm 6maKbhDmzEM6D2l2foOopo2Af6KoXKm5xDG4H1ASICXOleaRuDNUBz78SodKsAt9fxQdn clVIKSpA2CTASlb+/hXF38zk6gikgkNabtBM/cP6lr7JKzHmZqW6CjR8/FFj6ZyXlcL8I X/hkp5KsT5EPJE6iwuOiIhr2KcmrFPPt5MLqVfLypligaJtrhzBOhD14fw1N7cd0hAMeP 6mJ8+gWS7kXEnpU7hLOPPUnNZKmadjKyL9TSxZ4aKXcpCrMXhl0Yh/ALUTs0rj86r6Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HiXTpvuO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F33CA606A327 for ; Tue, 1 Dec 2026 17:23:07 +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=HiXTpvuO Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2E9F1F000C1; Tue, 1 Dec 2026 17:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796145787; bh=ZP23kDJm11MbH4p8vQCtXlbDDmjSYdc43iaIapJZv68=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=HiXTpvuOzbzMerIZEOJ1jzNcpRmLXOiY6ZE9zbboUtd4kSStbq9DG48RSakbL/OIC Z3rCBPSzZJTzY/nsewKROZd/m31EybIh5PuRwZ61b9lluUbRMhrX7KvE2Oig08pec+ 0vcgGDHvULoTIE5cw8YelDk3QzWBhwjXPD4WzzsxIG2t/6JkVymXUSAmQz25ItuAZl 0ObQILMPoYlPrC4FIMJ5hZ2me8sYPEIJ0lEW7qiNOkMAXv2WmA9i1x8LEPxTaipa6d uQN9nKBd6ybZ88owXHNNvYx+FSojLpeAgToGBJeTm/lekqNzOhJojrhGo9k5dI735u jv4QV+TCKZ4gA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 12/20] x86/mm: Introduce helper for checking direct map 1G page support Reply-To: sashiko-reviews@lists.linux.dev To: "Yeoreum Yun" , "Russell King" , "Huacai Chen" , "WANG Xuerui" , "Thomas Bogendoerfer" , "Catalin Marinas" , "Will Deacon" , "Arnd Bergmann" , "Andrew Morton" , "Kairui Song" , "Qi Zheng" , "Shakeel Butt" , "Barry Song" , "Axel Rasmussen" , "Yuanchu Xie" , "Wei Xu" , "Johannes Weiner" , "David Hildenbrand" , "Michal Hocko" , "Lorenzo Stoakes" , "Tianrui Zhao" , "Bibo Mao" , "Anup Patel" , "Atish Patra" , "Paul Walmsley" , "Palmer Dabbelt" , "Albert Ou" , "Alexandre Ghiti" , "Dave Hansen" , "Andy Lutomirski" , "Peter Zijlstra" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , x86@kernel.org, "H. Peter Anvin" , "Liam R. Howlett" , "Vlastimil Babka" , "Mike Rapoport" , "Suren Baghdasaryan" , "Michal Hocko" , "Jonas Bonn" , "Stefan Kristiansson" , "Stafford Horne" Cc: linux-mm@kvack.org, kvm@vger.kernel.org, "Sohil Mehta" In-Reply-To: <20261130-dummy_ptxp3-v3-12-456081a8ed0e@arm.com> References: <20261130-dummy_ptxp3-v3-0-456081a8ed0e@arm.com> <20261130-dummy_ptxp3-v3-12-456081a8ed0e@arm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 17:23:03 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] x86/mm: broken >1G fallback in populate_pud() with direct_gbpages_enabled() -- commit 79c8ba44eb682b178b3e4466183d231cfc6a3a55 Author: Dave Hansen x86/mm: Introduce helper for checking direct map 1G page support This commit introduces direct_gbpages_enabled() to check CONFIG_X86_DIRECT_GBPAGES, X86_FEATURE_GBPAGES, and direct_gbpages, and replaces existing direct_gbpages and X86_FEATURE_GBPAGES checks with it. Link: https://lore.kernel.org/all/20260902-dummy_ptxp3-v3-15-5d8f5b17c25c@a= rm.com/ [1] > diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c > index b1d5c5a0ffb41..f27811e6e00bd 100644 > --- a/arch/x86/mm/pat/set_memory.c > +++ b/arch/x86/mm/pat/set_memory.c [ ... ] > @@ -1737,7 +1737,7 @@ static int populate_pud(struct cpa_data *cpa, unsig= ned long start, p4d_t *p4d, > /* > * Map everything starting from the Gb boundary, possibly with 1G pages > */ > - while (boot_cpu_has(X86_FEATURE_GBPAGES) && end - start >=3D PUD_SIZE) { > + while (direct_gbpages_enabled() && end - start >=3D PUD_SIZE) { > set_pud(pud, pud_mkhuge(pfn_pud(cpa->pfn, > canon_pgprot(pud_pgprot)))); > =20 [Severity: High] Can this corrupt the page tables in populate_pud() when direct_gbpages is disabled (for example with nogbpages or debug_pagealloc=3Don) and a mapping in an alternate PGD such as efi_mm.pgd spans more than PUD_SIZE past a 1G boundary? When direct_gbpages_enabled() is false, the 1G loop is skipped with end - start >=3D PUD_SIZE. The trailing leftover block then looks up only the single PUD entry at start and passes the entire remaining [start, end) range to populate_pmd(): arch/x86/mm/pat/set_memory.c:populate_pud() { ... /* Map trailing leftover */ if (start < end) { long tmp; pud =3D pud_offset(p4d, start); if (pud_none(*pud)) if (alloc_pmd_page(pud)) return -1; tmp =3D populate_pmd(cpa, start, end, cpa->numpages - cur_pages, pud, pgprot); ... } populate_pmd() never advances pud across PUD_SIZE boundaries. Once start crosses the next 1G boundary, pmd_offset(pud, start) wraps pmd_index(start) within the first PUD's PMD page, overwriting its earlier PMD entries while leaving subsequent PUD entries unmapped. If a trailing 4K tail follows, pmd_none(*pmd) is false on the overwritten 2M leaf PMD and populate_pte() writes PTE entries directly into the mapped physical page. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-dummy_ptxp= 3-v3-0-456081a8ed0e@arm.com?part=3D12