From patchwork Wed Jun 5 11:40:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686714 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2D99C27C53 for ; Wed, 5 Jun 2024 11:41:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=U6MGAB6b7eXQqj7cFWAoYPUxi5S0SCHBdLZQpC6+pQ0=; b=FlR4Q26b05oJCQ tTpfbOa/B5kEJFi5kLT4nPvKZqNPdyt2JScFoCPxSHdOsHLPtZ7KAAd+zzIfBC9t+W+rZKcKACUE9 l3rubBxKX+r4gIoh9ctUtbpnfLbMEJ8oeOzKVC3pZ0aaGhmt91i7qjWn2RE5Myi84R042B2MYS2j8 DjFS/t5fSpEQejrMd+dhEZpAt7shAFzZ+ylY2UArTv+KFircWEo5NOevkeDFcqiw0dXZXWP++0P75 xCOWLvwszV4jgSUswmnxAumKcjAiJwEDgax7MrTtVXMTzzlzbB9sH2cP0bzEmsdnpySIgRye6NsCM hZhUu614eC1h00HhwjRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1A-00000005jpS-0won; Wed, 05 Jun 2024 11:41:24 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp17-00000005joE-0Fet for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:41:22 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A405E617FE; Wed, 5 Jun 2024 11:41:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3803C32781; Wed, 5 Jun 2024 11:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587679; bh=DeWhhyy/Pd+ZMACSRHJGzJta3bvo66kmrO80PItBsh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U1Ioy0maA5AwRckov58PI1dPUHyyGGgTWfzppxKvOJ5vKG4OYfFjGk9LswC/lA67g AiIlfX+S+u9KX+idcOdeOFgkILKcjRmMy3P2mRnigjBzo6o8YhsVcdGLtPS1U5tG25 tAl6eEfOl+uJ0lnDHnB9krao18oZMsRfj3bVMcQ8Hhec/AU5okt/9ANWoqlsbg/v9B 6XAEJYTzUpZ4AMmjN82aSGoJ09nWwo5+Iq8Uc98aESGuk1kqIDdE25dT0Ew5lBYyMI tbHq6/DNAi6bsnOYdF3D68Me1apb1caKmDIAUghJSJNQu3/1DH/vbtfVidTyA9KTpx 4/ZFTWv4bC1MQ== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 01/11] riscv: mm: Properly forward vmemmap_populate() altmap parameter Date: Wed, 5 Jun 2024 13:40:44 +0200 Message-ID: <20240605114100.315918-2-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044121_186494_6EF1C930 X-CRM114-Status: UNSURE ( 9.58 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel Make sure that the altmap parameter is properly passed on to vmemmap_populate_hugepages(). Reviewed-by: Alexandre Ghiti Signed-off-by: Björn Töpel --- arch/riscv/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index e3405e4b99af..fe5072f66c8c 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1439,7 +1439,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, * memory hotplug, we are not able to update all the page tables with * the new PMDs. */ - return vmemmap_populate_hugepages(start, end, node, NULL); + return vmemmap_populate_hugepages(start, end, node, altmap); } #endif From patchwork Wed Jun 5 11:40:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686713 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BD81C25B76 for ; Wed, 5 Jun 2024 11:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DZVUe3iM7d6+WZBolyfHdCRUp7hOCdkR0tZyUr9+w/8=; b=U2eHvFv1MXSL+s a0KQYH0vJQO5bu1SopKMBcvm+ooVWKDeToVntLQPqr7nVuRn6Dihz7+YE4qAZAMeSJVwLXLPORbpn OmUQQI9E/7qUIbLQUAviBfdVSIy5TWETZXDJx96zww/pfC9djTxq0KqfNh4v6+mikkr8nL6/br9uu vXEEvpSoZMUGFr1Y97hik00WRKaTl2XmnIq7OsFUVXWO2hZGSt5/1xV3EOMRatSvUPINSPPL2n/6a t4L5pBOqCa/u7a7KMAIkQuB4VjTYQ4v+b5YZgBhuqKd79gGB7nq6YDktUJmYhGqPmhx5xOxe/k9Ub yzBQQ0xPGEz37ACeWynw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1G-00000005js3-0Wvg; Wed, 05 Jun 2024 11:41:30 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1C-00000005jpx-2AE3 for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:41:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 83D64CE1784; Wed, 5 Jun 2024 11:41:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0A38C32781; Wed, 5 Jun 2024 11:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587683; bh=HsHTP5EMBxXRbP7gHM9U5cuEmdv/0OsepSBXxmcR9vk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HATjXYkuNGAJd6ZLv+T2v73tr+Mc6k2jRhJItwlkYIAMhhwWJcS9UAkccUyjIGocm FpT5Qk21uUbdooqRUAgy0kZUw+P/J0vSaZ/BBxDRdx4Ux/+hf7kGQ9N5Qrv6wvPA7i nDivxB55BW0xjUIvNRnHMGR086mp0iiVgd/1dXwNc6PCovq009SjJTw4oRIZcmWQYR jCrbPH4Os670nJF5DH11/jvO5GP+uTC5v335/W5W7nBd01MhUwdEyweJtBVvSA7sad ALF4qUwr8X3xtfo2/HtKrJcfrhAbSKFg21UaNds30Hdi0KwftR7UHoI+cd51TBVay7 nivI6FKPDR+hA== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 02/11] riscv: mm: Pre-allocate vmemmap/direct map/kasan PGD entries Date: Wed, 5 Jun 2024 13:40:45 +0200 Message-ID: <20240605114100.315918-3-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044127_087095_638DC809 X-CRM114-Status: GOOD ( 14.00 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel The RISC-V port copies the PGD table from init_mm/swapper_pg_dir to all userland page tables, which means that if the PGD level table is changed, other page tables has to be updated as well. Instead of having the PGD changes ripple out to all tables, the synchronization can be avoided by pre-allocating the PGD entries/pages at boot, avoiding the synchronization all together. This is currently done for the bpf/modules, and vmalloc PGD regions. Extend this scheme for the PGD regions touched by memory hotplugging. Prepare the RISC-V port for memory hotplug by pre-allocate vmemmap/direct map/kasan entries at the PGD level. This will roughly waste ~128 (plus 32 if KASAN is enabled) worth of 4K pages when memory hotplugging is enabled in the kernel configuration. Reviewed-by: Alexandre Ghiti Signed-off-by: Björn Töpel --- arch/riscv/include/asm/kasan.h | 4 ++-- arch/riscv/mm/init.c | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/kasan.h b/arch/riscv/include/asm/kasan.h index 0b85e363e778..e6a0071bdb56 100644 --- a/arch/riscv/include/asm/kasan.h +++ b/arch/riscv/include/asm/kasan.h @@ -6,8 +6,6 @@ #ifndef __ASSEMBLY__ -#ifdef CONFIG_KASAN - /* * The following comment was copied from arm64: * KASAN_SHADOW_START: beginning of the kernel virtual addresses. @@ -34,6 +32,8 @@ */ #define KASAN_SHADOW_START ((KASAN_SHADOW_END - KASAN_SHADOW_SIZE) & PGDIR_MASK) #define KASAN_SHADOW_END MODULES_LOWEST_VADDR + +#ifdef CONFIG_KASAN #define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL) void kasan_init(void); diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index fe5072f66c8c..a5b3bc1f3b88 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -1493,11 +1494,19 @@ static void __init preallocate_pgd_pages_range(unsigned long start, unsigned lon panic("Failed to pre-allocate %s pages for %s area\n", lvl, area); } +#define PAGE_END KASAN_SHADOW_START + void __init pgtable_cache_init(void) { preallocate_pgd_pages_range(VMALLOC_START, VMALLOC_END, "vmalloc"); if (IS_ENABLED(CONFIG_MODULES)) preallocate_pgd_pages_range(MODULES_VADDR, MODULES_END, "bpf/modules"); + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) { + preallocate_pgd_pages_range(VMEMMAP_START, VMEMMAP_END, "vmemmap"); + preallocate_pgd_pages_range(PAGE_OFFSET, PAGE_END, "direct map"); + if (IS_ENABLED(CONFIG_KASAN)) + preallocate_pgd_pages_range(KASAN_SHADOW_START, KASAN_SHADOW_END, "kasan"); + } } #endif From patchwork Wed Jun 5 11:40:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686715 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95016C27C53 for ; Wed, 5 Jun 2024 11:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/zj2sBY93JRkSIymjYamV4tRJpra14d9NmcKJSfprRg=; b=GmnV943AojR48O jrU/wW9cSprxSPhVcg6zrwXkCt/88fIBvqSt8JdVSa0YaWVHlxKoeeMvgwPrjd+8TuBSp16O+POmF LtfKs57l5dI2/i//fn9wqNrvLONQZKSiw+SD1KS56iRnaeU3t19oY2M1Hw2uUqbl2yyB4+32ns7GT NLxRdqt20halMbq5OgRPqgaCt+cychKkWvj8dDEIaeM/v78Yj5VCGKhH50/B1Gk8m1QtLnQnd4awK PXllCZhQQ6HLdhjv/X6Laom3LaNnSehLiWk00KJOpYNQWTMnMTBYVfUbI0UEX1t31oS8mUOUBm8S9 7aZKLNdT2Kd87QYf7PpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1L-00000005jvf-2sxC; Wed, 05 Jun 2024 11:41:35 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1H-00000005jsA-1hyW for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:41:33 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 6F2F8CE176A; Wed, 5 Jun 2024 11:41:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5382CC32786; Wed, 5 Jun 2024 11:41:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587688; bh=MFof7xn/oSifUp6j3V5p4AYP/CSYuS80BqueZAmmuuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pbFVgcWHRiy8pGFDtngTEv5eU6zwJP5WKhapkZnCc2mI03cZWTm4GzvL8iv/Je5MF oWk3OVTiG83nP8OWaGHrdw+5nwhzAkmJrNMIcwNMLOvmZu8MZUQ3BNkaksv1UyWJ2i OYHMGVswkTwTQSes3oSvy40gJcpCLSJ6ma+leHj6n4bikuN++iRIG+IUTthtz2pvuW 2JSchG9gqfdrCInzs6Ty2xoH4RRiofEW1UNYJg3Hra555cYeBPfDkvtDjGE+GxD9yg JvfaSOCKVfspDfSQ+OxaRJt1zHhTct51b72y77qW2EuFj7hJNM9yFEpFwX7z/m+z9v Wc79Ge1oe18gA== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 03/11] riscv: mm: Change attribute from __init to __meminit for page functions Date: Wed, 5 Jun 2024 13:40:46 +0200 Message-ID: <20240605114100.315918-4-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044131_907638_80F209A2 X-CRM114-Status: GOOD ( 15.42 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel Prepare for memory hotplugging support by changing from __init to __meminit for the page table functions that are used by the upcoming architecture specific callbacks. Changing the __init attribute to __meminit, avoids that the functions are removed after init. The __meminit attribute makes sure the functions are kept in the kernel text post init, but only if memory hotplugging is enabled for the build. Reviewed-by: Alexandre Ghiti Reviewed-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Björn Töpel --- arch/riscv/include/asm/mmu.h | 4 +-- arch/riscv/include/asm/pgtable.h | 2 +- arch/riscv/mm/init.c | 56 ++++++++++++++------------------ 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/arch/riscv/include/asm/mmu.h b/arch/riscv/include/asm/mmu.h index 947fd60f9051..c9e03e9da3dc 100644 --- a/arch/riscv/include/asm/mmu.h +++ b/arch/riscv/include/asm/mmu.h @@ -31,8 +31,8 @@ typedef struct { #define cntx2asid(cntx) ((cntx) & SATP_ASID_MASK) #define cntx2version(cntx) ((cntx) & ~SATP_ASID_MASK) -void __init create_pgd_mapping(pgd_t *pgdp, uintptr_t va, phys_addr_t pa, - phys_addr_t sz, pgprot_t prot); +void __meminit create_pgd_mapping(pgd_t *pgdp, uintptr_t va, phys_addr_t pa, phys_addr_t sz, + pgprot_t prot); #endif /* __ASSEMBLY__ */ #endif /* _ASM_RISCV_MMU_H */ diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index aad8b8ca51f1..41f1b2c6f949 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -165,7 +165,7 @@ struct pt_alloc_ops { #endif }; -extern struct pt_alloc_ops pt_ops __initdata; +extern struct pt_alloc_ops pt_ops __meminitdata; #ifdef CONFIG_MMU /* Number of PGD entries that a user-mode program can use */ diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index a5b3bc1f3b88..0dd04cedc0d2 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -297,7 +297,7 @@ static void __init setup_bootmem(void) } #ifdef CONFIG_MMU -struct pt_alloc_ops pt_ops __initdata; +struct pt_alloc_ops pt_ops __meminitdata; pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss; pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss; @@ -359,7 +359,7 @@ static inline pte_t *__init get_pte_virt_fixmap(phys_addr_t pa) return (pte_t *)set_fixmap_offset(FIX_PTE, pa); } -static inline pte_t *__init get_pte_virt_late(phys_addr_t pa) +static inline pte_t *__meminit get_pte_virt_late(phys_addr_t pa) { return (pte_t *) __va(pa); } @@ -378,7 +378,7 @@ static inline phys_addr_t __init alloc_pte_fixmap(uintptr_t va) return memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE); } -static phys_addr_t __init alloc_pte_late(uintptr_t va) +static phys_addr_t __meminit alloc_pte_late(uintptr_t va) { struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL & ~__GFP_HIGHMEM, 0); @@ -386,9 +386,8 @@ static phys_addr_t __init alloc_pte_late(uintptr_t va) return __pa((pte_t *)ptdesc_address(ptdesc)); } -static void __init create_pte_mapping(pte_t *ptep, - uintptr_t va, phys_addr_t pa, - phys_addr_t sz, pgprot_t prot) +static void __meminit create_pte_mapping(pte_t *ptep, uintptr_t va, phys_addr_t pa, phys_addr_t sz, + pgprot_t prot) { uintptr_t pte_idx = pte_index(va); @@ -442,7 +441,7 @@ static pmd_t *__init get_pmd_virt_fixmap(phys_addr_t pa) return (pmd_t *)set_fixmap_offset(FIX_PMD, pa); } -static pmd_t *__init get_pmd_virt_late(phys_addr_t pa) +static pmd_t *__meminit get_pmd_virt_late(phys_addr_t pa) { return (pmd_t *) __va(pa); } @@ -459,7 +458,7 @@ static phys_addr_t __init alloc_pmd_fixmap(uintptr_t va) return memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE); } -static phys_addr_t __init alloc_pmd_late(uintptr_t va) +static phys_addr_t __meminit alloc_pmd_late(uintptr_t va) { struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL & ~__GFP_HIGHMEM, 0); @@ -467,9 +466,9 @@ static phys_addr_t __init alloc_pmd_late(uintptr_t va) return __pa((pmd_t *)ptdesc_address(ptdesc)); } -static void __init create_pmd_mapping(pmd_t *pmdp, - uintptr_t va, phys_addr_t pa, - phys_addr_t sz, pgprot_t prot) +static void __meminit create_pmd_mapping(pmd_t *pmdp, + uintptr_t va, phys_addr_t pa, + phys_addr_t sz, pgprot_t prot) { pte_t *ptep; phys_addr_t pte_phys; @@ -505,7 +504,7 @@ static pud_t *__init get_pud_virt_fixmap(phys_addr_t pa) return (pud_t *)set_fixmap_offset(FIX_PUD, pa); } -static pud_t *__init get_pud_virt_late(phys_addr_t pa) +static pud_t *__meminit get_pud_virt_late(phys_addr_t pa) { return (pud_t *)__va(pa); } @@ -523,7 +522,7 @@ static phys_addr_t __init alloc_pud_fixmap(uintptr_t va) return memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE); } -static phys_addr_t alloc_pud_late(uintptr_t va) +static phys_addr_t __meminit alloc_pud_late(uintptr_t va) { unsigned long vaddr; @@ -543,7 +542,7 @@ static p4d_t *__init get_p4d_virt_fixmap(phys_addr_t pa) return (p4d_t *)set_fixmap_offset(FIX_P4D, pa); } -static p4d_t *__init get_p4d_virt_late(phys_addr_t pa) +static p4d_t *__meminit get_p4d_virt_late(phys_addr_t pa) { return (p4d_t *)__va(pa); } @@ -561,7 +560,7 @@ static phys_addr_t __init alloc_p4d_fixmap(uintptr_t va) return memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE); } -static phys_addr_t alloc_p4d_late(uintptr_t va) +static phys_addr_t __meminit alloc_p4d_late(uintptr_t va) { unsigned long vaddr; @@ -570,9 +569,8 @@ static phys_addr_t alloc_p4d_late(uintptr_t va) return __pa(vaddr); } -static void __init create_pud_mapping(pud_t *pudp, - uintptr_t va, phys_addr_t pa, - phys_addr_t sz, pgprot_t prot) +static void __meminit create_pud_mapping(pud_t *pudp, uintptr_t va, phys_addr_t pa, phys_addr_t sz, + pgprot_t prot) { pmd_t *nextp; phys_addr_t next_phys; @@ -597,9 +595,8 @@ static void __init create_pud_mapping(pud_t *pudp, create_pmd_mapping(nextp, va, pa, sz, prot); } -static void __init create_p4d_mapping(p4d_t *p4dp, - uintptr_t va, phys_addr_t pa, - phys_addr_t sz, pgprot_t prot) +static void __meminit create_p4d_mapping(p4d_t *p4dp, uintptr_t va, phys_addr_t pa, phys_addr_t sz, + pgprot_t prot) { pud_t *nextp; phys_addr_t next_phys; @@ -655,9 +652,8 @@ static void __init create_p4d_mapping(p4d_t *p4dp, #define create_pmd_mapping(__pmdp, __va, __pa, __sz, __prot) do {} while(0) #endif /* __PAGETABLE_PMD_FOLDED */ -void __init create_pgd_mapping(pgd_t *pgdp, - uintptr_t va, phys_addr_t pa, - phys_addr_t sz, pgprot_t prot) +void __meminit create_pgd_mapping(pgd_t *pgdp, uintptr_t va, phys_addr_t pa, phys_addr_t sz, + pgprot_t prot) { pgd_next_t *nextp; phys_addr_t next_phys; @@ -682,8 +678,7 @@ void __init create_pgd_mapping(pgd_t *pgdp, create_pgd_next_mapping(nextp, va, pa, sz, prot); } -static uintptr_t __init best_map_size(phys_addr_t pa, uintptr_t va, - phys_addr_t size) +static uintptr_t __meminit best_map_size(phys_addr_t pa, uintptr_t va, phys_addr_t size) { if (debug_pagealloc_enabled()) return PAGE_SIZE; @@ -719,7 +714,7 @@ asmlinkage void __init __copy_data(void) #endif #ifdef CONFIG_STRICT_KERNEL_RWX -static __init pgprot_t pgprot_from_va(uintptr_t va) +static __meminit pgprot_t pgprot_from_va(uintptr_t va) { if (is_va_kernel_text(va)) return PAGE_KERNEL_READ_EXEC; @@ -744,7 +739,7 @@ void mark_rodata_ro(void) set_memory_ro); } #else -static __init pgprot_t pgprot_from_va(uintptr_t va) +static __meminit pgprot_t pgprot_from_va(uintptr_t va) { if (IS_ENABLED(CONFIG_64BIT) && !is_kernel_mapping(va)) return PAGE_KERNEL; @@ -1236,9 +1231,8 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) pt_ops_set_fixmap(); } -static void __init create_linear_mapping_range(phys_addr_t start, - phys_addr_t end, - uintptr_t fixed_map_size) +static void __meminit create_linear_mapping_range(phys_addr_t start, phys_addr_t end, + uintptr_t fixed_map_size) { phys_addr_t pa; uintptr_t va, map_size; From patchwork Wed Jun 5 11:40:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686716 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89F95C25B76 for ; Wed, 5 Jun 2024 11:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NY9OLW9RU3R/3BpZW1xCMP2e2/X4AFIO2BLnNtIUdWg=; b=tykNK/w29Rpw7A DVh2TcqyE2js+u3RAu3WJLLpS+90VMefzVmns7GeXDg8xWt/qtpKiuEBWHmTTQ2K3HmO6QbVibD7m dyPgetF1YqTK4jBw6cEpVgsRmdcCVTa0RPpJXvvlc6+pSvc+sZG7NlWNdTaOzjj9AmLNY8EKvnnRd kiEhPGizajJ8ieVwOpOwpbjbpzLwdd+G9doYvvLHsol8U9DBzIcz1+4w4Qo7feujXCp4jHTLKWnkI WxMBtY6nPH5Alda9goUApCC8btzfYY61kVBDK863UG3c+rYh4fnDqzAto4FDfiOsxTucExMckX2sP 3QKZ2B5xvHciwH/vZaYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1O-00000005jx0-1uxv; Wed, 05 Jun 2024 11:41:38 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1L-00000005jv4-0Dau for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:41:36 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1A27B61828; Wed, 5 Jun 2024 11:41:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53260C32781; Wed, 5 Jun 2024 11:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587693; bh=MENbBPiOyzG6FBgO0rCD/3ta5d0qLTF/n4fv5DxVET4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p39Mrvw8AJVDKum0Jwg2kb6k87OxJJJ6NrzWSjUUAw1HBTx0uMsmH4QIVLXMIQSjh gGHpGG50o4vxjchkAer0QNCnDkBV9o8kftuixBD9zQDfl1A74EwF3vGFGAOgdDUt3J jhltzpH8+ixqmF4cy66BaweUitmK0U5TaHrrG7i0qbCCCYYDxf1H7GcZfuSiv3PEH5 ODfv8fk9v6erj4Ljcbke3zr58EffgPQNPBd1xbKrR/e1Bfw5dXLk5FkLcBVflIxCHI Bc0UHKuPkQS00F3mFuO5iPHr7YzBmcdN+Gt/nFL77/pTRGZDMKBxiaC+EFfD06kZCo 9XJgH9lq5cqLw== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 04/11] riscv: mm: Refactor create_linear_mapping_range() for memory hot add Date: Wed, 5 Jun 2024 13:40:47 +0200 Message-ID: <20240605114100.315918-5-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044135_266355_7CB940AF X-CRM114-Status: UNSURE ( 8.87 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel Add a parameter to the direct map setup function, so it can be used in arch_add_memory() later. Reviewed-by: Alexandre Ghiti Reviewed-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Björn Töpel --- arch/riscv/mm/init.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 0dd04cedc0d2..1f7e7c223bec 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1232,7 +1232,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) } static void __meminit create_linear_mapping_range(phys_addr_t start, phys_addr_t end, - uintptr_t fixed_map_size) + uintptr_t fixed_map_size, const pgprot_t *pgprot) { phys_addr_t pa; uintptr_t va, map_size; @@ -1243,7 +1243,7 @@ static void __meminit create_linear_mapping_range(phys_addr_t start, phys_addr_t best_map_size(pa, va, end - pa); create_pgd_mapping(swapper_pg_dir, va, pa, map_size, - pgprot_from_va(va)); + pgprot ? *pgprot : pgprot_from_va(va)); } } @@ -1287,22 +1287,19 @@ static void __init create_linear_mapping_page_table(void) if (end >= __pa(PAGE_OFFSET) + memory_limit) end = __pa(PAGE_OFFSET) + memory_limit; - create_linear_mapping_range(start, end, 0); + create_linear_mapping_range(start, end, 0, NULL); } #ifdef CONFIG_STRICT_KERNEL_RWX - create_linear_mapping_range(ktext_start, ktext_start + ktext_size, 0); - create_linear_mapping_range(krodata_start, - krodata_start + krodata_size, 0); + create_linear_mapping_range(ktext_start, ktext_start + ktext_size, 0, NULL); + create_linear_mapping_range(krodata_start, krodata_start + krodata_size, 0, NULL); memblock_clear_nomap(ktext_start, ktext_size); memblock_clear_nomap(krodata_start, krodata_size); #endif #ifdef CONFIG_KFENCE - create_linear_mapping_range(kfence_pool, - kfence_pool + KFENCE_POOL_SIZE, - PAGE_SIZE); + create_linear_mapping_range(kfence_pool, kfence_pool + KFENCE_POOL_SIZE, PAGE_SIZE, NULL); memblock_clear_nomap(kfence_pool, KFENCE_POOL_SIZE); #endif From patchwork Wed Jun 5 11:40:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686717 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89543C25B76 for ; Wed, 5 Jun 2024 11:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5x27UpBP1ndOqsD2lGBibKXFyonLZjAS598cfWgG31I=; b=iEEkOpNR78nX0J P/U+kI2aeSTwT1DpPymnop9n7EnBmFjCqDwxQhvSXZc6vO/9ZyrK9wOHf44DyArajbM55ejt+fLnB +Gslxqrd7TfJA88azgS+udP0alZIKOT4RGaBHdfeXqJsagkM8TFoTJGoPuZwusg8h2zDVjiUTiIdo VMsuM4timlROXBurF2Y/oDNJyRWT3z9VBEeJSsvqjTywws/En43N3hoqbIBovueiHtrDJYGhFgPlB eutbla6ujj/AQJ8neNqp6bm5LDnm/GSx1kIuB/GdV/VS/2SuHANjkQsz+0qJPGrRsoRrkICjfsq2u uqbhfJV0FCgFY3cR7Xcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1U-00000005k1f-20vW; Wed, 05 Jun 2024 11:41:44 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1R-00000005jy8-09hn for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:41:42 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 48605CE1774; Wed, 5 Jun 2024 11:41:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56EA3C3277B; Wed, 5 Jun 2024 11:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587698; bh=JhdeFloFX/xxhqkxVxMkwy3o8a+I7NU1Jr3K3J+2XHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yo0tPcOUDWbZKgAZCcnplN/Tpng+rYhahCirtGosu22vfbqUpPcHwDQA6k6SFhOAV ZJqZbW2Hub+7wW8blIcchz+3RvICwE2f/9Ybv7CyKA+D07H53Ebb5i0DPEtvRVmP7+ +UJZgr4Sp39itexUAPNROpGAAJDUgk4oCvOQX909f0SpiDFFPHsojDG2bl1yDM6WIT 1SeA46LAIXR14O9bfozUPdydSqNyrw8nINXW38klf+p8XKmw4BCQ/CsmeOD9GOvQFi hvRgm5Ntqz+0/jK4n1J/g/BIAKDgmEOtQ2+tEApA0MTtkbTxYZ4HxLyqMrMU4Yz12A PHsFFb2fJFJpQ== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 05/11] riscv: mm: Add pfn_to_kaddr() implementation Date: Wed, 5 Jun 2024 13:40:48 +0200 Message-ID: <20240605114100.315918-6-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044141_496108_D18D3FC7 X-CRM114-Status: UNSURE ( 8.54 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel The pfn_to_kaddr() function is used by KASAN's memory hotplugging path. Add the missing function to the RISC-V port, so that it can be built with MHP and CONFIG_KASAN. Signed-off-by: Björn Töpel Reviewed-by: Alexandre Ghiti --- arch/riscv/include/asm/page.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h index 115ac98b8d72..235fd45d998d 100644 --- a/arch/riscv/include/asm/page.h +++ b/arch/riscv/include/asm/page.h @@ -188,6 +188,11 @@ extern phys_addr_t __phys_addr_symbol(unsigned long x); unsigned long kaslr_offset(void); +static __always_inline void *pfn_to_kaddr(unsigned long pfn) +{ + return __va(pfn << PAGE_SHIFT); +} + #endif /* __ASSEMBLY__ */ #define virt_addr_valid(vaddr) ({ \ From patchwork Wed Jun 5 11:40:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686718 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3063C27C53 for ; Wed, 5 Jun 2024 11:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l/FkDjmBHYXKY5m6Nv1WTgxLbrqrNwcIPGHZFGlh4WA=; b=DQSWSb52LpEndb rGzJ9YhNImEBxrlgIvQZ5h4dOH6D7wThaiA367RC1awI+IOKxXRuB22ajQVMBpC0CqrJXX6kCycyz viJtkR93acdx6k5CmxknuEnmuDKwHqn3cte4GLsM5sMeMQuwsIdyeiIcev185zij+5porZfDZX2sL 7MAVkGzIAAFjy5zUFbBdY9iVdJEcKplzTcYmUGpMrL+HEBvhzZTKr/MW3+ikk7+TzF0rk9CNcMnLq aSesgDaNhxEVVRyzIHEca7yNljxCavYd5bQpbvIBAaHJWz5uDYhUUbhbkaRkJp1+KNX5FDfaJKZEf xMgD47b+HdG5AycVsNmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1Y-00000005k4Z-0JmW; Wed, 05 Jun 2024 11:41:48 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1U-00000005k0l-1iWf for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:41:47 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 816E461828; Wed, 5 Jun 2024 11:41:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17BD5C4AF07; Wed, 5 Jun 2024 11:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587703; bh=leGoQp8DEEvTCeM4J9FC79a8Zz3S/PSgaRX/3/h/W8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SrE60qV8oPpVdrRp9tUwh9ikl7xIxLTsNY63/3cH50PJYUc8iADgU6aQ2lWeBzVdC Bm/D+UZgx+0eqn6rNGPDrUbLTFBA2D98lam6/6CUgQU0w5daAlIVKzXOo3gLZtuy0q DQghfAdosXGf3Kxm7srDhYYV0bkMYx6RGPCm0Anlg7s8L2hxWW94oEgaGUZZBfR2+T 6x9wvIq33dfBPA55iWPQknOQO+x+spsb7EqaQ2bu9Mi4/U3NcJY07Uqia6jKeDvvXP miRZUaXHShRtvlG0Jg53UQWHeEHGOz94fFtNu/D+LJZ+EGh3HfDI3TAIw4rRxg72D7 1q6V+P31mOieA== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 06/11] riscv: mm: Add memory hotplugging support Date: Wed, 5 Jun 2024 13:40:49 +0200 Message-ID: <20240605114100.315918-7-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044144_776314_E391A504 X-CRM114-Status: GOOD ( 19.36 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel For an architecture to support memory hotplugging, a couple of callbacks needs to be implemented: arch_add_memory() This callback is responsible for adding the physical memory into the direct map, and call into the memory hotplugging generic code via __add_pages() that adds the corresponding struct page entries, and updates the vmemmap mapping. arch_remove_memory() This is the inverse of the callback above. vmemmap_free() This function tears down the vmemmap mappings (if CONFIG_SPARSEMEM_VMEMMAP is enabled), and also deallocates the backing vmemmap pages. Note that for persistent memory, an alternative allocator for the backing pages can be used; The vmem_altmap. This means that when the backing pages are cleared, extra care is needed so that the correct deallocation method is used. arch_get_mappable_range() This functions returns the PA range that the direct map can map. Used by the MHP internals for sanity checks. The page table unmap/teardown functions are heavily based on code from the x86 tree. The same remove_pgd_mapping() function is used in both vmemmap_free() and arch_remove_memory(), but in the latter function the backing pages are not removed. Signed-off-by: Björn Töpel Reviewed-by: Alexandre Ghiti --- arch/riscv/mm/init.c | 267 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 267 insertions(+) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 1f7e7c223bec..bfa2dea95354 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1534,3 +1534,270 @@ struct execmem_info __init *execmem_arch_setup(void) } #endif /* CONFIG_MMU */ #endif /* CONFIG_EXECMEM */ + +#ifdef CONFIG_MEMORY_HOTPLUG +static void __meminit free_pte_table(pte_t *pte_start, pmd_t *pmd) +{ + struct page *page = pmd_page(*pmd); + struct ptdesc *ptdesc = page_ptdesc(page); + pte_t *pte; + int i; + + for (i = 0; i < PTRS_PER_PTE; i++) { + pte = pte_start + i; + if (!pte_none(*pte)) + return; + } + + pagetable_pte_dtor(ptdesc); + if (PageReserved(page)) + free_reserved_page(page); + else + pagetable_free(ptdesc); + pmd_clear(pmd); +} + +static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud) +{ + struct page *page = pud_page(*pud); + struct ptdesc *ptdesc = page_ptdesc(page); + pmd_t *pmd; + int i; + + for (i = 0; i < PTRS_PER_PMD; i++) { + pmd = pmd_start + i; + if (!pmd_none(*pmd)) + return; + } + + pagetable_pmd_dtor(ptdesc); + if (PageReserved(page)) + free_reserved_page(page); + else + pagetable_free(ptdesc); + pud_clear(pud); +} + +static void __meminit free_pud_table(pud_t *pud_start, p4d_t *p4d) +{ + struct page *page = p4d_page(*p4d); + pud_t *pud; + int i; + + for (i = 0; i < PTRS_PER_PUD; i++) { + pud = pud_start + i; + if (!pud_none(*pud)) + return; + } + + if (PageReserved(page)) + free_reserved_page(page); + else + free_pages((unsigned long)page_address(page), 0); + p4d_clear(p4d); +} + +static void __meminit free_vmemmap_storage(struct page *page, size_t size, + struct vmem_altmap *altmap) +{ + int order = get_order(size); + + if (altmap) { + vmem_altmap_free(altmap, size >> PAGE_SHIFT); + return; + } + + if (PageReserved(page)) { + unsigned int nr_pages = 1 << order; + + while (nr_pages--) + free_reserved_page(page++); + return; + } + + free_pages((unsigned long)page_address(page), order); +} + +static void __meminit remove_pte_mapping(pte_t *pte_base, unsigned long addr, unsigned long end, + bool is_vmemmap, struct vmem_altmap *altmap) +{ + unsigned long next; + pte_t *ptep, pte; + + for (; addr < end; addr = next) { + next = (addr + PAGE_SIZE) & PAGE_MASK; + if (next > end) + next = end; + + ptep = pte_base + pte_index(addr); + pte = ptep_get(ptep); + if (!pte_present(*ptep)) + continue; + + pte_clear(&init_mm, addr, ptep); + if (is_vmemmap) + free_vmemmap_storage(pte_page(pte), PAGE_SIZE, altmap); + } +} + +static void __meminit remove_pmd_mapping(pmd_t *pmd_base, unsigned long addr, unsigned long end, + bool is_vmemmap, struct vmem_altmap *altmap) +{ + unsigned long next; + pte_t *pte_base; + pmd_t *pmdp, pmd; + + for (; addr < end; addr = next) { + next = pmd_addr_end(addr, end); + pmdp = pmd_base + pmd_index(addr); + pmd = pmdp_get(pmdp); + if (!pmd_present(pmd)) + continue; + + if (pmd_leaf(pmd)) { + pmd_clear(pmdp); + if (is_vmemmap) + free_vmemmap_storage(pmd_page(pmd), PMD_SIZE, altmap); + continue; + } + + pte_base = (pte_t *)pmd_page_vaddr(*pmdp); + remove_pte_mapping(pte_base, addr, next, is_vmemmap, altmap); + free_pte_table(pte_base, pmdp); + } +} + +static void __meminit remove_pud_mapping(pud_t *pud_base, unsigned long addr, unsigned long end, + bool is_vmemmap, struct vmem_altmap *altmap) +{ + unsigned long next; + pud_t *pudp, pud; + pmd_t *pmd_base; + + for (; addr < end; addr = next) { + next = pud_addr_end(addr, end); + pudp = pud_base + pud_index(addr); + pud = pudp_get(pudp); + if (!pud_present(pud)) + continue; + + if (pud_leaf(pud)) { + if (pgtable_l4_enabled) { + pud_clear(pudp); + if (is_vmemmap) + free_vmemmap_storage(pud_page(pud), PUD_SIZE, altmap); + } + continue; + } + + pmd_base = pmd_offset(pudp, 0); + remove_pmd_mapping(pmd_base, addr, next, is_vmemmap, altmap); + + if (pgtable_l4_enabled) + free_pmd_table(pmd_base, pudp); + } +} + +static void __meminit remove_p4d_mapping(p4d_t *p4d_base, unsigned long addr, unsigned long end, + bool is_vmemmap, struct vmem_altmap *altmap) +{ + unsigned long next; + p4d_t *p4dp, p4d; + pud_t *pud_base; + + for (; addr < end; addr = next) { + next = p4d_addr_end(addr, end); + p4dp = p4d_base + p4d_index(addr); + p4d = p4dp_get(p4dp); + if (!p4d_present(p4d)) + continue; + + if (p4d_leaf(p4d)) { + if (pgtable_l5_enabled) { + p4d_clear(p4dp); + if (is_vmemmap) + free_vmemmap_storage(p4d_page(p4d), P4D_SIZE, altmap); + } + continue; + } + + pud_base = pud_offset(p4dp, 0); + remove_pud_mapping(pud_base, addr, next, is_vmemmap, altmap); + + if (pgtable_l5_enabled) + free_pud_table(pud_base, p4dp); + } +} + +static void __meminit remove_pgd_mapping(unsigned long va, unsigned long end, bool is_vmemmap, + struct vmem_altmap *altmap) +{ + unsigned long addr, next; + p4d_t *p4d_base; + pgd_t *pgd; + + for (addr = va; addr < end; addr = next) { + next = pgd_addr_end(addr, end); + pgd = pgd_offset_k(addr); + + if (!pgd_present(*pgd)) + continue; + + if (pgd_leaf(*pgd)) + continue; + + p4d_base = p4d_offset(pgd, 0); + remove_p4d_mapping(p4d_base, addr, next, is_vmemmap, altmap); + } + + flush_tlb_all(); +} + +static void __meminit remove_linear_mapping(phys_addr_t start, u64 size) +{ + unsigned long va = (unsigned long)__va(start); + unsigned long end = (unsigned long)__va(start + size); + + remove_pgd_mapping(va, end, false, NULL); +} + +struct range arch_get_mappable_range(void) +{ + struct range mhp_range; + + mhp_range.start = __pa(PAGE_OFFSET); + mhp_range.end = __pa(PAGE_END - 1); + return mhp_range; +} + +int __ref arch_add_memory(int nid, u64 start, u64 size, struct mhp_params *params) +{ + int ret = 0; + + create_linear_mapping_range(start, start + size, 0, ¶ms->pgprot); + ret = __add_pages(nid, start >> PAGE_SHIFT, size >> PAGE_SHIFT, params); + if (ret) { + remove_linear_mapping(start, size); + goto out; + } + + max_pfn = PFN_UP(start + size); + max_low_pfn = max_pfn; + + out: + flush_tlb_all(); + return ret; +} + +void __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap) +{ + __remove_pages(start >> PAGE_SHIFT, size >> PAGE_SHIFT, altmap); + remove_linear_mapping(start, size); + flush_tlb_all(); +} + +void __ref vmemmap_free(unsigned long start, unsigned long end, struct vmem_altmap *altmap) +{ + remove_pgd_mapping(start, end, true, altmap); +} +#endif /* CONFIG_MEMORY_HOTPLUG */ From patchwork Wed Jun 5 11:40:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686719 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68F28C25B76 for ; Wed, 5 Jun 2024 11:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=F4J5ZM7PZJPIcjp1iFWyAowlW8i/Vs/y1rdOKzbQLqg=; b=pGbBqM3R7juVWP 9w7d3xAk7Oh/b6NfaL0uBboUuDUgRy5oZ+OWCh1Cxv6M6ja6t0oMJBqVzZekruWbupndjqZ1EP/m8 zXKMm5xhXcDykD1VhGrIORF4tFTXlCJLSOy8PA/hB6ZDPsLlU6nEbbBOLvrd/gw/3+T2YPBOBRcDc SVVfJNO2gtJE1AoMJvfqOlc4AEXjgWXW0VEaEpvqOXDPLKN/DqX4KcDOzjvCOw+XUtfZMmYdmoY69 T6LkLt8/x58ZNjuRg0VQ2tFzdEdIS0Fmp7mzXJl/hDPAnIZYgB8CQYVmrEda0dWqaDDU+3ueyVsTB c/QFZrqf0E9f72kdMkdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1d-00000005k8P-1SlY; Wed, 05 Jun 2024 11:41:53 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1a-00000005k5l-2LkI for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:41:52 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E9ED0CE1779; Wed, 5 Jun 2024 11:41:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADA0FC32786; Wed, 5 Jun 2024 11:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587708; bh=tu3HoOPPrk12D/HHChqAMB+6RlcJ+H95I8FoF9tFiiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=actIwcGKL7lMw7iHm/kYeLU0Im0MKA4ATYjc0eCD0iqFPQA3+RyZqVf1nydSeSUj0 gF9ZhAi8Cz89TfrWUuVf9dhYSzuUycsqYPT4dufEA7HfktKoCVWT5gVywjFH44bLxq FNTCqSW9+FkXOpJ/wxpC8P41lR4dMjOqX+wX6c6+uyD4sHqI51jkPKWdIKeosTC0K2 WSBy6vQk9sC3vPE9M08ir3qL9i3FzdGxn8iAQdWQ8EjWNitOO9u8IfVkxzec9k0tt9 kNzLKT3wBJLZ8wQiEitzX09XtnmJ30P5wj/gY3ges2Va9UAhUDJXEgw+464CKsyQPH ZFrpv32CPOuLg== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 07/11] riscv: mm: Take memory hotplug read-lock during kernel page table dump Date: Wed, 5 Jun 2024 13:40:50 +0200 Message-ID: <20240605114100.315918-8-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044150_815036_04491C71 X-CRM114-Status: UNSURE ( 9.21 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel During memory hot remove, the ptdump functionality can end up touching stale data. Avoid any potential crashes (or worse), by holding the memory hotplug read-lock while traversing the page table. This change is analogous to arm64's commit bf2b59f60ee1 ("arm64/mm: Hold memory hotplug lock while walking for kernel page table dump"). Reviewed-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Björn Töpel --- arch/riscv/mm/ptdump.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c index 1289cc6d3700..9d5f657a251b 100644 --- a/arch/riscv/mm/ptdump.c +++ b/arch/riscv/mm/ptdump.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -370,7 +371,9 @@ bool ptdump_check_wx(void) static int ptdump_show(struct seq_file *m, void *v) { + get_online_mems(); ptdump_walk(m, m->private); + put_online_mems(); return 0; } From patchwork Wed Jun 5 11:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686720 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44EC2C27C5E for ; Wed, 5 Jun 2024 11:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IJf4HEuLTmPNncIknc1x9v55R6nIJBIeS6s38HXh1A4=; b=cmqQIkvoYQIDKk JTMfLXzT8DkmvWuA+1eoGsfVSMZpWrlJ5Nyt4CkPh67R+/gs+y6T2eSBzhIyJ5yQesP11+4kP0Sui Hsw0W2AHK7AJ1Bhe3sRhpjDaomx3kEyRzAVqIZxegNSKEfTqvTwDpd6k8jsD60FmBRF+rsuvcYQBi 5eqAjgOgSNasEBd9Hvdq8axUBem/3wxf8W4jzpetiah4THRY2vZKGbUkz8VNVF5ixdV8AnnoKtVuZ myqdvWKgrNnzgQhqoIVJVo3gG9ocFFOORz0ymp+QOkV1bwNpdgGumsNbysirBQFCBWAFmP5uA9WDU r8XYkLKzh8eiQXP4FKzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1g-00000005kBT-3RvI; Wed, 05 Jun 2024 11:41:56 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1d-00000005k8Y-3loW for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:41:55 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5040A61828; Wed, 5 Jun 2024 11:41:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB9B2C4AF09; Wed, 5 Jun 2024 11:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587713; bh=L6J14KqpfXLFzLpqo0wTWwklGSKZlK82ek5ghR0epQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nB+tpFCKWoin2Io1tYNh/CpS+b2KOE96Igf2M+PajeAiqjcAwFpQdkIQ1roxi2gFS ybrJ6R3VNsPGfwYETuovRb8MmTUuzJYXMZkdk5PkklSmzl/mvUssCtdc8sq6Nn+608 Msnb1PAycmOOBfXZz9FDQCndMLunP+YGOi1F1+qIlP3WKOUwv5u+jFCiovPNw7bR/f mDZYBsTyIzCYUGva5g5QSNHBpM7IOMr7msMbj2JmcxdV3QiHfU6VxtsKG0bPV/tDWi hYQBxxJxkhebALDI+e5GZRgBFT6W8RxUwONIgOVjjb2cDwx5omNGuOKTPYICI4q2OY 63QpUaPxQzQfw== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 08/11] riscv: Enable memory hotplugging for RISC-V Date: Wed, 5 Jun 2024 13:40:51 +0200 Message-ID: <20240605114100.315918-9-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044154_034813_14B26948 X-CRM114-Status: UNSURE ( 7.43 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel Enable ARCH_ENABLE_MEMORY_HOTPLUG and ARCH_ENABLE_MEMORY_HOTREMOVE for RISC-V. Reviewed-by: Alexandre Ghiti Signed-off-by: Björn Töpel --- arch/riscv/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 0525ee2d63c7..8d860ad3b171 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -16,6 +16,8 @@ config RISCV select ACPI_REDUCED_HARDWARE_ONLY if ACPI select ARCH_DMA_DEFAULT_COHERENT select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION + select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM_VMEMMAP + select ARCH_ENABLE_MEMORY_HOTREMOVE if MEMORY_HOTPLUG select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2 select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE select ARCH_HAS_BINFMT_FLAT @@ -46,6 +48,7 @@ config RISCV select ARCH_HAS_UBSAN select ARCH_HAS_VDSO_DATA select ARCH_KEEP_MEMBLOCK if ACPI + select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if 64BIT && MMU select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT select ARCH_STACKWALK From patchwork Wed Jun 5 11:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686721 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1EA1C25B76 for ; Wed, 5 Jun 2024 11:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lHqbOXuR9NurKTLnSHyvbVs4B+zPuceW72cLOKhoIBY=; b=aVtwgC4Z9O+FsW 5daXOOi7/rlULdxTGqYktYIjSMz+BoqShEYvwcLF7lSPucOuG1bbl6mAEOgSmM8m8fclh3HR1FVv8 NH99x+Sxj9hXLYBsSwhuPEjFTWwFo0Hh5OPY9OaMqL8TfuRcSit7v3JSNiJW6ygewdmX7Wlzhfe9N 9mIpkmr/786WpmYg6L70GZOpu2mTwFgyQBBJKRQwZKcJ8ROKZZm9j5n2rnFr8quXmRtcyrVOVO2SM BhKLzypiWIBE/hy5wiVWzv9b65GFXeJpzzcH/0YQaPWm64easUPKA+PN7yvKaJmL+hOo5+gEZKZ1p zMOd8OB0V7B7cApeKhdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1p-00000005kJS-0j7D; Wed, 05 Jun 2024 11:42:05 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1k-00000005kDu-1YH7 for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:42:02 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A53F5CE176A; Wed, 5 Jun 2024 11:41:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C9B6C3277B; Wed, 5 Jun 2024 11:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587718; bh=cNH/faxi7/uMHF3i5ru1TGKN5bBuB3CG9oyUregFlwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fe2kjdHr8ojoEyfXhgZTloB0ifMmIHOiG5DKKusQ7Sy/pLVBqY69c3MDTz/IU9Zgo MOhwVt+ahqsvED2Vp8J9R+Q8ubBgqynFng83NWmTihwz/P2ChTKelcdKT2bUChXFK9 XPcoo8c3N4IbEGXTynF+kAx7m1dH5G/PPGoikssoDmop+tc7FNpWuiccwDm0/0jsfe H4f2dL3LvdfbCWfFtqsONnn/c9csqEX1jG6HQnp4UkSH/eCSeScKzEtuXeHHntRU0w WP5qZvrd9lyHDBzgPM4+Zt64wDTLbmT3TRs6NhwxTl4SmXf6mkzAM5N7uV58/eSTTK ItWw6ywddPduA== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 09/11] virtio-mem: Enable virtio-mem for RISC-V Date: Wed, 5 Jun 2024 13:40:52 +0200 Message-ID: <20240605114100.315918-10-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044200_815746_52A354FB X-CRM114-Status: UNSURE ( 9.52 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel Now that RISC-V has memory hotplugging support, virtio-mem can be used on the platform. Acked-by: David Hildenbrand Signed-off-by: Björn Töpel --- drivers/virtio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig index 6284538a8184..42a48ac763ee 100644 --- a/drivers/virtio/Kconfig +++ b/drivers/virtio/Kconfig @@ -122,7 +122,7 @@ config VIRTIO_BALLOON config VIRTIO_MEM tristate "Virtio mem driver" - depends on X86_64 || ARM64 + depends on X86_64 || ARM64 || RISCV depends on VIRTIO depends on MEMORY_HOTPLUG depends on MEMORY_HOTREMOVE From patchwork Wed Jun 5 11:40:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686722 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EDF13C27C5E for ; Wed, 5 Jun 2024 11:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mHlLamR4AjucazqzjOTPEgyDvhygyEj/Kv4hp5d002E=; b=3nIDO/uI6d32QN QfY4NxFYJ5GwvaCaZyb1rOkVqRLd13T+57elmCKgcvSsm3DEyYmeC/thI3S8to0vuSdo1F73yiX+6 oz86sXWMIFCwsiCSPdHQ+1cafzjWdWdJp4wk2JQJuEy0UhPR4XdNLwmHiqdUYJfIVitiR7hzIJo9l b6kGn5aPiDwBdncQVv1oQdFmjkRIweebGqEE2jOlTT7kra3OiJiZZYKMeFYAxflclif3/TkfhwSt3 nO9p8a5L3pJw+d4n7NbkuAOSsKaET3AIgyUVk4i9uYjmC4f1n2i50mZEVaGp1AKW3F5nhIu3AEH6L lwzYBl+9JI+hX+fN1Hyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1q-00000005kKM-1rNg; Wed, 05 Jun 2024 11:42:06 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1n-00000005kHk-2cpX for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:42:05 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D428D617FE; Wed, 5 Jun 2024 11:42:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FF64C4AF0C; Wed, 5 Jun 2024 11:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587722; bh=IPeVMzLSHAetEan16+4AGusBy5f8DjdVFow0+Vll8PM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jo6MEl7isuHaac7iV7kxZMsSBTLmj1eZ5KNdf9SnXhC9rpkaYD0C9ASvySkzfKVoA gTrKEdDt0gpQoX0BIky3ja2sj46cDjW3Qyrq9Zhidq96vvqVl2EBlJ8IJn42DtwXj0 89zFsSowmTJK3LO+jbOtmVtfSewlqRQ2mylsiCtsNb8OCmpycycaF7g0QtN6ZWQYMp D1MR8apn8ditgqYOGW2krAy1bR+WunmRVJsKyG1hF8dFzYx71C/RumhKLpICzYp+Z9 usff7UPHLDivgDix7qJnceDqNRkKGqCUQm7327NUeGvucwfxvEuUDf/sQ7o4ccSxvM lChmPPJRMdqTg== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 10/11] riscv: mm: Add support for ZONE_DEVICE Date: Wed, 5 Jun 2024 13:40:53 +0200 Message-ID: <20240605114100.315918-11-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044203_852071_D15969D1 X-CRM114-Status: GOOD ( 10.98 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel ZONE_DEVICE pages need DEVMAP PTEs support to function (ARCH_HAS_PTE_DEVMAP). Claim another RSW (reserved for software) bit in the PTE for DEVMAP mark, add the corresponding helpers, and enable ARCH_HAS_PTE_DEVMAP for riscv64. Reviewed-by: Alexandre Ghiti Signed-off-by: Björn Töpel --- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/pgtable-64.h | 20 ++++++++++++++++++++ arch/riscv/include/asm/pgtable-bits.h | 1 + arch/riscv/include/asm/pgtable.h | 17 +++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 8d860ad3b171..8a49b5f4c017 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -37,6 +37,7 @@ config RISCV select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PMEM_API select ARCH_HAS_PREPARE_SYNC_CORE_CMD + select ARCH_HAS_PTE_DEVMAP if 64BIT && MMU select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SET_DIRECT_MAP if MMU select ARCH_HAS_SET_MEMORY if MMU diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h index 8c36a8818432..0897dd99ab8d 100644 --- a/arch/riscv/include/asm/pgtable-64.h +++ b/arch/riscv/include/asm/pgtable-64.h @@ -398,4 +398,24 @@ static inline struct page *pgd_page(pgd_t pgd) #define p4d_offset p4d_offset p4d_t *p4d_offset(pgd_t *pgd, unsigned long address); +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static inline int pte_devmap(pte_t pte); +static inline pte_t pmd_pte(pmd_t pmd); + +static inline int pmd_devmap(pmd_t pmd) +{ + return pte_devmap(pmd_pte(pmd)); +} + +static inline int pud_devmap(pud_t pud) +{ + return 0; +} + +static inline int pgd_devmap(pgd_t pgd) +{ + return 0; +} +#endif + #endif /* _ASM_RISCV_PGTABLE_64_H */ diff --git a/arch/riscv/include/asm/pgtable-bits.h b/arch/riscv/include/asm/pgtable-bits.h index 179bd4afece4..a8f5205cea54 100644 --- a/arch/riscv/include/asm/pgtable-bits.h +++ b/arch/riscv/include/asm/pgtable-bits.h @@ -19,6 +19,7 @@ #define _PAGE_SOFT (3 << 8) /* Reserved for software */ #define _PAGE_SPECIAL (1 << 8) /* RSW: 0x1 */ +#define _PAGE_DEVMAP (1 << 9) /* RSW, devmap */ #define _PAGE_TABLE _PAGE_PRESENT /* diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 41f1b2c6f949..dd4d52940106 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -390,6 +390,13 @@ static inline int pte_special(pte_t pte) return pte_val(pte) & _PAGE_SPECIAL; } +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP +static inline int pte_devmap(pte_t pte) +{ + return pte_val(pte) & _PAGE_DEVMAP; +} +#endif + /* static inline pte_t pte_rdprotect(pte_t pte) */ static inline pte_t pte_wrprotect(pte_t pte) @@ -431,6 +438,11 @@ static inline pte_t pte_mkspecial(pte_t pte) return __pte(pte_val(pte) | _PAGE_SPECIAL); } +static inline pte_t pte_mkdevmap(pte_t pte) +{ + return __pte(pte_val(pte) | _PAGE_DEVMAP); +} + static inline pte_t pte_mkhuge(pte_t pte) { return pte; @@ -721,6 +733,11 @@ static inline pmd_t pmd_mkdirty(pmd_t pmd) return pte_pmd(pte_mkdirty(pmd_pte(pmd))); } +static inline pmd_t pmd_mkdevmap(pmd_t pmd) +{ + return pte_pmd(pte_mkdevmap(pmd_pte(pmd))); +} + static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd) { From patchwork Wed Jun 5 11:40:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13686723 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EDFC8C25B76 for ; Wed, 5 Jun 2024 11:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+GGZurKWnGwERCzVOd3pbWraCZ8BAjtRwGaIbUASh0Y=; b=XHWy6GPUeR5aEz T3eJ/hxKnKOjXdvVMjvEohNvFLXarljGAttqw0DPc+QArCwMLKUUgesY2uO4fzT8ObqupI1q/doST M1IJEiCSKQvxv1qoSYdqf2+ckFWkxk3IFw8ntqsw9tlC43WaqkjoHyaGw3BIdU5fZpZ5Vd/53LSxM b/lxBZw+tjJrhUWHMch78kvCxezpcP6Q4ExIGZNIuvLbTcWMzR7IW8jPv2XMYusT/5lvHjtxItybc oUydiVsXJM8pLjT3xLT58iZ0x11fwQPp6C+yXgBnAV/jg+dWDeL6kQ/6Byh4BTQpxpmsb69x0auK0 b/ve3ZkXAcWjGorD2EuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1x-00000005kRE-3MLp; Wed, 05 Jun 2024 11:42:13 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEp1u-00000005kMY-0Xw8 for linux-riscv@lists.infradead.org; Wed, 05 Jun 2024 11:42:11 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 1E518CE0EB2; Wed, 5 Jun 2024 11:42:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C49EC3277B; Wed, 5 Jun 2024 11:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717587727; bh=cXaL8X5xkqjru4qZvhtnJBNQd1jrCsGud/RraJezK+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P49tYTr8ENggo5fZvyKqZ4PxM1peSbHLq3cEfJefvxO26qq3VgrbD44w7SPHT1HkT yLZk4KJTmkXb4xi7nmVa9vtoQcspd+KSp86VRVE/N0ToZjrv8UmR3sqged4GllPn5h 5GvPvVSfGAeMGH24F5yZwuJ5PcsphzNqUIcASKCOtwEetL+b7w0teYBp/8DvVDy4KI evrzh5rO0PqNeq9Kf+oHWL+Lp3xUwlwdEzkfvR/QO6nuFAWCLeW2D2MUCFok7kI/s0 /y+gLAedifYQI5N+imnHHGNoDFCQrHDR/jrIIAKKecSFW6RBDuu4j+4/Tyl4w1ABwV fsHibJ697J1KA== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Subject: [PATCH v4 11/11] riscv: Enable DAX VMEMMAP optimization Date: Wed, 5 Jun 2024 13:40:54 +0200 Message-ID: <20240605114100.315918-12-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605114100.315918-1-bjorn@kernel.org> References: <20240605114100.315918-1-bjorn@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_044210_433033_38DE8E5E X-CRM114-Status: UNSURE ( 6.63 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Stoakes , Chethan Seshadri , linux-kernel@vger.kernel.org, Andrew Bresticker , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Santosh Mamila , linux-mm@kvack.org, Sivakumar Munnangi , virtualization@lists.linux-foundation.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel Now that DAX is usable, enable the DAX VMEMMAP optimization as well. Signed-off-by: Björn Töpel Reviewed-by: Alexandre Ghiti --- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 8a49b5f4c017..1631bf568158 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -73,6 +73,7 @@ config RISCV select ARCH_WANT_GENERAL_HUGETLB if !RISCV_ISA_SVNAPOT select ARCH_WANT_HUGE_PMD_SHARE if 64BIT select ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL + select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP select ARCH_WANTS_NO_INSTR select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE