From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796143564; b=iDDgWZmJBVxv9fBEIKDT2ryNj4/UZZtXvykzECd1N+UvS3X+b3b7QyhaXicRuFtrPxc4 QCad/SreROqVilaLjqzyC9ZruE4uQG5IH4tiWeTfqVOw/KJUInPsenmhswMKFUADmllle amydK+FkLm56mwSGoTkl1oRy4+Tvhq1CzHIt6dTYNdUO+f8aIDMR13xZgmdBwx5K4hJsj QgZ+OJ83DTp6hK0daq6fj7z/Ands0L3oIo2NFxeVm3NUImdJ55bq/a+qARhmzI3Wv0tlS Yhv8ScsEjcpc0eTpuGRnxd+g2vfQjuYNm0HHHB/R9MNg2CA0q3iwntlwgoG3aFOyObA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796143564; h=DMARC-Filter:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=MuGhybkqLGRmKQMdH6DO0jw+Sf7kKCerhnMldTaS6j8=; b=dTzJN5RGfbyKpGUpaq48AR9VGVkut37eCHOD5mk21vqZbAbmB2IP3V9NmUdmb2j2+qRI mr5W5Z3P5O8NFsYGjh2nZnvGMR+loMXn1uE1sH8LtkyKyV6xOq2zo/7899UGFvoEl06sG 3RVnx8y2xyf0jOY57EQ/KDVqMNiWjX1xcPR80yX05CwUjaX5vdGCpB05wVl22IT3lip+j nmWvq6yY3BOs1IlrqXZ4FVklheDa/AvCYJfqjhdnJiiTlm182r6GwIqtR2UsV/na78jsy tzsOIWckS9sLiOi3a6AzvjNpOifO6/P+uqeuZ1QMv24L1515T9INKuxnbnK9/NI8ySw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b="gfJeda/3"; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E514606A320; Tue, 1 Dec 2026 16:46:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9E514606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=gfJeda/3 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C7C8B1570; Tue, 1 Dec 2026 08:45:59 -0800 (PST) Received: from e129823.arm.com (e129823.arm.com [10.2.213.3]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 39A413F86F; Tue, 1 Dec 2026 08:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796143562; bh=n6+PkDwSVCu7YyikERYaE9c3qP7ftCUkfRLzNFOk9v4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gfJeda/3dQrB7nNOSSYaWMKsoeuWikVICPhncX6hZJjpz+J6zZ199MnEdUC3ECsUb nc5eW0XCDd+ZMzgNu4rfL8bvnn61Pfg1ZgoujW+WS5gpAHTP8mCkGnZZGRA73MjY4d OuydpMsUVQ4s2KGFBeDy6GO4F8T+TPEnMdjGIqD0= Date: Tue, 1 Dec 2026 16:45:52 +0000 From: Yeoreum Yun To: "David Hildenbrand (Arm)" Cc: 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 , 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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-openrisc@vger.kernel.org Subject: Re: [PATCH v3 19/20] mm/pgtable: disallow calling folded set_pgd/set_p4d/set_pud with dummy Message-ID: References: <20261130-dummy_ptxp3-v3-0-456081a8ed0e@arm.com> <20261130-dummy_ptxp3-v3-19-456081a8ed0e@arm.com> <713213d4-12a6-4866-bd85-18b42443e640@kernel.org> X-Mailing-List: linux-openrisc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <713213d4-12a6-4866-bd85-18b42443e640@kernel.org> On Tue, Dec 01, 2026 at 01:17:54PM +0100, David Hildenbrand (Arm) wrote: > On 11/30/26 18:18, Yeoreum Yun wrote: > > From: "David Hildenbrand (Arm)" > > > > pXdp_get() could return a dummy value for a page-table level folded at > > compile time. Passing this value to set_pXd() could cause unexpected > > behavior. > > > > Prevent this at compile time by ensuring that all calls to > > set_pgd()/set_p4d()/set_pud() are compiled out for folded page-table > > levels. Make the compiler complain if these helpers are called with > > dummy values. > > > > Since there are places where set_pXd() is called even when > > the corresponding page-table level is folded at compile time, > > drop the incorrect comments for set_pXd(). > > > > Signed-off-by: David Hildenbrand (Arm) > > Co-developed-by: Yeoreum Yun > > Signed-off-by: Yeoreum Yun > > --- > > include/asm-generic/pgtable-nop4d.h | 11 ++++++----- > > include/asm-generic/pgtable-nopmd.h | 10 +++++----- > > include/asm-generic/pgtable-nopud.h | 12 +++++++----- > > 3 files changed, 18 insertions(+), 15 deletions(-) > > > > diff --git a/include/asm-generic/pgtable-nop4d.h b/include/asm-generic/pgtable-nop4d.h > > index d2dccf7542da5..12b01768134b5 100644 > > --- a/include/asm-generic/pgtable-nop4d.h > > +++ b/include/asm-generic/pgtable-nop4d.h > > @@ -28,11 +28,12 @@ static inline bool pgd_leaf(pgd_t pgd) { return false; } > > > > #define pgd_populate(mm, pgd, p4d) do { } while (0) > > #define pgd_populate_safe(mm, pgd, p4d) do { } while (0) > > -/* > > - * (p4ds are folded into pgds so this doesn't get actually called, > > - * but the define is needed for a generic inline function.) > > - */ > > -#define set_pgd(pgdptr, pgdval) set_p4d((p4d_t *)(pgdptr), (p4d_t) { pgdval }) > > + > > +#define set_pgd(pgdptr, pgdval) \ > > +({ \ > > + pgd_check_dummy(pgdval); \ > > + set_p4d((p4d_t *)(pgdptr), (p4d_t) { pgdval }); \ > > +}) > > > > static __always_inline pgd_t pgdp_get(pgd_t *pgdp) > > { > > diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h > > index 2afbf2d8659dc..11b04c1071295 100644 > > --- a/include/asm-generic/pgtable-nopmd.h > > +++ b/include/asm-generic/pgtable-nopmd.h > > @@ -37,11 +37,11 @@ static inline void pud_clear(pud_t *pud) { } > > > > #define pud_populate(mm, pmd, pte) do { } while (0) > > > > -/* > > - * (pmds are folded into puds so this doesn't get actually called, > > - * but the define is needed for a generic inline function.) > > - */ > > -#define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval }) > > +#define set_pud(pudptr, pudval) \ > > +({ \ > > + pud_check_dummy(pudval); \ > > + set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval }); \ > > +}) > > > > static __always_inline pud_t pudp_get(pud_t *pudp) > > { > > diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h > > index 3264673c0c386..5ee8f1852cd8c 100644 > > --- a/include/asm-generic/pgtable-nopud.h > > +++ b/include/asm-generic/pgtable-nopud.h > > @@ -35,11 +35,13 @@ static inline bool p4d_leaf(p4d_t p4d) { return false; } > > > > #define p4d_populate(mm, p4d, pud) do { } while (0) > > #define p4d_populate_safe(mm, p4d, pud) do { } while (0) > > -/* > > - * (puds are folded into p4ds so this doesn't get actually called, > > - * but the define is needed for a generic inline function.) > > - */ > > -#define set_p4d(p4dptr, p4dval) set_pud((pud_t *)(p4dptr), (pud_t) { p4dval }) > > + > > +#define set_p4d(p4dptr, p4dval) \ > > +({ \ > > + p4d_check_dummy(p4dval); \ > > + set_pud((pud_t *)(p4dptr), (pud_t) { p4dval }); \ > > +}) > > + > > > > Extra empty line that can be dropped. Yes. I'll drop it. Thanks! -- Sincerely, Yeoreum Yun