From patchwork Mon Apr 22 08:47:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13637944 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 C25C4C10F15 for ; Mon, 22 Apr 2024 08:48:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DA236B00A0; Mon, 22 Apr 2024 04:48:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 38A416B00A1; Mon, 22 Apr 2024 04:48:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 253606B00A2; Mon, 22 Apr 2024 04:48:08 -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 07FED6B00A0 for ; Mon, 22 Apr 2024 04:48:08 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9D0F4120AEE for ; Mon, 22 Apr 2024 08:48:07 +0000 (UTC) X-FDA: 82036540614.18.35C19C1 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf27.hostedemail.com (Postfix) with ESMTP id 5D66E40007 for ; Mon, 22 Apr 2024 08:48:03 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tqjGhLma; spf=pass (imf27.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@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=1713775685; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2feFkw2/DNFlbT2CLv51WDiwJyrr0iuGHxvu/fZCE9Y=; b=GwMQIUCLQ589KWO9x5/EdowJjeubxr1zdImWWofCcFFDhftN+JrTCN0bQz89SJUMJfCg9h GFXSlq5AHpODpS2zb6YleirV1zAgJUxrIUWqA8sLylgvh3vPcPNE+ST4VK/ESsEioqPHnX 5M0nzVNW6JKvC8mueyjv5ro4H7zoJnc= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tqjGhLma; spf=pass (imf27.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713775685; a=rsa-sha256; cv=none; b=WCnkA/fiems9QkR2RIsW4KYrotJSL+eiWzRjaar9ILJgmj2FbNoSvUGHHHEHvaWZMs0Bfy yFi4mz0gQsxfTlbVbncrXA2PCnNozM7cGGXUaMenaDGWiGd/tM7Js2PIGTE/5GPTRm+mHR 5NB7C/DUfJD+8AWj7z1iTXuG+xYJRWM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 2E24ECE0AB0; Mon, 22 Apr 2024 08:48:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FFB7C113CC; Mon, 22 Apr 2024 08:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713775680; bh=Q5aCDGAMhe9LWjmBOe0KfqvsLthVcLCeaQ3ItO7ykso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tqjGhLmakj38qK7RgDjyBqXPIqmgUHctAJPuYLPYWfWlTQVzsz3Yv8bD9x5dI6Hnl zH4N1rZua3kKmp5Z9FTzzOnBDCkE6NkLQqo4SEXw8+hGJksLAPX+KPiTIYWYFcJ7aC NPF5rVfWqZE6OIc3RPkBGBu5CGvszUuUXO+9b2gFLqXc+3J3h1lSPne2TIenVv8BPH BhGnGacMV/GoI70AjaFFGfEWSKb3U7DqMgHV8L7lS8SLOZ7WSffFwUvy94mkdeCGPR 0yrZJ28u6aSN34J0ggfPqpKCgrNlu3cA3W008IMoUdJlKQ3f8tdajrnX4H1n0K2SKJ BnX44JYZzOV+w== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexandre Ghiti , Andrew Morton , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Donald Dutile , Eric Chanudet , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Michael Ellerman , Mike Rapoport , Nadav Amit , Palmer Dabbelt , Peter Zijlstra , Rick Edgecombe , Russell King , Sam Ravnborg , Song Liu , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Will Deacon , bpf@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v5 03/15] nios2: define virtual address space for modules Date: Mon, 22 Apr 2024 11:47:11 +0300 Message-ID: <20240422084717.3602332-3-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422084717.3602332-1-rppt@kernel.org> References: <20240422084717.3602332-1-rppt@kernel.org>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2DuIjUq03DbK3YyC6BXQAhjAcACFNCO3 s3QWdZ1D tN2QuzwD62exw0/DKvr5Cc0jJoauOlQCMDcq7Z63jsoydIzWRoZkWDRm5vNDJrXQ3uS9+OxRIC8EOjYEAXrb8qzD7DhFAIw4tqx657DFd/YDw57CkXGdBZr2QZIYetPvOijvk7c0zIrl91jYeja3wIucZ94DipWLiVsZDhhHJ+9f6InZyWAayKJc7SP5gLZ10T3hvOoai9KrHA+usgdz5lRQm2tatOZzOg3qoVGiaabrzyUNwHo9pLilqUytFGD+FyiusWHXDV1I9QqBhYijJnrSZ+yzIO2gvzeBlxTukf2P5VQFQaE3KvD1ORRuHElvewjr+7TgPXL2q7YYd+5y6DukRMg== 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: "Mike Rapoport (IBM)" nios2 uses kmalloc() to implement module_alloc() because CALL26/PCREL26 cannot reach all of vmalloc address space. Define module space as 32MiB below the kernel base and switch nios2 to use vmalloc for module allocations. Suggested-by: Thomas Gleixner Acked-by: Dinh Nguyen Acked-by: Song Liu Signed-off-by: Mike Rapoport (IBM) --- arch/nios2/include/asm/pgtable.h | 5 ++++- arch/nios2/kernel/module.c | 19 ++++--------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/nios2/include/asm/pgtable.h b/arch/nios2/include/asm/pgtable.h index d052dfcbe8d3..eab87c6beacb 100644 --- a/arch/nios2/include/asm/pgtable.h +++ b/arch/nios2/include/asm/pgtable.h @@ -25,7 +25,10 @@ #include #define VMALLOC_START CONFIG_NIOS2_KERNEL_MMU_REGION_BASE -#define VMALLOC_END (CONFIG_NIOS2_KERNEL_REGION_BASE - 1) +#define VMALLOC_END (CONFIG_NIOS2_KERNEL_REGION_BASE - SZ_32M - 1) + +#define MODULES_VADDR (CONFIG_NIOS2_KERNEL_REGION_BASE - SZ_32M) +#define MODULES_END (CONFIG_NIOS2_KERNEL_REGION_BASE - 1) struct mm_struct; diff --git a/arch/nios2/kernel/module.c b/arch/nios2/kernel/module.c index 76e0a42d6e36..9c97b7513853 100644 --- a/arch/nios2/kernel/module.c +++ b/arch/nios2/kernel/module.c @@ -21,23 +21,12 @@ #include -/* - * Modules should NOT be allocated with kmalloc for (obvious) reasons. - * But we do it for now to avoid relocation issues. CALL26/PCREL26 cannot reach - * from 0x80000000 (vmalloc area) to 0xc00000000 (kernel) (kmalloc returns - * addresses in 0xc0000000) - */ void *module_alloc(unsigned long size) { - if (size == 0) - return NULL; - return kmalloc(size, GFP_KERNEL); -} - -/* Free memory returned from module_alloc */ -void module_memfree(void *module_region) -{ - kfree(module_region); + return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, + GFP_KERNEL, PAGE_KERNEL_EXEC, + VM_FLUSH_RESET_PERMS, NUMA_NO_NODE, + __builtin_return_address(0)); } int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,