From patchwork Fri Apr 26 08:28:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13644225 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 D60C0C4345F for ; Fri, 26 Apr 2024 08:29:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 718C46B009C; Fri, 26 Apr 2024 04:29:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A23F6B009D; Fri, 26 Apr 2024 04:29:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 542B26B009E; Fri, 26 Apr 2024 04:29:54 -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 35D5A6B009C for ; Fri, 26 Apr 2024 04:29:54 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B42E5A081D for ; Fri, 26 Apr 2024 08:29:53 +0000 (UTC) X-FDA: 82051009866.20.8F48DD4 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf26.hostedemail.com (Postfix) with ESMTP id 9FA1B140007 for ; Fri, 26 Apr 2024 08:29:51 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NPrdkx38; spf=pass (imf26.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=1714120192; 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=DH/+DyvVm0SjhKTlQmNYjVkCebCwemBbL+T9l/mdoRF3uCXuZ4IbqaJ57TucQE5tIXGbUp uQiF5ISC72i1n1EbHTOYH0rP/K3iAQPW1RuKK2aT58VZHv8t3ZQR/Jw9X7KCtAx+NvBDr+ vHJIESXwN72ifdlLwWVgyo9Nr/X/fIE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714120192; a=rsa-sha256; cv=none; b=rTGjezy+7URDZdh/iqliB7Ez6Lo1E/MpbL8TMPIFtgAa/hgXQ5zPv+wLuD3UgOYcfsuN+s K3oq1epWq5h1iFcvsiyd41vwtWuSdT8bJecqkps2yJs0Zs140LfSv95GnEz/aKLdCXLRbB 4fHe5rHJv9c8I7/CGiPgrF4LMmXML14= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NPrdkx38; spf=pass (imf26.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9D0B8CE1BDF; Fri, 26 Apr 2024 08:29:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CD2DC32782; Fri, 26 Apr 2024 08:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714120187; bh=Q5aCDGAMhe9LWjmBOe0KfqvsLthVcLCeaQ3ItO7ykso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NPrdkx38WFrLGifzoA5K0QA3eIW1eoED+MgwpJcnRO4aMuvJHTNJozBx1ouUGQqXB QKvWVzKbowOfw+ctzP8PL3hhetlcUkPSieNI36n1bfkk2lbmKbEV9MYfG8JIcDuPnn TWYAoPdM4iZrJPVhOdhDM+lXTJS3T0ugeMkrbKCNz7h+NtHwV7Kh+zUE2iNpjbhggg 35NSzKOCyRnoVxeLV85ojoWTJUpr+ggXbNk7gyIkr2wcPQtTKAn9CirBNIwHHW+Bgf GhpUHCmP7WnGQfeuvGP091Q8GXQYHZ+nkAZ8Mvws8O83TgAv5lx2QCZBZWN12E7gGD 853B08FIaHrXQ== 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 v6 03/16] nios2: define virtual address space for modules Date: Fri, 26 Apr 2024 11:28:41 +0300 Message-ID: <20240426082854.7355-4-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240426082854.7355-1-rppt@kernel.org> References: <20240426082854.7355-1-rppt@kernel.org> M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1AokjEDwgmmIIfX6OZbglIMtX2ZqrWyi0l9FB1Kpy Px339oBH 1oJ6AwANUbbV4+vv+0yABLWBynwadLl/Krq9M8AHVmG4AfQWaS+ElHFC3Apgcbvyvfme481VrtcH7/4GpSiVUgbPtsdByKA0KjK/SVZKjXJRfI9M= 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,