From patchwork Sun May 5 16:06:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13654465 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 50930C04FFE for ; Sun, 5 May 2024 16:07:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C863A6B0089; Sun, 5 May 2024 12:07:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C36146B008A; Sun, 5 May 2024 12:07:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD6A16B008C; Sun, 5 May 2024 12:07:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8D2366B0089 for ; Sun, 5 May 2024 12:07:30 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1CDBE1A03B9 for ; Sun, 5 May 2024 16:07:30 +0000 (UTC) X-FDA: 82084822260.07.695A99E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf03.hostedemail.com (Postfix) with ESMTP id C56C820021 for ; Sun, 5 May 2024 16:07:27 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=P4CuvetV; spf=pass (imf03.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=1714925248; 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=hzL3QIc0qIql4A8yaFMGXYukvDC2sYcS24sg/zvWR9xSPMiQgGdtFblsBydTbHzx+Et4In ryZGI+hnMDJlNff3jmlKia+X+qwZXUNzMxsiahwasImt1pJnfTae7D+bOXQej17gVdvx9A kmkLvbLvM8kLUHKdYghbXDlOTsW0/fs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=P4CuvetV; spf=pass (imf03.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=1714925248; a=rsa-sha256; cv=none; b=glMRgTStp5QJvqkbTzWO5HIBHInSni6I4Cen4WFiIS0KToI2JChFa69H9g2U6rXp4S3L1s wvhOVnsAtKoj8Hdt3Xp3acv7omMeaIbyUc3YwCxpvK63eASbAeEqaduAER6s3eZ5NGl59+ p/L58PxMsNcptGBpIAniGepkmNFiv6Q= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 85129CE0AB4; Sun, 5 May 2024 16:07:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88E70C113CC; Sun, 5 May 2024 16:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714925243; bh=Q5aCDGAMhe9LWjmBOe0KfqvsLthVcLCeaQ3ItO7ykso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P4CuvetVGByVCBaaVxVGGOtA74RDHwFQjjwfPUauzLmoD3wdUW1jd7WI/FNUi9YXr ecSyHliyfMJi2cUpp51ECWceN7DeyR/FktquNEV76UWeLDSX8u5ntplCqdrTZGIyar D+P1a3P3j90UWgY0yEm1lcThQZQ68xgGlJ5P9pQsu+MdqtVgnD2sIkvJCtbHuzGhJY LIv/xEQp3DYvT0pZyyVNtIOhtztKpIuOB81GgZH8ewWLqk/Czr7GNGIJ8tGHZNrj1W kaDVaYV4Oj0AIJ4U/WkvPQlCnuijDIIbENO5+lgHxoBaL30p+JcIdJmJV59oRMq0WW 1ZePgAmim3Bkg== 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 , Liviu Dudau , 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 RESEND v8 03/16] nios2: define virtual address space for modules Date: Sun, 5 May 2024 19:06:15 +0300 Message-ID: <20240505160628.2323363-4-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240505160628.2323363-1-rppt@kernel.org> References: <20240505160628.2323363-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: bw35tkpit1uhg5d31gnuh4j1bjxrikmx X-Rspam-User: X-Rspamd-Queue-Id: C56C820021 X-Rspamd-Server: rspam05 X-HE-Tag: 1714925247-327595 X-HE-Meta: U2FsdGVkX194Ovdwoyucu0fJpyLfjJ9YMfmoYjdoFtrZ+OdQPZnCWDfgXIVZKiei64zGp0RAZP3g5eccAFr3pHavXoJZj6e/1FBXvAc2oxQXp2vMDW+ul4/FDFB3Vets0aDVWGbSAywXDMKDGiX2sDa0G+i5TKkQYmkYHWRl298Db3KK2thnGiCKLZQQZA9OZbbUYfcb6dysvqhG+pmtgA5py52AddHZ1IEKnwF3UW/gJ2yhcIa0QoFfIHOebEKCxPLqbCDxHReUV5ppH3qAQJQElsbeFaNhuO9L5KyLUY5Kd/7cjgRqQ+tECY8+OpVBBLnhYGTOusSXYE5dvkWMMxTAf4r30lfXdYvCMokCFqDWuhkngqjzR99Lx30hcIkUZyFK7ZkMKP0dWOlvxtHSiSJWJijJCLe8Z5tK9jjRBxDaFx9LVNgNBgPWzhBiRLepb0iie09Ex3KdPYuWuBBkHNi1d+q6d1xD8UK/FFNFjQFzjJJqcjEh6fG7GaIkXok/9KZUruwwpJlXzfkDF4fB4GkqVFSz3rYszIwM+R+jgrO+omx/7aSpJ9yHLcDfYY/YdQW7EuaBSfAwkUu/WoBS82IRAbepmwVfmOw9Ahgl/YGOP6JT6Ljk5zlejpbXDPk3yWelsvZYPv/ii3N4PgxhgoXxbOK53kZgFvXLesPVN8ZtssWrA5QSrxolwZNIeiqGKi9W2ek9kUPq/2S/ZscPGt13XivAqS6LlEaF/CChItZPh60S/pF+Rq9FBxxhGDpwyivmAN2veNN4n4khIPn9b8/MUmuHOrz7+PDk1TJV0Uo1Vpwk9YADmnXGoPlUourHrZ4ajG9Y63avYARQb2COApBldXjRl754b6ZBGr6pvl0JxIg6inuorgRcb9s0+EBHmaYKhd3QKxlEXhLgs4YdgFoz0L5aMWnQKuexVWFspJewOhT1PATuhiJT4WnzKaEcPDn5f16nQ95Ef8D3rtd fBeOling 4BCWxC3ZudbcsmRq5aSWTB8256117JV6YN/gaRIuFDwLcY8p7IuZ33L0+DarEh+St//GLHi70Lda6LihM3zCzxWCTL5ZOEJqcNme3liZhZksOUnPlHpmaF4GeUHRa8vs7RNzlUt9+TlhuK7AwMkWo1ke6FbSxF3QH4VC4WSNSFqpric9/7/5oGKoIpcGbyY2jb59XEm0fP1YVavfnOPeSzm+e16w0Egwb+VEwcjmx613AK1i8x678G5R3LSrJjzK0ZWkcJ5CHi56ou5KIP8WU12o+MXy7v7a906ArMx8FoXQU3r68LFmQX84F4YVemSbM2PHI/yDtsv9ovJt9XXLTPhLeIfMgWsvK6aM+h7nuTHKSYKAoEyZsWWCRTCDssXYOkNkS2Pa7HGN1WwRujxNHmyrS7phF1x1ZSZVamkTyd8tni/A= 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,