From patchwork Sun May 5 14:25:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13654314 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 CE7BFC04FFE for ; Sun, 5 May 2024 14:27:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68C7C6B0092; Sun, 5 May 2024 10:27:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 63D226B0093; Sun, 5 May 2024 10:27:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 504A26B0095; Sun, 5 May 2024 10:27:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 314F36B0092 for ; Sun, 5 May 2024 10:27:02 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AD155C0453 for ; Sun, 5 May 2024 14:27:00 +0000 (UTC) X-FDA: 82084569000.20.F80BB95 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id F121716000C for ; Sun, 5 May 2024 14:26:58 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=D+AEXZ1+; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.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=1714919219; 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=WH0O3bMdTIKOWpiRaJd9JoO3KXB0YwDiDwa05xdoLbYEraJMDzZoBbmGWt1Ldxfo0CtMJw TQcLhdlfNnrDuaKRQ+2HAncXhRnHjH7X2I6HWD8OAzmJPalcv9f3R6Fwa3LFo7beOINE6R YTE/BPPtpZ1c7lYF2oZ910bLKSHCOuY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=D+AEXZ1+; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.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=1714919219; a=rsa-sha256; cv=none; b=D1pQ0W7kRkvRUFiIZGKvBKTxG6RW/adpA7Ciq+Gv1h2hQxEXFNSSctNaJeSDf0alithNLe u6rr71w01KFuTjbfzsluFxTTgnUUstg8usNqtbcl1keBDE8kdJnsR8Fz9qx+k6TEFoFTLF B2E/djZaoJn/Zc33aRuJBJ4nX4zU1jM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2C86760C87; Sun, 5 May 2024 14:26:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69A43C4AF68; Sun, 5 May 2024 14:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714919217; bh=Q5aCDGAMhe9LWjmBOe0KfqvsLthVcLCeaQ3ItO7ykso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D+AEXZ1+edd26N9/8UI+5vqfzt0PI5uovgiDDR64glu60eQHUh9U/r9l1mLMgqbPy PSx7coEJARMFuqXTSz1qGggiwFJcsOaot+79bhH6NFAnozJPE/ZYNspdkDMHfDme7v KywFHtNx8EO37PSDv5nmAjzmWLCXrY7AK03iUjfJxfB0sYFQg43ypiUbsQZowMQcCm XW8+qGaq/gQE0FWV4qySrCFhucVOkKaE1eHGjW9Y7QcVIbjFVJjqFHMEVdoVxMp3y0 HDELXGNAVg7ov0da1Q8zWoQkFhiXLX2Og1s9FXRTGDBBnsZqJ2jnuoilS8B1kr7ICI FLfPc0Yl7YI2Q== 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 v8 03/17] nios2: define virtual address space for modules Date: Sun, 5 May 2024 17:25:46 +0300 Message-ID: <20240505142600.2322517-4-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240505142600.2322517-1-rppt@kernel.org> References: <20240505142600.2322517-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Stat-Signature: dkwq5e9jm8nskjjwfnpdg781utrtrum9 X-Rspam-User: X-Rspamd-Queue-Id: F121716000C X-HE-Tag: 1714919218-237834 X-HE-Meta: U2FsdGVkX19RXmVlPMtjJasN5uslzKlENWXr5OC+Hg3gY2ltjbX1SrSG4BkWcxRGgH7U+4zUjqQ0qtxaBV7skJuf6Jp2P8+t9XYMAGatVfhBeiQkLukLvTIWEV3DtkAJ0lTCh4ozWN6sxK1juDUKztomvsi++ipxgrLbKn4YBYA7q3bxCLOtT+stsUAdhIddXYKKrLAyvyp4nlwuSeRBJLHU9M4TAWk83POAThKa/nWSzPLXle66qBSjX6PEEVWTKrlrMhpOYKLPuBP+oFaIFchq+1J/T8cvxA9fMPzea2RRi0ZRQC1WOGhqg1YB8GJcpL86z28uQbAo5NcsHWG8mhWYAZ5pgr3eefwV2Y/aHXmAkQNQTa96+Ci6C9yIADxtzJt+tOlMSMySEqz30MIhph/mgznoN7Swke87M2r+pFS90L3TkDD4/ckPP4zTcvIFB6V77ap3TbT4Ofg/ya67pQTPHGYgY/fTtnue6VLfvOHURVACXB2e9OhN+9GN0S1UTnzf8GnTIHtX7S8I/mozB+/nlvorC9pR+zI1ERzN5LKzqHBCymI7j6to3MAD34vlsHBUPl0e4gBztcWzZ2jp/hMigGlr7PumzeTZkdBFNhCegaDWxIjTc3HtqYvJekwtxi5hHlso9SOlPjdZGbWZGVjGOIAXhhE9TBsbSNMPDLuvhK/t+Nr3E8bUUwNcRoHp1H8tgoIRaOugIQQ6i4PwEbZapNzAKZecEkoibW6KNSSNv48H4jGFL/A4aNhoLPG7uSDyxqwbVxo1B9Fk3Xhj9iT613/BMLp8IFXsBSRZMtFc/CoDi+FsnD0iDnd9KAl2L7HjMwzIaSlrqz20OFV5Z3gdi71wRwz6HF/UB9XtK6cm3R6aXq7yxIkVUhqqMNRNZGuuMti8iog9sydhTQQNDTjCGFq4+Es8ONlWfBu1D0b/E6SiArm9bo1p8oEZaq1Dwobi8d+lMzBcr+/YK8Z 8FzfBt60 Mx//kuS2oCc3QH8tKTJWK2xDpMbwqEsxbPd6iQuVci8gyDVkYI3mn9xPCn4PqvhxSbWDTP2aQTS2rYvv0Tc+PGrBXZw6deip8HHKmhrBlnv5OccIcx7x1Em5NEossVe21dctRHcEuioFCI3wbIIinZNoMu5q7dzlfBXdBkKdL6y1Kpz8oMbhFqhjnW+x6zpqxfcqnSHdrUN367oiuKAukMD4uEdi0Xoy9Pi/DEOUA5yXxRWSEBj/rbsbwoYyphH2AZkR/bCRIVM1T1S44F3ucM0r8rSlP2D36bS4uAPWuK7YV5gdcR7Idnfxv64uBeX60ICphsbAgZ5EnYxxc8yuZH5Jy7SrQuztgIO18E4INV7FZ8be31EVBResg3qhStqqjPFc42wmQxf2i0QB7QgbpJhOkDKm2sh5PEZ13aFzztV4RfBk= 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,