From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 A0C78606A332 for ; Thu, 26 Nov 2026 11:21:27 +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=MdONGc5D Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jZvJ62gvlz30g6; Thu, 26 Nov 2026 22:21:26 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=172.234.252.31 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1795692086; cv=none; b=MRye8kqj1gVanpzpiocvfZbZSlixYuLSVIVJ4MPCM8093w7+3K6tTpRyJKgL1DGZn6kMGwUlozFGpI7WV+R1/6qeVM/IROsGi1x7+Ypt8vjtE6nnZTJzzAQNYZ4Dre5MyJQ5hYpfj20w7vjUFn34UN8lUD2yFkeMnU/+Z1EsvNb435+Tho+teWa77O7Hj6mPKw4y7+j/jeWo4WVWmHMVBuPeI/fGrMMFVial+Cmwlw3IfsnTbWKnfahMA4BDEBaq7vZ/FpguQ4AUJfSPIM/iOrG6xgukohEUEYNKj4Gx+DN1beuy6BpxSE6oNPoJytr5FaPVtnEAYFqH7bIsNbq/LQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1795692086; c=relaxed/relaxed; bh=oczPXoX6LmrOL71NJs0ylkVxm4d3C/x+BrDR38WYHaE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UHrE6iE9Ke4bX6QAPFrDIZlMnUhpvJdE5so6DKz4AC3yk0mm3ohmOxoRsFeDxJ3vJDBppJT4lcSS5QoQaVHY3f2X16dm1GOSzLa30cXN6fQUhteEkyLl3CkxLc78izND4p22Mh80arvbBjWSP8P61RXkX5ACNLA3hNn1Ijz068PYNI+W5d3RBTYJEfFNfchxTmblrV9kh8Y2jHjYvNPR1Lt9jz1DtNAZ6v6rBcU6wDVEdVmnPNEdRfaw4kAQp1j+KgSRGrrFCnk1zO+tpSyQUGE7wW+TBmFsqYePON6NY7KOb2kVnoAx39vNNj96LYs9P6MnDQupC5YDaE6PN609kg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MdONGc5D; dkim-atps=neutral; spf=pass (client-ip=172.234.252.31; helo=sea.source.kernel.org; envelope-from=rppt@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MdONGc5D; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=172.234.252.31; helo=sea.source.kernel.org; envelope-from=rppt@kernel.org; receiver=lists.ozlabs.org) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4jZvJ54Tz9z30Wg for ; Thu, 26 Nov 2026 22:21:25 +1100 (AEDT) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 1184943D04; Thu, 26 Nov 2026 11:21:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E1641F000C0; Thu, 26 Nov 2026 11:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795692083; bh=oczPXoX6LmrOL71NJs0ylkVxm4d3C/x+BrDR38WYHaE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=MdONGc5D6rm4fAIyBNnofa7zpl+ADVHNhC4NDJwfkNfn8091gbfJmZAzoRVlM/UAl 38krRg5mk0qAmdNSn25jievEXiTiFYMnALk5q/eCta1QCgZ9gXPatAvYcRG58uVVBE 3wm4HYstziFwb74euNhfATKEVwYpu+Z970spJ7A+TWt8ilM4sCBjHWuMBCVIPGSzRx /6zudqAJDsL4am9+DVg43+2gXxLgl6UsPiaIN70VlmvNQeb+uYNXnrQTMkVGavd135 nxFSo02+WGH/4IoofGf/gRphDaH3v6Nduf1B5F3XSAOCSmOauduVMTOdJZelQ13K7m +/5p7bR7Qt+Hg== From: "Mike Rapoport (Microsoft)" Date: Thu, 26 Nov 2026 13:14:56 +0200 Subject: [PATCH RFC v2 43/54] mm/pageattr: let an architecture allocate the page tables for a split X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261126-generic-set-memory-v0-1-v2-43-723f1e33c3d8@kernel.org> References: <20261126-generic-set-memory-v0-1-v2-0-723f1e33c3d8@kernel.org> In-Reply-To: <20261126-generic-set-memory-v0-1-v2-0-723f1e33c3d8@kernel.org> To: linux-mm@kvack.org Cc: =?utf-8?q?Adrian_Barna=C5=9B?= , Alexander Gordeev , Andrew Morton , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Brendan Jackman , Catalin Marinas , Dave Hansen , David Hildenbrand , Gerald Schaefer , Heiko Carstens , Huacai Chen , Ingo Molnar , Kevin Brodsky , "Liam R. Howlett" , Lorenzo Stoakes , Madhavan Srinivasan , Michal Hocko , Mike Rapoport , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , Russell King , Suren Baghdasaryan , Thomas Gleixner , Vasily Gorbik , Vlastimil Babka , Will Deacon , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, x86@kernel.org X-Mailer: b4 0.16.1-dev X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The core allocates the page table for a split with pte_alloc_one_kernel() and pmd_alloc_one(). s390 cannot use them. vmem_map_init() write protects the kernel image before the page allocator is up, so a split at that time has to allocate from memblock. A fallback to memblock in the core would not be enough. With CMMA, the decompressor marks all memory as no-DAT, and a page has to be switched back to DAT before it is used as a page table. vmem_pte_alloc() and vmem_crst_alloc() do both: they fall back to memblock and initialize the page. Memory hot-remove frees the tables of the identity map with vmem_free_pages(), so a segment table in the identity map has to come from vmem_crst_alloc() rather than from pmd_alloc_one(). Let an architecture provide arch_cpa_alloc_pgtable() and arch_cpa_free_pgtable(). There are no users yet. s390 will use them when it switches to the core. Signed-off-by: Mike Rapoport (Microsoft) --- include/linux/pageattr.h | 6 ++++++ mm/pageattr.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/pageattr.h b/include/linux/pageattr.h index 091408ad328f..1a4e7c5dca98 100644 --- a/include/linux/pageattr.h +++ b/include/linux/pageattr.h @@ -111,6 +111,12 @@ static inline int arch_cpa_split_leaf(struct cpa_data *cpa, } #endif +#ifndef arch_cpa_alloc_pgtable +void *arch_cpa_alloc_pgtable(struct cpa_leaf *leaf); + +void arch_cpa_free_pgtable(struct cpa_leaf *leaf, void *table); +#endif + #ifndef cpa_is_direct_map static inline bool cpa_is_direct_map(unsigned long addr) { diff --git a/mm/pageattr.c b/mm/pageattr.c index 2f357a8c24d2..e05281a2b169 100644 --- a/mm/pageattr.c +++ b/mm/pageattr.c @@ -249,7 +249,8 @@ static pte_t *cpa_lookup(struct cpa_data *cpa, unsigned long address, return leaf->kpte; } -static void *arch_cpa_alloc_pgtable(struct cpa_leaf *leaf) +#ifndef arch_cpa_alloc_pgtable +void *arch_cpa_alloc_pgtable(struct cpa_leaf *leaf) { if (leaf->level == PGTABLE_LEVEL_PMD) return pte_alloc_one_kernel(&init_mm); @@ -257,13 +258,14 @@ static void *arch_cpa_alloc_pgtable(struct cpa_leaf *leaf) return pmd_alloc_one(&init_mm, leaf->addr); } -static void arch_cpa_free_pgtable(struct cpa_leaf *leaf, void *table) +void arch_cpa_free_pgtable(struct cpa_leaf *leaf, void *table) { if (leaf->level == PGTABLE_LEVEL_PMD) pte_free_kernel(&init_mm, table); else pmd_free(&init_mm, table); } +#endif static int should_split_large_page(struct cpa_data *cpa, struct cpa_leaf *leaf) { -- 2.53.0