From patchwork Mon Apr 29 12:16:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13646875 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 CA048C4345F for ; Mon, 29 Apr 2024 12:42:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B6476B00A4; Mon, 29 Apr 2024 08:42:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5653B6B00A5; Mon, 29 Apr 2024 08:42:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42CA26B00A7; Mon, 29 Apr 2024 08:42:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1F4C16B00A4 for ; Mon, 29 Apr 2024 08:42:49 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C2015140285 for ; Mon, 29 Apr 2024 12:42:48 +0000 (UTC) X-FDA: 82062533616.12.8706BCF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 3C7EE180006 for ; Mon, 29 Apr 2024 12:40:36 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DFlLUXKO; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 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=1714394436; 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=scP8KiE5ZFPIYFZ6fcKXXb30Oz4Fu8LdW1qaQ1j19cGBUeb1eDwvpDkm7aEoNm2YXBgB8u 2L/p1SLCv4pJ5hm588zXGD9swNpm82KtVOpSO+OevI7XmXIgyw8BgekNQfIyd1mLKufA/g JL3kdc9XRxWxqO+5mwHLQkdykxHwejI= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DFlLUXKO; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714394436; a=rsa-sha256; cv=none; b=QBTu0rZcX1hzwFj7bxsHcMf0h0z+tVeMrU2uCmHgvF7gbc26gQBtjy8JUwcXAQ0F4398kS EKk5obMF3wOvdcUxNIXWhiftW323ALTf/dmeQP8AJMWVS5ODZBY9fmS5SFRLjPpnPffvOy DPi0RMkSdT5cZ0/k0JaX8iDLClyYGzg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3CF0860CEC; Mon, 29 Apr 2024 12:17:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AE43C4AF1C; Mon, 29 Apr 2024 12:17:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714393033; bh=Q5aCDGAMhe9LWjmBOe0KfqvsLthVcLCeaQ3ItO7ykso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DFlLUXKOGW1bA9nT5em+gyu9NCPRcUND9+V0H60SUspwoRFLXFQitEQVYTPWgn1M9 z4gEdgmIOodHo5MssVhusRrGON/21XKdAobI8Xl76jIzIjGZ2nuBUJfu7xJYYKxN6v mqSCyhRtiPek7zSthB0V2kCkon2yq5wwYoKlvUuJyYdHWXbatxvOoIjhTRzCeWYglH QCcr2CU57MgnBVNzvmHRWGSC1sILdAjbcoinGJRtM59eQsergOHEcZKSSzUxlIdf1P viEhJNzAUN7etXMkoohraK1IxkhWxZdNrHYfsyJuMrZF0sTHEDTRg7teof836jRKrJ VY3god5uR3bLQ== 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 , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , 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 v7 03/16] nios2: define virtual address space for modules Date: Mon, 29 Apr 2024 15:16:07 +0300 Message-ID: <20240429121620.1186447-4-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429121620.1186447-1-rppt@kernel.org> References: <20240429121620.1186447-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 3C7EE180006 X-Stat-Signature: xj3p5hxsdy4afn9qfwpq7xjadtoysc47 X-HE-Tag: 1714394436-804150 X-HE-Meta: U2FsdGVkX1+Up/FMwqtdaFi0ZdKwYX5a8URqpua9B+8719pQLCtTXdZaQAejO864ddp1WWQGSjVkrR3fya803Yrs3/AooijsfIcadU9zKHsEmB68p//UtRJzAFAsXJdImChiu1urRb0VXYPGU8iFBlNB+b/JQ57tR+B4Z5sLY6epKrUOeKpXpwyGhN9/i6i3qokJwehUCHNhTEJ9XXAVa1eDpwF1vCUYeF2uFOcHiN1JKjD+p0gjiORVa3khAKLKil9QJwuO4oa69NFom+BUbF9yjxnG8bHDQ/8NRmcm28VYcs4ngE866eY8yuf/fLhj5RvTiVdbdbg6rL3qPzO7xH6bxxqtR3VUUsGaeSmzhnn9UgL84bLydEtOi3g8DoTyZVGuf0QFhjgJ91PSJdocGjl8AabOK+itybwo/BfIx6E4kexCzQnJvDlF+q28rdnz4hH/WwEERKh0kuoz0WMVsfJd1wWWdP9pf5EoOrYopR1C2ol50gZOsIYVHxCv9X5hdC9B1dXbxStWQ4PiMgWVL8SaMkXTX2lNA0RT3thopVhL3MPBloVZPdp3G4S7UMQmaQR0FaEq+Wmpe/QxtbQGl6QVekptoytccJS14vZKwEOD9UJnfPqTgrYrUAAq4PRrjsdfrpVzhIAPDPTee5QE+mFmyaPH2mjBeFdJjTWlX4ABm+ShCniBlx/o+ZO1MRdS0xqLjuaSf4Zbm+JFHtddZtHxthaCfH/sBuPgOVi3Gh8MQB20zmcVX8Yprxxy2bNZZ23GoWwZEehus75YkyS9Cftd8pXmHq9Iw1ZEghqPmBpsCvb4itWBMtbG8gAqnZDEn901dR/TT1kkawFgtspDQLI209eG9x9SKBoyeEC7kwQ4OLqQPI5Yj4wTty9zgoAilXblTX4YANwcMYkE4+Y275T0DsimndLPyLQ9N9Ph64iDeG9p694iglTG/z8nWtN4u2fTn7TUNtTdCXSw7kL csTIyF1E 6McFrID7AC46Cc2cBnJJk4q7d4vfKRXaTC06Q7c02eHCwLLyYQ/jj1x+BqD0myaM+q4vY0JZqXCStA11kpQ+zOVb+QhnKSHvZNJmjKmfc09IrRDKVLdUlSAl67wgpw3sZdJYAbr5mhWNKRLKuuSYFHZ1XVCdNAW88SIiyNa3TFTtefR9GgkG7vc7W/e/CoTZ8wuWTvjm+TatrqZxdZIs4UFhAq6ilYXm5hPqXFe8iHRmmLNzJFyp3h0HP3WU/I2neh2mCbTWCKEba1yP7nQHGbFHTc7UKz7MqZG/obPSjBTKSRnOD/NqOR1C5jHNDC9e3sLGcRfoojlBVmWwQ3lC0B/PSIaYNbkz4h0leM/MEEd0tPAqLJTk5dLL/WDuSpKXZMzziQke7K1tmISFvhIUdet3G8tVr9MabaHh2GMtDdPhAHC8= 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,