From patchwork Thu Apr 11 16:00:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13626213 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 97010C4345F for ; Thu, 11 Apr 2024 16:02:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D9526B009E; Thu, 11 Apr 2024 12:02:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B0C16B009F; Thu, 11 Apr 2024 12:02:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 150A66B00A0; Thu, 11 Apr 2024 12:02: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 E8F4C6B009E for ; Thu, 11 Apr 2024 12:02:22 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BAC0D40C30 for ; Thu, 11 Apr 2024 16:02:22 +0000 (UTC) X-FDA: 81997718124.12.AB03DA8 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id 5E7BB16003B for ; Thu, 11 Apr 2024 16:02:20 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tr6HQHuJ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712851341; 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=XFLlgs8TYDKET5x64ZeeywtEy75E3F469J4+1dV23RVQeWmzNo4iwrhsyQEO0ssi+Yq+GW NTdLIHzUAQP57lWowpOugKPRd8mRB5MVDjLryz3XS+4hLNOEAxpYAitMIUKIPLd4VWAU8x N1I9aZH5DYodaWRJ8Drvk26Ib+qbIzc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tr6HQHuJ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712851341; a=rsa-sha256; cv=none; b=xb/CjaY4ee1kn7f/JWhuCYn77YTotyrA3/4MLizdlDJ5Za/ys2RdEX9iZ4RFafNktyskN6 5K8XOwA0gGSi+qFAHUNPZ0d/bbKR1kkkBLmUq271s2lg237c22YSARdKmplHX9RP/3Js2R QuhsRRZsHUGrhcjuTU79SN8NerGQnYc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B4CD6CE179F; Thu, 11 Apr 2024 16:02:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2470CC113CE; Thu, 11 Apr 2024 16:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712851337; bh=Q5aCDGAMhe9LWjmBOe0KfqvsLthVcLCeaQ3ItO7ykso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tr6HQHuJ8bxaf7OwaHK0F7En4SSz1IUTUfCAsoEJfXYQ68T9i5iWX0ALZ/A23xhSl x1WbhFcpAYaTPmEvUVS9U2aNFPWZlDPMHCUPZkf5vSVjwFCLmtt8uvANdfkxoGqZTd a1NknNkrI4pxKAUc1ytaULkAqpK2FqN4GXTgQYPBvn7AjeqZm5o+pz4sJEjapq5Qiy WAkomqudI+SeGMXoQBTrxCtfCrYHYhtxyvZVEmaeObqzjIL1fR3qE9uKM63K8jvBr6 p3sT+9xfpJXzwz91JLZWiUeMKeRCNdTllJ9qFgdoPAG2LiQO3/UfBlsSHrPYQDyxgf s30+fws1oHu9g== 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 , Michael Ellerman , Mike Rapoport , Nadav Amit , Palmer Dabbelt , Puranjay Mohan , Rick Edgecombe , Russell King , 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 v4 03/15] nios2: define virtual address space for modules Date: Thu, 11 Apr 2024 19:00:39 +0300 Message-ID: <20240411160051.2093261-4-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411160051.2093261-1-rppt@kernel.org> References: <20240411160051.2093261-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id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MBL3 91Xl3Ok9 +GZipa+LzQNhDWQuDKFbmkCkBVHoVJEzuXqDADdSuRZ1Fthu+smmxKHACP99V8yD223frHYQdfKdcQNUfu+5cxtopvcxG/CmMI+y8oPMZTUSfauqIoQVFO7SJ1ZPlj6bFDZeyLTXnK2DQrQP8m379T18i7sIeXLuzCMiO5Je3Jipz2d/POUBWWWDgT0Q+l3PqmaV7bT2pT9DjqwEW/rIuJy+0LImxS+PEKqExvV82abRaQSDeylQgkEpxy2a2fFw5mdOj68QKUHmUu+DpjDyiyP1aqyzEBdEKxmhZSOJ4orUgAgulKALDpwRnlVUGN/DdLSrLkqkQo+LpCUsm/aelZbC40A== 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,