From patchwork Fri May 12 14:57:33 2023 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: 13239436 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 0160DC7EE26 for ; Fri, 12 May 2023 14:58:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83D3A6B0078; Fri, 12 May 2023 10:58:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7ED7C6B007B; Fri, 12 May 2023 10:58:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B5EB6B007D; Fri, 12 May 2023 10:58:09 -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 581FD6B0078 for ; Fri, 12 May 2023 10:58:09 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 24528A0E91 for ; Fri, 12 May 2023 14:58:09 +0000 (UTC) X-FDA: 80781908298.30.03D5C77 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 46059180013 for ; Fri, 12 May 2023 14:58:07 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YPQSWSrA; spf=pass (imf24.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=1683903487; a=rsa-sha256; cv=none; b=bPP6mBZFmUrjq6XVU3n6fQ5VYiirLsS9HZEFR0tjkxJKX7BCbU7oPk5uvI0fNdG6T2F2Ua i8iVfCj8v6RC755udcEwVCEOrn2XCvcdokpj64qf4OuI8Ab4mLL5oJXCYUrRKRQY0R+msH JdxKK9Bo71ONwc/mh9ZMUp7++GuFFEc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YPQSWSrA; spf=pass (imf24.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=1683903487; 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=HpZgKr5fu0P/l7DuXAWJOQwuEwXmxH+7XtfSyg24V+Y=; b=YwbkY8BiRcTrZCRoKU5jofBCFTLuqtyDeEImZvleD89VfRizF9iSUBaEgQ0FzgcIJjkjdn gFKHC1DnDNh8g2yoMzM4rhYNjOu3yWz3FtHJUg022JoB2XUEqSB2+vTJpEpvRc+5hA1pBf pgqc3FPAaNKcZTozaT9G4CsnzLwxFzs= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6610C654DC; Fri, 12 May 2023 14:58:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F83CC433D2; Fri, 12 May 2023 14:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683903485; bh=aaVyrjFt4Z24qTU7IkdzOXPq++vuBvyBWDRYOQbS9VA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YPQSWSrA4888qRlom2V9n0E4yFAcDlwO6kLEPA1Z3/jN+kNGhPXLeY8aFL0ESQTul RMyaIs6qUO82q50vSJrCQWrwL5FL7Zd2It0w/k09t7jeuI9/8zofE8JzaXyKCEZlUs 6vZOfEid0lLW22Wa0vb8u5t7SQjIJphqI/J9HwOCpQIywm81oMLE6fnM89OUtnUkFn j8XQGA0U7Xt+BTOHhoHC7wsFBB8N8mbrfH+4xlCjWl8xkta+DzSiBxsCwtLgzfktYM MaJ2hhSLpdhYY4k+7RXHrTEDITwtEA6t4tJs5cfx65BsquOpd3IWQp5793KvR6uCq6 t5vc9nXQmqCFQ== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , linux-kernel@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand , Oscar Salvador , virtualization@lists.linux-foundation.org, linux@rivosinc.com, Alexandre Ghiti Subject: [PATCH 3/7] riscv: mm: Refactor create_linear_mapping_range() for hot add Date: Fri, 12 May 2023 16:57:33 +0200 Message-Id: <20230512145737.985671-4-bjorn@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230512145737.985671-1-bjorn@kernel.org> References: <20230512145737.985671-1-bjorn@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 46059180013 X-Stat-Signature: p7btbgset8oouzaz1fje78mgrewfwsqm X-HE-Tag: 1683903487-798176 X-HE-Meta: U2FsdGVkX19PKuWHA8fxr2yRg8Q0vrC8VwdS8dF0dlB1TsbtTRcoBTnvgIK3BDGJ1TIDCtc90HaS56DFiOnHP3bP6epLkQccwupnkHgyd2oEzp6AWl4SRY8rjLaP0AfGi80c6zraash+cHTwsrD1fR1uf0fWI7qDAp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Af7XlSrxQFq1CclVTG1Q1d5Le+ixiT1r0yOHn+i81njCgwIfEH152z4w0jl8mojZ9stL2bAcFSiPqS2179nwotERKwE3ph6D592PCjwer5JKy113jflnnCUVni4Y8K5QkpIbGMSEGABf5u1NyqfMa1F7gtgxO6fkh5qQbL40vXFE0kk77VUSBxNIoxIIIWmkZVmb5kVOd+gYJG9J4fl1otFLKyq1KUKrmE9Bvp5PVQkG/noOBSYdzhVvIc6D24oQ== 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: From: Björn Töpel Add a parameter to the direct map setup function, so it can be used in arch_add_memory() later. Signed-off-by: Björn Töpel --- arch/riscv/mm/init.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index e974ff6ef036..aea8ccb3f4ae 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1247,18 +1247,19 @@ 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) +static void __meminit create_linear_mapping_range(phys_addr_t start, phys_addr_t end, + struct mhp_params *params) { phys_addr_t pa; uintptr_t va, map_size; for (pa = start; pa < end; pa += map_size) { + pgprot_t pgprot; + va = (uintptr_t)__va(pa); + pgprot = params ? params->pgprot : pgprot_from_va(va); map_size = best_map_size(pa, end - pa); - - create_pgd_mapping(swapper_pg_dir, va, pa, map_size, - pgprot_from_va(va)); + create_pgd_mapping(swapper_pg_dir, va, pa, map_size, pgprot); } } @@ -1288,13 +1289,12 @@ 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); + create_linear_mapping_range(start, end, NULL); } #ifdef CONFIG_STRICT_KERNEL_RWX - create_linear_mapping_range(ktext_start, ktext_start + ktext_size); - create_linear_mapping_range(krodata_start, - krodata_start + krodata_size); + create_linear_mapping_range(ktext_start, ktext_start + ktext_size, NULL); + create_linear_mapping_range(krodata_start, krodata_start + krodata_size, NULL); memblock_clear_nomap(ktext_start, ktext_size); memblock_clear_nomap(krodata_start, krodata_size);