From patchwork Tue May 21 11:48:22 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: 13669342 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89C3AC25B7A for ; Tue, 21 May 2024 11:48:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5CA96B0096; Tue, 21 May 2024 07:48:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ACC896B009A; Tue, 21 May 2024 07:48:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8060B6B0098; Tue, 21 May 2024 07:48:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5F2FC6B0096 for ; Tue, 21 May 2024 07:48:53 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0B038140A61 for ; Tue, 21 May 2024 11:48:53 +0000 (UTC) X-FDA: 82142231346.27.BC37DB0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 6562F180012 for ; Tue, 21 May 2024 11:48:51 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GXrl8c02; spf=pass (imf06.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716292131; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xl/Z2jYZBGJ5u6Vz8oQP9RZLmgParFb41gOw09Q9Sp4=; b=Mrgk6vCaw6t4Vz+gsr+dhc5HjT25NJpRfZPUQHOi16cRmY4f7+3D6EGQD6ALh7y2GVS8Mc ohzZdUM0ihHvZaFfWgG4oHBeaZtj5jjdCL77nlGejzfkuCWI2vXWT5qxdRwjoqd8aPAwnE cbKGgkfDJfiiMdmJvAEElq2Tc+GJ4Dc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716292131; a=rsa-sha256; cv=none; b=J47zBkC9+cki0bYqx1SysTZQysNnCOSW8rGVOW9oRW/L4pdvRjZUSNNuLyENP8v/aAhd/7 YaOE3h/10PLo81aAERSCibaS50i6pxZd3w5/Z11l8HlPyTYAoAGoCv43M2aU/RkxBAIPNr PPE2YKhtRfVVqkM7uXTFDEYKQ/AZh98= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GXrl8c02; spf=pass (imf06.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 58655621C6; Tue, 21 May 2024 11:48:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30B5DC32786; Tue, 21 May 2024 11:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716292130; bh=dNsU9/EzgA72vQ2DBRKYul88CUOKLAUu9MwoObC6yL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GXrl8c02sxRhi+iEOVG7cmPLve4hs9PdvC3ifTK/0ZJ2fpiI1XBIM4f+Tw1XUK7oJ E4gTG3lnIzNy0NnH7nrt/MisLxPNbNSdRPNHDns409n2DL9j/qql7OXIVmG+wbtrld Kjm+nN8ILu0EkFtcEGiGNyfxoJyIGgCdRUFHFljWi+6cXzT8JsNglHSC1kyO0Gjzvq TKOX/eyVGq0AbdiNIWzUz0oGDOjhKt/Mvsj09wXl9JKM00gjNZsK/YEwrBgqQ6GusU /dOVij7LrrF21Q72kX1xKptNkdTTAiN8fiiWs98gKQJ3bmwiqITGgPQJChzVFnhp2N k6bc9FLkN9NgQ== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 1/9] riscv: mm: Properly forward vmemmap_populate() altmap parameter Date: Tue, 21 May 2024 13:48:22 +0200 Message-Id: <20240521114830.841660-2-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240521114830.841660-1-bjorn@kernel.org> References: <20240521114830.841660-1-bjorn@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 9oguzbf1hcbm8q8e6dwtdqu7n517ndo9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 6562F180012 X-HE-Tag: 1716292131-935721 X-HE-Meta: U2FsdGVkX1/DlNPSIABmDNuw3Q4y59YQ0VdCbO6sV40vBPEfW21Qt27JydYkZ0z5QAzop3HOMlVJe5Lww354ciojsU4pU3irXXjMfBDoSCDEQdrdpXpDy+wDRwyZFIFIUemYXTlP2ZB+JK8BMCnxZrR9HaNaJK2RmuVvRTQIq4qVBaeLcoaE8bBXDhU9uFS+CxEgfn4d12l9HHP6QIFrvUed/F/a71GFSvYrNlq4LDDJMvrt4LrFQZA8L12vZMBXyefKUjOfBAwdsYbSrfbnREpDCqpNtAPS9jw6R9i91uv9mvOiWdP+qER++QU0m206arFjKDhy/YbvVlWnGn30+6T79NBGRfD2xv2JRnfmGsZAu/UBrgDjTZrOCDhI7tvy9j/TfUYI8Dma9uRLm/TrG+azohxjMoGN5t0BgeJLxl1ydL4uNeaYkLPuTVA98H6pgkGnQuTM0Q9IZmis/6N7L8vusleIgA6NhdO4HqM6+CHbCS4KzXJ8IsiIq+gz2cKg4JlYsF85APFqE7yOr4yC+zwwFgeXdxGFqROZBrYu0c37bK9ipxV/wscB286EoHj0mZXcapMcaVarD1GnF4EUo+ERh+BKD70ACV4Klw14lG50ErX7nRDIE8PJQLWQADghyeCPfn2kSZDe+bdnpXS5//kAtxg96WVD63WOf43FFZebVjg8jSlmQZRDnv75J7sLjCQRKVgI9os+DhObHM4jNRGVQsm5wMhhvEVngZfthCT28SpB3FtqL8ouI049OLo6j+BvI/cWmeJgRov2jF19VGUEh0EGHx+1S9acrVRzwD/awlS896Njpch3unBeAasCFvnJDKzUTSa7Eon+7BEvN3j/kfW/nY3qcgYRXVstkEUE6R4phWm7EyZ9DiNo9mGvB9DCR2r3yXZRJdt12xBe2L31C8E/2ieUuvcLOSFlVZYglSZGJdaIFpm2o9/S8ehyLZ9x6We7/xdVyOSzYVx QrGCq2yq PEGzzybQrIP4h/GYQS9N+LO3f+m+Kr5AGwAwYEnvRAaOemicZccuas/wj2onoqJJ+RhJbLUGC1XXvPWVSaQRQbmD1wicEX6eLzKY4mxBuZg9Q3ORnFrXxDC5pA3IsSvpdanf1Crcl6qo3/Mckx5pFKUIabfKrj0kNn+sIUvEYwE3gxJ/T5vPttzEXADCy95u1v59c5EV8PEQfgR6qjWR7E4gBatsG5mNo9QJ5cvvzHOjYRl2ysquvG5W+ZdAU7KisrB7wojIXxsb1uBe5DuTrvk49OCMfkeVRwmbxO7LhotMfiyZ0MGlidvfOyYVQIHuVcjdaGAJfKFZhSByCxFClVb0cfmOMhIWHMxYOjz45mX6wMzVJ21GrCT6fmLqUseDZiBovsOUwomtIYxo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Björn Töpel Make sure that the altmap parameter is properly passed on to vmemmap_populate_hugepages(). Signed-off-by: Björn Töpel Reviewed-by: Alexandre Ghiti --- 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 2574f6a3b0e7..b66f846e7634 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1434,7 +1434,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 Tue May 21 11:48:23 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: 13669343 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD4F6C25B74 for ; Tue, 21 May 2024 11:49:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5ED356B009A; Tue, 21 May 2024 07:49:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 598FD6B009B; Tue, 21 May 2024 07:49:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 436056B009C; Tue, 21 May 2024 07:49:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 25FC16B009A for ; Tue, 21 May 2024 07:49:00 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0E8D01411F3 for ; Tue, 21 May 2024 11:48:58 +0000 (UTC) X-FDA: 82142231556.09.92AD0E9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 609DF40019 for ; Tue, 21 May 2024 11:48:55 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=o5nLepXe; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716292135; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DxS7gl1tG68/oOAo3eCp2XGdbHDrgigFYs+jMjpC2vw=; b=L9qNxtU57niXzkpYJfe4J7PiFQh5OPiDPlu3sPRri+t+A5kP8AA/gFPcIDVNjmb/5WDuV+ Ax+GNtsmQ3+aTNYiW7mxGb6b5d1BbTAcM5QVLSeW1/I0is/rieBTqhD7jgCvZYsQHrFplO WwQBtJj/znISw8cExdfQo/gcl0OKTiE= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=o5nLepXe; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716292135; a=rsa-sha256; cv=none; b=buNT6eBggyaIX/84JnLPAdE4M4DbSdBpr4vROQYlZ3+k/pkIAVPld2IZdPjFNFoENjcsQg +9v5bHSZnYmP7hHbmB0zM0bJTDHUImaruM7d6IFXVqpI8rE/G2hA8zcDXammJ9BpEzkElD qeiPsZtMQDYAPPAmvJBTWcF1eYdEcsQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A15556220F; Tue, 21 May 2024 11:48:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1475C4AF09; Tue, 21 May 2024 11:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716292134; bh=nfJcShROxet1Zcs9SjZc/rXdynjgyC+wVMctU8YOdM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o5nLepXejKU2VOMdC1SRZPZvOZANI4opdVRkd8+TPMDK5sR0P07NwX2ZJc79N4eQZ bfaqTkEl6t3lFSwKwGIAvi6aKuwLCtjqA4R28DwMCONu+LBEGDp5huVkPzSrGGxpd3 eAcze83sdvqq0s5ijrEJlIMQhBoRLsPinLO1fb+pp/i5dnM4oCQdFZahjroxJU+tqs ZfAsw+QYO295mUt8WJNF8A1EuNCBtYJdN32QaUsHu3K8cxyCjruvL8/XB8PAlIhEie b/8oz9DQETq8tgzZZdrqszIj0S0PXOjWIcDgLIx3Il4t+3513huBPyuUBrwrHotznV 5JmJyHV48MBQA== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 2/9] riscv: mm: Pre-allocate vmemmap/direct map PGD entries Date: Tue, 21 May 2024 13:48:23 +0200 Message-Id: <20240521114830.841660-3-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240521114830.841660-1-bjorn@kernel.org> References: <20240521114830.841660-1-bjorn@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 609DF40019 X-Stat-Signature: xq596bjki556m99eozta8xjpu8s7x3z6 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1716292135-626117 X-HE-Meta: U2FsdGVkX19i9JevgD2TuCVFMvh0YDGdhJiFPrYfbq+gJ8MklcWB6z7K8ucZ4cZDQcgNTE3Cxd0aRxxUj+95v93V9rGBRWjQyPdvEWfL5hBhCHep6ITePHy1pKUTrQd/IdYY3tlRq4oACFYsEFfS5ehofa29k3D6X/VxdoQZSEwfd/cuaeVpgezScz5J8gxq7Q61N11eyX5A2/7I28qKysue2KG+/jxROOS3rpzsAucadHcHsDt0cKqv1BvhTAyE3mv737ZBZjafDcXQGCsri0JhBNGilq2vFu+dZ3kExGf/KVmCa8OMgf/4LT0mBAA/Cn2tGOMepYEs9UALlj2ni8pJIyo2xFfnf7C8hem6WqDNLgqO+DN9Omrd9+epaNAC5rYF2I/iIedWltJNgGRXrih0tyD1Zn/U/vhJC674INIgC06lZ5vGH+2yS9sbi/fwAORLSI3POPugtbQB+bPDR2Pc+A+Wn2Pxly0VXoWJiTk81qLtrx8fT7pp3CFXL1MsirBeqlHdFOz1v1hurDV7Tpn7k5bxzJOqtbMF2I7NVWeuAsa1GV7B3v3zeTFXdNo1J2DAx511qUDCBJWdXWGrUaPs/kstte4wOfIGhjwgUAWLrVl0cAUvVR96l3Gbc93GzHOsLA64qjIReyuWtkQL+nlh0pFjJSze0WagZsJVmd2sdoQ34IKa1ENKaDCbYE8+/8Xngo90Sl9jlVY9TOqmGI5TVTDn5/TP4w61Q3LtZZg//UySgf85IylB+QET0oApBVy3Xv34fqpT63CTz85iMkqfHVyDAYuvVUwcnLlr/TS7XV7Cz4v1zjf2oBzQfs+PYEr5sZNDxeewWbcFRZKJwfe03r8/Tg4HXQNvGxHhJSK4XkAulhR57VTUrGXOnd1+WGdRczbFmsTepckYm0T18VPewcYF2hqeBWood9Kp+9dpG+6WARbEne6yFRXFyAg4ntnc4OcsTM1y/II4c6/ GIkK7FYT f3N6H36QEBTf9msOsj2gKlnKM2KKCXRnUVWeyXt3jme9IGQYzN0c4NZUySqkso2lcxZNYtlif1rDhd61TOJWK7D988oEf91PBDUZ9g9QkYYjr649voO2WCNJJrgBP+9Uh4obbXMrbrsZUBXUPbSzEQxRbeip00LoPv/D1eJgygSrIebzHZMy77NSGUBD1gwrvCs/fl9XozqHbjZtEEdqbXKYhUrDMYdCiPBpDfPAbj5Vor3ULppz3YqCIYKNZtwUFboe1TQKMZSIipwLefg/f8faBEfHtZAhfDcST2i1z+PWKgmxuOB7B49g/OKRl/oxcoCaa8Aj0nTVDQEF7zop+A7C2AjBTGGSqpxZfDHCO/r+4wgsS+acHgcw30vZDdvTGYNjJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 entries at the PGD level. This will roughly waste ~128 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 | 7 +++++++ 2 files changed, 9 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 b66f846e7634..c98010ede810 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -1488,10 +1489,16 @@ 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"); + } } #endif From patchwork Tue May 21 11:48:24 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: 13669344 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7261C25B7A for ; Tue, 21 May 2024 11:49:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BA816B009B; Tue, 21 May 2024 07:49:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76C9B6B009C; Tue, 21 May 2024 07:49:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 596E26B009D; Tue, 21 May 2024 07:49:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 385896B009B for ; Tue, 21 May 2024 07:49:02 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9E1621411E6 for ; Tue, 21 May 2024 11:49:01 +0000 (UTC) X-FDA: 82142231682.15.9E05312 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id DBF5DA0009 for ; Tue, 21 May 2024 11:48:59 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EtdarXYk; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716292140; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sid8G4qK9ecWd/CGuaqXmnuXTPDqx1CpgeD1GqrGKQ4=; b=ILnZymdl4jcUdCfgOW0yiM+i/7w3k7nZxsLp/OMDCLrdcm/bkGaYRTgObECUZrJGrCXLEg uoWK0hR8OP3P0rYrqLb33ePDo4UH1qqGxtIZ1EK+juIcAc6mdcDr6wuDNfDrh9gJaQBN+C J23mVpE7mB1aOOwvK1zsacAMAsRQKGE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EtdarXYk; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716292140; a=rsa-sha256; cv=none; b=Sxxi3Z3tj1gI2IA61DVvBl/WuojZvC13SHk2aC/CW9c8C6lMtY8Q8gRGgQznw5RHSg+/Zb wlFNLeMQi/nkwjxf4Mb/jA1Y+RhsZe4ieSg73W/fMJxUIX/QNE5IgNtFjYaDGxKGHCX4Wn lM9TBLMLvjh67ErEBJji4UsIZlSbpV4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 13AE762215; Tue, 21 May 2024 11:48:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 065ADC2BD11; Tue, 21 May 2024 11:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716292138; bh=DyW6NyCJCRvw/wgT+8WCsVm6Sv3fnQSVUnww9+XHdH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EtdarXYkV3DME9vOo1G0uAPmao9Ep7FhO3CDDdIUvSEx3nuRwgv4S46uO2nY4T2FU YeGt33vbk2te65221+YRq/egYDqtZ6eBhzy78fucQZtK4W52ztIGQ5/WhcRsr1Nlju Qwv/qdJqaOZPH+pww3sKHzD7n4SN2EyuQBE4R9wvKDvotLBnsrbvQWAh49lxQ6cXjt wywCLyng4NP+pp9ETrxKI9oDwDRyWeOnsia06rJKFlIikjyrffEd3Qs7sP+1gTUsR+ qvDhvMYxZcVUmfiBhOEEfJFplGJ7msBamcfVEuyxdIz4ZSbjzxqvol954Hks91OGbq exPQiAZeHjeuQ== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 3/9] riscv: mm: Change attribute from __init to __meminit for page functions Date: Tue, 21 May 2024 13:48:24 +0200 Message-Id: <20240521114830.841660-4-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240521114830.841660-1-bjorn@kernel.org> References: <20240521114830.841660-1-bjorn@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: DBF5DA0009 X-Stat-Signature: zrqjccsoutbycycxpft3xpnwn8ijj1zp X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1716292139-988197 X-HE-Meta: U2FsdGVkX18kVDGn+M6ZqB6LYn+FWIXuremFjFgYhi03JORwHqdU6pJo1IYVLHazg6aKS7ULlXUv++uqeZ/p3up5WCZ2JEhGC63X81uzMHkix5vrs8AozVduUNJX1jX8l+lPPzax+APFtDJfITG/1sJh6BYr09qVtqgaK/h+4PeyM9K8cR2sQmOByBcArxhfT8eaO4h8F4odXRG+bJeVYIsYd5ZxHqK/r5MZk0ZJQymh9N2/HUdCRIckKpk/jvv4s1MqhYHydxQtKTOU8iBY1UFxYLDtsrfYyRj69q7zeGt7hmSRA93Ic9xBT8gJNfm2W4//XSlhXlqwUzNtNY+CVsEjM1sVuqNirqaj5/3CvWxgBAoygpUn4aqaHjM3IEoaq+GxRtKRRxonz9l8/M0IQ8wPL7ePGUvI2B7LQ/s4YfFpiYnQ8+hc31to9/Twf+zM834EMavU+s1WSQ4vKetCWql10KpJp0DRccZWguxKr+PB6TBnbapKRn27p5w+3hpWZEpPwzZoDtdBaiqPfdmaQoqwV+jSGiXU1vLtJD3X+5pYyJzcFXkrcMwAMKEnfenO8HEs0c6feAL5n/09bIHmlWoizWWX8zCWvo3x7Ze6xh1sC4sxySPoDAwRcfL3VSuuKyZXAj8m3OLqNknjVRfu6TSNuaI7A3HqtnY/ewBEznOQFy0490YNayajes/l60nnqqaqreVtjIoGGhn5g323/dt1VFYBnEG4DsIxpeZ9KmmVEKU3DtOFsvc9NPuC3/OGbSZ7Fwkz0tFb1t/5e9SiZhucmV8gz5Nks///6rxGCI/XLHhlN7GfSyEf8Q9g/ux2mwWwoGbs+C5qgC+3M7KofQ3wDzR9AlvPHgDUKB+2UsidbmKcau58yPVZEBrZb7NGiGaRz3IP0je8MNBH6bj2DU9s/ekGxJMhQo3pSFMjQYfVMgN6aVfi8zTQbAAMIFa5madojGaBy4gZ3hu7i9c jmQt8Bhx 3DZ5QIWADNBx4bIeH6aNi3XvJ2SkYTq1SeSrlMHELJZcJ6GZR4RNQvC5rNRzBaQvvVTJneFWdSPviVYitg+MsIbsm7VY2J0A65rjPMP+h8nl+x+qndlvKoogytBfWr35uNKCztPU329lBJgunlGDgH+Z4O5og4Yc15KnMqJIhD6Gt+7NMotpBdpBCuMDexwhzJIbkED5o2F/V3r9ZgD8zHggIfChsdnb32Xarz67K2U6Msas41s/1ypizZbztVNz3LYzfuDVs5g/P8s2CGna2fBT/wzInEVGuzjpo06o2KhIh8KRXIRuveTei+c/PV9ZAujusZBQlNe+hOJoCe4GVolL/3RI4iohTM7G3ONU3NyFY3J1V5mGxbnqLPxNjLIRUDvzBFoR9Yl+sdozuI6Y4D/RKqt03kTqso/Bo X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Björn Töpel Reviewed-by: Alexandre Ghiti --- 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 58fd7b70b903..7933f493db71 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -162,7 +162,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 c98010ede810..c969427eab88 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -295,7 +295,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; @@ -357,7 +357,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); } @@ -376,7 +376,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); @@ -384,9 +384,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); @@ -440,7 +439,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); } @@ -457,7 +456,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); @@ -465,9 +464,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; @@ -503,7 +502,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); } @@ -521,7 +520,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; @@ -541,7 +540,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); } @@ -559,7 +558,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; @@ -568,9 +567,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; @@ -595,9 +593,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; @@ -653,9 +650,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; @@ -680,8 +676,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 (pgtable_l5_enabled && !(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE) @@ -714,7 +709,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; @@ -739,7 +734,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; @@ -1231,9 +1226,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 Tue May 21 11:48:25 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: 13669345 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0381C41513 for ; Tue, 21 May 2024 11:49:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 570E06B009D; Tue, 21 May 2024 07:49:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 521CC6B00A0; Tue, 21 May 2024 07:49:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FF4F6B00A1; Tue, 21 May 2024 07:49:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 10F356B009D for ; Tue, 21 May 2024 07:49:06 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B8232C0FDD for ; Tue, 21 May 2024 11:49:05 +0000 (UTC) X-FDA: 82142231850.16.40C5496 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 31DE81C000C for ; Tue, 21 May 2024 11:49:04 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JuFto51Y; spf=pass (imf21.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716292144; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KrhY5+IXUY1q1Rops6fEj8P0VRbkM9gC4LVl5Q7HPdg=; b=uqPqHFNXyvg0A1XIAxeq7Hp+w993vth8HlapbjDO611cjd7mTCwmAsXYlD4IfXANx7nkbg NZ9xccbQB4To3R/bZX15hGpuE0gPVI7/jKWprMfylbbmL13BR6lQpN1v6ZHRqzso1Sv9Ak fWXCpe6kD5SkHiZr7KTByzdkpEux7D0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716292144; a=rsa-sha256; cv=none; b=43EjOZQrakb4dzVpemfBImoUlPtnlMKaSlcBDJEhtIMlYm8i6cS3bXiPO/mwf2HYsX/RqN KUlxAKU7PU46MwE5VDorqPk4OBcY3rlnMoOPV2dEl3pe2vD/8a7Ia+66w/aTwxv3g/5M39 o3jdiVKccj6lZq9ri5jhpC+dLeoOjek= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JuFto51Y; spf=pass (imf21.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 71891621B6; Tue, 21 May 2024 11:49:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A029C2BD11; Tue, 21 May 2024 11:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716292143; bh=OVWdCLBgos2+PxBgxUayZBCsMHg1Thrc2DYHTXT9Xk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JuFto51YhlnEYtIE5p7m81bgvn/FesIVCWWQrgta9FQ3B2VFM/MCwDRyv7PAP2PlM OcGLM/qjlm9yHvJ42jxE/UVj9EaiKy4E4zOVTD7Aea+fGMPCYzFxrVrBmSXy/h4HDF t926Rbef+QZc/5v6EBJZ92qopYPJAzrENcM/2kOdAKCneRJkyCJGk4uZ6XvWBnWTNY UE0khZMgvG8QpNoNPeaJxOTsVFSCWY8XS77MDoU002hcPtheNG1MeEYymcH5WPgVDs MmithN7NtP4w31zwP1/4w2/Ea+uNEwNZpSwC/G3ClsBE05NPIEj8Isbdxl0d8R08Xw kjhfVQUKhzJew== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 4/9] riscv: mm: Refactor create_linear_mapping_range() for memory hot add Date: Tue, 21 May 2024 13:48:25 +0200 Message-Id: <20240521114830.841660-5-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240521114830.841660-1-bjorn@kernel.org> References: <20240521114830.841660-1-bjorn@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 31DE81C000C X-Rspam-User: X-Stat-Signature: w1rq7sf64cggcbeuoj39xb6gcjtknd5y X-HE-Tag: 1716292144-73559 X-HE-Meta: U2FsdGVkX18Sh0B87QuNqix8D7rh0LjH19QnLoYaFAoDEfiBZu6oBi48OVI+NSsjMEMa1uyhs4TKReqpQcpUmZYbpQlTFTwhksG3cZtCYBFnyeVoNT3JPXA12DAdGlx/kG8u7mQ1WFd+kDWXfUSo0zkhFnZ3yEosQC8EMjfdfOI9yPi/tUyu/0gpmuU3hrC8EyuABeWFX68D8i3t8l1l8tPssFxTJpMfWfHNTD2bkcfgq3EkaORK9RlA091xRhiBrHRTrxvnD2SAceE+vcxIZpkZ5Emx/WVCI4XS7teqgXfJ/kCzeV5lQSCSOsWDVaxWT3/N/4/QVCGZpczVJzt68hZEdX0gwNdaHJ6S4MJ+IEmDHUPKCPRLDwxYrE6Nwnlxte4h+ZkKIYYZpxk+RYMOVemDxrOxyDNYW/b/u7KbaH8kF/HGOppdYkrDhWEfIg8jH0qOHCKHlO9Gja4iZPEZmK6TLl9Tz0w1NPmbKeK+KawZyDLk5cy+0QNXJvySfPCx6QECxHHsyp8YguY5yD24bl34N972am4JD8aX6gVfVcgjs2RWOZOiq0+MZdsk2P/WXDnjoQZwrMr1UJaTxUKDewRLLU1WTTmfmOHbWbR4b3XciNjVPOYH5Z7IaWgd5s36s03GqD2CdUdaYxQfpwkpK9J26VxEmwaBFNJ67d8oUa7zBB4ZPeCUrXYqmPOhVIZjUWEiPhLrT8V3blDcIUSX1Y8hytiCDzAUWI7jjZDhHMQoSA2Q4nJJ2jOPY4jUasEWiGdvksLN3bA4/XnRsDGSkjyTOo2cG8I7AvZkMAzcPtm5ddiWz1ML3lWUbmfJ0ta13DlBAPhtsK6rAZu9fbdmn6ypHASL8tx+uS7yQAMIgF5mXXVd0aFR+OtfAoVuKoTxjoib9ACNgUxgrmpe/WitL8WvTbbhMl03XFi9bd2JW6XA+RdI2lAaQ/rRTXVGFE40mtMa22VomkBSIu1AdF8 hkeyNplT 96l5HK91vCMb6VFc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 c969427eab88..6f72b0b2b854 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1227,7 +1227,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; @@ -1238,7 +1238,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)); } } @@ -1282,22 +1282,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 Tue May 21 11:48:26 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: 13669346 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DF0DC25B7C for ; Tue, 21 May 2024 11:49:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0416D6B00A3; Tue, 21 May 2024 07:49:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F332A6B00A4; Tue, 21 May 2024 07:49:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFA9D6B00A5; Tue, 21 May 2024 07:49:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BF1636B00A3 for ; Tue, 21 May 2024 07:49:10 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6240541168 for ; Tue, 21 May 2024 11:49:10 +0000 (UTC) X-FDA: 82142232060.11.741CB15 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id A40EC10000E for ; Tue, 21 May 2024 11:49:08 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UzvEzHHe; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716292148; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PzoVN0O8QYKhz5+OZLe6l2232w+6FDwpFpJ2JeqdSRI=; b=SzFtFqKfpp6QhJfiHkw4k/MS9EnT2Nuoy6MA4YWhctv4pmA0zdD7YaQFgPne3PK+Arwvgf zGfDFZWTHs1/TXXGSFyS1P0bhM79Wn3nwFs50BdkWqFJCDryXMyjiYazp3BcDcyJWB+/rc K13zr7URzq51kquzKWUn85CEmiHH2cM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UzvEzHHe; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716292148; a=rsa-sha256; cv=none; b=fSlmprDVpoh1jmnZOaqsgyoXdpZFOHs7GA+Sn/ml035i9EfbIH/gnCev1YnLHQadLs4juH 8v3dJfGw/AK5BLkM1DzCmkvSN6B5BKFnCDIc9uVy3S7/nyxz1MBSzt1dm8GnwLXTkTqeJM HvxzN0KCW8IQNG+bYherm7LA8gCVs+4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D3FD462213; Tue, 21 May 2024 11:49:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC39FC2BD11; Tue, 21 May 2024 11:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716292147; bh=YmNQGTYS7tg+RvjQBa8mIUVU0Q8jznFPplKEu6+/K8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UzvEzHHexF7JresSjbUV+sseX7MhZnOt/Q6RxfcvlB4jlYBbvS+Mc5EYr2OPt3w1n VnthCTVkILvDLIi1nYESspY9tZiEk/S8GdRdvBNtYuxxGJgGKsmeVaJ4NdBI2fjNpL O4lr9BqHQjAn99ZqfKqqrd8aspSj2moxL790uHQs3eJW+b7TxXtKU8u1ydUEtbB+SJ pUsoV8TCLbwqbeD5kw7g+Jin6DjIO1XOT1XywHo8E6kMryiVfWswgG3ubvVFBby7xy B5SfqddkJ20baZ98Z3B4D3Kkq65i2wxIOluwx6t+d5EhaQjAj2Q9LikQm46I4C6dpm fz3dUdiRyl1CQ== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 5/9] riscv: mm: Add memory hotplugging support Date: Tue, 21 May 2024 13:48:26 +0200 Message-Id: <20240521114830.841660-6-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240521114830.841660-1-bjorn@kernel.org> References: <20240521114830.841660-1-bjorn@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: A40EC10000E X-Stat-Signature: jkk3o7onyz6i7wok9dfz4k8tputn8pn8 X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1716292148-336330 X-HE-Meta: U2FsdGVkX19pvPNPul0d1t8bRFWaxgWPRadptLlWZyKd4SBwd0qq7V168uLEOIy++bmB3+nP2xIQDTeJV3SRB1Yo2vLXB4X1qHZG0EEoBhGIjnxF61mjvjG1hGvO0TvdMbXfoFHo4QkL1mFmSBepLZWbqQMjMCAkfc4sKXGZftOpLD7zh+ZIoIiuey9klqvvjcdtZv0ygFSvaYUmXwycA7tktYXP87NCOju1dyLDi7LnMl4oMZRAtHPVSbvHecZ+DADv+bTOe/Ih/h5cafTA2pYbhthMdhaUPqGzxHRiee2ytV6s9LXokn/Pn5YwZV82gthZuc6lnnWL2M+j/3IGGJkCZ+VecPNoiJ1JfO+MnYxMm1jEn87FpkmJ6NlWHokxcNSF5hGHyU+vEBOJPkGpRfxZabxswxyYFz+UT7M9j497NYYVv1gO/ATIVgZIAqfTW5OBJpgCdsyJOZnTgHnIcClwkLx3zhs9PLKxutJBFfeTdQCIg6NIq9eGRIiZIUXgjZSbW/P6jtoTQBL6IxcHO9Iygcl80t7fZ6tWKMDMSE8LzAfa/OBDax071VofVhobLICR6yXZShwYB3dIP79ReNdbQekAjZtaTy+4O3/saHujQTN06CIlNNNlJSxK19lYJebnZRYiEtSlFfe+JiXBsg6IECgjyBhO3dA9KycRFBGklG8JC+zQPI+jbtXQw7F70q54NgQtdInCQsWXxytOGXvhvZ77OVHj2qf6dcW+X+zoyb9CjK/bx/aO/aisHzu86aMF0JFIDskbdFQTUOZ3ovazMsESxlHu7EHWeEwJz/YzaS4vHdDgtw4Xm0YL7CYxXeJaX19+KK2ewkoR3egYvnR5TU5EBxHnwDSnX2WGG5L5K14Sm8A61afJeJ20EfDpB+8/EbyWCD/Mljf/7sLnmzqtN3hs+xNVk9S1dpi0fD4Chg+vnupC6/siu8Uq9Di7/AzfcLn9Cune3X87rZc V/YkgmZ3 el8q8PH2x5Er6yWWnEoDqzwwBL4GKCuUttXeZMG9J0/GiqiVcZ/JzuDDEQZb+bi0aSd09BtkrPRf81r3xoi25UxUi6nqFGHlR9Gjv9B11h3hQ5Un723+19yAIOv4tP7kAE25eNvlZO4r1nXxgspn8gBRR0mwf1hZbvH1YplZQVLbH2dBOKPsHPtLZYoo5CQ7s+XjZtstRtM03shOnygqQ11hoUMvMfSfaQpyTOeDLkQxO65Dag8WORVosQR3dkKO/1mu2sTQK1FTQ22XfszO5NxgcZaNL15A/QHj1JqbiW143iMuS+gdXs+CZyMd2Hx+5R1Ug3NgP1FomRUKaLSYcOzOsQ1YMD6+FWilP X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 --- arch/riscv/mm/init.c | 261 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 6f72b0b2b854..6693b742bf2f 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1493,3 +1493,264 @@ void __init pgtable_cache_init(void) } } #endif + +#ifdef CONFIG_MEMORY_HOTPLUG +static void __meminit free_pagetable(struct page *page, int order) +{ + unsigned int nr_pages = 1 << order; + + /* + * vmemmap/direct page tables can be reserved, if added at + * boot. + */ + if (PageReserved(page)) { + __ClearPageReserved(page); + while (nr_pages--) + free_reserved_page(page++); + return; + } + + free_pages((unsigned long)page_address(page), order); +} + +static void __meminit free_pte_table(pte_t *pte_start, pmd_t *pmd) +{ + pte_t *pte; + int i; + + for (i = 0; i < PTRS_PER_PTE; i++) { + pte = pte_start + i; + if (!pte_none(*pte)) + return; + } + + free_pagetable(pmd_page(*pmd), 0); + pmd_clear(pmd); +} + +static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud) +{ + pmd_t *pmd; + int i; + + for (i = 0; i < PTRS_PER_PMD; i++) { + pmd = pmd_start + i; + if (!pmd_none(*pmd)) + return; + } + + free_pagetable(pud_page(*pud), 0); + pud_clear(pud); +} + +static void __meminit free_pud_table(pud_t *pud_start, p4d_t *p4d) +{ + pud_t *pud; + int i; + + for (i = 0; i < PTRS_PER_PUD; i++) { + pud = pud_start + i; + if (!pud_none(*pud)) + return; + } + + free_pagetable(p4d_page(*p4d), 0); + p4d_clear(p4d); +} + +static void __meminit free_vmemmap_storage(struct page *page, size_t size, + struct vmem_altmap *altmap) +{ + if (altmap) + vmem_altmap_free(altmap, size >> PAGE_SHIFT); + else + free_pagetable(page, get_order(size)); +} + +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 = READ_ONCE(*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 = READ_ONCE(*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 = READ_ONCE(*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 = READ_ONCE(*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 Tue May 21 11:48:27 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: 13669347 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4780C25B75 for ; Tue, 21 May 2024 11:49:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 411B16B00A5; Tue, 21 May 2024 07:49:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C11C6B00A6; Tue, 21 May 2024 07:49:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 288526B00A7; Tue, 21 May 2024 07:49:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 09A316B00A5 for ; Tue, 21 May 2024 07:49:18 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A7BE91A0C2C for ; Tue, 21 May 2024 11:49:17 +0000 (UTC) X-FDA: 82142232354.30.B643E4A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf28.hostedemail.com (Postfix) with ESMTP id 9434AC0014 for ; Tue, 21 May 2024 11:49:15 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QP7xHTIr; spf=pass (imf28.hostedemail.com: domain of bjorn@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=bjorn@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716292156; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BuXuu2bnylLUwFqILrVy58O+7c/VMKIWm9IXIjW+NvY=; b=R7Bxb5XQdjDSuGQmw8aFTkJ2iPrJh3lF1mMhWSbWEAzjtuE66QYV4tsPEd8cTNFuiutLlX n9JPd925B+YNliuB+AFnqzso2PLVf2RWw4wGaQv9souC9wybkumUOq6xjsJyv3zfEyw/lE uPY4qNvxL0iyv+Wxj85QSC50SaDPHMQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QP7xHTIr; spf=pass (imf28.hostedemail.com: domain of bjorn@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=bjorn@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716292156; a=rsa-sha256; cv=none; b=dOWt8EFlAFb3WnPNVmf1Lq3nKSRc1BRUFSEJYk6UhARw5JmKwrqskwbaamQ7DRJ/7R36Vo DTk+CmejoIkz/5iu1mSDyGRo4R05gbnCGs8BfBrB4XLpFYNs0bvYJGQ33cWwRpMFG0MBkq 09bv383bQJ1uB8HVvz8MyieuuTCIUdM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9F1EACE0FAA; Tue, 21 May 2024 11:49:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07C0EC4AF09; Tue, 21 May 2024 11:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716292151; bh=zdSV3EpJ/CKXjaWQ8/cD0+JOT+VH5rhvpIEde4YPaWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QP7xHTIroKWAL1koAwZ6jjCgJLvRHG023RGth9xuUk2aAr6xVwWVLbscARU+Pv1ub rE7DpLmED0b0CVDykMK6Zx+Q7jnCMVy2PLYf754MVZMJIdV0GVpwGIlm3I3gUCQ0Q6 2H95BXA0It8CFEHUA2Cu/eAEMYUpIeaDtiemAskbUWoLdUlQdP1W1YSYtVV7ha1mAp T00CEcLQ7pEpSb3jAdqZceJbTnCXDIJ0KCDyF2nAHBRoyXITau6AkUfMqaNoMFbKQN QACCVo7OV9T3gy3HBJuXXKgSubA2i3XC1J2EvODkvPbaXRZ/G6/pdAH3MvgRE1voV6 WqhaCAyjmm6LQ== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 6/9] riscv: mm: Take memory hotplug read-lock during kernel page table dump Date: Tue, 21 May 2024 13:48:27 +0200 Message-Id: <20240521114830.841660-7-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240521114830.841660-1-bjorn@kernel.org> References: <20240521114830.841660-1-bjorn@kernel.org> MIME-Version: 1.0 X-Stat-Signature: qcys36i1aiskw4nmj6uum7zofr9jk69j X-Rspamd-Queue-Id: 9434AC0014 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716292155-535979 X-HE-Meta: U2FsdGVkX1+DsKdU3i/9/xxFFY0upfZnCEwKvJ0ztigKyLXTh00jatJoUjwxBj8AT+42kh4TtvMTkBYmFccec1PcOFom3uobqrxXl8g/aoq/WdMkIGE2CvYf0h6CQm4Pd2mkYGiec+x7++f+7xs5elZdSaxQgi83tQOrUQcTOBlE6oAoynrWcQ/L1g+4gVsG6Hyr6pTxpz0R3ojqLNmzM1Zlzng8q4CSPn9uCy0GELkzD00cKk3BcGhBePQbMscpHlVmXV43o3nknNf4sAKK152kI+16hTYIRXheOSiESSotE1EHsj2DlpSNHCbgXXvR/4UOrS02bnweK/9sFRc6/tUR4EEhdo5AUOLXDBK94EQ6z8zFMuuCLClrZc9f4IMwTb0HSzbb2pK4i3rHxQ3koY+hjalh+90y5yrbespak4lZHFo6k8COUyGC/d54iY1v2hpVdwDFXMeA09cqpaHh+pGQbG9g443VHNBI6qpzvrYO+/z3o5evrN0ME1yTM5s9dy85OiG6Iva4s/y/QBH6OG0RIRJp6Ni9RM6DWALfC3rzr1DY5JeGrubPadtWxQqcOkUaUv3gAp1oDwMc1aA43k7/eIHlKhDxoZUzaEh7gAGBvbGSxvbCYvNAPd99akmuUAJ9fKRvax6HDkW2vffZpDX1y3PDfnOowPgqE89tZ/1aGmU2njvWavLqU0G33BOBAEow4kRhGjZAHHVk71xeG6QuyqqUaSYFk26YIrsCTL9tHnm/RIr0utwZZnZfdYuEZbIhR/NLjDXkl+mTJjJ4xlAwH+eojRv4hMPT/BBrRGSaPXuBkbtDIyLIJLz+Wc6FiLQ+UV9Qunf5z3a4RbHZydGWfFWvN1NCmbr2VdrW6gvJjh5ujVRvqh9LM5uBsKZgXFHJy4sx+teR1GBBqn56FT8P0r00tSHCmMfO4TgeOBZaZTw92ewqd4v64d/T490QzY1mc1XQfgMEBVCk1qL UuO9ItvR EzSNmP2OXhqfHTI8gOp5ZSPx/fM7Y1ycIhHDxBlLDPf/mTKphsquNZTVWuX/EHJXGXuO37GTf+VILPjMJerN7AbZ4b0MRfqviMpxkEHa/CSAxu7nnmY3EOg4tECSGvQFZbo/bKS+L7/Q8JrYwkQyhm25q4kESElHtAyPxZyYu1gDF877XR02GLc3qnU+2LWpWUVhSt4ybt0QgObaRD/rLNJuifOVuySjY/8PiytwBdCuWceuVIrHHU309umfpOJjVvdk9EDNGwHVtRLJCpvAtp0JuQdqQ3509RrHRqfO5xnbLkRWC01VybjKH+oDknkpMiTvxCg2Yr9BsRUNkfnjqwjUMjCWL2lvSlFW+tUw/pHQP/t8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 Tue May 21 11:48:28 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: 13669348 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71F09C25B74 for ; Tue, 21 May 2024 11:49:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DABA6B00A6; Tue, 21 May 2024 07:49:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1781C6B00A7; Tue, 21 May 2024 07:49:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0185F6B00A8; Tue, 21 May 2024 07:49:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C66436B00A6 for ; Tue, 21 May 2024 07:49:18 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7BADEA238C for ; Tue, 21 May 2024 11:49:18 +0000 (UTC) X-FDA: 82142232396.06.16B712E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id D191510000A for ; Tue, 21 May 2024 11:49:16 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UEzghIrA; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716292156; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DGC1ckiZkCk/XZCjCVHkpwlmQjUt2YFRxuhk7fYc4O4=; b=zGk2clVLYLYLhO7WNIeXBgkacXHIMDA6kA777CnWagRjYDAYRl2UT7hLWO6PH0KSVX0/fB 7nnzEmuGHKdbvfZdHRzF2oM7bilhSf5MqNnhNeXwPM+e0RoQ/8pXW/wwGVXe9f5LoP7OBU Nn26JyOAnenR7aHhBmHaLUghKjI/z1g= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UEzghIrA; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716292156; a=rsa-sha256; cv=none; b=VYRBp0/lr3mlkLXuxzDRZDVeE5a7ncChc1ZtOW4V3y6YCPa5q/mvuemR/HlHOfyljjKXio oVnjmCmQnAMlw2y7y5jU3DmYPI34c0XjC56Y9jmYfzgd3k3T4wUjEdKE3Kwkx07q9HvvHI cSyjOXGmQGWXjrQB0rsX+gSIw1N6JLA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 20AB662213; Tue, 21 May 2024 11:49:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3296AC4AF0E; Tue, 21 May 2024 11:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716292155; bh=i0Ih+w27uGb8ApwJcyy8K/wXBEe5AomGLiW94Z7779U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UEzghIrA4Xj8E+KJcv5rV4Fg3OTCWpAUwdbjYoPWT7gVOSRV6SQWe8m/tqWm/Z9j5 LOq8iVVDdA9rPeFRqn06kyALX/Y+uzSJpXu3xND6BGYItuRbp/7eyMzvWoJ0sru44g x4d1w6d0UF1SDAapeQK/4zR5j4SC+2FuKlwzMgObcR/47F8hL81htaSV4Rnu0ZDg4e fEo46pfirWJf5acsZojEOXkrupLGS8O0Hsh4ukXb9lgUJXlztR8hWESUBNwCG8lIb8 KgEaYeUmtF8QkqoLyQKmF8kJUAICzjbt8epkz2evCCZ1IFxRnNAHVmemOu17uDk2yJ LmoRZmxGAxPhQ== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 7/9] riscv: Enable memory hotplugging for RISC-V Date: Tue, 21 May 2024 13:48:28 +0200 Message-Id: <20240521114830.841660-8-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240521114830.841660-1-bjorn@kernel.org> References: <20240521114830.841660-1-bjorn@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D191510000A X-Stat-Signature: 9jffh5pc6shb4uoyo19s1yoeewqij6gp X-HE-Tag: 1716292156-556827 X-HE-Meta: U2FsdGVkX18qbkBJLI2ibb8pBUnqhqdPvMEdpvZinVGg+48etmSp/UkW7HEcBIKVDfRb44NXeuVYCX5fZdGnFPLjO4O5CAckyjXT03bWVTF3kd9UqZ5kUJtf01/2zzKTl4qnfcETw2feswho9qMP0zgCiOTnXLDTA/oUu+E5Ex6QgPQrPsdjv8VYG1rZOJFX+cPN/LkHxDwTY6wkyy3Tgv0IOkkI0W2hCvw1WGCGjtdMs+0CLLz5I6r8A29u/VKvCbVuVBiM758mx2s+o1kfKKaNZbF74UO5NZCGFLX/MkpSZM1pVa69/+PsQOqdgvPabUUPix+DUmWiLIDBgOAxiSvOPUA6mwYbvwJ1+znHG/Eoczy4gvJ15p7AmvNIy21Fj0ebzv8qdXUOroovOHKhJPbf9/TOvBIXaeAE1wyDDUkMtXoyMHtmnwW58qSXUBc4qn+ik26/CFsgNmHn1ow+bTYnixGT3kMVXHvbn+ekoGqNtBuoy+YWYhK4xzKiJ3OOCYhCvr5l/Gk4dDP0wbOkITtdoeEHMtrxPXdrKPcwj3ZqTapQfYwU7bCF22Rbyd2kHLvoJEdaTOMLZufZfXJWhJ+pWzZ+I/3xY1DYUpIIWpd9lfX6i1CPIZ7TWn4WdbPNJTdhAgJhIxzjcEACHoAJsiIFXFwMWY36o/uAtmlulhdyKo6jB3SPRx/cyw1SYbT+BO7BNOZZS6aBAoPdNnyn8c1wmp6BRWsKQDeJJ3xr/4Get3dp6OsTFxVUpUCjhZQWjckl4Ib4+hS3AT2WgPwwGxecSmAqRAPDrcUkwMr1mOMUr/+vWh6tVxMcbtWbddb+3b3cPuBlVE+uchwK2Psd6SPNmyOm93b3lexTxQjyionrzT6N/Gm+TCgz+BtoeoZsEZWOLnDj+HEDraRb03hQe4AHslsUXN9cqNSGMhMDgOslJ/yJgp4nbRMD4hJalrxtvP+2tCmU8PHn5YWFtgF 1gvvUaSt 63ThQlMAbKQAd36ChvS8Bycfalzot4pav1mJDonnl9+BwnBl1mpTKr7N7ElAAPdsneFtLt95ynMtJWlibqfawtT9EuWZchEtKGgFLl6+sBaQxH7w3LkDIanAvxDo51D0m/ay5jRBQ1DwYQXCqn+8c731AYrbi0iBrnAGz54jmhq0+gSiiO5t2fe6ssgmLdVj3dO6qs9HpJce39rTTNu50SHuyLjzslD74tYLNSc2dGLfkFxzel+o5ouZX//5TdkOggQYXlmikCrok5XrcnoTJsfz5p0SKubZb01L+cEyHxcYkSI+//aLvVeLSKu5TYlmf0QuHay1KgN8CqTi3uYU9K86vN347SxlwtQ7h X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Björn Töpel Enable ARCH_ENABLE_MEMORY_HOTPLUG and ARCH_ENABLE_MEMORY_HOTREMOVE for RISC-V. Signed-off-by: Björn Töpel Reviewed-by: Alexandre Ghiti --- arch/riscv/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index fe5281398543..2724dc2af29f 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 && 64BIT && MMU + 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 From patchwork Tue May 21 11:48:29 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: 13669349 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B16BC25B7A for ; Tue, 21 May 2024 11:49:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 91BDD6B00A8; Tue, 21 May 2024 07:49:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C9E06B00A9; Tue, 21 May 2024 07:49:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76C506B00AA; Tue, 21 May 2024 07:49:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 577FF6B00A8 for ; Tue, 21 May 2024 07:49:23 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D5893A2845 for ; Tue, 21 May 2024 11:49:22 +0000 (UTC) X-FDA: 82142232564.12.137F3B1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 609E312001A for ; Tue, 21 May 2024 11:49:21 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="AE2HJc/Z"; spf=pass (imf29.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716292161; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nwJ4aXs+ERuLBNxuA94tgfXNhGxtO3GUreewZzvflrg=; b=BMd/MrQ0rUDDre2VtA5mHz9tpcBDYiowxE6bYpdlMerZKZfEkSotobGPc2nqnKe/2GC8Kt Pw55568Kzmp9iwhrlfUyZBVysQJx1t7gos3Qd3wQwTlkTUySuqc6pryCtcmvY3OFBxJYOP A7oQ/Zk9ii5jkz1alhNGO80OEGRVOcM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716292161; a=rsa-sha256; cv=none; b=GTWL3vXfFgLRJ66ASEKXZ3ZnJ+uiafeHAezbYoRs2dH7VIzJfjlnau9geEy+VCY78HEQ/r pSObx90IxXEIfGC5XUSADdU1O0JI9/0rh+dKajs7o4fQAJ4tY3PuX0l17yUYC853qi3WXP /epmNLZ8lGyLjyCV1+Jf4hBKmGkJQJo= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="AE2HJc/Z"; spf=pass (imf29.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A3ACE621B6; Tue, 21 May 2024 11:49:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D227C4AF09; Tue, 21 May 2024 11:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716292160; bh=kYHsD4H/RUxm26ELjeG4CcFUjPg7NPg0mup/+DL8qlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AE2HJc/Zo839RiPkn077HFAru7fuQ3IdqockYIAAK4zrgbbEvq7k/6D1z1skg/3ef RBh4dJwbAkn6gux0u6dNld3GBZYMx2VqFWHEMI0zvFmccCkrfEHAR2ddpZ24phAuqa mI0SCQ+ctgny3cFlc2/TsvQRGX/sEZoIceuOrAT0CeIc90szt7ePzoutW/5i4kLtFF qDWUDAGevJg9PqJeLprnBHn6L2mH7CMZnVN2piLag+A9h5W2rL/rpWPDEtL+u7oND2 9e7GTMsDYuPcl9ftqfNlKcpfbLlW30egyyPtb5iTFjfLza91IxsO77cTeetIR+UAPT cyOonut+Y4MSA== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 8/9] virtio-mem: Enable virtio-mem for RISC-V Date: Tue, 21 May 2024 13:48:29 +0200 Message-Id: <20240521114830.841660-9-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240521114830.841660-1-bjorn@kernel.org> References: <20240521114830.841660-1-bjorn@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 5sjmzn65ekp6fnbyp777htkudsmmqf6s X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 609E312001A X-HE-Tag: 1716292161-471608 X-HE-Meta: U2FsdGVkX19ErtIdEa/Rzyz4nSS2gP/bLk+wq4U/Cox4Pfwc+LquWxH4i4EwKCFgji7ds4hguZJtzr6/zfaVZ/hp7rSl9wa8P3u9rnHOTSZAY51KTwHDWAB+jW/nJVX/xcVdcXWnbHAM77UOlRIVp6rMYWavEvD+N6ujd0Khw91DbfFspNcxSi39PNi6/sDqIOJAz8ujYcMFJtu3CgH0ykg955/lb8ZB5NwSW3ml6C9KSwOjdK4aPEHgiCINs8LsSBCYFdv5jeFi7TGl3oqccTjJnyB2l5FhHqMANbQAYNe2d3NY6/93BSpd7/6B34pp6fXdI8shgHdybkxz0luZ/5yVhjLV+y+6pWDVx29nIX/KjmSzSQseQ5Tpiphcn9DH8HFbglQdP3cmDcQ/PzeGTnT4FdxIRZR95faT8iv3wf9cuvlCmJVbyreGBlC+u2Kja8/mEmPqtgpIVQoj/lfKC0YtKMvKfQ/6nsrNzObG1oP6Gpi1/GpXh39swgeOcR1RWTQCmwtGH6kV/KMNS6/4rp2GR2wPIL+Tye4uyYIj5WE11/PBB5KgAcxmikYCFnYOjGhCGSUL7vHJtrp9aG6scpdYdkEHRMGFNdUOX+X7js8D9+3uEFk2vXbkiJlSdRRLbcmnOg5yHMYmy7PwZRSQV9yvwj0iuX6SxWY/ktYt1A3tO/5piCPhCiMUVEUA3UX2O7dstfMUbNZSA0orLA4ylmLNJUP+K/YlmL+CmxTm6L82c6WucCYsQXuRhm1j6LaX0aDmyU62jDl+JKQju9YFpuv73DLOl5jSKNfnaWnZC5lhKJqW+Q732P6flbUHmUvz6YwdmWoW9kq8vqcNdx6PdsLth9jcXbidM/2OaIFujGj343ikKO1jAgMXM0W/1R9ytNg6ytn69yqMPfJROfVw2SpxZWuhC//mQEBXpI+tFBGLIGrjhUCxPjVu7YnQOp5L X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 c17193544268..4e5cebf1b82a 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 Tue May 21 11:48:30 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: 13669350 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E721C25B75 for ; Tue, 21 May 2024 11:49:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E24276B00AA; Tue, 21 May 2024 07:49:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD4396B00AC; Tue, 21 May 2024 07:49:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4D1F6B00AD; Tue, 21 May 2024 07:49:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A4BED6B00AA for ; Tue, 21 May 2024 07:49:27 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 658A7C0F0C for ; Tue, 21 May 2024 11:49:27 +0000 (UTC) X-FDA: 82142232774.27.7BA0CF7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id BB88080012 for ; Tue, 21 May 2024 11:49:25 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rESFWlwt; spf=pass (imf02.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716292165; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=elBXcfnoR4KKXTWbk6sPE0xpNIO1vlFJUCUIUZxkcfM=; b=p0O2dMWvli82gI5BjVScNigaOadGkvdwIE2J1lbjVebUVzCxz7QdtJXXLWMoMx/mTnM7xa 8dbTObLbtRSr2RGlxV0g5vK54b658osxts8V/DAUO0xA0uPdBBIFiJSCuQyR3mC5I9Hoha bNq+GiP4LXNUnTnGk/wa6wofwQT3+No= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rESFWlwt; spf=pass (imf02.hostedemail.com: domain of bjorn@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=bjorn@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716292165; a=rsa-sha256; cv=none; b=g79rgR4lcJ1VJZ358Xn1nRzlSLh6DbFD0x/disOUEFiESnP/tWoUSuKevXL4bqmWhPMJz7 RTRbcAORmYo1MFXmXzbUtxUQ4zdsznk5rvdSYSB9dB3bIRj5qcWTpt3adMXRdGmxZkv9NJ Hn/yfQqrzXaFYSrqQXs0Dz3D0rFwrKg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 157E162210; Tue, 21 May 2024 11:49:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6F4EC2BD11; Tue, 21 May 2024 11:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716292164; bh=UfTTCJAd6gAR/W/+kWuHX2+0dwTK25Vi11SpkX7YGOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rESFWlwtcK7rvFv8Um9btQJZUwRB2RdO8MjvUB2BICQEPh/EbugiTsxumyL5292hX SaghKnmizBA/pp7A+Dtlq+qwqNSRixbwdlsADGbs6CIn15dyBN0k28FwBbMS8aiTPI Kp1INLM1FgGFhmvmSsgoX0Ju3Cx9yzirSxLHZ/7IJ7s8WGmxnG22tVNZm7926LBz6M m49b2985aSBi87GawTioSdpHQvEIGdWaOc7nHUaGWvtz6CXRNKEfKQBtE6tGfFo5qO sEpBR+MlOfCff/Ge6iR1CKDRfbGBh0FxjrF7lgu/xXIUY28Ntlxfpz6GDjZg2lyHDr N+eN0jCwq4bcw== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Oscar Salvador Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 9/9] riscv: mm: Add support for ZONE_DEVICE Date: Tue, 21 May 2024 13:48:30 +0200 Message-Id: <20240521114830.841660-10-bjorn@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240521114830.841660-1-bjorn@kernel.org> References: <20240521114830.841660-1-bjorn@kernel.org> MIME-Version: 1.0 X-Stat-Signature: dqex98jzxwj93fxyknsx69je3swt9n4s X-Rspamd-Queue-Id: BB88080012 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716292165-114240 X-HE-Meta: U2FsdGVkX1/i+DGcYgU5JRSAdJK2FjXotxA8HqW4xY+ihGV3kZ2WUd932bC/UPCFQy61FY+9iv64/qEj4mI2LcsAag7nqCMkXgXJEz4NMhwbtrQiBFTYU1W4iLJze7jW/6tiQzGCYsJqHmnTeh588d6gqGA0uMWbGmZcFBLfwWhNf3pTkq8KFzFgrfj41BZGZkGUrnW+cBVk+hoIsozBlfEzOjB3fMR9q+d0gvc5uRsAaiBw8iNjUocj8ds1TUbug2AWPvOag5tN+9JVvxyIZWrnLxL/YjDAoCc6778soMUsw1G/gi51eEDpasKo0gzBT00u9j3mSB/sbrx8XyFd8/cPWn8YO+TR6/xH3HAc+jZS7MkXuus7/xxaaoPZl5Q3SY1728gEmaTts+GWrK0bRvh2ihYt50h58osPo7E0uMxCPmdBasZEoXoSq4n4DqAUjTuZ6iBmUuBn83yEOvnmqGcM8dD2NTjrHUNnWtmPBfJhDsUEorUz5DBDGlBTbyhd/CUsE4+rlZ2SXcIfwFkQRaGTdFqODyDHZzPbSbLEd3ASXYlhF8rfisrKXgYILh+iDIQJ3bwlmbLOC/LgX9SBuZMO4s7a9VYgLov8Z8DWGOL/AXMbdycgtDAWKykTWOGIbBk2LIXxTIVLe/3h0TrCADKL7WsKNZTnJ0BElpS+ymCyJ8JeRnq06QVCNJtRAn1+6OoML6k2vRn1bHRHVEhDo2SnnM5tC/DK0mJDge1r2C+pDNiHP0YNYOZPJAu5feGo0j14VIAYsVHIn8NUgGES4huqzw0xm7XygELLRga4h+kT5ujqY6G/YZV7SN+rc6SM4C8bMEBl+BpHdzlMJfgqeMe13qYDTY1Wacb1mxX/Vz8SRfAaQfQ/T/J/6rfLytKf2EUODbwjyYZk6iDa6shuD/ILa/pafQjCc11WPGdT24yd+2wvQ3DCqI9CPj0j/vB/epgFEuXUL8fITa32rKj b6DTsdB1 ixSske7uu1UiPKLTWEh1LG55GR+jV9K+wdJkbvC7yBWL4VFW/Z5SDvj5+H7oHz9l19MPmnxJwuSKfkSfT99SEhA67pVeL4A40w0ffRX48NMBaXqdoLW9CTjP7T+leZYrDQBUm3ZL4YSfn9DzgM/9H48vc5DswhK8hOq1i9jgdOV2hnZkmB+dIiVjmml7kBbfbeeogoXgYief159awW9/5yzeJ/AsmPVtX4xLZLmijMqI0ADePoB1TNL1PqaXX1HNp2Of2WSy+3+FYc9twWSO/hV9rPckjfyb+0SiVdf+E+73vCWyOoUb0qhDA5bb/v72PfeNeYob5HRH1PEDwtsEoxsgcwtfu0E+Je5PpPKQj3fjJfKM5l0X6JksO1w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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. Signed-off-by: Björn Töpel Reviewed-by: Alexandre Ghiti --- 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 2724dc2af29f..0b74698c63c7 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -36,6 +36,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 221a5c1ee287..c67a9bbfd010 100644 --- a/arch/riscv/include/asm/pgtable-64.h +++ b/arch/riscv/include/asm/pgtable-64.h @@ -400,4 +400,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 7933f493db71..02fadc276064 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -387,6 +387,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) @@ -428,6 +435,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; @@ -711,6 +723,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) {