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